pax_global_header00006660000000000000000000000064145636660560014533gustar00rootroot0000000000000052 comment=8458171690b9e32d81fb20d17f6a527b1777918d golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/000077500000000000000000000000001456366605600222565ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/.github/000077500000000000000000000000001456366605600236165ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/.github/dependabot.yml000066400000000000000000000006651456366605600264550ustar00rootroot00000000000000# To get started with Dependabot version updates, you'll need to specify which # package ecosystems to update and where the package manifests are located. # Please see the documentation for all configuration options: # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates version: 2 updates: - package-ecosystem: gomod directory: "/" schedule: interval: daily golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/.github/workflows/000077500000000000000000000000001456366605600256535ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/.github/workflows/codeql-analysis.yml000066400000000000000000000044361456366605600314750ustar00rootroot00000000000000# For most projects, this workflow file will not need changing; you simply need # to commit it to your repository. # # You may wish to alter this file to override the set of languages analyzed, # or to provide custom queries or build logic. # # ******** NOTE ******** # We have attempted to detect the languages in your repository. Please check # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # name: "CodeQL" on: push: branches: [ master ] pull_request: # The branches below must be a subset of the branches above branches: [ master ] schedule: - cron: '26 20 * * 2' jobs: analyze: name: Analyze runs-on: ubuntu-latest permissions: actions: read contents: read security-events: write strategy: fail-fast: false matrix: language: [ 'go' ] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # Learn more about CodeQL language support at https://git.io/codeql-language-support steps: - name: Checkout repository uses: actions/checkout@v3 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v2 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. # queries: ./path/to/local/query, your-org/your-repo/queries@main # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild uses: github/codeql-action/autobuild@v2 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines # and modify them (or add more) to build your code if your project # uses a compiled language #- run: | # make bootstrap # make release - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/.github/workflows/pull-request.yaml000066400000000000000000000026001456366605600311770ustar00rootroot00000000000000name: pull-request on: - pull_request - merge_group jobs: unit-test: strategy: matrix: go-version: [1.17.x, 1.18.x] platform: [ubuntu-latest] runs-on: ${{ matrix.platform }} steps: - name: Install Go uses: actions/setup-go@v1 with: go-version: ${{ matrix.go-version }} - name: checkout uses: actions/checkout@v2 with: fetch-depth: 1 - name: Run unit tests run: go test -v ./... build-arch-test: strategy: matrix: go-version: [1.17.x, 1.18.x] platform: [ubuntu-latest] arch: [386, amd64, arm, arm64] runs-on: ${{ matrix.platform }} steps: - name: Install Go uses: actions/setup-go@v1 with: go-version: ${{ matrix.go-version }} - name: checkout uses: actions/checkout@v2 with: fetch-depth: 1 - name: Test to build binary run: GOARCH=${{ matrix.arch }} go build ./... build-platform-test: strategy: matrix: go-version: [1.17.x, 1.18.x] platform: [windows-latest, macos-latest] runs-on: ${{ matrix.platform }} steps: - name: Install Go uses: actions/setup-go@v1 with: go-version: ${{ matrix.go-version }} - name: checkout uses: actions/checkout@v2 with: fetch-depth: 1 - name: Test to build binary run: go build ./... golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/.github/workflows/release.yaml000066400000000000000000000011421456366605600301550ustar00rootroot00000000000000name: goreleaser on: push: tags: - '*' permissions: contents: write jobs: goreleaser: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 with: fetch-depth: 0 - name: Set up Go uses: actions/setup-go@v2 with: go-version: 1.17 - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 with: distribution: goreleaser version: latest args: release --rm-dist env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/.gitignore000066400000000000000000000000331456366605600242420ustar00rootroot00000000000000.idea .vscode node_modules golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/.golangci.yml000066400000000000000000000011751456366605600246460ustar00rootroot00000000000000# # Golang CI pipeline configuration # # To execute linters in local the ./scripts/lint.sh script can be used. linters: disable-all: true # Run golangci-lint linters to see enable: - deadcode - errcheck - gosimple - govet - ineffassign - staticcheck - structcheck - typecheck - unused - varcheck - goconst - goimports - golint - misspell - stylecheck - unconvert - unparam - whitespace - gosec # - wsl Could be interesting but need a lot of changes issues: exclude-rules: - path: _test\.go linters: - stylecheck - gosec golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/.goreleaser.yml000066400000000000000000000007501456366605600252110ustar00rootroot00000000000000# Visit https://goreleaser.com for documentation on how to customize this # behavior. before: hooks: - go mod tidy builds: - skip: true source: enabled: true name_template: '{{ .ProjectName }}-{{ .Version }}' format: 'tar.gz' prefix_template: '{{ .ProjectName }}-{{ .Version }}/' checksum: name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS' algorithm: sha256 release: # Manually examine the release before it's live draft: true changelog: skip: false golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/CHANGELOG.md000066400000000000000000000524671456366605600241050ustar00rootroot00000000000000# Changelog ## v1.0.0-beta.7 (2020-10-07) ### Features * **account**: add project id to ssh key object ([#447](https://github.com/scaleway/scaleway-sdk-go/pull/447)) * **account**: add project_id in ssh-key ([#438](https://github.com/scaleway/scaleway-sdk-go/pull/438)) * **baremetal**: add RetryInterval variable ([#357](https://github.com/scaleway/scaleway-sdk-go/pull/357)) * **baremetal**: add boot type in start server ([#500](https://github.com/scaleway/scaleway-sdk-go/pull/500)) * **baremetal**: add install in create server ([#499](https://github.com/scaleway/scaleway-sdk-go/pull/499)) * **baremetal**: add ping status in server ([#390](https://github.com/scaleway/scaleway-sdk-go/pull/390)) * **baremetal**: add project-id to ipfailover v1alpha1 ([#559](https://github.com/scaleway/scaleway-sdk-go/pull/559)) * **baremetal**: add server helpers func in v1 ([#397](https://github.com/scaleway/scaleway-sdk-go/pull/397)) * **baremetal**: add support for projects ([#535](https://github.com/scaleway/scaleway-sdk-go/pull/535)) * **baremetal**: add v1 ([#396](https://github.com/scaleway/scaleway-sdk-go/pull/396)) * **config**: add support for default profile ([#478](https://github.com/scaleway/scaleway-sdk-go/pull/478)) * **config**: move telemetry config in profile ([#427](https://github.com/scaleway/scaleway-sdk-go/pull/427)) * **core**: add GetSecretKey and GetAccessKey ([#386](https://github.com/scaleway/scaleway-sdk-go/pull/386)) * **domain**: add domain registration process on DomainSummary ([#560](https://github.com/scaleway/scaleway-sdk-go/pull/560)) * **domain**: add external domain support ([#401](https://github.com/scaleway/scaleway-sdk-go/pull/401)) * **domain**: add new task types ([#415](https://github.com/scaleway/scaleway-sdk-go/pull/415)) * **domain**: add new types in messages and email validated in domain contact ([#423](https://github.com/scaleway/scaleway-sdk-go/pull/423)) * **domain**: add organization_id filter ([#424](https://github.com/scaleway/scaleway-sdk-go/pull/424)) * **domain**: add registration process and is_external filter ([#507](https://github.com/scaleway/scaleway-sdk-go/pull/507)) * **error**: add resource locked error ([#361](https://github.com/scaleway/scaleway-sdk-go/pull/361)) * **errors**: handle instance unknown resource ([#374](https://github.com/scaleway/scaleway-sdk-go/pull/374)) * **instance**: Add private_network filter on ListServers ([#567](https://github.com/scaleway/scaleway-sdk-go/pull/567)) * **instance**: Remove private_networks in CreateServerRequest ([#572](https://github.com/scaleway/scaleway-sdk-go/pull/572)) * **instance**: add a WaitForImage method ([#381](https://github.com/scaleway/scaleway-sdk-go/pull/381)) * **instance**: add a wait on volume ([#418](https://github.com/scaleway/scaleway-sdk-go/pull/418)) * **instance**: add project to others resources ([#519](https://github.com/scaleway/scaleway-sdk-go/pull/519)) * **instance**: add project to resource IP ([#460](https://github.com/scaleway/scaleway-sdk-go/pull/460)) * **instance**: add snapshot wait utils ([#398](https://github.com/scaleway/scaleway-sdk-go/pull/398)) * **instance**: add support for name in backup action ([#383](https://github.com/scaleway/scaleway-sdk-go/pull/383)) * **instance**: add tags to IP ([#344](https://github.com/scaleway/scaleway-sdk-go/pull/344)) * **instance**: add volume type endpoint ([#440](https://github.com/scaleway/scaleway-sdk-go/pull/440)) * **instance**: allow filter by tags in server list ([#373](https://github.com/scaleway/scaleway-sdk-go/pull/373)) * **instance**: exclude SetIp of the SDK ([#461](https://github.com/scaleway/scaleway-sdk-go/pull/461)) * **instance**: fix volume template project oneof ([#561](https://github.com/scaleway/scaleway-sdk-go/pull/561)) * **instance**: fix volume type endpoint ([#441](https://github.com/scaleway/scaleway-sdk-go/pull/441)) * **instance**: update metadata struct ([#541](https://github.com/scaleway/scaleway-sdk-go/pull/541)) * **instance**: use generated UpdateVolume ([#417](https://github.com/scaleway/scaleway-sdk-go/pull/417)) * **iot**: add REST network type ([#505](https://github.com/scaleway/scaleway-sdk-go/pull/505)) * **iot**: add WaitForHub IoT helper ([#445](https://github.com/scaleway/scaleway-sdk-go/pull/445)) * **iot**: add hub events settings ([#476](https://github.com/scaleway/scaleway-sdk-go/pull/476)) * **iot**: add name generation on hub network and device ([#526](https://github.com/scaleway/scaleway-sdk-go/pull/526)) * **iot**: add product plan in UpdateHubRequest ([#513](https://github.com/scaleway/scaleway-sdk-go/pull/513)) * **iot**: add support for hub-id in an UpdateDeviceRequest #554 * **iot**: enable sdk generation ([#444](https://github.com/scaleway/scaleway-sdk-go/pull/444)) * **k8s**: add kubeconfig and helpers ([#364](https://github.com/scaleway/scaleway-sdk-go/pull/364)) * **k8s**: add project support ([#517](https://github.com/scaleway/scaleway-sdk-go/pull/517)) * **k8s**: add scaledown unneeded time ([#385](https://github.com/scaleway/scaleway-sdk-go/pull/385)) * **k8s**: add traefik2 ingress ([#443](https://github.com/scaleway/scaleway-sdk-go/pull/443)) * **k8s**: add v1 api * **k8s**: add wait for node method ([#352](https://github.com/scaleway/scaleway-sdk-go/pull/352)) * **k8s**: flag to delete block and pvc with kapsule ([#416](https://github.com/scaleway/scaleway-sdk-go/pull/416)) * **lb**: add SSL compatibility level ([#343](https://github.com/scaleway/scaleway-sdk-go/pull/343)) * **lb**: multi-certificacte in frontend ([#492](https://github.com/scaleway/scaleway-sdk-go/pull/492)) * **lb**: add default on the lb name generation ([#493](https://github.com/scaleway/scaleway-sdk-go/pull/493)) * **lb**: add private network ([#402](https://github.com/scaleway/scaleway-sdk-go/pull/402)) * **lb**: add support for multiple certificates in frontend ([#479](https://github.com/scaleway/scaleway-sdk-go/pull/479)) * **lb**: remove subscriber from cli generation ([#490](https://github.com/scaleway/scaleway-sdk-go/pull/490)) * **lb**: support projects ([#504](https://github.com/scaleway/scaleway-sdk-go/pull/504)) * **rdb**: add GetInstanceLogs method ([#484](https://github.com/scaleway/scaleway-sdk-go/pull/484)) * **rdb**: add beta flags ([#411](https://github.com/scaleway/scaleway-sdk-go/pull/411)) * **rdb**: add generated prefix ([#558](https://github.com/scaleway/scaleway-sdk-go/pull/558)) * **rdb**: add project_id to resources ([#571](https://github.com/scaleway/scaleway-sdk-go/pull/571)) * **rdb**: allow setting initial settings while creating an RDB instance. ([#536](https://github.com/scaleway/scaleway-sdk-go/pull/536)) * **rdb**: update upgrade call to add non-ha to ha upgrade ([#451](https://github.com/scaleway/scaleway-sdk-go/pull/451)) * **registry**: add wait functions on image and tag ([#426](https://github.com/scaleway/scaleway-sdk-go/pull/426)) * **registry**: support projects ([#506](https://github.com/scaleway/scaleway-sdk-go/pull/506)) * **vpc**: add support for project ([#565](https://github.com/scaleway/scaleway-sdk-go/pull/565)) * **vpc**: generate doc/cli/sdk ([#532](https://github.com/scaleway/scaleway-sdk-go/pull/532)) * add configurable retryInterval and timeout ([#428](https://github.com/scaleway/scaleway-sdk-go/pull/428)) * add projects ([#452](https://github.com/scaleway/scaleway-sdk-go/pull/452)) * add support for pl-waw-1 zone and pl-waw region ([#557](https://github.com/scaleway/scaleway-sdk-go/pull/557)) * set default project client value when request is empty ([#457](https://github.com/scaleway/scaleway-sdk-go/pull/457)) * use pointer to time.Time to allow null value ([#523](https://github.com/scaleway/scaleway-sdk-go/pull/523)) ### Fixes * **config**: LoadConfigFromPath better handle cross platform error ([#395](https://github.com/scaleway/scaleway-sdk-go/pull/395)) * **config**: debug level when reading env ([#349](https://github.com/scaleway/scaleway-sdk-go/pull/349)) * **errors**: handle all instance not found return messages ([#432](https://github.com/scaleway/scaleway-sdk-go/pull/432)) * **instance**: GetServerTypesAvailabilityResponse nested object * **instance**: volume listing return all types by default * **k8s**: add global retry interval for wait func ([#354](https://github.com/scaleway/scaleway-sdk-go/pull/354)) * **k8s**: change type for kubeconfig certificates ([#362](https://github.com/scaleway/scaleway-sdk-go/pull/362)) * **k8s**: panic on helpers timeout ([#369](https://github.com/scaleway/scaleway-sdk-go/pull/369)) * **k8s**: remove oldbinpacking from autoscaler estimator ([#389](https://github.com/scaleway/scaleway-sdk-go/pull/389)) * **rdb**: switch from ip to ipnet in ACL ([#482](https://github.com/scaleway/scaleway-sdk-go/pull/482)) * **registry**: use scw.Size ([#391](https://github.com/scaleway/scaleway-sdk-go/pull/391)) * date format in query parameters ([#471](https://github.com/scaleway/scaleway-sdk-go/pull/471)) * handle additional non standards errors ([#525](https://github.com/scaleway/scaleway-sdk-go/pull/525)) ### Others * **chore - baremetal**: rename to GetOfferFromOfferNameRequest ([#353](https://github.com/scaleway/scaleway-sdk-go/pull/353)) * **chore - config**: use os.UserHomeDir * **chore - iot**: deprecate organization ID in CreateNetworkRequest ([#501](https://github.com/scaleway/scaleway-sdk-go/pull/501)) * **chore - locality**: small fixes ([#455](https://github.com/scaleway/scaleway-sdk-go/pull/455)) * **chore - rdb**: add locked status ([#568](https://github.com/scaleway/scaleway-sdk-go/pull/568)) * **chore - sdk_compilation_test**: add missing api packages in test ([#446](https://github.com/scaleway/scaleway-sdk-go/pull/446)) * **chore - vendor**: remove vendor folder and rely on go module instead ([#469](https://github.com/scaleway/scaleway-sdk-go/pull/469)) * **chore**: export Scaleway environment variable constants ([#400](https://github.com/scaleway/scaleway-sdk-go/pull/400)) * **chore**: export scw.getScwConfigDir ([#514](https://github.com/scaleway/scaleway-sdk-go/pull/514)) * **chore**: use focal fossa as an example ([#408](https://github.com/scaleway/scaleway-sdk-go/pull/408)) * **doc - account**: improve ssh-key documentation ([#375](https://github.com/scaleway/scaleway-sdk-go/pull/375)) * **doc - config**: add project_id ([#543](https://github.com/scaleway/scaleway-sdk-go/pull/543)) * **doc - core**: update credentials links ([#564](https://github.com/scaleway/scaleway-sdk-go/pull/564)) * **doc - instance**: documentation improvments ([#563](https://github.com/scaleway/scaleway-sdk-go/pull/563)) * **doc - instance**: fix project documentation ([#551](https://github.com/scaleway/scaleway-sdk-go/pull/551)) * **doc - rdb**: add go doc ([#465](https://github.com/scaleway/scaleway-sdk-go/pull/465)) * **doc - rdb**: remove dev1-s mention ([#472](https://github.com/scaleway/scaleway-sdk-go/pull/472)) * **docs**: add deprecation notices ([#570](https://github.com/scaleway/scaleway-sdk-go/pull/570)) * **docs**: improve API documentations ([#345](https://github.com/scaleway/scaleway-sdk-go/pull/345)) * **docs**: update generated godoc ([#481](https://github.com/scaleway/scaleway-sdk-go/pull/481)) * **docs - account**: comment few fields #380 * **docs - baremetal**: update comment ([#503](https://github.com/scaleway/scaleway-sdk-go/pull/503)) * **docs**: fix badges and update godoc links ([#520](https://github.com/scaleway/scaleway-sdk-go/pull/520)) * **rdb**: add support for wait on backup resource ([#474](https://github.com/scaleway/scaleway-sdk-go/pull/474)) * **rdb**: add wait function for instance logs ([#485](https://github.com/scaleway/scaleway-sdk-go/pull/485)) * **refactor**: rename method DurationPtr ## v1.0.0-beta.6 (2020-02-28) ### Features * **baremetal**: add zone in primary resource ([#305](https://github.com/scaleway/scaleway-sdk-go/pull/305)) * **baremetal**: add get metrics method ([#298](https://github.com/scaleway/scaleway-sdk-go/pull/298)) * **core**: add String method to scw.Money ([#284](https://github.com/scaleway/scaleway-sdk-go/pull/284)) * **core**: add send_telemetry setting in the config ([#273](https://github.com/scaleway/scaleway-sdk-go/pull/273)) * **core**: add custom duration type ([#291](https://github.com/scaleway/scaleway-sdk-go/pull/291)) * **core**: handle instance quota exceeded error ([#287](https://github.com/scaleway/scaleway-sdk-go/pull/287)) * **core**: handle non standard errors ([#274](https://github.com/scaleway/scaleway-sdk-go/pull/274)) * **core**: support more instance error types ([#278](https://github.com/scaleway/scaleway-sdk-go/pull/278)) * **core**: Add ResourceExpiredError ([#280](https://github.com/scaleway/scaleway-sdk-go/pull/280)) * **core**: add GetCacheDirectory method ([#304](https://github.com/scaleway/scaleway-sdk-go/pull/304)) * **domain**: first release of the API ([#297](https://github.com/scaleway/scaleway-sdk-go/pull/297)) * **instance**: add OrganizationDefault to UpdateSecurityGroup ([#279](https://github.com/scaleway/scaleway-sdk-go/pull/279)) * **instance**: add zone field in instance resources response ([#331](https://github.com/scaleway/scaleway-sdk-go/pull/331)) * **instance**: allow empty boot type on create server [#325](https://github.com/scaleway/scaleway-sdk-go/pull/325)) * **k8s**: add FeatureGates and AdmissionPlugins ([#289](https://github.com/scaleway/scaleway-sdk-go/pull/289)) * **k8s**: add WaitForPoolNodesReady and WaitForClusterNodesReady helper methods ([#312](https://github.com/scaleway/scaleway-sdk-go/pull/312)) * **k8s**: add creation_error node status ([#328](https://github.com/scaleway/scaleway-sdk-go/pull/328)) * **k8s**: add upgrading pool status ([#319](https://github.com/scaleway/scaleway-sdk-go/pull/319)) * **k8s**: add UpgradeAvailable in pool ([#276](https://github.com/scaleway/scaleway-sdk-go/pull/276)) * **k8s**: add a field to rename Cluster ([#285](https://github.com/scaleway/scaleway-sdk-go/pull/285)) * **k8s**: add v1beta4 version ([#276](https://github.com/scaleway/scaleway-sdk-go/pull/276)) * **lb**: add CreateIP method ([#290](https://github.com/scaleway/scaleway-sdk-go/pull/290)) * **lb**: add support for proxy protocol ([#299](https://github.com/scaleway/scaleway-sdk-go/pull/299)) * **lb**: add Subscriber related methods ([#276](https://github.com/scaleway/scaleway-sdk-go/pull/276)) * **rdb**: add ExportDatabaseBackup method ([#292](https://github.com/scaleway/scaleway-sdk-go/pull/292)) * **rdb**: add OrganizationID field to ListDatabaseBackups ([#321](https://github.com/scaleway/scaleway-sdk-go/pull/321)) * **strcase**: add functions ([#275](https://github.com/scaleway/scaleway-sdk-go/pull/275)) ### Fixes * **core**: doc typo ([#293](https://github.com/scaleway/scaleway-sdk-go/pull/293)) * **core**: do not omit empty Money fields ([#288](https://github.com/scaleway/scaleway-sdk-go/pull/288)) * **core**: handle content-types in ResponseError ([#315](https://github.com/scaleway/scaleway-sdk-go/pull/315)) * **core**: handle precision and clean rounding of Money ([#286](https://github.com/scaleway/scaleway-sdk-go/pull/286)) * **instance**: set all server user data stop deleting all keys ([#281](https://github.com/scaleway/scaleway-sdk-go/pull/281)) * **instance**: properly convert ipId to ip-id, rename field of DeleteIpRequest ([#272](https://github.com/scaleway/scaleway-sdk-go/pull/272)) * **lb**: UpdateIP method reverse field ([#320](https://github.com/scaleway/scaleway-sdk-go/pull/320)) * **scripts**: golangci-lint binary installation test ([#301](https://github.com/scaleway/scaleway-sdk-go/pull/301)) ## v1.0.0-beta.5 (2019-12-09) ### Features * **baremetal**: add ListOffers and ListOs methods ([#259](https://github.com/scaleway/scaleway-sdk-go/pull/259)) * **config**: add a typed error on config file not found ([#264](https://github.com/scaleway/scaleway-sdk-go/pull/264)) * **config**: add a commented configuration file ([#231](https://github.com/scaleway/scaleway-sdk-go/pull/231)) * **core**: get Region from Zone ([#255](https://github.com/scaleway/scaleway-sdk-go/pull/255)) * **core**: client validation ([#238](https://github.com/scaleway/scaleway-sdk-go/pull/238)) * **core**: IPNet type ([#236](https://github.com/scaleway/scaleway-sdk-go/pull/236)) * **core**: introduce format validation in locality parsing ([#237](https://github.com/scaleway/scaleway-sdk-go/pull/237)) * **core**: add scw.MergeProfiles command ([#234](https://github.com/scaleway/scaleway-sdk-go/pull/234)) * **core**: add ClientCredentialError ([#228](https://github.com/scaleway/scaleway-sdk-go/pull/228)) * **core**: client without auth by default ([#233](https://github.com/scaleway/scaleway-sdk-go/pull/233)) * **k8s**: add maintenance and upgrade features ([#258](https://github.com/scaleway/scaleway-sdk-go/pull/258)) * **k8s**: add Pool.PlacementGroupID field ([#246](https://github.com/scaleway/scaleway-sdk-go/pull/246)) * **lb**: custom certificate ([#262](https://github.com/scaleway/scaleway-sdk-go/pull/262)) * **lb**: add ListBackendStats method ([#252](https://github.com/scaleway/scaleway-sdk-go/pull/252)) * **instance**: publish WaitForServer ([#244](https://github.com/scaleway/scaleway-sdk-go/pull/244)) * **instance**: generate name for new snapshot or image ([#230](https://github.com/scaleway/scaleway-sdk-go/pull/230)) * **strcase**: add strcase lib ([#229](https://github.com/scaleway/scaleway-sdk-go/pull/229)) * **rdb**: wait for Instance ([#249](https://github.com/scaleway/scaleway-sdk-go/pull/249)) * **rdb**: add rdb API ([#247](https://github.com/scaleway/scaleway-sdk-go/pull/247)) * **registry**: add WaitForNamespace method ([#253](https://github.com/scaleway/scaleway-sdk-go/pull/253)) * **validation**: add IsEmail ([#242](https://github.com/scaleway/scaleway-sdk-go/pull/242)) * **validation**: make validation package public ([#241](https://github.com/scaleway/scaleway-sdk-go/pull/241)) ### Fixes * **baremetal**: fix WaitForServer and add WaitForServerInstall ([#263](https://github.com/scaleway/scaleway-sdk-go/pull/263)) * **baremetal**: add Undelivered and Locked to terminalStatus ([#260](https://github.com/scaleway/scaleway-sdk-go/pull/260)) * **config**: merge selected profile on top of default profile ([#243](https://github.com/scaleway/scaleway-sdk-go/pull/243)) * **instance**: WaitForServer returns an error interface ([#245](https://github.com/scaleway/scaleway-sdk-go/pull/245)) * **instance**: use IPNet type for security group rule ip_range ([#240](https://github.com/scaleway/scaleway-sdk-go/pull/240)) * **instance**: update placement-group now works ([#224](https://github.com/scaleway/scaleway-sdk-go/pull/224)) ## v1.0.0-beta.4 (2019-10-25) ### Breaking Changes * use uint32 for page_size ([#210](https://github.com/scaleway/scaleway-sdk-go/pull/210)) ### Features * update generated apis ([#218](https://github.com/scaleway/scaleway-sdk-go/pull/218)) * update generated apis ([#216](https://github.com/scaleway/scaleway-sdk-go/pull/216)) * **lb**: add WaitForLb method ([#212](https://github.com/scaleway/scaleway-sdk-go/pull/212)) * update generated apis ([#213](https://github.com/scaleway/scaleway-sdk-go/pull/213)) * update generated apis ([#208](https://github.com/scaleway/scaleway-sdk-go/pull/208)) * **marketplace**: uppercase commercial type in GetLocalImageIDByLabel ([#205](https://github.com/scaleway/scaleway-sdk-go/pull/205)) * add kubeconfig helpers for k8s ([#204](https://github.com/scaleway/scaleway-sdk-go/pull/204)) * update generated apis ([#203](https://github.com/scaleway/scaleway-sdk-go/pull/203)) * add k8s WaitForCluster method ([#202](https://github.com/scaleway/scaleway-sdk-go/pull/202)) * add scw.IPPtr ([#200](https://github.com/scaleway/scaleway-sdk-go/pull/200)) * add k8s v1beta3 ([#198](https://github.com/scaleway/scaleway-sdk-go/pull/198)) ### Fixes * **instance**: update generated apis ([#219](https://github.com/scaleway/scaleway-sdk-go/pull/219)) * **instance**: ListImage total count ([#209](https://github.com/scaleway/scaleway-sdk-go/pull/209)) * cleanup unused code ([#217](https://github.com/scaleway/scaleway-sdk-go/pull/217)) * **scw.File**: add unmarshal ([#201](https://github.com/scaleway/scaleway-sdk-go/pull/201)) ### Documentation * fix examples ([#215](https://github.com/scaleway/scaleway-sdk-go/pull/215)) ## v1.0.0-beta.3 (2019-10-01) ### Features * add interface body getter to std err ([#192](https://github.com/scaleway/scaleway-sdk-go/pull/192)) * add support for out of stock error ([#190](https://github.com/scaleway/scaleway-sdk-go/pull/190)) * use uint32 for page count ([#193](https://github.com/scaleway/scaleway-sdk-go/pull/193)) * add raw body to standard errors ([#191](https://github.com/scaleway/scaleway-sdk-go/pull/191)) * update generated apis ([#188](https://github.com/scaleway/scaleway-sdk-go/pull/188)) ### Fixes * e2e tests project ([#195](https://github.com/scaleway/scaleway-sdk-go/pull/195)) * **instance**: allow image to be empty in CreateServer ([#189](https://github.com/scaleway/scaleway-sdk-go/pull/189)) ## v1.0.0-beta.2 (2019-09-16) ### Features * test standard errors ([#183](https://github.com/scaleway/scaleway-sdk-go/pull/183)) * update generated apis ([#182](https://github.com/scaleway/scaleway-sdk-go/pull/182)) * standard error structures ([#177](https://github.com/scaleway/scaleway-sdk-go/pull/177)) ### Fixes * attach volume key choice ([#184](https://github.com/scaleway/scaleway-sdk-go/pull/184)) * add user agent to e2e tests ([#181](https://github.com/scaleway/scaleway-sdk-go/pull/181)) * update version ([#180](https://github.com/scaleway/scaleway-sdk-go/pull/180)) * UpdateSecurityGroupRule can now remove DestPortFrom and DestPortTo ([#179](https://github.com/scaleway/scaleway-sdk-go/pull/179)) golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/CODE_OF_CONDUCT.md000066400000000000000000000064561456366605600250700ustar00rootroot00000000000000# Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: - Using welcoming and inclusive language - Being respectful of differing viewpoints and experiences - Gracefully accepting constructive criticism - Focusing on what is best for the community - Showing empathy towards other community members Examples of unacceptable behavior by participants include: - The use of sexualized language or imagery and unwelcome sexual attention or advances - Trolling, insulting/derogatory comments, and personal or political attacks - Public or private harassment - Publishing others' private information, such as a physical or electronic address, without explicit permission - Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies within all project spaces, and it also applies when an individual is representing the project or its community in public spaces. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at opensource@scaleway.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/CONTRIBUTING.md000066400000000000000000000111541456366605600245110ustar00rootroot00000000000000# Contribute to `scaleway-sdk-go` `scaleway-sdk-go` is Apache 2.0 licensed and accepts contributions via GitHub. This document will cover how to contribute to the project and report issues.

## Topics - [Reporting Security Issues](#reporting-security-issues) - [Reporting Issues](#reporting-issues) - [Suggesting feature](#suggesting-feature) - [Contributing Code](#contributing-code) - [Community Guidelines](#community-guidelines) ## Reporting security issues At Scaleway we take security seriously. If you have any issue regarding security, please notify us by sending an email to [security@scaleway.com](mailto:security@scaleway.com). Please _DO NOT_ create a GitHub issue. We will follow up with you promptly with more information and a plan for remediation. We currently do not offer a paid security bounty program, but we would love to send some Scaleway swag your way along with our deepest gratitude for your assistance in making Scaleway a more secure Cloud ecosystem. ## Reporting issues A great way to contribute to the project is to send a detailed report when you encounter a bug. We always appreciate a well-written, thorough bug report, and will thank you for it! Before opening a new issue, we appreciate you reviewing open issues to see if there are any similar requests. If there is a match, thumbs up the issue with a 👍 and leave a comment if you have additional information. When reporting an issue, include the following: - The version of `scaleway-sdk-go` you are using (v2.0.0-beta1, v2.0.0, master,...) - Go version - GOOS - GOARCH ## Suggesting a feature When requesting a feature, some of the questions we want to answer are: - What value does this feature bring to end users? - How urgent is the need (nice to have feature or need to have)? - Does this align with the goals of `scaleway-sdk-go`? ## Contributing code Before contributing to the code, make sure you have read about the [continuous code deployment](docs/CONTINUOUS_CODE_DEPLOYMENT.md) process we are using on this repo. ### Submit code To submit code: - Create a fork of the project - Create a topic branch from where you want to base your work (usually master) - Add tests to cover contributed code - Push your commit(s) to your topic branch on your fork - Open a pull request against `scaleway-sdk-go` master branch that follows [PR guidelines](#pull-request-guidelines) The [maintainers](MAINTAINERS.md) of `scaleway-sdk-go` use a "Let's Get This Merged" (LGTM) message in the pull request to note that the commits are ready to merge. After one or more maintainer states LGTM, we will merge. If you have questions or comments on your code, feel free to correct these in your branch through new commits. ### Pull Request Guidelines The goal of the following guidelines is to have Pull Requests (PRs) that are fairly easy to review and comprehend, and code that is easy to maintain in the future. - **Pull Request title should be clear** on what is being fixed or added to the code base. If you are addressing an open issue, please start the title with "fix: #XXX" or "feature: #XXX" - **Keep it readable for human reviewers** and prefer a subset of functionality (code) with tests and documentation over delivering them separately - **Don't forget commenting code** to help reviewers understand and to keep [our Go Report Card](https://goreportcard.com/report/github.com/scaleway/scaleway-sdk-go) at A+ - **Notify Work In Progress PRs** by prefixing the title with `[WIP]` - **Please, keep us updated.** We will try our best to merge your PR, but please notice that PRs may be closed after 30 days of inactivity. Your pull request should be rebased against the current master branch. Please do not merge the current master branch in with your topic branch, nor use the Update Branch button provided by GitHub on the pull request page. Keep in mind only the **Pull Request Title** will be used as commit message as we stash all commits on merge. ## Community guidelines See [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md). Thank you for reading through all of this, if you have any question feel free to [reach us](README.md#reach-us)! ## Developer documentation ### Namespaces Namespaces SHOULD only be written using lowercase letters. No dash are allowed. Example: `accountprivate` is a valid Go namespace. ### Validation Some validation is done internally on Scaleway's side: see [scaleway-sdk-go/docs/CONTINUOUS_CODE_DEPLOYMENT.md](https://github.com/scaleway/scaleway-sdk-go/blob/master/docs/CONTINUOUS_CODE_DEPLOYMENT.md) This is true for: - package namespaces. The rest is manually checked for now. golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/LICENSE000066400000000000000000000250051456366605600232650ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 https://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS Copyright 2019 Scaleway. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/MAINTAINERS.md000066400000000000000000000007561456366605600243620ustar00rootroot00000000000000This page lists all active maintainers of `scaleway-sdk-go`. This can be used for routing PRs, questions, etc. to the right place. - See [CONTRIBUTING.md](CONTRIBUTING.md) for general contribution guidelines. ### Maintainers | Name | Tag | | :------------- | :-------------- | | Jérôme Quéré | @jerome-quere | | Quentin Brosse | @QuentinBrosse | | Loïc Bourgois | @loicbourgois | | Olivier Cano | @kindermoumoute | | Rémy Léone | @remyleone | golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/README.md000066400000000000000000000060211456366605600235340ustar00rootroot00000000000000

PkgGoDev GitHub Actions GoReportCard

# Scaleway GO SDK **:warning: This is an early release, keep in mind that the API can break** Scaleway is a single way to create, deploy and scale your infrastructure in the cloud. We help thousands of businesses to run their infrastructures easily. ## Documentation - [Godoc](https://pkg.go.dev/github.com/scaleway/scaleway-sdk-go?tab=doc) - [Developers website](https://developers.scaleway.com) (API documentation) - [Products availability guide](https://www.scaleway.com/en/docs/console/my-account/reference-content/products-availability/) - [The community tools](https://developers.scaleway.com/en/community-tools/#official-repos) ## Installation ```bash go get github.com/scaleway/scaleway-sdk-go ``` ## Getting Started ```go package main import ( "fmt" "github.com/scaleway/scaleway-sdk-go/api/instance/v1" "github.com/scaleway/scaleway-sdk-go/scw" "github.com/scaleway/scaleway-sdk-go/utils" ) func main() { // Create a Scaleway client client, err := scw.NewClient( // Get your organization ID at https://console.scaleway.com/organization/settings scw.WithDefaultOrganizationID("SCW_DEFAULT_ORGANIZATION_ID"), // Get your credentials at https://console.scaleway.com/iam/api-keys scw.WithAuth("SCW_ACCESS_KEY", "SCW_SECRET_KEY"), // Get more about our availability zones at https://www.scaleway.com/en/docs/console/my-account/reference-content/products-availability/ scw.WithDefaultRegion("SCW_REGION"), ) if err != nil { panic(err) } // Create SDK objects for Scaleway Instance product instanceApi := instance.NewAPI(client) // Call the ListServers method on the Instance SDK response, err := instanceApi.ListServers(&instance.ListServersRequest{ Zone: scw.ZoneFrPar1, }) if err != nil { panic(err) } // Do something with the response... for _, server := range response.Servers { fmt.Println("Server", server.ID, server.Name) } } ``` ## Examples You can find additional examples in the [GoDoc](https://pkg.go.dev/github.com/scaleway/scaleway-sdk-go?tab=doc). ## Development This repository is at its early stage and is still in active development. If you are looking for a way to contribute please read [CONTRIBUTING.md](CONTRIBUTING.md). ## Reach us We love feedback. Feel free to reach us on [Scaleway Slack community](https://slack.scaleway.com/), we are waiting for you on [#opensource](https://scaleway-community.slack.com/app_redirect?channel=opensource). golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/000077500000000000000000000000001456366605600230275ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/account/000077500000000000000000000000001456366605600244635ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/account/v2/000077500000000000000000000000001456366605600250125ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/account/v2/account_sdk.go000066400000000000000000000227461456366605600276510ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package account provides methods and message types of the account v2 API. package account import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type ListProjectsRequestOrderBy string const ( // Creation date ascending. ListProjectsRequestOrderByCreatedAtAsc = ListProjectsRequestOrderBy("created_at_asc") // Creation date descending. ListProjectsRequestOrderByCreatedAtDesc = ListProjectsRequestOrderBy("created_at_desc") // Name ascending. ListProjectsRequestOrderByNameAsc = ListProjectsRequestOrderBy("name_asc") // Name descending. ListProjectsRequestOrderByNameDesc = ListProjectsRequestOrderBy("name_desc") ) func (enum ListProjectsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListProjectsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListProjectsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListProjectsRequestOrderBy(ListProjectsRequestOrderBy(tmp).String()) return nil } // Project: project. type Project struct { // ID: ID of the Project. ID string `json:"id"` // Name: name of the Project. Name string `json:"name"` // OrganizationID: organization ID of the Project. OrganizationID string `json:"organization_id"` // CreatedAt: creation date of the Project. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: update date of the Project. UpdatedAt *time.Time `json:"updated_at"` // Description: description of the Project. Description string `json:"description"` } // CreateProjectRequest: create project request. type CreateProjectRequest struct { // Name: name of the Project. Name string `json:"name"` // OrganizationID: organization ID of the Project. OrganizationID string `json:"organization_id"` // Description: description of the Project. Description *string `json:"description,omitempty"` } // DeleteProjectRequest: delete project request. type DeleteProjectRequest struct { // ProjectID: project ID of the Project. ProjectID string `json:"-"` } // GetProjectRequest: get project request. type GetProjectRequest struct { // ProjectID: project ID of the Project. ProjectID string `json:"-"` } // ListProjectsRequest: list projects request. type ListProjectsRequest struct { // OrganizationID: organization ID of the Project. OrganizationID string `json:"-"` // Name: name of the Project. Name *string `json:"-"` // Page: page number for the returned Projects. Page *int32 `json:"-"` // PageSize: maximum number of Project per page. PageSize *uint32 `json:"-"` // OrderBy: sort order of the returned Projects. // Default value: created_at_asc OrderBy ListProjectsRequestOrderBy `json:"-"` // ProjectIDs: project IDs to filter for. The results will be limited to any Projects with an ID in this array. ProjectIDs []string `json:"-"` } // ListProjectsResponse: list projects response. type ListProjectsResponse struct { // TotalCount: total number of Projects. TotalCount uint32 `json:"total_count"` // Projects: paginated returned Projects. Projects []*Project `json:"projects"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListProjectsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListProjectsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListProjectsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Projects = append(r.Projects, results.Projects...) r.TotalCount += uint32(len(results.Projects)) return uint32(len(results.Projects)), nil } // UpdateProjectRequest: update project request. type UpdateProjectRequest struct { // ProjectID: project ID of the Project. ProjectID string `json:"-"` // Name: name of the Project. Name *string `json:"name,omitempty"` // Description: description of the Project. Description *string `json:"description,omitempty"` } // This API allows you to manage projects. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } // Deprecated: CreateProject: Deprecated in favor of Account API v3. // Generate a new Project for an Organization, specifying its configuration including name and description. func (s *API) CreateProject(req *CreateProjectRequest, opts ...scw.RequestOption) (*Project, error) { var err error if req.OrganizationID == "" { defaultOrganizationID, _ := s.client.GetDefaultOrganizationID() req.OrganizationID = defaultOrganizationID } if req.Name == "" { req.Name = namegenerator.GetRandomName("proj") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/account/v2/projects", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Project err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // Deprecated: ListProjects: Deprecated in favor of Account API v3. // List all Projects of an Organization. The response will include the total number of Projects as well as their associated Organizations, names and IDs. Other information include the creation and update date of the Project. func (s *API) ListProjects(req *ListProjectsRequest, opts ...scw.RequestOption) (*ListProjectsResponse, error) { var err error if req.OrganizationID == "" { defaultOrganizationID, _ := s.client.GetDefaultOrganizationID() req.OrganizationID = defaultOrganizationID } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "project_ids", req.ProjectIDs) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/account/v2/projects", Query: query, } var resp ListProjectsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // Deprecated: GetProject: Deprecated in favor of Account API v3. // Retrieve information about an existing Project, specified by its Project ID. Its full details, including ID, name and description, are returned in the response object. func (s *API) GetProject(req *GetProjectRequest, opts ...scw.RequestOption) (*Project, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.ProjectID) == "" { return nil, errors.New("field ProjectID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/account/v2/projects/" + fmt.Sprint(req.ProjectID) + "", } var resp Project err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // Deprecated: DeleteProject: Deprecated in favor of Account API v3. // Delete an existing Project, specified by its Project ID. The Project needs to be empty (meaning there are no resources left in it) to be deleted effectively. Note that deleting a Project is permanent, and cannot be undone. func (s *API) DeleteProject(req *DeleteProjectRequest, opts ...scw.RequestOption) error { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.ProjectID) == "" { return errors.New("field ProjectID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/account/v2/projects/" + fmt.Sprint(req.ProjectID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // Deprecated: UpdateProject: Deprecated in favor of Account API v3. // Update the parameters of an existing Project, specified by its Project ID. These parameters include the name and description. func (s *API) UpdateProject(req *UpdateProjectRequest, opts ...scw.RequestOption) (*Project, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.ProjectID) == "" { return nil, errors.New("field ProjectID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/account/v2/projects/" + fmt.Sprint(req.ProjectID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Project err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/account/v2alpha1/000077500000000000000000000000001456366605600261015ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/account/v2alpha1/account_sdk.go000066400000000000000000000175621456366605600307400ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package account provides methods and message types of the account v2alpha1 API. package account import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) // API: account API. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } type ListSSHKeysRequestOrderBy string const ( ListSSHKeysRequestOrderByCreatedAtAsc = ListSSHKeysRequestOrderBy("created_at_asc") ListSSHKeysRequestOrderByCreatedAtDesc = ListSSHKeysRequestOrderBy("created_at_desc") ListSSHKeysRequestOrderByUpdatedAtAsc = ListSSHKeysRequestOrderBy("updated_at_asc") ListSSHKeysRequestOrderByUpdatedAtDesc = ListSSHKeysRequestOrderBy("updated_at_desc") ListSSHKeysRequestOrderByNameAsc = ListSSHKeysRequestOrderBy("name_asc") ListSSHKeysRequestOrderByNameDesc = ListSSHKeysRequestOrderBy("name_desc") ) func (enum ListSSHKeysRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListSSHKeysRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListSSHKeysRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListSSHKeysRequestOrderBy(ListSSHKeysRequestOrderBy(tmp).String()) return nil } // ListSSHKeysResponse: list ssh keys response. type ListSSHKeysResponse struct { SSHKeys []*SSHKey `json:"ssh_keys"` TotalCount uint32 `json:"total_count"` } // SSHKey: ssh key. type SSHKey struct { ID string `json:"id"` Name string `json:"name"` PublicKey string `json:"public_key"` Fingerprint string `json:"fingerprint"` CreatedAt *time.Time `json:"created_at"` UpdatedAt *time.Time `json:"updated_at"` CreationInfo *SSHKeyCreationInfo `json:"creation_info"` OrganizationID string `json:"organization_id"` ProjectID string `json:"project_id"` } type SSHKeyCreationInfo struct { Address string `json:"address"` UserAgent string `json:"user_agent"` CountryCode string `json:"country_code"` } // Service API type ListSSHKeysRequest struct { // OrderBy: default value: created_at_asc OrderBy ListSSHKeysRequestOrderBy `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` Name *string `json:"-"` OrganizationID *string `json:"-"` ProjectID *string `json:"-"` } // ListSSHKeys: list all SSH keys of your project. func (s *API) ListSSHKeys(req *ListSSHKeysRequest, opts ...scw.RequestOption) (*ListSSHKeysResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/account/v2alpha1/ssh-keys", Query: query, Headers: http.Header{}, } var resp ListSSHKeysResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } type CreateSSHKeyRequest struct { // Name: the name of the SSH key. Name string `json:"name"` // PublicKey: SSH public key. Currently ssh-rsa, ssh-dss (DSA), ssh-ed25519 and ecdsa keys with NIST curves are supported. PublicKey string `json:"public_key"` // Deprecated: OrganizationID: use project_id field instead. // Precisely one of OrganizationID, ProjectID must be set. OrganizationID *string `json:"organization_id,omitempty"` // ProjectID: project owning the resource. // Precisely one of OrganizationID, ProjectID must be set. ProjectID *string `json:"project_id,omitempty"` } // CreateSSHKey: add an SSH key to your project. func (s *API) CreateSSHKey(req *CreateSSHKeyRequest, opts ...scw.RequestOption) (*SSHKey, error) { var err error defaultProjectID, exist := s.client.GetDefaultProjectID() if exist && req.OrganizationID == nil && req.ProjectID == nil { req.ProjectID = &defaultProjectID } defaultOrganizationID, exist := s.client.GetDefaultOrganizationID() if exist && req.OrganizationID == nil && req.ProjectID == nil { req.OrganizationID = &defaultOrganizationID } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/account/v2alpha1/ssh-keys", Headers: http.Header{}, } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SSHKey err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } type GetSSHKeyRequest struct { // SSHKeyID: the ID of the SSH key. SSHKeyID string `json:"-"` } // GetSSHKey: get an SSH key from your project. func (s *API) GetSSHKey(req *GetSSHKeyRequest, opts ...scw.RequestOption) (*SSHKey, error) { var err error if fmt.Sprint(req.SSHKeyID) == "" { return nil, errors.New("field SSHKeyID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/account/v2alpha1/ssh-key/" + fmt.Sprint(req.SSHKeyID) + "", Headers: http.Header{}, } var resp SSHKey err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } type UpdateSSHKeyRequest struct { SSHKeyID string `json:"-"` // Name: name of the SSH key. Name *string `json:"name"` } // UpdateSSHKey: update an SSH key on your project. func (s *API) UpdateSSHKey(req *UpdateSSHKeyRequest, opts ...scw.RequestOption) (*SSHKey, error) { var err error if fmt.Sprint(req.SSHKeyID) == "" { return nil, errors.New("field SSHKeyID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/account/v2alpha1/ssh-key/" + fmt.Sprint(req.SSHKeyID) + "", Headers: http.Header{}, } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SSHKey err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } type DeleteSSHKeyRequest struct { SSHKeyID string `json:"-"` } // DeleteSSHKey: remove an SSH key from your project. func (s *API) DeleteSSHKey(req *DeleteSSHKeyRequest, opts ...scw.RequestOption) error { var err error if fmt.Sprint(req.SSHKeyID) == "" { return errors.New("field SSHKeyID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/account/v2alpha1/ssh-key/" + fmt.Sprint(req.SSHKeyID) + "", Headers: http.Header{}, } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListSSHKeysResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListSSHKeysResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListSSHKeysResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.SSHKeys = append(r.SSHKeys, results.SSHKeys...) r.TotalCount += uint32(len(results.SSHKeys)) return uint32(len(results.SSHKeys)), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/account/v3/000077500000000000000000000000001456366605600250135ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/account/v3/account_sdk.go000066400000000000000000000227561456366605600276530ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package account provides methods and message types of the account v3 API. package account import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type ListProjectsRequestOrderBy string const ( // Creation date ascending. ListProjectsRequestOrderByCreatedAtAsc = ListProjectsRequestOrderBy("created_at_asc") // Creation date descending. ListProjectsRequestOrderByCreatedAtDesc = ListProjectsRequestOrderBy("created_at_desc") // Name ascending. ListProjectsRequestOrderByNameAsc = ListProjectsRequestOrderBy("name_asc") // Name descending. ListProjectsRequestOrderByNameDesc = ListProjectsRequestOrderBy("name_desc") ) func (enum ListProjectsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListProjectsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListProjectsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListProjectsRequestOrderBy(ListProjectsRequestOrderBy(tmp).String()) return nil } // Project: project. type Project struct { // ID: ID of the Project. ID string `json:"id"` // Name: name of the Project. Name string `json:"name"` // OrganizationID: organization ID of the Project. OrganizationID string `json:"organization_id"` // CreatedAt: creation date of the Project. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: update date of the Project. UpdatedAt *time.Time `json:"updated_at"` // Description: description of the Project. Description string `json:"description"` } // ListProjectsResponse: list projects response. type ListProjectsResponse struct { // TotalCount: total number of Projects. TotalCount uint64 `json:"total_count"` // Projects: paginated returned Projects. Projects []*Project `json:"projects"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListProjectsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListProjectsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListProjectsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Projects = append(r.Projects, results.Projects...) r.TotalCount += uint64(len(results.Projects)) return uint64(len(results.Projects)), nil } // ProjectAPICreateProjectRequest: project api create project request. type ProjectAPICreateProjectRequest struct { // Name: name of the Project. Name string `json:"name"` // OrganizationID: organization ID of the Project. OrganizationID string `json:"organization_id"` // Description: description of the Project. Description string `json:"description"` } // ProjectAPIDeleteProjectRequest: project api delete project request. type ProjectAPIDeleteProjectRequest struct { // ProjectID: project ID of the Project. ProjectID string `json:"-"` } // ProjectAPIGetProjectRequest: project api get project request. type ProjectAPIGetProjectRequest struct { // ProjectID: project ID of the Project. ProjectID string `json:"-"` } // ProjectAPIListProjectsRequest: project api list projects request. type ProjectAPIListProjectsRequest struct { // OrganizationID: organization ID of the Project. OrganizationID string `json:"-"` // Name: name of the Project. Name *string `json:"-"` // Page: page number for the returned Projects. Page *int32 `json:"-"` // PageSize: maximum number of Project per page. PageSize *uint32 `json:"-"` // OrderBy: sort order of the returned Projects. // Default value: created_at_asc OrderBy ListProjectsRequestOrderBy `json:"-"` // ProjectIDs: project IDs to filter for. The results will be limited to any Projects with an ID in this array. ProjectIDs []string `json:"-"` } // ProjectAPIUpdateProjectRequest: project api update project request. type ProjectAPIUpdateProjectRequest struct { // ProjectID: project ID of the Project. ProjectID string `json:"-"` // Name: name of the Project. Name *string `json:"name,omitempty"` // Description: description of the Project. Description *string `json:"description,omitempty"` } // This API allows you to manage projects. type ProjectAPI struct { client *scw.Client } // NewProjectAPI returns a ProjectAPI object from a Scaleway client. func NewProjectAPI(client *scw.Client) *ProjectAPI { return &ProjectAPI{ client: client, } } // CreateProject: Generate a new Project for an Organization, specifying its configuration including name and description. func (s *ProjectAPI) CreateProject(req *ProjectAPICreateProjectRequest, opts ...scw.RequestOption) (*Project, error) { var err error if req.OrganizationID == "" { defaultOrganizationID, _ := s.client.GetDefaultOrganizationID() req.OrganizationID = defaultOrganizationID } if req.Name == "" { req.Name = namegenerator.GetRandomName("proj") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/account/v3/projects", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Project err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListProjects: List all Projects of an Organization. The response will include the total number of Projects as well as their associated Organizations, names, and IDs. Other information includes the creation and update date of the Project. func (s *ProjectAPI) ListProjects(req *ProjectAPIListProjectsRequest, opts ...scw.RequestOption) (*ListProjectsResponse, error) { var err error if req.OrganizationID == "" { defaultOrganizationID, _ := s.client.GetDefaultOrganizationID() req.OrganizationID = defaultOrganizationID } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "project_ids", req.ProjectIDs) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/account/v3/projects", Query: query, } var resp ListProjectsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetProject: Retrieve information about an existing Project, specified by its Project ID. Its full details, including ID, name and description, are returned in the response object. func (s *ProjectAPI) GetProject(req *ProjectAPIGetProjectRequest, opts ...scw.RequestOption) (*Project, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.ProjectID) == "" { return nil, errors.New("field ProjectID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/account/v3/projects/" + fmt.Sprint(req.ProjectID) + "", } var resp Project err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteProject: Delete an existing Project, specified by its Project ID. The Project needs to be empty (meaning there are no resources left in it) to be deleted effectively. Note that deleting a Project is permanent, and cannot be undone. func (s *ProjectAPI) DeleteProject(req *ProjectAPIDeleteProjectRequest, opts ...scw.RequestOption) error { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.ProjectID) == "" { return errors.New("field ProjectID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/account/v3/projects/" + fmt.Sprint(req.ProjectID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // UpdateProject: Update the parameters of an existing Project, specified by its Project ID. These parameters include the name and description. func (s *ProjectAPI) UpdateProject(req *ProjectAPIUpdateProjectRequest, opts ...scw.RequestOption) (*Project, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.ProjectID) == "" { return nil, errors.New("field ProjectID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/account/v3/projects/" + fmt.Sprint(req.ProjectID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Project err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/applesilicon/000077500000000000000000000000001456366605600255115ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/applesilicon/v1alpha1/000077500000000000000000000000001456366605600271265ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/applesilicon/v1alpha1/apple_silicon_utils.go000066400000000000000000000031031456366605600335130ustar00rootroot00000000000000package applesilicon import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) const ( defaultRetryInterval = 15 * time.Second defaultTimeout = 60 * time.Minute ) // WaitForInstanceRequest is used by WaitForServer method. type WaitForServerRequest struct { ServerID string Zone scw.Zone Timeout *time.Duration RetryInterval *time.Duration } // WaitForServer waits for the instance to be in a "terminal state" before returning. // This function can be used to wait for an instance to be ready for example. func (s *API) WaitForServer(req *WaitForServerRequest, opts ...scw.RequestOption) (*Server, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[ServerStatus]struct{}{ ServerStatusReady: {}, ServerStatusError: {}, } server, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetServer(&GetServerRequest{ ServerID: req.ServerID, Zone: req.Zone, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.Status] return res, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for server failed") } return server.(*Server), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/applesilicon/v1alpha1/applesilicon_sdk.go000066400000000000000000000530711456366605600330060ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package applesilicon provides methods and message types of the applesilicon v1alpha1 API. package applesilicon import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type ListServersRequestOrderBy string const ( ListServersRequestOrderByCreatedAtAsc = ListServersRequestOrderBy("created_at_asc") ListServersRequestOrderByCreatedAtDesc = ListServersRequestOrderBy("created_at_desc") ) func (enum ListServersRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListServersRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListServersRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListServersRequestOrderBy(ListServersRequestOrderBy(tmp).String()) return nil } type ServerStatus string const ( ServerStatusUnknownStatus = ServerStatus("unknown_status") ServerStatusStarting = ServerStatus("starting") ServerStatusReady = ServerStatus("ready") ServerStatusError = ServerStatus("error") ServerStatusRebooting = ServerStatus("rebooting") ServerStatusUpdating = ServerStatus("updating") ServerStatusLocking = ServerStatus("locking") ServerStatusLocked = ServerStatus("locked") ServerStatusUnlocking = ServerStatus("unlocking") ServerStatusReinstalling = ServerStatus("reinstalling") ) func (enum ServerStatus) String() string { if enum == "" { // return default value if empty return "unknown_status" } return string(enum) } func (enum ServerStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ServerStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ServerStatus(ServerStatus(tmp).String()) return nil } type ServerTypeStock string const ( ServerTypeStockUnknownStock = ServerTypeStock("unknown_stock") ServerTypeStockNoStock = ServerTypeStock("no_stock") ServerTypeStockLowStock = ServerTypeStock("low_stock") ServerTypeStockHighStock = ServerTypeStock("high_stock") ) func (enum ServerTypeStock) String() string { if enum == "" { // return default value if empty return "unknown_stock" } return string(enum) } func (enum ServerTypeStock) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ServerTypeStock) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ServerTypeStock(ServerTypeStock(tmp).String()) return nil } // ServerTypeCPU: server type cpu. type ServerTypeCPU struct { Name string `json:"name"` CoreCount uint32 `json:"core_count"` } // ServerTypeDisk: server type disk. type ServerTypeDisk struct { Capacity scw.Size `json:"capacity"` Type string `json:"type"` } // ServerTypeMemory: server type memory. type ServerTypeMemory struct { Capacity scw.Size `json:"capacity"` Type string `json:"type"` } // OS: os. type OS struct { // ID: unique ID of the OS. ID string `json:"id"` // Name: oS name. Name string `json:"name"` // Label: oS name as it should be displayed. Label string `json:"label"` // ImageURL: URL of the image. ImageURL string `json:"image_url"` // CompatibleServerTypes: list of compatible server types. CompatibleServerTypes []string `json:"compatible_server_types"` } // ServerType: server type. type ServerType struct { // CPU: CPU description. CPU *ServerTypeCPU `json:"cpu"` // Disk: size of the local disk of the server. Disk *ServerTypeDisk `json:"disk"` // Name: name of the type. Name string `json:"name"` // Memory: size of memory available. Memory *ServerTypeMemory `json:"memory"` // Stock: current stock. // Default value: unknown_stock Stock ServerTypeStock `json:"stock"` // MinimumLeaseDuration: minimum duration of the lease in seconds (example. 3.4s). MinimumLeaseDuration *scw.Duration `json:"minimum_lease_duration"` } // Server: server. type Server struct { // ID: UUID of the server. ID string `json:"id"` // Type: type of the server. Type string `json:"type"` // Name: name of the server. Name string `json:"name"` // ProjectID: project this server is associated with. ProjectID string `json:"project_id"` // OrganizationID: organization this server is associated with. OrganizationID string `json:"organization_id"` // IP: iPv4 address of the server. IP net.IP `json:"ip"` // VncURL: URL of the VNC. VncURL string `json:"vnc_url"` // Status: current status of the server. // Default value: unknown_status Status ServerStatus `json:"status"` // CreatedAt: date on which the server was created. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date on which the server was last updated. UpdatedAt *time.Time `json:"updated_at"` // DeletableAt: date on which the server was last deleted. DeletableAt *time.Time `json:"deletable_at"` // Zone: zone of the server. Zone scw.Zone `json:"zone"` } // CreateServerRequest: create server request. type CreateServerRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Name: create a server with this given name. Name string `json:"name"` // ProjectID: create a server in the given project ID. ProjectID string `json:"project_id"` // Type: create a server of the given type. Type string `json:"type"` } // DeleteServerRequest: delete server request. type DeleteServerRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: UUID of the server you want to delete. ServerID string `json:"-"` } // GetOSRequest: get os request. type GetOSRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // OsID: UUID of the OS you want to get. OsID string `json:"-"` } // GetServerRequest: get server request. type GetServerRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: UUID of the server you want to get. ServerID string `json:"-"` } // GetServerTypeRequest: get server type request. type GetServerTypeRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerType: server type identifier. ServerType string `json:"-"` } // ListOSRequest: list os request. type ListOSRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Page: positive integer to choose the page to return. Page *int32 `json:"-"` // PageSize: positive integer lower or equal to 100 to select the number of items to return. PageSize *uint32 `json:"-"` // ServerType: list of compatible server types. ServerType *string `json:"-"` // Name: filter OS by name (note that "11.1" will return "11.1.2" and "11.1" but not "12")). Name *string `json:"-"` } // ListOSResponse: list os response. type ListOSResponse struct { // TotalCount: total number of OS. TotalCount uint32 `json:"total_count"` // Os: list of OS. Os []*OS `json:"os"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListOSResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListOSResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListOSResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Os = append(r.Os, results.Os...) r.TotalCount += uint32(len(results.Os)) return uint32(len(results.Os)), nil } // ListServerTypesRequest: list server types request. type ListServerTypesRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` } // ListServerTypesResponse: list server types response. type ListServerTypesResponse struct { // ServerTypes: available server types. ServerTypes []*ServerType `json:"server_types"` } // ListServersRequest: list servers request. type ListServersRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // OrderBy: sort order of the returned servers. // Default value: created_at_asc OrderBy ListServersRequestOrderBy `json:"-"` // ProjectID: only list servers of this project ID. ProjectID *string `json:"-"` // OrganizationID: only list servers of this Organization ID. OrganizationID *string `json:"-"` // Page: positive integer to choose the page to return. Page *int32 `json:"-"` // PageSize: positive integer lower or equal to 100 to select the number of items to return. PageSize *uint32 `json:"-"` } // ListServersResponse: list servers response. type ListServersResponse struct { // TotalCount: total number of servers. TotalCount uint32 `json:"total_count"` // Servers: paginated returned servers. Servers []*Server `json:"servers"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListServersResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListServersResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListServersResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Servers = append(r.Servers, results.Servers...) r.TotalCount += uint32(len(results.Servers)) return uint32(len(results.Servers)), nil } // RebootServerRequest: reboot server request. type RebootServerRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: UUID of the server you want to reboot. ServerID string `json:"-"` } // ReinstallServerRequest: reinstall server request. type ReinstallServerRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: UUID of the server you want to reinstall. ServerID string `json:"-"` } // UpdateServerRequest: update server request. type UpdateServerRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: UUID of the server you want to update. ServerID string `json:"-"` // Name: updated name for your server. Name *string `json:"name,omitempty"` } type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Zones() []scw.Zone { return []scw.Zone{scw.ZoneFrPar3} } // ListServerTypes: List all technical details about Apple silicon server types available in the specified zone. Since there is only one Availability Zone for Apple silicon servers, the targeted value is `fr-par-3`. func (s *API) ListServerTypes(req *ListServerTypesRequest, opts ...scw.RequestOption) (*ListServerTypesResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/apple-silicon/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/server-types", } var resp ListServerTypesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetServerType: Get technical details (CPU, disk size etc.) of a server type. func (s *API) GetServerType(req *GetServerTypeRequest, opts ...scw.RequestOption) (*ServerType, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerType) == "" { return nil, errors.New("field ServerType cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/apple-silicon/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/server-type/" + fmt.Sprint(req.ServerType) + "", } var resp ServerType err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateServer: Create a new server in the targeted zone, specifying its configuration including name and type. func (s *API) CreateServer(req *CreateServerRequest, opts ...scw.RequestOption) (*Server, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if req.Name == "" { req.Name = namegenerator.GetRandomName("as") } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/apple-silicon/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/servers", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Server err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListServers: List all servers in the specified zone. By default, returned servers in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. func (s *API) ListServers(req *ListServersRequest, opts ...scw.RequestOption) (*ListServersResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/apple-silicon/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/servers", Query: query, } var resp ListServersResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListOS: List all Operating Systems (OS). The response will include the total number of OS as well as their associated IDs, names and labels. func (s *API) ListOS(req *ListOSRequest, opts ...scw.RequestOption) (*ListOSResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "server_type", req.ServerType) parameter.AddToQuery(query, "name", req.Name) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/apple-silicon/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/os", Query: query, } var resp ListOSResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetOS: Get an Operating System (OS). The response will include the OS's unique ID as well as its name and label. func (s *API) GetOS(req *GetOSRequest, opts ...scw.RequestOption) (*OS, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.OsID) == "" { return nil, errors.New("field OsID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/apple-silicon/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/os/" + fmt.Sprint(req.OsID) + "", } var resp OS err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetServer: Retrieve information about an existing Apple silicon server, specified by its server ID. Its full details, including name, status and IP address, are returned in the response object. func (s *API) GetServer(req *GetServerRequest, opts ...scw.RequestOption) (*Server, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/apple-silicon/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "", } var resp Server err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateServer: Update the parameters of an existing Apple silicon server, specified by its server ID. func (s *API) UpdateServer(req *UpdateServerRequest, opts ...scw.RequestOption) (*Server, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/apple-silicon/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Server err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteServer: Delete an existing Apple silicon server, specified by its server ID. Deleting a server is permanent, and cannot be undone. Note that the minimum allocation period for Apple silicon-as-a-service is 24 hours, meaning you cannot delete your server prior to that. func (s *API) DeleteServer(req *DeleteServerRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/apple-silicon/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // RebootServer: Reboot an existing Apple silicon server, specified by its server ID. func (s *API) RebootServer(req *RebootServerRequest, opts ...scw.RequestOption) (*Server, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/apple-silicon/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/reboot", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Server err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ReinstallServer: Reinstall an existing Apple silicon server (specified by its server ID) from a new image (OS). All the data on the disk is deleted and all configuration is reset to the defailt configuration values of the image (OS). func (s *API) ReinstallServer(req *ReinstallServerRequest, opts ...scw.RequestOption) (*Server, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/apple-silicon/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/reinstall", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Server err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/baremetal/000077500000000000000000000000001456366605600247635ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/baremetal/v1/000077500000000000000000000000001456366605600253115ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/baremetal/v1/baremetal_sdk.go000066400000000000000000002205751456366605600304500ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package baremetal provides methods and message types of the baremetal v1 API. package baremetal import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type IPReverseStatus string const ( IPReverseStatusUnknown = IPReverseStatus("unknown") IPReverseStatusPending = IPReverseStatus("pending") IPReverseStatusActive = IPReverseStatus("active") IPReverseStatusError = IPReverseStatus("error") ) func (enum IPReverseStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum IPReverseStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *IPReverseStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = IPReverseStatus(IPReverseStatus(tmp).String()) return nil } type IPVersion string const ( IPVersionIPv4 = IPVersion("IPv4") IPVersionIPv6 = IPVersion("IPv6") ) func (enum IPVersion) String() string { if enum == "" { // return default value if empty return "IPv4" } return string(enum) } func (enum IPVersion) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *IPVersion) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = IPVersion(IPVersion(tmp).String()) return nil } type ListServerEventsRequestOrderBy string const ( ListServerEventsRequestOrderByCreatedAtAsc = ListServerEventsRequestOrderBy("created_at_asc") ListServerEventsRequestOrderByCreatedAtDesc = ListServerEventsRequestOrderBy("created_at_desc") ) func (enum ListServerEventsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListServerEventsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListServerEventsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListServerEventsRequestOrderBy(ListServerEventsRequestOrderBy(tmp).String()) return nil } type ListServerPrivateNetworksRequestOrderBy string const ( ListServerPrivateNetworksRequestOrderByCreatedAtAsc = ListServerPrivateNetworksRequestOrderBy("created_at_asc") ListServerPrivateNetworksRequestOrderByCreatedAtDesc = ListServerPrivateNetworksRequestOrderBy("created_at_desc") ListServerPrivateNetworksRequestOrderByUpdatedAtAsc = ListServerPrivateNetworksRequestOrderBy("updated_at_asc") ListServerPrivateNetworksRequestOrderByUpdatedAtDesc = ListServerPrivateNetworksRequestOrderBy("updated_at_desc") ) func (enum ListServerPrivateNetworksRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListServerPrivateNetworksRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListServerPrivateNetworksRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListServerPrivateNetworksRequestOrderBy(ListServerPrivateNetworksRequestOrderBy(tmp).String()) return nil } type ListServersRequestOrderBy string const ( ListServersRequestOrderByCreatedAtAsc = ListServersRequestOrderBy("created_at_asc") ListServersRequestOrderByCreatedAtDesc = ListServersRequestOrderBy("created_at_desc") ) func (enum ListServersRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListServersRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListServersRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListServersRequestOrderBy(ListServersRequestOrderBy(tmp).String()) return nil } type ListSettingsRequestOrderBy string const ( ListSettingsRequestOrderByCreatedAtAsc = ListSettingsRequestOrderBy("created_at_asc") ListSettingsRequestOrderByCreatedAtDesc = ListSettingsRequestOrderBy("created_at_desc") ) func (enum ListSettingsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListSettingsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListSettingsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListSettingsRequestOrderBy(ListSettingsRequestOrderBy(tmp).String()) return nil } type OfferStock string const ( OfferStockEmpty = OfferStock("empty") OfferStockLow = OfferStock("low") OfferStockAvailable = OfferStock("available") ) func (enum OfferStock) String() string { if enum == "" { // return default value if empty return "empty" } return string(enum) } func (enum OfferStock) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *OfferStock) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = OfferStock(OfferStock(tmp).String()) return nil } type OfferSubscriptionPeriod string const ( OfferSubscriptionPeriodUnknownSubscriptionPeriod = OfferSubscriptionPeriod("unknown_subscription_period") OfferSubscriptionPeriodHourly = OfferSubscriptionPeriod("hourly") OfferSubscriptionPeriodMonthly = OfferSubscriptionPeriod("monthly") ) func (enum OfferSubscriptionPeriod) String() string { if enum == "" { // return default value if empty return "unknown_subscription_period" } return string(enum) } func (enum OfferSubscriptionPeriod) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *OfferSubscriptionPeriod) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = OfferSubscriptionPeriod(OfferSubscriptionPeriod(tmp).String()) return nil } type ServerBootType string const ( ServerBootTypeUnknownBootType = ServerBootType("unknown_boot_type") ServerBootTypeNormal = ServerBootType("normal") ServerBootTypeRescue = ServerBootType("rescue") ) func (enum ServerBootType) String() string { if enum == "" { // return default value if empty return "unknown_boot_type" } return string(enum) } func (enum ServerBootType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ServerBootType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ServerBootType(ServerBootType(tmp).String()) return nil } type ServerInstallStatus string const ( ServerInstallStatusUnknown = ServerInstallStatus("unknown") ServerInstallStatusToInstall = ServerInstallStatus("to_install") ServerInstallStatusInstalling = ServerInstallStatus("installing") ServerInstallStatusCompleted = ServerInstallStatus("completed") ServerInstallStatusError = ServerInstallStatus("error") ) func (enum ServerInstallStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum ServerInstallStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ServerInstallStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ServerInstallStatus(ServerInstallStatus(tmp).String()) return nil } type ServerOptionOptionStatus string const ( ServerOptionOptionStatusOptionStatusUnknown = ServerOptionOptionStatus("option_status_unknown") ServerOptionOptionStatusOptionStatusEnable = ServerOptionOptionStatus("option_status_enable") ServerOptionOptionStatusOptionStatusEnabling = ServerOptionOptionStatus("option_status_enabling") ServerOptionOptionStatusOptionStatusDisabling = ServerOptionOptionStatus("option_status_disabling") ServerOptionOptionStatusOptionStatusError = ServerOptionOptionStatus("option_status_error") ) func (enum ServerOptionOptionStatus) String() string { if enum == "" { // return default value if empty return "option_status_unknown" } return string(enum) } func (enum ServerOptionOptionStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ServerOptionOptionStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ServerOptionOptionStatus(ServerOptionOptionStatus(tmp).String()) return nil } type ServerPingStatus string const ( ServerPingStatusPingStatusUnknown = ServerPingStatus("ping_status_unknown") ServerPingStatusPingStatusUp = ServerPingStatus("ping_status_up") ServerPingStatusPingStatusDown = ServerPingStatus("ping_status_down") ) func (enum ServerPingStatus) String() string { if enum == "" { // return default value if empty return "ping_status_unknown" } return string(enum) } func (enum ServerPingStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ServerPingStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ServerPingStatus(ServerPingStatus(tmp).String()) return nil } type ServerPrivateNetworkStatus string const ( ServerPrivateNetworkStatusUnknown = ServerPrivateNetworkStatus("unknown") ServerPrivateNetworkStatusAttaching = ServerPrivateNetworkStatus("attaching") ServerPrivateNetworkStatusAttached = ServerPrivateNetworkStatus("attached") ServerPrivateNetworkStatusError = ServerPrivateNetworkStatus("error") ServerPrivateNetworkStatusDetaching = ServerPrivateNetworkStatus("detaching") ServerPrivateNetworkStatusLocked = ServerPrivateNetworkStatus("locked") ) func (enum ServerPrivateNetworkStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum ServerPrivateNetworkStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ServerPrivateNetworkStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ServerPrivateNetworkStatus(ServerPrivateNetworkStatus(tmp).String()) return nil } type ServerStatus string const ( ServerStatusUnknown = ServerStatus("unknown") ServerStatusDelivering = ServerStatus("delivering") ServerStatusReady = ServerStatus("ready") ServerStatusStopping = ServerStatus("stopping") ServerStatusStopped = ServerStatus("stopped") ServerStatusStarting = ServerStatus("starting") ServerStatusError = ServerStatus("error") ServerStatusDeleting = ServerStatus("deleting") ServerStatusLocked = ServerStatus("locked") ServerStatusOutOfStock = ServerStatus("out_of_stock") ServerStatusOrdered = ServerStatus("ordered") ServerStatusResetting = ServerStatus("resetting") ) func (enum ServerStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum ServerStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ServerStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ServerStatus(ServerStatus(tmp).String()) return nil } type SettingType string const ( SettingTypeUnknown = SettingType("unknown") SettingTypeSMTP = SettingType("smtp") ) func (enum SettingType) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum SettingType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *SettingType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = SettingType(SettingType(tmp).String()) return nil } // OSOSField: osos field. type OSOSField struct { Editable bool `json:"editable"` Required bool `json:"required"` DefaultValue *string `json:"default_value"` } // CPU: cpu. type CPU struct { // Name: name of the CPU. Name string `json:"name"` // CoreCount: number of CPU cores. CoreCount uint32 `json:"core_count"` // ThreadCount: number CPU threads. ThreadCount uint32 `json:"thread_count"` // Frequency: frequency of the CPU in MHz. Frequency uint32 `json:"frequency"` // Benchmark: benchmark of the CPU. Benchmark string `json:"benchmark"` } // Disk: disk. type Disk struct { // Capacity: capacity of the disk in bytes. Capacity scw.Size `json:"capacity"` // Type: type of the disk. Type string `json:"type"` } // Memory: memory. type Memory struct { // Capacity: capacity of the memory in bytes. Capacity scw.Size `json:"capacity"` // Type: type of the memory. Type string `json:"type"` // Frequency: frequency of the memory in MHz. Frequency uint32 `json:"frequency"` // IsEcc: true if the memory is an error-correcting code memory. IsEcc bool `json:"is_ecc"` } // OfferOptionOffer: offer option offer. type OfferOptionOffer struct { // ID: ID of the option. ID string `json:"id"` // Name: name of the option. Name string `json:"name"` // Enabled: if true the option is enabled and included by default in the offer // If false the option is available for the offer but not included by default. Enabled bool `json:"enabled"` // SubscriptionPeriod: period of subscription for the offer. // Default value: unknown_subscription_period SubscriptionPeriod OfferSubscriptionPeriod `json:"subscription_period"` // Price: price of the option. Price *scw.Money `json:"price"` // Manageable: boolean to know if option could be managed. Manageable bool `json:"manageable"` // OsID: ID of the OS linked to the option. OsID *string `json:"os_id"` } // PersistentMemory: persistent memory. type PersistentMemory struct { // Capacity: capacity of the memory in bytes. Capacity scw.Size `json:"capacity"` // Type: type of the memory. Type string `json:"type"` // Frequency: frequency of the memory in MHz. Frequency uint32 `json:"frequency"` } // RaidController: raid controller. type RaidController struct { Model string `json:"model"` RaidLevel []string `json:"raid_level"` } // IP: ip. type IP struct { // ID: ID of the IP. ID string `json:"id"` // Address: address of the IP. Address net.IP `json:"address"` // Reverse: reverse IP value. Reverse string `json:"reverse"` // Version: version of IP (v4 or v6). // Default value: IPv4 Version IPVersion `json:"version"` // ReverseStatus: status of the reverse. // Default value: unknown ReverseStatus IPReverseStatus `json:"reverse_status"` // ReverseStatusMessage: a message related to the reverse status, e.g. in case of an error. ReverseStatusMessage string `json:"reverse_status_message"` } // ServerInstall: server install. type ServerInstall struct { // OsID: ID of the OS. OsID string `json:"os_id"` // Hostname: host defined during the server installation. Hostname string `json:"hostname"` // SSHKeyIDs: SSH public key IDs defined during server installation. SSHKeyIDs []string `json:"ssh_key_ids"` // Status: status of the server installation. // Default value: unknown Status ServerInstallStatus `json:"status"` // User: user defined in the server installation, or the default user if none were specified. User string `json:"user"` // ServiceUser: service user defined in the server installation, or the default user if none were specified. ServiceUser string `json:"service_user"` // ServiceURL: address of the installed service. ServiceURL string `json:"service_url"` } // ServerOption: server option. type ServerOption struct { // ID: ID of the option. ID string `json:"id"` // Name: name of the option. Name string `json:"name"` // Status: status of the option on this server. // Default value: option_status_unknown Status ServerOptionOptionStatus `json:"status"` // Manageable: defines whether the option can be managed (added or removed). Manageable bool `json:"manageable"` // ExpiresAt: auto expiration date for compatible options. ExpiresAt *time.Time `json:"expires_at"` } // ServerRescueServer: server rescue server. type ServerRescueServer struct { // User: rescue user name. User string `json:"user"` // Password: rescue password. Password string `json:"password"` } // CreateServerRequestInstall: create server request install. type CreateServerRequestInstall struct { // OsID: ID of the OS to installation on the server. OsID string `json:"os_id"` // Hostname: hostname of the server. Hostname string `json:"hostname"` // SSHKeyIDs: SSH key IDs authorized on the server. SSHKeyIDs []string `json:"ssh_key_ids"` // User: user for the installation. User *string `json:"user"` // Password: password for the installation. Password *string `json:"password"` // ServiceUser: regular user that runs the service to be installed on the server. ServiceUser *string `json:"service_user"` // ServicePassword: password used for the service to install. ServicePassword *string `json:"service_password"` } // OS: os. type OS struct { // ID: ID of the OS. ID string `json:"id"` // Name: name of the OS. Name string `json:"name"` // Version: version of the OS. Version string `json:"version"` // LogoURL: URL of this OS's logo. LogoURL string `json:"logo_url"` // SSH: object defining the SSH requirements to install the OS. SSH *OSOSField `json:"ssh"` // User: object defining the username requirements to install the OS. User *OSOSField `json:"user"` // Password: object defining the password requirements to install the OS. Password *OSOSField `json:"password"` // ServiceUser: object defining the username requirements to install the service. ServiceUser *OSOSField `json:"service_user"` // ServicePassword: object defining the password requirements to install the service. ServicePassword *OSOSField `json:"service_password"` // Enabled: defines if the operating system is enabled or not. Enabled bool `json:"enabled"` // LicenseRequired: license required (check server options for pricing details). LicenseRequired bool `json:"license_required"` // Allowed: defines if a specific Organization is allowed to install this OS type. Allowed bool `json:"allowed"` } // Offer: offer. type Offer struct { // ID: ID of the offer. ID string `json:"id"` // Name: name of the offer. Name string `json:"name"` // Stock: stock level. // Default value: empty Stock OfferStock `json:"stock"` // Bandwidth: public bandwidth available (in bits/s) with the offer. Bandwidth uint64 `json:"bandwidth"` // CommercialRange: commercial range of the offer. CommercialRange string `json:"commercial_range"` // PricePerHour: price of the offer for the next 60 minutes (a server order at 11h32 will be payed until 12h32). PricePerHour *scw.Money `json:"price_per_hour"` // PricePerMonth: monthly price of the offer, if subscribing on a monthly basis. PricePerMonth *scw.Money `json:"price_per_month"` // Disks: disks specifications of the offer. Disks []*Disk `json:"disks"` // Enable: defines whether the offer is currently available. Enable bool `json:"enable"` // CPUs: CPU specifications of the offer. CPUs []*CPU `json:"cpus"` // Memories: memory specifications of the offer. Memories []*Memory `json:"memories"` // QuotaName: name of the quota associated to the offer. QuotaName string `json:"quota_name"` // PersistentMemories: persistent memory specifications of the offer. PersistentMemories []*PersistentMemory `json:"persistent_memories"` // RaidControllers: raid controller specifications of the offer. RaidControllers []*RaidController `json:"raid_controllers"` // IncompatibleOsIDs: array of OS images IDs incompatible with the server. IncompatibleOsIDs []string `json:"incompatible_os_ids"` // SubscriptionPeriod: period of subscription for the offer. // Default value: unknown_subscription_period SubscriptionPeriod OfferSubscriptionPeriod `json:"subscription_period"` // OperationPath: operation path of the service. OperationPath string `json:"operation_path"` // Fee: one time fee invoiced by Scaleway for the setup and activation of the server. Fee *scw.Money `json:"fee"` // Options: available options for customization of the server. Options []*OfferOptionOffer `json:"options"` // PrivateBandwidth: private bandwidth available in bits/s with the offer. PrivateBandwidth uint64 `json:"private_bandwidth"` // SharedBandwidth: defines whether the offer's bandwidth is shared or not. SharedBandwidth bool `json:"shared_bandwidth"` // Tags: array of tags attached to the offer. Tags []string `json:"tags"` } // Option: option. type Option struct { // ID: ID of the option. ID string `json:"id"` // Name: name of the option. Name string `json:"name"` // Manageable: defines whether the option is manageable (could be added or removed). Manageable bool `json:"manageable"` } // ServerEvent: server event. type ServerEvent struct { // ID: ID of the server to which the action will be applied. ID string `json:"id"` // Action: the action that will be applied to the server. Action string `json:"action"` // UpdatedAt: date of last modification of the action. UpdatedAt *time.Time `json:"updated_at"` // CreatedAt: date of creation of the action. CreatedAt *time.Time `json:"created_at"` } // ServerPrivateNetwork: server private network. type ServerPrivateNetwork struct { // ID: the Private Network ID. ID string `json:"id"` // ProjectID: the Private Network Project ID. ProjectID string `json:"project_id"` // ServerID: the server ID. ServerID string `json:"server_id"` // PrivateNetworkID: the Private Network ID. PrivateNetworkID string `json:"private_network_id"` // Vlan: the VLAN ID associated to the Private Network. Vlan *uint32 `json:"vlan"` // Status: the configuration status of the Private Network. // Default value: unknown Status ServerPrivateNetworkStatus `json:"status"` // CreatedAt: the Private Network creation date. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: the date the Private Network was last modified. UpdatedAt *time.Time `json:"updated_at"` } // Server: server. type Server struct { // ID: ID of the server. ID string `json:"id"` // OrganizationID: organization ID the server is attached to. OrganizationID string `json:"organization_id"` // ProjectID: project ID the server is attached to. ProjectID string `json:"project_id"` // Name: name of the server. Name string `json:"name"` // Description: description of the server. Description string `json:"description"` // UpdatedAt: last modification date of the server. UpdatedAt *time.Time `json:"updated_at"` // CreatedAt: creation date of the server. CreatedAt *time.Time `json:"created_at"` // Status: status of the server. // Default value: unknown Status ServerStatus `json:"status"` // OfferID: offer ID of the server. OfferID string `json:"offer_id"` // OfferName: offer name of the server. OfferName string `json:"offer_name"` // Tags: array of custom tags attached to the server. Tags []string `json:"tags"` // IPs: array of IPs attached to the server. IPs []*IP `json:"ips"` // Domain: domain of the server. Domain string `json:"domain"` // BootType: boot type of the server. // Default value: unknown_boot_type BootType ServerBootType `json:"boot_type"` // Zone: zone in which is the server located. Zone scw.Zone `json:"zone"` // Install: configuration of the installation. Install *ServerInstall `json:"install"` // PingStatus: status of server ping. // Default value: ping_status_unknown PingStatus ServerPingStatus `json:"ping_status"` // Options: options enabled on the server. Options []*ServerOption `json:"options"` // RescueServer: configuration of rescue boot. RescueServer *ServerRescueServer `json:"rescue_server"` } // Setting: setting. type Setting struct { // ID: ID of the setting. ID string `json:"id"` // Type: type of the setting. // Default value: unknown Type SettingType `json:"type"` // ProjectID: ID of the Project ID. ProjectID string `json:"project_id"` // Enabled: defines whether the setting is enabled. Enabled bool `json:"enabled"` } // AddOptionServerRequest: add option server request. type AddOptionServerRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: ID of the server. ServerID string `json:"-"` // OptionID: ID of the option to add. OptionID string `json:"-"` // ExpiresAt: auto expire the option after this date. ExpiresAt *time.Time `json:"expires_at,omitempty"` } // BMCAccess: bmc access. type BMCAccess struct { // URL: URL to access to the server console. URL string `json:"url"` // Login: the login to use for the BMC (Baseboard Management Controller) access authentification. Login string `json:"login"` // Password: the password to use for the BMC (Baseboard Management Controller) access authentification. Password string `json:"password"` // ExpiresAt: the date after which the BMC (Baseboard Management Controller) access will be closed. ExpiresAt *time.Time `json:"expires_at"` } // CreateServerRequest: create server request. type CreateServerRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // OfferID: offer ID of the new server. OfferID string `json:"offer_id"` // Deprecated: OrganizationID: organization ID with which the server will be created. // Precisely one of ProjectID, OrganizationID must be set. OrganizationID *string `json:"organization_id,omitempty"` // ProjectID: project ID with which the server will be created. // Precisely one of ProjectID, OrganizationID must be set. ProjectID *string `json:"project_id,omitempty"` // Name: name of the server (≠hostname). Name string `json:"name"` // Description: description associated with the server, max 255 characters. Description string `json:"description"` // Tags: tags to associate to the server. Tags []string `json:"tags"` // Install: object describing the configuration details of the OS installation on the server. Install *CreateServerRequestInstall `json:"install,omitempty"` // OptionIDs: iDs of options to enable on server. OptionIDs []string `json:"option_ids"` } // DeleteOptionServerRequest: delete option server request. type DeleteOptionServerRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: ID of the server. ServerID string `json:"-"` // OptionID: ID of the option to delete. OptionID string `json:"-"` } // DeleteServerRequest: delete server request. type DeleteServerRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: ID of the server to delete. ServerID string `json:"-"` } // GetBMCAccessRequest: get bmc access request. type GetBMCAccessRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: ID of the server. ServerID string `json:"-"` } // GetOSRequest: get os request. type GetOSRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // OsID: ID of the OS. OsID string `json:"-"` } // GetOfferRequest: get offer request. type GetOfferRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // OfferID: ID of the researched Offer. OfferID string `json:"-"` } // GetOptionRequest: get option request. type GetOptionRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // OptionID: ID of the option. OptionID string `json:"-"` } // GetServerMetricsRequest: get server metrics request. type GetServerMetricsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: server ID to get the metrics. ServerID string `json:"-"` } // GetServerMetricsResponse: get server metrics response. type GetServerMetricsResponse struct { // Pings: timeseries object representing pings on the server. Pings *scw.TimeSeries `json:"pings"` } // GetServerRequest: get server request. type GetServerRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: ID of the server. ServerID string `json:"-"` } // InstallServerRequest: install server request. type InstallServerRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: server ID to install. ServerID string `json:"-"` // OsID: ID of the OS to installation on the server. OsID string `json:"os_id"` // Hostname: hostname of the server. Hostname string `json:"hostname"` // SSHKeyIDs: SSH key IDs authorized on the server. SSHKeyIDs []string `json:"ssh_key_ids"` // User: user used for the installation. User *string `json:"user,omitempty"` // Password: password used for the installation. Password *string `json:"password,omitempty"` // ServiceUser: user used for the service to install. ServiceUser *string `json:"service_user,omitempty"` // ServicePassword: password used for the service to install. ServicePassword *string `json:"service_password,omitempty"` } // ListOSRequest: list os request. type ListOSRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: number of OS per page. PageSize *uint32 `json:"-"` // OfferID: offer IDs to filter OSes for. OfferID *string `json:"-"` } // ListOSResponse: list os response. type ListOSResponse struct { // TotalCount: total count of matching OS. TotalCount uint32 `json:"total_count"` // Os: oS that match filters. Os []*OS `json:"os"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListOSResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListOSResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListOSResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Os = append(r.Os, results.Os...) r.TotalCount += uint32(len(results.Os)) return uint32(len(results.Os)), nil } // ListOffersRequest: list offers request. type ListOffersRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: number of offers per page. PageSize *uint32 `json:"-"` // SubscriptionPeriod: subscription period type to filter offers by. // Default value: unknown_subscription_period SubscriptionPeriod OfferSubscriptionPeriod `json:"-"` } // ListOffersResponse: list offers response. type ListOffersResponse struct { // TotalCount: total count of matching offers. TotalCount uint32 `json:"total_count"` // Offers: offers that match filters. Offers []*Offer `json:"offers"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListOffersResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListOffersResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListOffersResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Offers = append(r.Offers, results.Offers...) r.TotalCount += uint32(len(results.Offers)) return uint32(len(results.Offers)), nil } // ListOptionsRequest: list options request. type ListOptionsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: number of options per page. PageSize *uint32 `json:"-"` // OfferID: offer ID to filter options for. OfferID *string `json:"-"` // Name: name to filter options for. Name *string `json:"-"` } // ListOptionsResponse: list options response. type ListOptionsResponse struct { // TotalCount: total count of matching options. TotalCount uint32 `json:"total_count"` // Options: options that match filters. Options []*Option `json:"options"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListOptionsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListOptionsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListOptionsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Options = append(r.Options, results.Options...) r.TotalCount += uint32(len(results.Options)) return uint32(len(results.Options)), nil } // ListServerEventsRequest: list server events request. type ListServerEventsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: ID of the server events searched. ServerID string `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: number of server events per page. PageSize *uint32 `json:"-"` // OrderBy: order of the server events. // Default value: created_at_asc OrderBy ListServerEventsRequestOrderBy `json:"-"` } // ListServerEventsResponse: list server events response. type ListServerEventsResponse struct { // TotalCount: total count of matching events. TotalCount uint32 `json:"total_count"` // Events: server events that match filters. Events []*ServerEvent `json:"events"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListServerEventsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListServerEventsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListServerEventsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Events = append(r.Events, results.Events...) r.TotalCount += uint32(len(results.Events)) return uint32(len(results.Events)), nil } // ListServerPrivateNetworksResponse: list server private networks response. type ListServerPrivateNetworksResponse struct { ServerPrivateNetworks []*ServerPrivateNetwork `json:"server_private_networks"` TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListServerPrivateNetworksResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListServerPrivateNetworksResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListServerPrivateNetworksResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.ServerPrivateNetworks = append(r.ServerPrivateNetworks, results.ServerPrivateNetworks...) r.TotalCount += uint32(len(results.ServerPrivateNetworks)) return uint32(len(results.ServerPrivateNetworks)), nil } // ListServersRequest: list servers request. type ListServersRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: number of servers per page. PageSize *uint32 `json:"-"` // OrderBy: order of the servers. // Default value: created_at_asc OrderBy ListServersRequestOrderBy `json:"-"` // Tags: tags to filter for. Tags []string `json:"-"` // Status: status to filter for. Status []string `json:"-"` // Name: names to filter for. Name *string `json:"-"` // OrganizationID: organization ID to filter for. OrganizationID *string `json:"-"` // ProjectID: project ID to filter for. ProjectID *string `json:"-"` // OptionID: option ID to filter for. OptionID *string `json:"-"` } // ListServersResponse: list servers response. type ListServersResponse struct { // TotalCount: total count of matching servers. TotalCount uint32 `json:"total_count"` // Servers: array of Elastic Metal server objects matching the filters in the request. Servers []*Server `json:"servers"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListServersResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListServersResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListServersResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Servers = append(r.Servers, results.Servers...) r.TotalCount += uint32(len(results.Servers)) return uint32(len(results.Servers)), nil } // ListSettingsRequest: list settings request. type ListSettingsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: set the maximum list size. PageSize *uint32 `json:"-"` // OrderBy: sort order for items in the response. // Default value: created_at_asc OrderBy ListSettingsRequestOrderBy `json:"-"` // ProjectID: ID of the Project. ProjectID *string `json:"-"` } // ListSettingsResponse: list settings response. type ListSettingsResponse struct { // TotalCount: total count of matching settings. TotalCount uint32 `json:"total_count"` // Settings: settings that match filters. Settings []*Setting `json:"settings"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListSettingsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListSettingsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListSettingsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Settings = append(r.Settings, results.Settings...) r.TotalCount += uint32(len(results.Settings)) return uint32(len(results.Settings)), nil } // PrivateNetworkAPIAddServerPrivateNetworkRequest: private network api add server private network request. type PrivateNetworkAPIAddServerPrivateNetworkRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: the ID of the server. ServerID string `json:"-"` // PrivateNetworkID: the ID of the Private Network. PrivateNetworkID string `json:"private_network_id"` } // PrivateNetworkAPIDeleteServerPrivateNetworkRequest: private network api delete server private network request. type PrivateNetworkAPIDeleteServerPrivateNetworkRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: the ID of the server. ServerID string `json:"-"` // PrivateNetworkID: the ID of the Private Network. PrivateNetworkID string `json:"-"` } // PrivateNetworkAPIListServerPrivateNetworksRequest: private network api list server private networks request. type PrivateNetworkAPIListServerPrivateNetworksRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // OrderBy: the sort order for the returned Private Networks. // Default value: created_at_asc OrderBy ListServerPrivateNetworksRequestOrderBy `json:"-"` // Page: the page number for the returned Private Networks. Page *int32 `json:"-"` // PageSize: the maximum number of Private Networks per page. PageSize *uint32 `json:"-"` // ServerID: filter Private Networks by server ID. ServerID *string `json:"-"` // PrivateNetworkID: filter Private Networks by Private Network ID. PrivateNetworkID *string `json:"-"` // OrganizationID: filter Private Networks by Organization ID. OrganizationID *string `json:"-"` // ProjectID: filter Private Networks by Project ID. ProjectID *string `json:"-"` } // PrivateNetworkAPISetServerPrivateNetworksRequest: private network api set server private networks request. type PrivateNetworkAPISetServerPrivateNetworksRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: the ID of the server. ServerID string `json:"-"` // PrivateNetworkIDs: the IDs of the Private Networks. PrivateNetworkIDs []string `json:"private_network_ids"` } // RebootServerRequest: reboot server request. type RebootServerRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: ID of the server to reboot. ServerID string `json:"-"` // BootType: the type of boot. // Default value: unknown_boot_type BootType ServerBootType `json:"boot_type"` } // SetServerPrivateNetworksResponse: set server private networks response. type SetServerPrivateNetworksResponse struct { ServerPrivateNetworks []*ServerPrivateNetwork `json:"server_private_networks"` } // StartBMCAccessRequest: start bmc access request. type StartBMCAccessRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: ID of the server. ServerID string `json:"-"` // IP: the IP authorized to connect to the server. IP net.IP `json:"ip"` } // StartServerRequest: start server request. type StartServerRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: ID of the server to start. ServerID string `json:"-"` // BootType: the type of boot. // Default value: unknown_boot_type BootType ServerBootType `json:"boot_type"` } // StopBMCAccessRequest: stop bmc access request. type StopBMCAccessRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: ID of the server. ServerID string `json:"-"` } // StopServerRequest: stop server request. type StopServerRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: ID of the server to stop. ServerID string `json:"-"` } // UpdateIPRequest: update ip request. type UpdateIPRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: ID of the server. ServerID string `json:"-"` // IPID: ID of the IP to update. IPID string `json:"-"` // Reverse: new reverse IP to update, not updated if null. Reverse *string `json:"reverse,omitempty"` } // UpdateServerRequest: update server request. type UpdateServerRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: ID of the server to update. ServerID string `json:"-"` // Name: name of the server (≠hostname), not updated if null. Name *string `json:"name,omitempty"` // Description: description associated with the server, max 255 characters, not updated if null. Description *string `json:"description,omitempty"` // Tags: tags associated with the server, not updated if null. Tags *[]string `json:"tags,omitempty"` } // UpdateSettingRequest: update setting request. type UpdateSettingRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // SettingID: ID of the setting. SettingID string `json:"-"` // Enabled: defines whether the setting is enabled. Enabled *bool `json:"enabled,omitempty"` } // This API allows to manage your Elastic Metal server. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Zones() []scw.Zone { return []scw.Zone{scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2} } // ListServers: List Elastic Metal servers for a specific Organization. func (s *API) ListServers(req *ListServersRequest, opts ...scw.RequestOption) (*ListServersResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "tags", req.Tags) parameter.AddToQuery(query, "status", req.Status) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "option_id", req.OptionID) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/servers", Query: query, } var resp ListServersResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetServer: Get full details of an existing Elastic Metal server associated with the ID. func (s *API) GetServer(req *GetServerRequest, opts ...scw.RequestOption) (*Server, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "", } var resp Server err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateServer: Create a new Elastic Metal server. Once the server is created, proceed with the [installation of an OS](#post-3e949e). func (s *API) CreateServer(req *CreateServerRequest, opts ...scw.RequestOption) (*Server, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultProjectID, exist := s.client.GetDefaultProjectID() if exist && req.ProjectID == nil && req.OrganizationID == nil { req.ProjectID = &defaultProjectID } defaultOrganizationID, exist := s.client.GetDefaultOrganizationID() if exist && req.ProjectID == nil && req.OrganizationID == nil { req.OrganizationID = &defaultOrganizationID } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/servers", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Server err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateServer: Update the server associated with the ID. You can update parameters such as the server's name, tags and description. Any parameters left null in the request body are not updated. func (s *API) UpdateServer(req *UpdateServerRequest, opts ...scw.RequestOption) (*Server, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Server err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // InstallServer: Install an Operating System (OS) on the Elastic Metal server with a specific ID. func (s *API) InstallServer(req *InstallServerRequest, opts ...scw.RequestOption) (*Server, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/install", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Server err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetServerMetrics: Get the ping status of the server associated with the ID. func (s *API) GetServerMetrics(req *GetServerMetricsRequest, opts ...scw.RequestOption) (*GetServerMetricsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/metrics", } var resp GetServerMetricsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteServer: Delete the server associated with the ID. func (s *API) DeleteServer(req *DeleteServerRequest, opts ...scw.RequestOption) (*Server, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "", } var resp Server err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // RebootServer: Reboot the Elastic Metal server associated with the ID, use the `boot_type` `rescue` to reboot the server in rescue mode. func (s *API) RebootServer(req *RebootServerRequest, opts ...scw.RequestOption) (*Server, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/reboot", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Server err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // StartServer: Start the server associated with the ID. func (s *API) StartServer(req *StartServerRequest, opts ...scw.RequestOption) (*Server, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/start", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Server err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // StopServer: Stop the server associated with the ID. The server remains allocated to your account and all data remains on the local storage of the server. func (s *API) StopServer(req *StopServerRequest, opts ...scw.RequestOption) (*Server, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/stop", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Server err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListServerEvents: List event (i.e. start/stop/reboot) associated to the server ID. func (s *API) ListServerEvents(req *ListServerEventsRequest, opts ...scw.RequestOption) (*ListServerEventsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/events", Query: query, } var resp ListServerEventsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // StartBMCAccess: Start BMC (Baseboard Management Controller) access associated with the ID. // The BMC (Baseboard Management Controller) access is available one hour after the installation of the server. // You need first to create an option Remote Access. You will find the ID and the price with a call to listOffers (https://developers.scaleway.com/en/products/baremetal/api/#get-78db92). Then add the option https://developers.scaleway.com/en/products/baremetal/api/#post-b14abd. // After adding the BMC option, you need to Get Remote Access to get the login/password https://developers.scaleway.com/en/products/baremetal/api/#get-cefc0f. Do not forget to delete the Option after use. func (s *API) StartBMCAccess(req *StartBMCAccessRequest, opts ...scw.RequestOption) (*BMCAccess, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/bmc-access", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp BMCAccess err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetBMCAccess: Get the BMC (Baseboard Management Controller) access associated with the ID, including the URL and login information needed to connect. func (s *API) GetBMCAccess(req *GetBMCAccessRequest, opts ...scw.RequestOption) (*BMCAccess, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/bmc-access", } var resp BMCAccess err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // StopBMCAccess: Stop BMC (Baseboard Management Controller) access associated with the ID. func (s *API) StopBMCAccess(req *StopBMCAccessRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/bmc-access", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // UpdateIP: Configure the IP address associated with the server ID and IP ID. You can use this method to set a reverse DNS for an IP address. func (s *API) UpdateIP(req *UpdateIPRequest, opts ...scw.RequestOption) (*IP, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } if fmt.Sprint(req.IPID) == "" { return nil, errors.New("field IPID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/ips/" + fmt.Sprint(req.IPID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp IP err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // AddOptionServer: Add an option, such as Private Networks, to a specific server. func (s *API) AddOptionServer(req *AddOptionServerRequest, opts ...scw.RequestOption) (*Server, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } if fmt.Sprint(req.OptionID) == "" { return nil, errors.New("field OptionID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/options/" + fmt.Sprint(req.OptionID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Server err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteOptionServer: Delete an option from a specific server. func (s *API) DeleteOptionServer(req *DeleteOptionServerRequest, opts ...scw.RequestOption) (*Server, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } if fmt.Sprint(req.OptionID) == "" { return nil, errors.New("field OptionID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/options/" + fmt.Sprint(req.OptionID) + "", } var resp Server err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListOffers: List all available Elastic Metal server configurations. func (s *API) ListOffers(req *ListOffersRequest, opts ...scw.RequestOption) (*ListOffersResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "subscription_period", req.SubscriptionPeriod) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/offers", Query: query, } var resp ListOffersResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetOffer: Get details of an offer identified by its offer ID. func (s *API) GetOffer(req *GetOfferRequest, opts ...scw.RequestOption) (*Offer, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.OfferID) == "" { return nil, errors.New("field OfferID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/offers/" + fmt.Sprint(req.OfferID) + "", } var resp Offer err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetOption: Return specific option for the ID. func (s *API) GetOption(req *GetOptionRequest, opts ...scw.RequestOption) (*Option, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.OptionID) == "" { return nil, errors.New("field OptionID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/options/" + fmt.Sprint(req.OptionID) + "", } var resp Option err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListOptions: List all options matching with filters. func (s *API) ListOptions(req *ListOptionsRequest, opts ...scw.RequestOption) (*ListOptionsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "offer_id", req.OfferID) parameter.AddToQuery(query, "name", req.Name) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/options", Query: query, } var resp ListOptionsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListSettings: Return all settings for a Project ID. func (s *API) ListSettings(req *ListSettingsRequest, opts ...scw.RequestOption) (*ListSettingsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/settings", Query: query, } var resp ListSettingsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateSetting: Update a setting for a Project ID (enable or disable). func (s *API) UpdateSetting(req *UpdateSettingRequest, opts ...scw.RequestOption) (*Setting, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.SettingID) == "" { return nil, errors.New("field SettingID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/settings/" + fmt.Sprint(req.SettingID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Setting err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListOS: List all OSes that are available for installation on Elastic Metal servers. func (s *API) ListOS(req *ListOSRequest, opts ...scw.RequestOption) (*ListOSResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "offer_id", req.OfferID) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/os", Query: query, } var resp ListOSResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetOS: Return the specific OS for the ID. func (s *API) GetOS(req *GetOSRequest, opts ...scw.RequestOption) (*OS, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.OsID) == "" { return nil, errors.New("field OsID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/os/" + fmt.Sprint(req.OsID) + "", } var resp OS err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // Elastic Metal Private Network API. type PrivateNetworkAPI struct { client *scw.Client } // NewPrivateNetworkAPI returns a PrivateNetworkAPI object from a Scaleway client. func NewPrivateNetworkAPI(client *scw.Client) *PrivateNetworkAPI { return &PrivateNetworkAPI{ client: client, } } func (s *PrivateNetworkAPI) Zones() []scw.Zone { return []scw.Zone{scw.ZoneFrPar2} } // AddServerPrivateNetwork: Add a server to a Private Network. func (s *PrivateNetworkAPI) AddServerPrivateNetwork(req *PrivateNetworkAPIAddServerPrivateNetworkRequest, opts ...scw.RequestOption) (*ServerPrivateNetwork, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/private-networks", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp ServerPrivateNetwork err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SetServerPrivateNetworks: Set multiple Private Networks on a server. func (s *PrivateNetworkAPI) SetServerPrivateNetworks(req *PrivateNetworkAPISetServerPrivateNetworksRequest, opts ...scw.RequestOption) (*SetServerPrivateNetworksResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/private-networks", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SetServerPrivateNetworksResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListServerPrivateNetworks: List the Private Networks of a server. func (s *PrivateNetworkAPI) ListServerPrivateNetworks(req *PrivateNetworkAPIListServerPrivateNetworksRequest, opts ...scw.RequestOption) (*ListServerPrivateNetworksResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "server_id", req.ServerID) parameter.AddToQuery(query, "private_network_id", req.PrivateNetworkID) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/server-private-networks", Query: query, } var resp ListServerPrivateNetworksResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteServerPrivateNetwork: Delete a Private Network. func (s *PrivateNetworkAPI) DeleteServerPrivateNetwork(req *PrivateNetworkAPIDeleteServerPrivateNetworkRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return errors.New("field ServerID cannot be empty in request") } if fmt.Sprint(req.PrivateNetworkID) == "" { return errors.New("field PrivateNetworkID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/baremetal/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/private-networks/" + fmt.Sprint(req.PrivateNetworkID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/baremetal/v1/server_utils.go000066400000000000000000000165131456366605600303740ustar00rootroot00000000000000package baremetal import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) const ( defaultRetryInterval = 15 * time.Second defaultTimeout = 2 * time.Hour ) // WaitForServerRequest is used by WaitForServer method. type WaitForServerRequest struct { ServerID string Zone scw.Zone Timeout *time.Duration RetryInterval *time.Duration } // WaitForServer wait for the server to be in a "terminal state" before returning. // This function can be used to wait for a server to be created. func (s *API) WaitForServer(req *WaitForServerRequest, opts ...scw.RequestOption) (*Server, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[ServerStatus]struct{}{ ServerStatusReady: {}, ServerStatusStopped: {}, ServerStatusError: {}, ServerStatusLocked: {}, ServerStatusUnknown: {}, } server, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetServer(&GetServerRequest{ ServerID: req.ServerID, Zone: req.Zone, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.Status] return res, isTerminal, err }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for server failed") } return server.(*Server), nil } // WaitForServerInstallRequest is used by WaitForServerInstall method. type WaitForServerInstallRequest struct { ServerID string Zone scw.Zone Timeout *time.Duration RetryInterval *time.Duration } // WaitForServerInstall wait for the server install to be in a // "terminal state" before returning. // This function can be used to wait for a server to be installed. func (s *API) WaitForServerInstall(req *WaitForServerInstallRequest, opts ...scw.RequestOption) (*Server, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } installTerminalStatus := map[ServerInstallStatus]struct{}{ ServerInstallStatusCompleted: {}, ServerInstallStatusError: {}, ServerInstallStatusUnknown: {}, } server, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetServer(&GetServerRequest{ ServerID: req.ServerID, Zone: req.Zone, }, opts...) if err != nil { return nil, false, err } if res.Install == nil { return nil, false, errors.New("server creation has not begun for server %s", req.ServerID) } _, isTerminal := installTerminalStatus[res.Install.Status] return res, isTerminal, err }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for server installation failed") } return server.(*Server), nil } // GetServerOffer returns the offer of a baremetal server func (s *API) GetServerOffer(server *Server) (*Offer, error) { offer, err := s.GetOffer(&GetOfferRequest{ OfferID: server.OfferID, Zone: server.Zone, }) if err != nil { return nil, err } return offer, nil } type GetOfferByNameRequest struct { OfferName string Zone scw.Zone } // GetOfferByName returns an offer from its commercial name func (s *API) GetOfferByName(req *GetOfferByNameRequest) (*Offer, error) { res, err := s.ListOffers(&ListOffersRequest{ Zone: req.Zone, }, scw.WithAllPages()) if err != nil { return nil, err } for _, offer := range res.Offers { if req.OfferName == offer.Name { return offer, nil } } return nil, errors.New("could not find the offer ID from name %s", req.OfferName) } // WaitForServerOptionsRequest is used by WaitForServerOptions method. type WaitForServerOptionsRequest struct { ServerID string Zone scw.Zone Timeout *time.Duration RetryInterval *time.Duration } // WaitForServerOptions wait for all server options to be in a "terminal state" before returning. // This function can be used to wait for all server options to be set. func (s *API) WaitForServerOptions(req *WaitForServerOptionsRequest, opts ...scw.RequestOption) (*Server, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[ServerOptionOptionStatus]struct{}{ ServerOptionOptionStatusOptionStatusEnable: {}, ServerOptionOptionStatusOptionStatusError: {}, ServerOptionOptionStatusOptionStatusUnknown: {}, } server, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetServer(&GetServerRequest{ ServerID: req.ServerID, Zone: req.Zone, }, opts...) if err != nil { return nil, false, err } for i := range res.Options { _, isTerminal := terminalStatus[res.Options[i].Status] if !isTerminal { return res, isTerminal, nil } } return res, true, err }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for server options failed") } return server.(*Server), nil } // WaitForServerPrivateNetworksRequest is used by WaitForServerPrivateNetworks method. type WaitForServerPrivateNetworksRequest struct { ServerID string Zone scw.Zone Timeout *time.Duration RetryInterval *time.Duration } // WaitForServerPrivateNetworks wait for all server private networks to be in a "terminal state" before returning. // This function can be used to wait for all server private networks to be set. func (s *PrivateNetworkAPI) WaitForServerPrivateNetworks(req *WaitForServerPrivateNetworksRequest, opts ...scw.RequestOption) ([]*ServerPrivateNetwork, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[ServerPrivateNetworkStatus]struct{}{ ServerPrivateNetworkStatusAttached: {}, ServerPrivateNetworkStatusError: {}, ServerPrivateNetworkStatusUnknown: {}, ServerPrivateNetworkStatusLocked: {}, } serverPrivateNetwork, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.ListServerPrivateNetworks(&PrivateNetworkAPIListServerPrivateNetworksRequest{ ServerID: &req.ServerID, Zone: req.Zone, }, opts...) if err != nil { return nil, false, err } for i := range res.ServerPrivateNetworks { _, isTerminal := terminalStatus[res.ServerPrivateNetworks[i].Status] if !isTerminal { return res.ServerPrivateNetworks, isTerminal, nil } } return res.ServerPrivateNetworks, true, err }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for server private networks failed") } return serverPrivateNetwork.([]*ServerPrivateNetwork), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/billing/000077500000000000000000000000001456366605600244475ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/billing/v2alpha1/000077500000000000000000000000001456366605600260655ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/billing/v2alpha1/billing_sdk.go000066400000000000000000000436121456366605600307030ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package billing provides methods and message types of the billing v2alpha1 API. package billing import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type DiscountDiscountMode string const ( // Unknown discount mode. DiscountDiscountModeUnknownDiscountMode = DiscountDiscountMode("unknown_discount_mode") // A rate discount that reduces each customer bill by the discount value percentage. DiscountDiscountModeDiscountModeRate = DiscountDiscountMode("discount_mode_rate") // A value discount that reduces the amount of the customer bill by the discount value. DiscountDiscountModeDiscountModeValue = DiscountDiscountMode("discount_mode_value") // A fixed sum to be deducted from the user's bills. DiscountDiscountModeDiscountModeSplittable = DiscountDiscountMode("discount_mode_splittable") ) func (enum DiscountDiscountMode) String() string { if enum == "" { // return default value if empty return "unknown_discount_mode" } return string(enum) } func (enum DiscountDiscountMode) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DiscountDiscountMode) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DiscountDiscountMode(DiscountDiscountMode(tmp).String()) return nil } type DiscountFilterType string const ( // Unknown filter type. DiscountFilterTypeUnknownType = DiscountFilterType("unknown_type") // Product category, such as Compute, Network, Observability. DiscountFilterTypeProductCategory = DiscountFilterType("product_category") // Products within the Product category. For example, VPC, Private Networks, and Public Gateways are products in the Network category. DiscountFilterTypeProduct = DiscountFilterType("product") // The offer of a product. For example, "VPC Public Gateway S", "VPC Public Gateway M" for the VPC product. DiscountFilterTypeProductOffer = DiscountFilterType("product_offer") // Identifies the reference based on category, product, range, size, region, and zone. It can sometimes include different product options, such as licenses and monthly payments. DiscountFilterTypeProductReference = DiscountFilterType("product_reference") // Region name like "FR-PAR", "NL-AMS", "PL-WAW". DiscountFilterTypeRegion = DiscountFilterType("region") // Zone name like "FR-PAR-1", "FR-PAR-2", "FR-PAR-3". DiscountFilterTypeZone = DiscountFilterType("zone") ) func (enum DiscountFilterType) String() string { if enum == "" { // return default value if empty return "unknown_type" } return string(enum) } func (enum DiscountFilterType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DiscountFilterType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DiscountFilterType(DiscountFilterType(tmp).String()) return nil } type DownloadInvoiceRequestFileType string const ( DownloadInvoiceRequestFileTypePdf = DownloadInvoiceRequestFileType("pdf") ) func (enum DownloadInvoiceRequestFileType) String() string { if enum == "" { // return default value if empty return "pdf" } return string(enum) } func (enum DownloadInvoiceRequestFileType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DownloadInvoiceRequestFileType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DownloadInvoiceRequestFileType(DownloadInvoiceRequestFileType(tmp).String()) return nil } type InvoiceType string const ( InvoiceTypeUnknownType = InvoiceType("unknown_type") InvoiceTypePeriodic = InvoiceType("periodic") InvoiceTypePurchase = InvoiceType("purchase") ) func (enum InvoiceType) String() string { if enum == "" { // return default value if empty return "unknown_type" } return string(enum) } func (enum InvoiceType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *InvoiceType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = InvoiceType(InvoiceType(tmp).String()) return nil } type ListDiscountsRequestOrderBy string const ( // Order discounts by creation date (descending chronological order). ListDiscountsRequestOrderByCreationDateDesc = ListDiscountsRequestOrderBy("creation_date_desc") // Order discounts by creation date (ascending chronological order). ListDiscountsRequestOrderByCreationDateAsc = ListDiscountsRequestOrderBy("creation_date_asc") ) func (enum ListDiscountsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "creation_date_desc" } return string(enum) } func (enum ListDiscountsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListDiscountsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListDiscountsRequestOrderBy(ListDiscountsRequestOrderBy(tmp).String()) return nil } type ListInvoicesRequestOrderBy string const ( ListInvoicesRequestOrderByInvoiceNumberDesc = ListInvoicesRequestOrderBy("invoice_number_desc") ListInvoicesRequestOrderByInvoiceNumberAsc = ListInvoicesRequestOrderBy("invoice_number_asc") ListInvoicesRequestOrderByStartDateDesc = ListInvoicesRequestOrderBy("start_date_desc") ListInvoicesRequestOrderByStartDateAsc = ListInvoicesRequestOrderBy("start_date_asc") ListInvoicesRequestOrderByIssuedDateDesc = ListInvoicesRequestOrderBy("issued_date_desc") ListInvoicesRequestOrderByIssuedDateAsc = ListInvoicesRequestOrderBy("issued_date_asc") ListInvoicesRequestOrderByDueDateDesc = ListInvoicesRequestOrderBy("due_date_desc") ListInvoicesRequestOrderByDueDateAsc = ListInvoicesRequestOrderBy("due_date_asc") ListInvoicesRequestOrderByTotalUntaxedDesc = ListInvoicesRequestOrderBy("total_untaxed_desc") ListInvoicesRequestOrderByTotalUntaxedAsc = ListInvoicesRequestOrderBy("total_untaxed_asc") ListInvoicesRequestOrderByTotalTaxedDesc = ListInvoicesRequestOrderBy("total_taxed_desc") ListInvoicesRequestOrderByTotalTaxedAsc = ListInvoicesRequestOrderBy("total_taxed_asc") ListInvoicesRequestOrderByInvoiceTypeDesc = ListInvoicesRequestOrderBy("invoice_type_desc") ListInvoicesRequestOrderByInvoiceTypeAsc = ListInvoicesRequestOrderBy("invoice_type_asc") ) func (enum ListInvoicesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "invoice_number_desc" } return string(enum) } func (enum ListInvoicesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListInvoicesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListInvoicesRequestOrderBy(ListInvoicesRequestOrderBy(tmp).String()) return nil } // DiscountCoupon: discount coupon. type DiscountCoupon struct { // Description: the description of the coupon. Description *string `json:"description"` } // DiscountFilter: discount filter. type DiscountFilter struct { // Type: type of the filter. // Default value: unknown_type Type DiscountFilterType `json:"type"` // Value: value of filter, it can be a product/range/region/zone value. Value string `json:"value"` } // GetConsumptionResponseConsumption: get consumption response consumption. type GetConsumptionResponseConsumption struct { // Value: monetary value of the consumption. Value *scw.Money `json:"value"` // Description: description of the consumption. Description string `json:"description"` // ProjectID: project ID of the consumption. ProjectID string `json:"project_id"` // Category: category of the consumption. Category string `json:"category"` // OperationPath: unique identifier of the product. OperationPath string `json:"operation_path"` } // Discount: discount. type Discount struct { // ID: the ID of the discount. ID string `json:"id"` // CreationDate: the creation date of the discount. CreationDate *time.Time `json:"creation_date"` // OrganizationID: the organization ID of the discount. OrganizationID string `json:"organization_id"` // Description: the description of the discount. Description string `json:"description"` // Value: the initial value of the discount. Value float64 `json:"value"` // ValueUsed: the value indicating how much of the discount has been used. ValueUsed float64 `json:"value_used"` // ValueRemaining: the remaining value of the discount. ValueRemaining float64 `json:"value_remaining"` // Mode: the mode of the discount. // Default value: unknown_discount_mode Mode DiscountDiscountMode `json:"mode"` // StartDate: the start date of the discount. StartDate *time.Time `json:"start_date"` // StopDate: the stop date of the discount. StopDate *time.Time `json:"stop_date"` // Coupon: the description of the coupon. Coupon *DiscountCoupon `json:"coupon"` // Filters: list of products/ranges/regions/zones to limit the usability of discounts. Filters []*DiscountFilter `json:"filters"` } // Invoice: invoice. type Invoice struct { // ID: invoice ID. ID string `json:"id"` // StartDate: start date of the billing period. StartDate *time.Time `json:"start_date"` // IssuedDate: date when the invoice was sent to the customer. IssuedDate *time.Time `json:"issued_date"` // DueDate: payment time limit, set according to the Organization's payment conditions. DueDate *time.Time `json:"due_date"` // TotalUntaxed: total amount, untaxed. TotalUntaxed *scw.Money `json:"total_untaxed"` // TotalTaxed: total amount, taxed. TotalTaxed *scw.Money `json:"total_taxed"` // InvoiceType: type of invoice. // Default value: unknown_type InvoiceType InvoiceType `json:"invoice_type"` // Number: invoice number. Number int32 `json:"number"` } // DownloadInvoiceRequest: download invoice request. type DownloadInvoiceRequest struct { // InvoiceID: invoice ID. InvoiceID string `json:"-"` // FileType: wanted file type. // Default value: pdf FileType DownloadInvoiceRequestFileType `json:"-"` } // GetConsumptionRequest: get consumption request. type GetConsumptionRequest struct { // OrganizationID: filter by organization ID. OrganizationID string `json:"-"` } // GetConsumptionResponse: get consumption response. type GetConsumptionResponse struct { // Consumptions: detailed consumption list. Consumptions []*GetConsumptionResponseConsumption `json:"consumptions"` // UpdatedAt: last consumption update date. UpdatedAt *time.Time `json:"updated_at"` } // ListDiscountsRequest: list discounts request. type ListDiscountsRequest struct { // OrderBy: order discounts in the response by their description. // Default value: creation_date_desc OrderBy ListDiscountsRequestOrderBy `json:"-"` // Page: positive integer to choose the page to return. Page *int32 `json:"-"` // PageSize: positive integer lower or equal to 100 to select the number of items to return. PageSize *uint32 `json:"-"` // OrganizationID: ID of the organization. OrganizationID *string `json:"-"` } // ListDiscountsResponse: list discounts response. type ListDiscountsResponse struct { // TotalCount: total number of discounts. TotalCount uint64 `json:"total_count"` // Discounts: paginated returned discounts. Discounts []*Discount `json:"discounts"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListDiscountsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListDiscountsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListDiscountsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Discounts = append(r.Discounts, results.Discounts...) r.TotalCount += uint64(len(results.Discounts)) return uint64(len(results.Discounts)), nil } // ListInvoicesRequest: list invoices request. type ListInvoicesRequest struct { // OrganizationID: organization ID to filter for, only invoices from this Organization will be returned. OrganizationID *string `json:"-"` // StartedAfter: invoice's `start_date` is greater or equal to `started_after`. StartedAfter *time.Time `json:"-"` // StartedBefore: invoice's `start_date` precedes `started_before`. StartedBefore *time.Time `json:"-"` // InvoiceType: invoice type. It can either be `periodic` or `purchase`. // Default value: unknown_type InvoiceType InvoiceType `json:"-"` // Page: positive integer to choose the page to return. Page *int32 `json:"-"` // PageSize: positive integer lower or equal to 100 to select the number of items to return. PageSize *uint32 `json:"-"` // OrderBy: how invoices are ordered in the response. // Default value: invoice_number_desc OrderBy ListInvoicesRequestOrderBy `json:"-"` } // ListInvoicesResponse: list invoices response. type ListInvoicesResponse struct { // TotalCount: total number of invoices. TotalCount uint32 `json:"total_count"` // Invoices: paginated returned invoices. Invoices []*Invoice `json:"invoices"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListInvoicesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListInvoicesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListInvoicesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Invoices = append(r.Invoices, results.Invoices...) r.TotalCount += uint32(len(results.Invoices)) return uint32(len(results.Invoices)), nil } // This API allows you to query your consumption. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } // GetConsumption: The consumption reflects the amount of money you have spent for the products you have used. // The consumption value is monetary and is not computed in real time. func (s *API) GetConsumption(req *GetConsumptionRequest, opts ...scw.RequestOption) (*GetConsumptionResponse, error) { var err error if req.OrganizationID == "" { defaultOrganizationID, _ := s.client.GetDefaultOrganizationID() req.OrganizationID = defaultOrganizationID } query := url.Values{} parameter.AddToQuery(query, "organization_id", req.OrganizationID) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/billing/v2alpha1/consumption", Query: query, } var resp GetConsumptionResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListInvoices: List all your invoices, filtering by `start_date` and `invoice_type`. Each invoice has its own ID. func (s *API) ListInvoices(req *ListInvoicesRequest, opts ...scw.RequestOption) (*ListInvoicesResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "started_after", req.StartedAfter) parameter.AddToQuery(query, "started_before", req.StartedBefore) parameter.AddToQuery(query, "invoice_type", req.InvoiceType) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/billing/v2alpha1/invoices", Query: query, } var resp ListInvoicesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DownloadInvoice: Download a specific invoice, specified by its ID. func (s *API) DownloadInvoice(req *DownloadInvoiceRequest, opts ...scw.RequestOption) (*scw.File, error) { var err error query := url.Values{} parameter.AddToQuery(query, "file_type", req.FileType) if fmt.Sprint(req.InvoiceID) == "" { return nil, errors.New("field InvoiceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/billing/v2alpha1/invoices/" + fmt.Sprint(req.InvoiceID) + "/download", Query: query, } var resp scw.File err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListDiscounts: List all discounts for an organization and usable categories/products/offers/references/regions/zones where the discount can be applied. func (s *API) ListDiscounts(req *ListDiscountsRequest, opts ...scw.RequestOption) (*ListDiscountsResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "organization_id", req.OrganizationID) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/billing/v2alpha1/discounts", Query: query, } var resp ListDiscountsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/billing/v2beta1/000077500000000000000000000000001456366605600257135ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/billing/v2beta1/billing_sdk.go000066400000000000000000001004541456366605600305270ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package billing provides methods and message types of the billing v2beta1 API. package billing import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type DiscountDiscountMode string const ( // Unknown discount mode. DiscountDiscountModeUnknownDiscountMode = DiscountDiscountMode("unknown_discount_mode") // A rate discount that reduces each customer bill by the discount value percentage. DiscountDiscountModeDiscountModeRate = DiscountDiscountMode("discount_mode_rate") // A value discount that reduces the amount of the customer bill by the discount value. DiscountDiscountModeDiscountModeValue = DiscountDiscountMode("discount_mode_value") // A fixed sum to be deducted from the user's bills. DiscountDiscountModeDiscountModeSplittable = DiscountDiscountMode("discount_mode_splittable") ) func (enum DiscountDiscountMode) String() string { if enum == "" { // return default value if empty return "unknown_discount_mode" } return string(enum) } func (enum DiscountDiscountMode) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DiscountDiscountMode) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DiscountDiscountMode(DiscountDiscountMode(tmp).String()) return nil } type DiscountFilterType string const ( // Unknown filter type. DiscountFilterTypeUnknownType = DiscountFilterType("unknown_type") // Product category, such as Compute, Network, Observability. DiscountFilterTypeCategoryName = DiscountFilterType("category_name") // Products within the Product category. For example, VPC, Private Networks, and Public Gateways are products in the Network category. DiscountFilterTypeProductName = DiscountFilterType("product_name") // The range of a product. For example, `Production Optimized` or `Cost Optimized` for an `instance` product of the `compute` category. DiscountFilterTypeProductRange = DiscountFilterType("product_range") // Identifies the reference based on category, product, range, size, region, and zone. It can sometimes include different product options, such as licenses and monthly payments. DiscountFilterTypeResourceName = DiscountFilterType("resource_name") // Region name like "FR-PAR", "NL-AMS", "PL-WAW". DiscountFilterTypeRegion = DiscountFilterType("region") // Zone name like "FR-PAR-1", "FR-PAR-2", "FR-PAR-3". DiscountFilterTypeZone = DiscountFilterType("zone") ) func (enum DiscountFilterType) String() string { if enum == "" { // return default value if empty return "unknown_type" } return string(enum) } func (enum DiscountFilterType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DiscountFilterType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DiscountFilterType(DiscountFilterType(tmp).String()) return nil } type DownloadInvoiceRequestFileType string const ( DownloadInvoiceRequestFileTypePdf = DownloadInvoiceRequestFileType("pdf") ) func (enum DownloadInvoiceRequestFileType) String() string { if enum == "" { // return default value if empty return "pdf" } return string(enum) } func (enum DownloadInvoiceRequestFileType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DownloadInvoiceRequestFileType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DownloadInvoiceRequestFileType(DownloadInvoiceRequestFileType(tmp).String()) return nil } type ExportInvoicesRequestFileType string const ( ExportInvoicesRequestFileTypeCsv = ExportInvoicesRequestFileType("csv") ) func (enum ExportInvoicesRequestFileType) String() string { if enum == "" { // return default value if empty return "csv" } return string(enum) } func (enum ExportInvoicesRequestFileType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ExportInvoicesRequestFileType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ExportInvoicesRequestFileType(ExportInvoicesRequestFileType(tmp).String()) return nil } type ExportInvoicesRequestOrderBy string const ( ExportInvoicesRequestOrderByInvoiceNumberDesc = ExportInvoicesRequestOrderBy("invoice_number_desc") ExportInvoicesRequestOrderByInvoiceNumberAsc = ExportInvoicesRequestOrderBy("invoice_number_asc") ExportInvoicesRequestOrderByStartDateDesc = ExportInvoicesRequestOrderBy("start_date_desc") ExportInvoicesRequestOrderByStartDateAsc = ExportInvoicesRequestOrderBy("start_date_asc") ExportInvoicesRequestOrderByIssuedDateDesc = ExportInvoicesRequestOrderBy("issued_date_desc") ExportInvoicesRequestOrderByIssuedDateAsc = ExportInvoicesRequestOrderBy("issued_date_asc") ExportInvoicesRequestOrderByDueDateDesc = ExportInvoicesRequestOrderBy("due_date_desc") ExportInvoicesRequestOrderByDueDateAsc = ExportInvoicesRequestOrderBy("due_date_asc") ExportInvoicesRequestOrderByTotalUntaxedDesc = ExportInvoicesRequestOrderBy("total_untaxed_desc") ExportInvoicesRequestOrderByTotalUntaxedAsc = ExportInvoicesRequestOrderBy("total_untaxed_asc") ExportInvoicesRequestOrderByTotalTaxedDesc = ExportInvoicesRequestOrderBy("total_taxed_desc") ExportInvoicesRequestOrderByTotalTaxedAsc = ExportInvoicesRequestOrderBy("total_taxed_asc") ExportInvoicesRequestOrderByInvoiceTypeDesc = ExportInvoicesRequestOrderBy("invoice_type_desc") ExportInvoicesRequestOrderByInvoiceTypeAsc = ExportInvoicesRequestOrderBy("invoice_type_asc") ) func (enum ExportInvoicesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "invoice_number_desc" } return string(enum) } func (enum ExportInvoicesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ExportInvoicesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ExportInvoicesRequestOrderBy(ExportInvoicesRequestOrderBy(tmp).String()) return nil } type InvoiceType string const ( InvoiceTypeUnknownType = InvoiceType("unknown_type") InvoiceTypePeriodic = InvoiceType("periodic") InvoiceTypePurchase = InvoiceType("purchase") ) func (enum InvoiceType) String() string { if enum == "" { // return default value if empty return "unknown_type" } return string(enum) } func (enum InvoiceType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *InvoiceType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = InvoiceType(InvoiceType(tmp).String()) return nil } type ListConsumptionsRequestOrderBy string const ( // Order consumptions by update date (descending chronological order). ListConsumptionsRequestOrderByUpdatedAtDesc = ListConsumptionsRequestOrderBy("updated_at_desc") // Order consumptions by update date (ascending chronological order). ListConsumptionsRequestOrderByUpdatedAtAsc = ListConsumptionsRequestOrderBy("updated_at_asc") // Order consumptions by category name (descending alphabetical order). ListConsumptionsRequestOrderByCategoryNameDesc = ListConsumptionsRequestOrderBy("category_name_desc") // Order consumptions by category name (ascending alphabetical order). ListConsumptionsRequestOrderByCategoryNameAsc = ListConsumptionsRequestOrderBy("category_name_asc") ) func (enum ListConsumptionsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "updated_at_desc" } return string(enum) } func (enum ListConsumptionsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListConsumptionsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListConsumptionsRequestOrderBy(ListConsumptionsRequestOrderBy(tmp).String()) return nil } type ListDiscountsRequestOrderBy string const ( // Order discounts by creation date (descending chronological order). ListDiscountsRequestOrderByCreationDateDesc = ListDiscountsRequestOrderBy("creation_date_desc") // Order discounts by creation date (ascending chronological order). ListDiscountsRequestOrderByCreationDateAsc = ListDiscountsRequestOrderBy("creation_date_asc") ) func (enum ListDiscountsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "creation_date_desc" } return string(enum) } func (enum ListDiscountsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListDiscountsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListDiscountsRequestOrderBy(ListDiscountsRequestOrderBy(tmp).String()) return nil } type ListInvoicesRequestOrderBy string const ( ListInvoicesRequestOrderByInvoiceNumberDesc = ListInvoicesRequestOrderBy("invoice_number_desc") ListInvoicesRequestOrderByInvoiceNumberAsc = ListInvoicesRequestOrderBy("invoice_number_asc") ListInvoicesRequestOrderByStartDateDesc = ListInvoicesRequestOrderBy("start_date_desc") ListInvoicesRequestOrderByStartDateAsc = ListInvoicesRequestOrderBy("start_date_asc") ListInvoicesRequestOrderByIssuedDateDesc = ListInvoicesRequestOrderBy("issued_date_desc") ListInvoicesRequestOrderByIssuedDateAsc = ListInvoicesRequestOrderBy("issued_date_asc") ListInvoicesRequestOrderByDueDateDesc = ListInvoicesRequestOrderBy("due_date_desc") ListInvoicesRequestOrderByDueDateAsc = ListInvoicesRequestOrderBy("due_date_asc") ListInvoicesRequestOrderByTotalUntaxedDesc = ListInvoicesRequestOrderBy("total_untaxed_desc") ListInvoicesRequestOrderByTotalUntaxedAsc = ListInvoicesRequestOrderBy("total_untaxed_asc") ListInvoicesRequestOrderByTotalTaxedDesc = ListInvoicesRequestOrderBy("total_taxed_desc") ListInvoicesRequestOrderByTotalTaxedAsc = ListInvoicesRequestOrderBy("total_taxed_asc") ListInvoicesRequestOrderByInvoiceTypeDesc = ListInvoicesRequestOrderBy("invoice_type_desc") ListInvoicesRequestOrderByInvoiceTypeAsc = ListInvoicesRequestOrderBy("invoice_type_asc") ) func (enum ListInvoicesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "invoice_number_desc" } return string(enum) } func (enum ListInvoicesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListInvoicesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListInvoicesRequestOrderBy(ListInvoicesRequestOrderBy(tmp).String()) return nil } type ListTaxesRequestOrderBy string const ( // Order consumptions by update date (descending chronological order). ListTaxesRequestOrderByUpdatedAtDesc = ListTaxesRequestOrderBy("updated_at_desc") // Order consumptions by update date (ascending chronological order). ListTaxesRequestOrderByUpdatedAtAsc = ListTaxesRequestOrderBy("updated_at_asc") // Order consumptions by category name (descending alphabetical order). ListTaxesRequestOrderByCategoryNameDesc = ListTaxesRequestOrderBy("category_name_desc") // Order consumptions by category name (ascending alphabetical order). ListTaxesRequestOrderByCategoryNameAsc = ListTaxesRequestOrderBy("category_name_asc") ) func (enum ListTaxesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "updated_at_desc" } return string(enum) } func (enum ListTaxesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListTaxesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListTaxesRequestOrderBy(ListTaxesRequestOrderBy(tmp).String()) return nil } // DiscountCoupon: discount coupon. type DiscountCoupon struct { // Description: the description of the coupon. Description *string `json:"description"` } // DiscountFilter: discount filter. type DiscountFilter struct { // Type: type of the filter (category name, product name, product range, resource name, region or zone). // Default value: unknown_type Type DiscountFilterType `json:"type"` // Value: value of filter. Value string `json:"value"` } // ListConsumptionsResponseConsumption: list consumptions response consumption. type ListConsumptionsResponseConsumption struct { // Value: monetary value of the consumption. Value *scw.Money `json:"value"` // ProductName: the product name. For example, "VPC Public Gateway S", "VPC Public Gateway M" for the VPC product. ProductName string `json:"product_name"` // ResourceName: identifies the reference based on the category. ResourceName string `json:"resource_name"` // Sku: unique identifier of the product. Sku string `json:"sku"` // ProjectID: project ID of the consumption. ProjectID string `json:"project_id"` // CategoryName: name of consumption category. CategoryName string `json:"category_name"` // Unit: unit of consumed quantity. Unit string `json:"unit"` // BilledQuantity: consumed quantity. BilledQuantity string `json:"billed_quantity"` } // Discount: discount. type Discount struct { // ID: the ID of the discount. ID string `json:"id"` // CreationDate: the creation date of the discount. CreationDate *time.Time `json:"creation_date"` // OrganizationID: the organization ID of the discount. OrganizationID string `json:"organization_id"` // Description: the description of the discount. Description string `json:"description"` // Value: the initial value of the discount. Value float64 `json:"value"` // ValueUsed: the value indicating how much of the discount has been used. ValueUsed float64 `json:"value_used"` // ValueRemaining: the remaining value of the discount. ValueRemaining float64 `json:"value_remaining"` // Mode: the mode of the discount. // Default value: unknown_discount_mode Mode DiscountDiscountMode `json:"mode"` // StartDate: the start date of the discount. StartDate *time.Time `json:"start_date"` // StopDate: the stop date of the discount. StopDate *time.Time `json:"stop_date"` // Coupon: the description of the coupon. Coupon *DiscountCoupon `json:"coupon"` // Filters: list of the discount scopes. Filters []*DiscountFilter `json:"filters"` } // Invoice: invoice. type Invoice struct { // ID: invoice ID. ID string `json:"id"` OrganizationID string `json:"organization_id"` OrganizationName string `json:"organization_name"` // StartDate: start date of the billing period. StartDate *time.Time `json:"start_date"` StopDate *time.Time `json:"stop_date"` // BillingPeriod: the billing period of the invoice in the YYYY-MM format. BillingPeriod *time.Time `json:"billing_period"` // IssuedDate: date when the invoice was sent to the customer. IssuedDate *time.Time `json:"issued_date"` // DueDate: payment time limit, set according to the Organization's payment conditions. DueDate *time.Time `json:"due_date"` // TotalUntaxed: total amount, untaxed. TotalUntaxed *scw.Money `json:"total_untaxed"` // TotalTaxed: total amount, taxed. TotalTaxed *scw.Money `json:"total_taxed"` // TotalTax: the total tax amount of the invoice. TotalTax *scw.Money `json:"total_tax"` // TotalDiscount: the total discount amount of the invoice. TotalDiscount *scw.Money `json:"total_discount"` // TotalUndiscount: the total amount of the invoice before applying the discount. TotalUndiscount *scw.Money `json:"total_undiscount"` // Type: type of invoice, either periodic or purchase. // Default value: unknown_type Type InvoiceType `json:"type"` // State: the state of the Invoice. State string `json:"state"` // Number: invoice number. Number int32 `json:"number"` // SellerName: the name of the seller (Scaleway). SellerName string `json:"seller_name"` } // ListTaxesResponseTax: list taxes response tax. type ListTaxesResponseTax struct { // Description: description of the tax applied. Description string `json:"description"` // Currency: the three-letter currency code. Currency string `json:"currency"` // Rate: applied tax rate (0.2 means a VAT of 20%). Rate *float64 `json:"rate"` // TotalTaxValue: the total tax value of the consumption. TotalTaxValue *float64 `json:"total_tax_value"` } // DownloadInvoiceRequest: download invoice request. type DownloadInvoiceRequest struct { // InvoiceID: invoice ID. InvoiceID string `json:"-"` // FileType: file type. PDF by default. // Default value: pdf FileType DownloadInvoiceRequestFileType `json:"-"` } // ExportInvoicesRequest: export invoices request. type ExportInvoicesRequest struct { // OrganizationID: organization ID. If specified, only invoices from this Organization will be returned. OrganizationID *string `json:"-"` // BillingPeriodStartAfter: return only invoice with start date greater than billing_period_start. BillingPeriodStartAfter *time.Time `json:"-"` // BillingPeriodStartBefore: return only invoice with start date less than billing_period_start. BillingPeriodStartBefore *time.Time `json:"-"` // InvoiceType: invoice type. It can either be `periodic` or `purchase`. // Default value: unknown_type InvoiceType InvoiceType `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: positive integer lower or equal to 100 to select the number of items to return. PageSize *uint32 `json:"-"` // OrderBy: how invoices are ordered in the response. // Default value: invoice_number_desc OrderBy ExportInvoicesRequestOrderBy `json:"-"` // FileType: file format for exporting the invoice list. // Default value: csv FileType ExportInvoicesRequestFileType `json:"-"` } // GetInvoiceRequest: get invoice request. type GetInvoiceRequest struct { // InvoiceID: invoice ID. InvoiceID string `json:"-"` } // ListConsumptionsRequest: list consumptions request. type ListConsumptionsRequest struct { // OrderBy: order consumptions list in the response by their update date. // Default value: updated_at_desc OrderBy ListConsumptionsRequestOrderBy `json:"-"` // Page: positive integer to choose the page to return. Page *int32 `json:"-"` // PageSize: positive integer lower or equal to 100 to select the number of items to return. PageSize *uint32 `json:"-"` // OrganizationID: filter by Organization ID. // Precisely one of OrganizationID, ProjectID must be set. OrganizationID *string `json:"organization_id,omitempty"` // ProjectID: filter by Project ID. // Precisely one of OrganizationID, ProjectID must be set. ProjectID *string `json:"project_id,omitempty"` // CategoryName: filter by name of a Category as they are shown in the invoice (Compute, Network, Observability). CategoryName *string `json:"-"` // BillingPeriod: filter by the billing period in the YYYY-MM format. If it is empty the current billing period will be used as default. BillingPeriod *string `json:"-"` } // ListConsumptionsResponse: list consumptions response. type ListConsumptionsResponse struct { // Consumptions: detailed consumption list. Consumptions []*ListConsumptionsResponseConsumption `json:"consumptions"` // TotalCount: total number of returned items. TotalCount uint64 `json:"total_count"` // TotalDiscountUntaxedValue: sum of all discounts, displayed only when no category or project ID filter is applied. TotalDiscountUntaxedValue float64 `json:"total_discount_untaxed_value"` // UpdatedAt: last consumption update date. UpdatedAt *time.Time `json:"updated_at"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListConsumptionsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListConsumptionsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListConsumptionsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Consumptions = append(r.Consumptions, results.Consumptions...) r.TotalCount += uint64(len(results.Consumptions)) return uint64(len(results.Consumptions)), nil } // ListDiscountsRequest: list discounts request. type ListDiscountsRequest struct { // OrderBy: order discounts in the response by their description. // Default value: creation_date_desc OrderBy ListDiscountsRequestOrderBy `json:"-"` // Page: positive integer to choose the page to return. Page *int32 `json:"-"` // PageSize: positive integer lower or equal to 100 to select the number of items to return. PageSize *uint32 `json:"-"` // OrganizationID: ID of the organization. OrganizationID *string `json:"-"` } // ListDiscountsResponse: list discounts response. type ListDiscountsResponse struct { // TotalCount: total number of discounts. TotalCount uint64 `json:"total_count"` // Discounts: paginated returned discounts. Discounts []*Discount `json:"discounts"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListDiscountsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListDiscountsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListDiscountsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Discounts = append(r.Discounts, results.Discounts...) r.TotalCount += uint64(len(results.Discounts)) return uint64(len(results.Discounts)), nil } // ListInvoicesRequest: list invoices request. type ListInvoicesRequest struct { // OrganizationID: organization ID. If specified, only invoices from this Organization will be returned. OrganizationID *string `json:"-"` // BillingPeriodStartAfter: return only invoice with start date greater than billing_period_start. BillingPeriodStartAfter *time.Time `json:"-"` // BillingPeriodStartBefore: return only invoice with start date less than billing_period_start. BillingPeriodStartBefore *time.Time `json:"-"` // InvoiceType: invoice type. It can either be `periodic` or `purchase`. // Default value: unknown_type InvoiceType InvoiceType `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: positive integer lower or equal to 100 to select the number of items to return. PageSize *uint32 `json:"-"` // OrderBy: how invoices are ordered in the response. // Default value: invoice_number_desc OrderBy ListInvoicesRequestOrderBy `json:"-"` } // ListInvoicesResponse: list invoices response. type ListInvoicesResponse struct { // TotalCount: total number of invoices. TotalCount uint64 `json:"total_count"` // Invoices: paginated returned invoices. Invoices []*Invoice `json:"invoices"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListInvoicesResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListInvoicesResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListInvoicesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Invoices = append(r.Invoices, results.Invoices...) r.TotalCount += uint64(len(results.Invoices)) return uint64(len(results.Invoices)), nil } // ListTaxesRequest: list taxes request. type ListTaxesRequest struct { // OrderBy: order consumed taxes list in the response by their update date. // Default value: updated_at_desc OrderBy ListTaxesRequestOrderBy `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: positive integer lower or equal to 100 to select the number of items to return. PageSize *uint32 `json:"-"` // OrganizationID: filter by Organization ID. OrganizationID string `json:"-"` // BillingPeriod: filter by the billing period in the YYYY-MM format. If it is empty the current billing period will be used as default. BillingPeriod *string `json:"-"` } // ListTaxesResponse: list taxes response. type ListTaxesResponse struct { // Taxes: detailed consumption tax. Taxes []*ListTaxesResponseTax `json:"taxes"` // TotalCount: total number of returned items. TotalCount uint64 `json:"total_count"` // UpdatedAt: last consumption update date. UpdatedAt *time.Time `json:"updated_at"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListTaxesResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListTaxesResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListTaxesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Taxes = append(r.Taxes, results.Taxes...) r.TotalCount += uint64(len(results.Taxes)) return uint64(len(results.Taxes)), nil } // This API allows you to query your consumption. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } // ListConsumptions: Consumption allows you to retrieve your past or current consumption cost, by project or category. func (s *API) ListConsumptions(req *ListConsumptionsRequest, opts ...scw.RequestOption) (*ListConsumptionsResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } defaultOrganizationID, exist := s.client.GetDefaultOrganizationID() if exist && req.OrganizationID == nil && req.ProjectID == nil { req.OrganizationID = &defaultOrganizationID } defaultProjectID, exist := s.client.GetDefaultProjectID() if exist && req.OrganizationID == nil && req.ProjectID == nil { req.ProjectID = &defaultProjectID } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "category_name", req.CategoryName) parameter.AddToQuery(query, "billing_period", req.BillingPeriod) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/billing/v2beta1/consumptions", Query: query, } var resp ListConsumptionsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListTaxes: Consumption Tax allows you to retrieve your past or current tax charges, by project or category. func (s *API) ListTaxes(req *ListTaxesRequest, opts ...scw.RequestOption) (*ListTaxesResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } if req.OrganizationID == "" { defaultOrganizationID, _ := s.client.GetDefaultOrganizationID() req.OrganizationID = defaultOrganizationID } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "billing_period", req.BillingPeriod) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/billing/v2beta1/taxes", Query: query, } var resp ListTaxesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListInvoices: List all your invoices, filtering by `start_date` and `invoice_type`. Each invoice has its own ID. func (s *API) ListInvoices(req *ListInvoicesRequest, opts ...scw.RequestOption) (*ListInvoicesResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "billing_period_start_after", req.BillingPeriodStartAfter) parameter.AddToQuery(query, "billing_period_start_before", req.BillingPeriodStartBefore) parameter.AddToQuery(query, "invoice_type", req.InvoiceType) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/billing/v2beta1/invoices", Query: query, } var resp ListInvoicesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ExportInvoices: Export invoices in a CSV file. func (s *API) ExportInvoices(req *ExportInvoicesRequest, opts ...scw.RequestOption) (*scw.File, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "billing_period_start_after", req.BillingPeriodStartAfter) parameter.AddToQuery(query, "billing_period_start_before", req.BillingPeriodStartBefore) parameter.AddToQuery(query, "invoice_type", req.InvoiceType) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "file_type", req.FileType) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/billing/v2beta1/export-invoices", Query: query, } var resp scw.File err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetInvoice: Get a specific invoice, specified by its ID. func (s *API) GetInvoice(req *GetInvoiceRequest, opts ...scw.RequestOption) (*Invoice, error) { var err error if fmt.Sprint(req.InvoiceID) == "" { return nil, errors.New("field InvoiceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/billing/v2beta1/invoices/" + fmt.Sprint(req.InvoiceID) + "", } var resp Invoice err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DownloadInvoice: Download a specific invoice, specified by its ID. func (s *API) DownloadInvoice(req *DownloadInvoiceRequest, opts ...scw.RequestOption) (*scw.File, error) { var err error query := url.Values{} parameter.AddToQuery(query, "file_type", req.FileType) if fmt.Sprint(req.InvoiceID) == "" { return nil, errors.New("field InvoiceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/billing/v2beta1/invoices/" + fmt.Sprint(req.InvoiceID) + "/download", Query: query, } var resp scw.File err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListDiscounts: List all discounts for your organization and usable categories, products, offers, references, regions and zones where the discount can be applied. func (s *API) ListDiscounts(req *ListDiscountsRequest, opts ...scw.RequestOption) (*ListDiscountsResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "organization_id", req.OrganizationID) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/billing/v2beta1/discounts", Query: query, } var resp ListDiscountsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/block/000077500000000000000000000000001456366605600241215ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/block/v1alpha1/000077500000000000000000000000001456366605600255365ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/block/v1alpha1/block_sdk.go000066400000000000000000001024371456366605600300270ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package block provides methods and message types of the block v1alpha1 API. package block import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type ListSnapshotsRequestOrderBy string const ( // Order by creation date (ascending chronological order). ListSnapshotsRequestOrderByCreatedAtAsc = ListSnapshotsRequestOrderBy("created_at_asc") // Order by creation date (descending chronological order). ListSnapshotsRequestOrderByCreatedAtDesc = ListSnapshotsRequestOrderBy("created_at_desc") // Order by name (ascending order). ListSnapshotsRequestOrderByNameAsc = ListSnapshotsRequestOrderBy("name_asc") // Order by name (descending order). ListSnapshotsRequestOrderByNameDesc = ListSnapshotsRequestOrderBy("name_desc") ) func (enum ListSnapshotsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListSnapshotsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListSnapshotsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListSnapshotsRequestOrderBy(ListSnapshotsRequestOrderBy(tmp).String()) return nil } type ListVolumesRequestOrderBy string const ( // Order by creation date (ascending chronological order). ListVolumesRequestOrderByCreatedAtAsc = ListVolumesRequestOrderBy("created_at_asc") // Order by creation date (descending chronological order). ListVolumesRequestOrderByCreatedAtDesc = ListVolumesRequestOrderBy("created_at_desc") // Order by name (ascending order). ListVolumesRequestOrderByNameAsc = ListVolumesRequestOrderBy("name_asc") // Order by name (descending order). ListVolumesRequestOrderByNameDesc = ListVolumesRequestOrderBy("name_desc") ) func (enum ListVolumesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListVolumesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListVolumesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListVolumesRequestOrderBy(ListVolumesRequestOrderBy(tmp).String()) return nil } type ReferenceStatus string const ( // If unspecified, the status of the reference is unknown by default. ReferenceStatusUnknownStatus = ReferenceStatus("unknown_status") // When the reference is being attached (transient). ReferenceStatusAttaching = ReferenceStatus("attaching") // When the reference attached to a volume. ReferenceStatusAttached = ReferenceStatus("attached") // When the reference is being detached (transient). ReferenceStatusDetaching = ReferenceStatus("detaching") // When the reference is detached from a volume - the reference ceases to exist. ReferenceStatusDetached = ReferenceStatus("detached") // Reference undergoing snapshotting operation (transient). ReferenceStatusSnapshotting = ReferenceStatus("snapshotting") // Error status. ReferenceStatusError = ReferenceStatus("error") ) func (enum ReferenceStatus) String() string { if enum == "" { // return default value if empty return "unknown_status" } return string(enum) } func (enum ReferenceStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ReferenceStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ReferenceStatus(ReferenceStatus(tmp).String()) return nil } type ReferenceType string const ( // If unspecified, the reference type is unknown by default. ReferenceTypeUnknownType = ReferenceType("unknown_type") // Reference linked to a snapshot (for snapshots only). ReferenceTypeLink = ReferenceType("link") // Exclusive reference that can be associated to a volume (for volumes only). ReferenceTypeExclusive = ReferenceType("exclusive") // Access to the volume or snapshot in a read-only mode, without storage write access to the resource. ReferenceTypeReadOnly = ReferenceType("read_only") ) func (enum ReferenceType) String() string { if enum == "" { // return default value if empty return "unknown_type" } return string(enum) } func (enum ReferenceType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ReferenceType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ReferenceType(ReferenceType(tmp).String()) return nil } type SnapshotStatus string const ( // If unspecified, the snapshot status is unknown by default. SnapshotStatusUnknownStatus = SnapshotStatus("unknown_status") // The snapshot is under creation (transient). SnapshotStatusCreating = SnapshotStatus("creating") // Snapshot exists and is not attached to any reference. SnapshotStatusAvailable = SnapshotStatus("available") // Snapshot in an error status. SnapshotStatusError = SnapshotStatus("error") // Snapshot is being deleted (transient). SnapshotStatusDeleting = SnapshotStatus("deleting") // Snapshot was deleted. SnapshotStatusDeleted = SnapshotStatus("deleted") // Snapshot attached to one or more references. SnapshotStatusInUse = SnapshotStatus("in_use") SnapshotStatusLocked = SnapshotStatus("locked") ) func (enum SnapshotStatus) String() string { if enum == "" { // return default value if empty return "unknown_status" } return string(enum) } func (enum SnapshotStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *SnapshotStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = SnapshotStatus(SnapshotStatus(tmp).String()) return nil } type StorageClass string const ( // If unspecified, the Storage Class is unknown by default. StorageClassUnknownStorageClass = StorageClass("unknown_storage_class") // No specific Storage Class selected. StorageClassUnspecified = StorageClass("unspecified") // Classic storage. StorageClassBssd = StorageClass("bssd") // Performance storage with lower latency. StorageClassSbs = StorageClass("sbs") ) func (enum StorageClass) String() string { if enum == "" { // return default value if empty return "unknown_storage_class" } return string(enum) } func (enum StorageClass) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *StorageClass) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = StorageClass(StorageClass(tmp).String()) return nil } type VolumeStatus string const ( // If unspecified, the volume status is unknown by default. VolumeStatusUnknownStatus = VolumeStatus("unknown_status") // The volume is under creation (transient). VolumeStatusCreating = VolumeStatus("creating") // The volume exists and is not attached to any reference. VolumeStatusAvailable = VolumeStatus("available") // The volume exists and is already attached to a reference. VolumeStatusInUse = VolumeStatus("in_use") // The volume undergoing deletion (transient). VolumeStatusDeleting = VolumeStatus("deleting") VolumeStatusDeleted = VolumeStatus("deleted") // The volume is being increased (transient). VolumeStatusResizing = VolumeStatus("resizing") // The volume is an error status. VolumeStatusError = VolumeStatus("error") // The volume is undergoing snapshotting operation (transient). VolumeStatusSnapshotting = VolumeStatus("snapshotting") VolumeStatusLocked = VolumeStatus("locked") ) func (enum VolumeStatus) String() string { if enum == "" { // return default value if empty return "unknown_status" } return string(enum) } func (enum VolumeStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *VolumeStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = VolumeStatus(VolumeStatus(tmp).String()) return nil } // Reference: reference. type Reference struct { // ID: UUID of the reference. ID string `json:"id"` // ProductResourceType: type of resource to which the reference is associated. ProductResourceType string `json:"product_resource_type"` // ProductResourceID: UUID of the product resource it refers to (according to the product_resource_type). ProductResourceID string `json:"product_resource_id"` // CreatedAt: creation date of the reference. CreatedAt *time.Time `json:"created_at"` // Type: type of reference (link, exclusive, read_only). // Default value: unknown_type Type ReferenceType `json:"type"` // Status: status of reference (attaching, attached, detaching). // Default value: unknown_status Status ReferenceStatus `json:"status"` } // SnapshotParentVolume: snapshot parent volume. type SnapshotParentVolume struct { // ID: parent volume UUID (volume from which the snapshot originates). ID string `json:"id"` // Name: name of the parent volume. Name string `json:"name"` // Type: volume type of the parent volume. Type string `json:"type"` // Status: current status the parent volume. // Default value: unknown_status Status VolumeStatus `json:"status"` } // VolumeSpecifications: volume specifications. type VolumeSpecifications struct { // PerfIops: the maximum IO/s expected, according to the different options available in stock (`5000 | 15000`). PerfIops *uint32 `json:"perf_iops"` // Class: the storage class of the volume. // Default value: unknown_storage_class Class StorageClass `json:"class"` } // CreateVolumeRequestFromEmpty: create volume request from empty. type CreateVolumeRequestFromEmpty struct { // Size: must be compliant with the minimum (1 GB) and maximum (10 TB) allowed size. Size scw.Size `json:"size"` } // CreateVolumeRequestFromSnapshot: create volume request from snapshot. type CreateVolumeRequestFromSnapshot struct { // Size: must be compliant with the minimum (1 GB) and maximum (10 TB) allowed size. // Size is optional and is used only if a resize of the volume is requested, otherwise original snapshot size will be used. Size *scw.Size `json:"size"` // SnapshotID: source snapshot from which volume will be created. SnapshotID string `json:"snapshot_id"` } // Snapshot: snapshot. type Snapshot struct { // ID: UUID of the snapshot. ID string `json:"id"` // Name: name of the snapshot. Name string `json:"name"` // ParentVolume: if the parent volume was deleted, value is null. ParentVolume *SnapshotParentVolume `json:"parent_volume"` // Size: size in bytes of the snapshot. Size scw.Size `json:"size"` // ProjectID: UUID of the project the snapshot belongs to. ProjectID string `json:"project_id"` // CreatedAt: creation date of the snapshot. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: last modification date of the properties of a snapshot. UpdatedAt *time.Time `json:"updated_at"` // References: list of the references to the snapshot. References []*Reference `json:"references"` // Status: current status of the snapshot (available, in_use, ...). // Default value: unknown_status Status SnapshotStatus `json:"status"` // Tags: list of tags assigned to the volume. Tags []string `json:"tags"` // Zone: snapshot zone. Zone scw.Zone `json:"zone"` // Class: storage class of the snapshot. // Default value: unknown_storage_class Class StorageClass `json:"class"` } // VolumeType: volume type. type VolumeType struct { // Type: volume type. Type string `json:"type"` // Pricing: price of the volume billed in GB/hour. Pricing *scw.Money `json:"pricing"` // SnapshotPricing: price of the snapshot billed in GB/hour. SnapshotPricing *scw.Money `json:"snapshot_pricing"` // Specs: volume specifications of the volume type. Specs *VolumeSpecifications `json:"specs"` } // Volume: volume. type Volume struct { // ID: UUID of the volume. ID string `json:"id"` // Name: name of the volume. Name string `json:"name"` // Type: volume type. Type string `json:"type"` // Size: volume size in bytes. Size scw.Size `json:"size"` // ProjectID: UUID of the project to which the volume belongs. ProjectID string `json:"project_id"` // CreatedAt: creation date of the volume. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: last update of the properties of a volume. UpdatedAt *time.Time `json:"updated_at"` // References: list of the references to the volume. References []*Reference `json:"references"` // ParentSnapshotID: when a volume is created from a snapshot, is the UUID of the snapshot from which the volume has been created. ParentSnapshotID *string `json:"parent_snapshot_id"` // Status: current status of the volume (available, in_use, ...). // Default value: unknown_status Status VolumeStatus `json:"status"` // Tags: list of tags assigned to the volume. Tags []string `json:"tags"` // Zone: volume zone. Zone scw.Zone `json:"zone"` // Specs: specifications of the volume. Specs *VolumeSpecifications `json:"specs"` // LastDetachedAt: last time the volume was detached. LastDetachedAt *time.Time `json:"last_detached_at"` } // CreateSnapshotRequest: create snapshot request. type CreateSnapshotRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // VolumeID: UUID of the volume to snapshot. VolumeID string `json:"volume_id"` // Name: name of the snapshot. Name string `json:"name"` // ProjectID: UUID of the project to which the volume and the snapshot belong. ProjectID string `json:"project_id"` // Tags: list of tags assigned to the snapshot. Tags []string `json:"tags"` } // CreateVolumeRequest: create volume request. type CreateVolumeRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Name: name of the volume. Name string `json:"name"` // PerfIops: the maximum IO/s expected, according to the different options available in stock (`5000 | 15000`). // Precisely one of PerfIops must be set. PerfIops *uint32 `json:"perf_iops,omitempty"` // ProjectID: UUID of the project the volume belongs to. ProjectID string `json:"project_id"` // FromEmpty: specify the size of the new volume if creating a new one from scratch. // Precisely one of FromEmpty, FromSnapshot must be set. FromEmpty *CreateVolumeRequestFromEmpty `json:"from_empty,omitempty"` // FromSnapshot: specify the snapshot ID of the original snapshot. // Precisely one of FromEmpty, FromSnapshot must be set. FromSnapshot *CreateVolumeRequestFromSnapshot `json:"from_snapshot,omitempty"` // Tags: list of tags assigned to the volume. Tags []string `json:"tags"` } // DeleteSnapshotRequest: delete snapshot request. type DeleteSnapshotRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // SnapshotID: UUID of the snapshot. SnapshotID string `json:"-"` } // DeleteVolumeRequest: delete volume request. type DeleteVolumeRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // VolumeID: UUID of the volume. VolumeID string `json:"-"` } // GetSnapshotRequest: get snapshot request. type GetSnapshotRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // SnapshotID: UUID of the snapshot. SnapshotID string `json:"-"` } // GetVolumeRequest: get volume request. type GetVolumeRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // VolumeID: UUID of the volume. VolumeID string `json:"-"` } // ListSnapshotsRequest: list snapshots request. type ListSnapshotsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // OrderBy: criteria to use when ordering the list. // Default value: created_at_asc OrderBy ListSnapshotsRequestOrderBy `json:"-"` // ProjectID: filter by Project ID. ProjectID *string `json:"-"` // OrganizationID: filter by Organization ID. OrganizationID *string `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: page size, defines how many entries are returned in one page, must be lower or equal to 100. PageSize *uint32 `json:"-"` // VolumeID: filter snapshots by the ID of the original volume. VolumeID *string `json:"-"` // Name: filter snapshots by their names. Name *string `json:"-"` } // ListSnapshotsResponse: list snapshots response. type ListSnapshotsResponse struct { // Snapshots: paginated returned list of snapshots. Snapshots []*Snapshot `json:"snapshots"` // TotalCount: total number of snpashots in the project. TotalCount uint64 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListSnapshotsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListSnapshotsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListSnapshotsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Snapshots = append(r.Snapshots, results.Snapshots...) r.TotalCount += uint64(len(results.Snapshots)) return uint64(len(results.Snapshots)), nil } // ListVolumeTypesRequest: list volume types request. type ListVolumeTypesRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: page size, defines how many entries are returned in one page, must be lower or equal to 100. PageSize *uint32 `json:"-"` } // ListVolumeTypesResponse: list volume types response. type ListVolumeTypesResponse struct { // VolumeTypes: returns paginated list of volume-types. VolumeTypes []*VolumeType `json:"volume_types"` // TotalCount: total number of volume-types currently available in stock. TotalCount uint64 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListVolumeTypesResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListVolumeTypesResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListVolumeTypesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.VolumeTypes = append(r.VolumeTypes, results.VolumeTypes...) r.TotalCount += uint64(len(results.VolumeTypes)) return uint64(len(results.VolumeTypes)), nil } // ListVolumesRequest: list volumes request. type ListVolumesRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // OrderBy: criteria to use when ordering the list. // Default value: created_at_asc OrderBy ListVolumesRequestOrderBy `json:"-"` // ProjectID: filter by Project ID. ProjectID *string `json:"-"` // OrganizationID: filter by Organization ID. OrganizationID *string `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: page size, defines how many entries are returned in one page, must be lower or equal to 100. PageSize *uint32 `json:"-"` // Name: filter the return volumes by their names. Name *string `json:"-"` // ProductResourceID: filter by a product resource ID linked to this volume (such as an Instance ID). ProductResourceID *string `json:"-"` } // ListVolumesResponse: list volumes response. type ListVolumesResponse struct { // Volumes: paginated returned list of volumes. Volumes []*Volume `json:"volumes"` // TotalCount: total number of volumes in the project. TotalCount uint64 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListVolumesResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListVolumesResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListVolumesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Volumes = append(r.Volumes, results.Volumes...) r.TotalCount += uint64(len(results.Volumes)) return uint64(len(results.Volumes)), nil } // UpdateSnapshotRequest: update snapshot request. type UpdateSnapshotRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // SnapshotID: UUID of the snapshot. SnapshotID string `json:"-"` // Name: when defined, is the name of the snapshot. Name *string `json:"name,omitempty"` // Tags: list of tags assigned to the snapshot. Tags *[]string `json:"tags,omitempty"` } // UpdateVolumeRequest: update volume request. type UpdateVolumeRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // VolumeID: UUID of the volume. VolumeID string `json:"-"` // Name: when defined, is the new name of the volume. Name *string `json:"name,omitempty"` // Size: size in bytes of the volume, with a granularity of 1 GB (10^9 bytes). // Must be compliant with the minimum (1GB) and maximum (10TB) allowed size. Size *scw.Size `json:"size,omitempty"` // Tags: list of tags assigned to the volume. Tags *[]string `json:"tags,omitempty"` // PerfIops: the selected value must be available for the volume's current storage class. PerfIops *uint32 `json:"perf_iops,omitempty"` } // This API allows you to use and manage your Block Storage volumes. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Zones() []scw.Zone { return []scw.Zone{scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms3, scw.ZonePlWaw3} } // ListVolumeTypes: List all available volume types in a specified zone. The volume types listed are ordered by name in ascending order. func (s *API) ListVolumeTypes(req *ListVolumeTypesRequest, opts ...scw.RequestOption) (*ListVolumeTypesResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/block/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/volume-types", Query: query, } var resp ListVolumeTypesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListVolumes: List all existing volumes in a specified zone. By default, the volumes listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. func (s *API) ListVolumes(req *ListVolumesRequest, opts ...scw.RequestOption) (*ListVolumesResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "product_resource_id", req.ProductResourceID) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/block/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/volumes", Query: query, } var resp ListVolumesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateVolume: To create a new volume from scratch, you must specify `from_empty` and the `size`. // To create a volume from an existing snapshot, specify `from_snapshot` and the `snapshot_id` in the request payload instead, size is optional and can be specified if you need to extend the original size. The volume will take on the same volume class and underlying IOPS limitations as the original snapshot. func (s *API) CreateVolume(req *CreateVolumeRequest, opts ...scw.RequestOption) (*Volume, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/block/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/volumes", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Volume err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetVolume: Retrieve technical information about a specific volume. Details such as size, type, and status are returned in the response. func (s *API) GetVolume(req *GetVolumeRequest, opts ...scw.RequestOption) (*Volume, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.VolumeID) == "" { return nil, errors.New("field VolumeID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/block/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/volumes/" + fmt.Sprint(req.VolumeID) + "", } var resp Volume err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteVolume: You must specify the `volume_id` of the volume you want to delete. The volume must not be in the `in_use` status. func (s *API) DeleteVolume(req *DeleteVolumeRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.VolumeID) == "" { return errors.New("field VolumeID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/block/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/volumes/" + fmt.Sprint(req.VolumeID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // UpdateVolume: Update the technical details of a volume, such as its name, tags, or its new size and `volume_type` (within the same Block Storage class). // You can only resize a volume to a larger size. It is currently not possible to change your Block Storage Class. func (s *API) UpdateVolume(req *UpdateVolumeRequest, opts ...scw.RequestOption) (*Volume, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.VolumeID) == "" { return nil, errors.New("field VolumeID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/block/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/volumes/" + fmt.Sprint(req.VolumeID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Volume err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListSnapshots: List all available snapshots in a specified zone. By default, the snapshots listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. func (s *API) ListSnapshots(req *ListSnapshotsRequest, opts ...scw.RequestOption) (*ListSnapshotsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "volume_id", req.VolumeID) parameter.AddToQuery(query, "name", req.Name) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/block/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/snapshots", Query: query, } var resp ListSnapshotsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetSnapshot: Retrieve technical information about a specific snapshot. Details such as size, volume type, and status are returned in the response. func (s *API) GetSnapshot(req *GetSnapshotRequest, opts ...scw.RequestOption) (*Snapshot, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.SnapshotID) == "" { return nil, errors.New("field SnapshotID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/block/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/snapshots/" + fmt.Sprint(req.SnapshotID) + "", } var resp Snapshot err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateSnapshot: To create a snapshot, the volume must be in the `in_use` or the `available` status. // If your volume is in a transient state, you need to wait until the end of the current operation. func (s *API) CreateSnapshot(req *CreateSnapshotRequest, opts ...scw.RequestOption) (*Snapshot, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/block/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/snapshots", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Snapshot err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteSnapshot: You must specify the `snapshot_id` of the snapshot you want to delete. The snapshot must not be in use. func (s *API) DeleteSnapshot(req *DeleteSnapshotRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.SnapshotID) == "" { return errors.New("field SnapshotID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/block/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/snapshots/" + fmt.Sprint(req.SnapshotID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // UpdateSnapshot: Update the name or tags of the snapshot. func (s *API) UpdateSnapshot(req *UpdateSnapshotRequest, opts ...scw.RequestOption) (*Snapshot, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.SnapshotID) == "" { return nil, errors.New("field SnapshotID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/block/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/snapshots/" + fmt.Sprint(req.SnapshotID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Snapshot err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/block/v1alpha1/snapshot_utils.go000066400000000000000000000030311456366605600311410ustar00rootroot00000000000000package block import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) // WaitForSnapshotRequest is used by WaitForSnapshot method. type WaitForSnapshotRequest struct { SnapshotID string Zone scw.Zone Timeout *time.Duration RetryInterval *time.Duration } // WaitForSnapshot wait for the snapshot to be in a "terminal state" before returning. func (s *API) WaitForSnapshot(req *WaitForSnapshotRequest, opts ...scw.RequestOption) (*Snapshot, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[SnapshotStatus]struct{}{ SnapshotStatusAvailable: {}, SnapshotStatusInUse: {}, SnapshotStatusError: {}, SnapshotStatusLocked: {}, SnapshotStatusDeleted: {}, } snapshot, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetSnapshot(&GetSnapshotRequest{ SnapshotID: req.SnapshotID, Zone: req.Zone, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.Status] return res, isTerminal, err }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for snapshot failed") } return snapshot.(*Snapshot), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/block/v1alpha1/volume_utils.go000066400000000000000000000102211456366605600306100ustar00rootroot00000000000000package block import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) const ( defaultTimeout = 5 * time.Minute defaultRetryInterval = 5 * time.Second ) // WaitForVolumeRequest is used by WaitForVolume method. type WaitForVolumeRequest struct { VolumeID string Zone scw.Zone Timeout *time.Duration RetryInterval *time.Duration // If set, will wait until this specific status has been reached or the // volume has an error status. This is useful when we need to wait for // the volume to transition from "in_use" to "available". TerminalStatus *VolumeStatus } // WaitForVolume waits for the volume to be in a "terminal state" before returning. func (s *API) WaitForVolume(req *WaitForVolumeRequest, opts ...scw.RequestOption) (*Volume, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[VolumeStatus]struct{}{ VolumeStatusError: {}, VolumeStatusLocked: {}, VolumeStatusDeleted: {}, } if req.TerminalStatus != nil { terminalStatus[*req.TerminalStatus] = struct{}{} } else { terminalStatus[VolumeStatusAvailable] = struct{}{} terminalStatus[VolumeStatusInUse] = struct{}{} } volume, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetVolume(&GetVolumeRequest{ VolumeID: req.VolumeID, Zone: req.Zone, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.Status] return res, isTerminal, err }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for volume failed") } return volume.(*Volume), nil } // WaitForVolumeAndReferencesRequest is used by WaitForVolumeAndReferences method. type WaitForVolumeAndReferencesRequest struct { VolumeID string Zone scw.Zone Timeout *time.Duration RetryInterval *time.Duration VolumeTerminalStatus *VolumeStatus ReferenceTerminalStatus *ReferenceStatus } // WaitForVolumeAndReferences waits for the volume and its references to be in a "terminal state" before returning. func (s *API) WaitForVolumeAndReferences(req *WaitForVolumeAndReferencesRequest, opts ...scw.RequestOption) (*Volume, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[VolumeStatus]struct{}{ VolumeStatusError: {}, VolumeStatusLocked: {}, VolumeStatusDeleted: {}, } if req.VolumeTerminalStatus != nil { terminalStatus[*req.VolumeTerminalStatus] = struct{}{} } else { terminalStatus[VolumeStatusAvailable] = struct{}{} terminalStatus[VolumeStatusInUse] = struct{}{} } referenceTerminalStatus := map[ReferenceStatus]struct{}{ ReferenceStatusError: {}, } if req.ReferenceTerminalStatus != nil { referenceTerminalStatus[*req.ReferenceTerminalStatus] = struct{}{} } else { referenceTerminalStatus[ReferenceStatusAttached] = struct{}{} referenceTerminalStatus[ReferenceStatusDetached] = struct{}{} } volume, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { volume, err := s.GetVolume(&GetVolumeRequest{ VolumeID: req.VolumeID, Zone: req.Zone, }, opts...) if err != nil { return nil, false, err } referencesAreTerminal := true for _, reference := range volume.References { _, referenceIsTerminal := referenceTerminalStatus[reference.Status] referencesAreTerminal = referencesAreTerminal && referenceIsTerminal } _, isTerminal := terminalStatus[volume.Status] return volume, isTerminal && referencesAreTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for Volume failed") } return volume.(*Volume), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/cockpit/000077500000000000000000000000001456366605600244635ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/cockpit/v1beta1/000077500000000000000000000000001456366605600257265ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/cockpit/v1beta1/cockpit_sdk.go000066400000000000000000001270171456366605600305620ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package cockpit provides methods and message types of the cockpit v1beta1 API. package cockpit import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type CockpitStatus string const ( CockpitStatusUnknownStatus = CockpitStatus("unknown_status") CockpitStatusCreating = CockpitStatus("creating") CockpitStatusReady = CockpitStatus("ready") CockpitStatusDeleting = CockpitStatus("deleting") CockpitStatusUpdating = CockpitStatus("updating") CockpitStatusError = CockpitStatus("error") ) func (enum CockpitStatus) String() string { if enum == "" { // return default value if empty return "unknown_status" } return string(enum) } func (enum CockpitStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *CockpitStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = CockpitStatus(CockpitStatus(tmp).String()) return nil } type DatasourceType string const ( DatasourceTypeUnknownDatasourceType = DatasourceType("unknown_datasource_type") DatasourceTypeMetrics = DatasourceType("metrics") DatasourceTypeLogs = DatasourceType("logs") DatasourceTypeTraces = DatasourceType("traces") DatasourceTypeAlerts = DatasourceType("alerts") ) func (enum DatasourceType) String() string { if enum == "" { // return default value if empty return "unknown_datasource_type" } return string(enum) } func (enum DatasourceType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DatasourceType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DatasourceType(DatasourceType(tmp).String()) return nil } type GrafanaUserRole string const ( GrafanaUserRoleUnknownRole = GrafanaUserRole("unknown_role") GrafanaUserRoleEditor = GrafanaUserRole("editor") GrafanaUserRoleViewer = GrafanaUserRole("viewer") ) func (enum GrafanaUserRole) String() string { if enum == "" { // return default value if empty return "unknown_role" } return string(enum) } func (enum GrafanaUserRole) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *GrafanaUserRole) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = GrafanaUserRole(GrafanaUserRole(tmp).String()) return nil } type ListDatasourcesRequestOrderBy string const ( ListDatasourcesRequestOrderByCreatedAtAsc = ListDatasourcesRequestOrderBy("created_at_asc") ListDatasourcesRequestOrderByCreatedAtDesc = ListDatasourcesRequestOrderBy("created_at_desc") ListDatasourcesRequestOrderByNameAsc = ListDatasourcesRequestOrderBy("name_asc") ListDatasourcesRequestOrderByNameDesc = ListDatasourcesRequestOrderBy("name_desc") ) func (enum ListDatasourcesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListDatasourcesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListDatasourcesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListDatasourcesRequestOrderBy(ListDatasourcesRequestOrderBy(tmp).String()) return nil } type ListGrafanaUsersRequestOrderBy string const ( ListGrafanaUsersRequestOrderByLoginAsc = ListGrafanaUsersRequestOrderBy("login_asc") ListGrafanaUsersRequestOrderByLoginDesc = ListGrafanaUsersRequestOrderBy("login_desc") ) func (enum ListGrafanaUsersRequestOrderBy) String() string { if enum == "" { // return default value if empty return "login_asc" } return string(enum) } func (enum ListGrafanaUsersRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListGrafanaUsersRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListGrafanaUsersRequestOrderBy(ListGrafanaUsersRequestOrderBy(tmp).String()) return nil } type ListPlansRequestOrderBy string const ( ListPlansRequestOrderByNameAsc = ListPlansRequestOrderBy("name_asc") ListPlansRequestOrderByNameDesc = ListPlansRequestOrderBy("name_desc") ) func (enum ListPlansRequestOrderBy) String() string { if enum == "" { // return default value if empty return "name_asc" } return string(enum) } func (enum ListPlansRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListPlansRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListPlansRequestOrderBy(ListPlansRequestOrderBy(tmp).String()) return nil } type ListTokensRequestOrderBy string const ( ListTokensRequestOrderByCreatedAtAsc = ListTokensRequestOrderBy("created_at_asc") ListTokensRequestOrderByCreatedAtDesc = ListTokensRequestOrderBy("created_at_desc") ListTokensRequestOrderByNameAsc = ListTokensRequestOrderBy("name_asc") ListTokensRequestOrderByNameDesc = ListTokensRequestOrderBy("name_desc") ) func (enum ListTokensRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListTokensRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListTokensRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListTokensRequestOrderBy(ListTokensRequestOrderBy(tmp).String()) return nil } type PlanName string const ( PlanNameUnknownName = PlanName("unknown_name") PlanNameFree = PlanName("free") PlanNamePremium = PlanName("premium") PlanNameCustom = PlanName("custom") ) func (enum PlanName) String() string { if enum == "" { // return default value if empty return "unknown_name" } return string(enum) } func (enum PlanName) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *PlanName) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = PlanName(PlanName(tmp).String()) return nil } // ContactPointEmail: contact point email. type ContactPointEmail struct { To string `json:"to"` } // TokenScopes: token scopes. type TokenScopes struct { // QueryMetrics: permission to fetch metrics. QueryMetrics bool `json:"query_metrics"` // WriteMetrics: permission to write metrics. WriteMetrics bool `json:"write_metrics"` // SetupMetricsRules: permission to setup metrics rules. SetupMetricsRules bool `json:"setup_metrics_rules"` // QueryLogs: permission to fetch logs. QueryLogs bool `json:"query_logs"` // WriteLogs: permission to write logs. WriteLogs bool `json:"write_logs"` // SetupLogsRules: permission to set up logs rules. SetupLogsRules bool `json:"setup_logs_rules"` // SetupAlerts: permission to set up alerts. SetupAlerts bool `json:"setup_alerts"` // QueryTraces: permission to fetch traces. QueryTraces bool `json:"query_traces"` // WriteTraces: permission to write traces. WriteTraces bool `json:"write_traces"` } // CockpitEndpoints: cockpit endpoints. type CockpitEndpoints struct { // MetricsURL: URL for metrics. MetricsURL string `json:"metrics_url"` // LogsURL: URL for logs. LogsURL string `json:"logs_url"` // TracesURL: URL for traces. TracesURL string `json:"traces_url"` // AlertmanagerURL: URL for the alert manager. AlertmanagerURL string `json:"alertmanager_url"` // GrafanaURL: URL for the Grafana dashboard. GrafanaURL string `json:"grafana_url"` } // Plan: Pricing plan. type Plan struct { // ID: ID of a given pricing plan. ID string `json:"id"` // Name: name of a given pricing plan. // Default value: unknown_name Name PlanName `json:"name"` // RetentionMetricsInterval: interval of time during which Scaleway's Cockpit keeps your metrics. RetentionMetricsInterval *scw.Duration `json:"retention_metrics_interval"` // RetentionLogsInterval: interval of time during which Scaleway's Cockpit keeps your logs. RetentionLogsInterval *scw.Duration `json:"retention_logs_interval"` // RetentionTracesInterval: interval of time during which Scaleway's Cockpit keeps your traces. RetentionTracesInterval *scw.Duration `json:"retention_traces_interval"` // SampleIngestionPrice: ingestion price in cents for 1 million samples. SampleIngestionPrice uint32 `json:"sample_ingestion_price"` // LogsIngestionPrice: ingestion price in cents for 1 GB of logs. LogsIngestionPrice uint32 `json:"logs_ingestion_price"` // TracesIngestionPrice: ingestion price in cents for 1 GB of traces. TracesIngestionPrice uint32 `json:"traces_ingestion_price"` // RetentionPrice: retention price in euros per month. RetentionPrice uint32 `json:"retention_price"` } // ContactPoint: Contact point. type ContactPoint struct { // Email: contact point configuration. // Precisely one of Email must be set. Email *ContactPointEmail `json:"email,omitempty"` } // Datasource: Data source. type Datasource struct { // ID: ID of the data source. ID string `json:"id"` // ProjectID: ID of the Project the Cockpit belongs to. ProjectID string `json:"project_id"` // Name: data source name. Name string `json:"name"` // URL: data source URL. URL string `json:"url"` // Type: data source type. // Default value: unknown_datasource_type Type DatasourceType `json:"type"` // IsManagedByScaleway: specifies that the data source receives data from Scaleway products and is managed by Scaleway. IsManagedByScaleway bool `json:"is_managed_by_scaleway"` } // GrafanaProductDashboard: Grafana dashboard. type GrafanaProductDashboard struct { // DashboardName: name of the dashboard. DashboardName string `json:"dashboard_name"` // Title: title of the dashboard. Title string `json:"title"` // URL: URL of the dashboard. URL string `json:"url"` // Tags: tags of the dashboard. Tags []string `json:"tags"` // Variables: variables of the dashboard. Variables []string `json:"variables"` } // GrafanaUser: Grafana user. type GrafanaUser struct { // ID: ID of the Grafana user. ID uint32 `json:"id"` // Login: username of the Grafana user. Login string `json:"login"` // Role: role assigned to the Grafana user. // Default value: unknown_role Role GrafanaUserRole `json:"role"` // Password: the Grafana user's password. Password *string `json:"password"` } // Token: token. type Token struct { // ID: ID of the token. ID string `json:"id"` // ProjectID: ID of the Project. ProjectID string `json:"project_id"` // Name: name of the token. Name string `json:"name"` // CreatedAt: date and time of the token's creation. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date and time of the token's last update. UpdatedAt *time.Time `json:"updated_at"` // Scopes: token's permissions. Scopes *TokenScopes `json:"scopes"` // SecretKey: token's secret key. SecretKey *string `json:"secret_key"` } // ActivateCockpitRequest: activate cockpit request. type ActivateCockpitRequest struct { // ProjectID: ID of the Project the Cockpit belongs to. ProjectID string `json:"project_id"` } // Cockpit: Cockpit. type Cockpit struct { // ProjectID: ID of the Project the Cockpit belongs to. ProjectID string `json:"project_id"` // CreatedAt: date and time of the Cockpit's creation. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date and time of the Cockpit's last update. UpdatedAt *time.Time `json:"updated_at"` // Endpoints: endpoints of the Cockpit. Endpoints *CockpitEndpoints `json:"endpoints"` // Status: status of the Cockpit. // Default value: unknown_status Status CockpitStatus `json:"status"` // ManagedAlertsEnabled: specifies whether managed alerts are enabled or disabled. ManagedAlertsEnabled bool `json:"managed_alerts_enabled"` // Plan: pricing plan information. Plan *Plan `json:"plan"` } // CockpitMetrics: Metrics for a given Cockpit. type CockpitMetrics struct { // Timeseries: time series array. Timeseries []*scw.TimeSeries `json:"timeseries"` } // CreateContactPointRequest: Request to create a contact point. type CreateContactPointRequest struct { // ProjectID: ID of the Project in which to create the contact point. ProjectID string `json:"project_id"` // ContactPoint: contact point to create. ContactPoint *ContactPoint `json:"contact_point,omitempty"` } // CreateDatasourceRequest: Request to create a data source. type CreateDatasourceRequest struct { // ProjectID: ID of the Project the Cockpit belongs to. ProjectID string `json:"project_id"` // Name: data source name. Name string `json:"name"` // Type: data source type. // Default value: unknown_datasource_type Type DatasourceType `json:"type"` // IsDefault: specifies that the returned output is the default data source per type. IsDefault bool `json:"is_default"` } // CreateGrafanaUserRequest: Request to create a Grafana user. type CreateGrafanaUserRequest struct { // ProjectID: ID of the Project. ProjectID string `json:"project_id"` // Login: username of the Grafana user. Login string `json:"login"` // Role: role assigned to the Grafana user. // Default value: unknown_role Role GrafanaUserRole `json:"role"` } // CreateTokenRequest: create token request. type CreateTokenRequest struct { // ProjectID: ID of the Project. ProjectID string `json:"project_id"` // Name: name of the token. Name string `json:"name"` // Scopes: token's permissions. Scopes *TokenScopes `json:"scopes,omitempty"` } // DeactivateCockpitRequest: deactivate cockpit request. type DeactivateCockpitRequest struct { // ProjectID: ID of the Project the Cockpit belongs to. ProjectID string `json:"project_id"` } // DeleteContactPointRequest: Request to delete a contact point. type DeleteContactPointRequest struct { // ProjectID: ID of the Project. ProjectID string `json:"project_id"` // ContactPoint: contact point to delete. ContactPoint *ContactPoint `json:"contact_point,omitempty"` } // DeleteDatasourceRequest: Request to delete a data source. type DeleteDatasourceRequest struct { // DatasourceID: ID of the data source. DatasourceID string `json:"-"` } // DeleteGrafanaUserRequest: Request to delete a Grafana user. type DeleteGrafanaUserRequest struct { // GrafanaUserID: ID of the Grafana user. GrafanaUserID uint32 `json:"-"` // ProjectID: ID of the Project. ProjectID string `json:"project_id"` } // DeleteTokenRequest: delete token request. type DeleteTokenRequest struct { // TokenID: ID of the token. TokenID string `json:"-"` } // DisableManagedAlertsRequest: Request to disable the sending of managed alerts. type DisableManagedAlertsRequest struct { // ProjectID: ID of the Project. ProjectID string `json:"project_id"` } // EnableManagedAlertsRequest: Request to enable the sending of managed alerts. type EnableManagedAlertsRequest struct { // ProjectID: ID of the Project. ProjectID string `json:"project_id"` } // GetCockpitMetricsRequest: Request to get a given Cockpit's metrics. type GetCockpitMetricsRequest struct { // ProjectID: ID of the Project the Cockpit belongs to. ProjectID string `json:"-"` // StartDate: desired time range's start date for the metrics. StartDate *time.Time `json:"-"` // EndDate: desired time range's end date for the metrics. EndDate *time.Time `json:"-"` // MetricName: name of the metric requested. MetricName *string `json:"-"` } // GetCockpitRequest: get cockpit request. type GetCockpitRequest struct { // ProjectID: ID of the Project the Cockpit belongs to. ProjectID string `json:"-"` } // GetGrafanaProductDashboardRequest: Request to get a dashboard. type GetGrafanaProductDashboardRequest struct { // DashboardName: name of the dashboard. DashboardName string `json:"-"` // ProjectID: ID of the Project. ProjectID string `json:"-"` } // GetTokenRequest: get token request. type GetTokenRequest struct { // TokenID: ID of the token. TokenID string `json:"-"` } // ListContactPointsRequest: Request to list all contact points. type ListContactPointsRequest struct { // Page: page number. Page *int32 `json:"-"` // PageSize: page size. PageSize *uint32 `json:"-"` // ProjectID: ID of the Project from which to list the contact points. ProjectID string `json:"-"` } // ListContactPointsResponse: Response returned when listing contact points. type ListContactPointsResponse struct { // TotalCount: count of all contact points created. TotalCount uint32 `json:"total_count"` // ContactPoints: array of contact points. ContactPoints []*ContactPoint `json:"contact_points"` // HasAdditionalReceivers: specifies whether the contact point has other receivers than the default receiver. HasAdditionalReceivers bool `json:"has_additional_receivers"` // HasAdditionalContactPoints: specifies whether there are unmanaged contact points. HasAdditionalContactPoints bool `json:"has_additional_contact_points"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListContactPointsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListContactPointsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListContactPointsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.ContactPoints = append(r.ContactPoints, results.ContactPoints...) r.TotalCount += uint32(len(results.ContactPoints)) return uint32(len(results.ContactPoints)), nil } // ListDatasourcesRequest: list datasources request. type ListDatasourcesRequest struct { // Page: page number. Page *int32 `json:"-"` // PageSize: page size. PageSize *uint32 `json:"-"` // OrderBy: how the response is ordered. // Default value: created_at_asc OrderBy ListDatasourcesRequestOrderBy `json:"-"` // ProjectID: ID of the Project. ProjectID string `json:"-"` // Types: filter by datasource types. Types []DatasourceType `json:"-"` // IsManagedByScaleway: filter by managed datasources. IsManagedByScaleway *bool `json:"-"` } // ListDatasourcesResponse: list datasources response. type ListDatasourcesResponse struct { // TotalCount: count of all datasources corresponding to the request. TotalCount uint32 `json:"total_count"` // Datasources: list of the datasources within the pagination. Datasources []*Datasource `json:"datasources"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListDatasourcesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListDatasourcesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListDatasourcesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Datasources = append(r.Datasources, results.Datasources...) r.TotalCount += uint32(len(results.Datasources)) return uint32(len(results.Datasources)), nil } // ListGrafanaProductDashboardsRequest: Request to get a list of dashboards. type ListGrafanaProductDashboardsRequest struct { // ProjectID: ID of the Project. ProjectID string `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: page size. PageSize *uint32 `json:"-"` // Tags: tags to filter the dashboards. Tags []string `json:"-"` } // ListGrafanaProductDashboardsResponse: Response returned when getting a list of dashboards. type ListGrafanaProductDashboardsResponse struct { // TotalCount: count of grafana dasboards. TotalCount uint64 `json:"total_count"` // Dashboards: information on grafana dashboards. Dashboards []*GrafanaProductDashboard `json:"dashboards"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListGrafanaProductDashboardsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListGrafanaProductDashboardsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListGrafanaProductDashboardsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Dashboards = append(r.Dashboards, results.Dashboards...) r.TotalCount += uint64(len(results.Dashboards)) return uint64(len(results.Dashboards)), nil } // ListGrafanaUsersRequest: Request to list all Grafana users. type ListGrafanaUsersRequest struct { // Page: page number. Page *int32 `json:"-"` // PageSize: page size. PageSize *uint32 `json:"-"` // OrderBy: default value: login_asc OrderBy ListGrafanaUsersRequestOrderBy `json:"-"` // ProjectID: ID of the Project. ProjectID string `json:"-"` } // ListGrafanaUsersResponse: Response returned when listing Grafana users. type ListGrafanaUsersResponse struct { // TotalCount: count of all Grafana users. TotalCount uint32 `json:"total_count"` // GrafanaUsers: information on all Grafana users. GrafanaUsers []*GrafanaUser `json:"grafana_users"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListGrafanaUsersResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListGrafanaUsersResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListGrafanaUsersResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.GrafanaUsers = append(r.GrafanaUsers, results.GrafanaUsers...) r.TotalCount += uint32(len(results.GrafanaUsers)) return uint32(len(results.GrafanaUsers)), nil } // ListPlansRequest: Request to list all pricing plans. type ListPlansRequest struct { // Page: page number. Page *int32 `json:"-"` // PageSize: page size. PageSize *uint32 `json:"-"` // OrderBy: default value: name_asc OrderBy ListPlansRequestOrderBy `json:"-"` } // ListPlansResponse: Response returned when listing all pricing plans. type ListPlansResponse struct { // TotalCount: count of all pricing plans. TotalCount uint64 `json:"total_count"` // Plans: information on plans. Plans []*Plan `json:"plans"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListPlansResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListPlansResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListPlansResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Plans = append(r.Plans, results.Plans...) r.TotalCount += uint64(len(results.Plans)) return uint64(len(results.Plans)), nil } // ListTokensRequest: list tokens request. type ListTokensRequest struct { // Page: page number. Page *int32 `json:"-"` // PageSize: page size. PageSize *uint32 `json:"-"` // OrderBy: how the response is ordered. // Default value: created_at_asc OrderBy ListTokensRequestOrderBy `json:"-"` // ProjectID: ID of the Project. ProjectID string `json:"-"` } // ListTokensResponse: list tokens response. type ListTokensResponse struct { // TotalCount: count of all tokens created. TotalCount uint32 `json:"total_count"` // Tokens: list of all tokens created. Tokens []*Token `json:"tokens"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListTokensResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListTokensResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListTokensResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Tokens = append(r.Tokens, results.Tokens...) r.TotalCount += uint32(len(results.Tokens)) return uint32(len(results.Tokens)), nil } // ResetGrafanaUserPasswordRequest: Request to reset a Grafana user's password. type ResetGrafanaUserPasswordRequest struct { // GrafanaUserID: ID of the Grafana user. GrafanaUserID uint32 `json:"-"` // ProjectID: ID of the Project. ProjectID string `json:"project_id"` } // SelectPlanRequest: Request to select a specific pricing plan. type SelectPlanRequest struct { // ProjectID: ID of the Project. ProjectID string `json:"project_id"` // PlanID: ID of the pricing plan. PlanID string `json:"plan_id"` } // SelectPlanResponse: Response returned when selecting a pricing plan. type SelectPlanResponse struct { } // TriggerTestAlertRequest: trigger test alert request. type TriggerTestAlertRequest struct { ProjectID string `json:"project_id"` } // The Cockpit API allows you to activate your Cockpit to store metrics and logs. It also provides you with a dedicated Grafana for dashboarding to visualize your metrics and logs. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } // ActivateCockpit: Activate the Cockpit of a given Project specified by the Project ID. func (s *API) ActivateCockpit(req *ActivateCockpitRequest, opts ...scw.RequestOption) (*Cockpit, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/cockpit/v1beta1/activate", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Cockpit err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetCockpit: Retrieve the Cockpit of a given Project specified by the Project ID. func (s *API) GetCockpit(req *GetCockpitRequest, opts ...scw.RequestOption) (*Cockpit, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } query := url.Values{} parameter.AddToQuery(query, "project_id", req.ProjectID) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/cockpit/v1beta1/cockpit", Query: query, } var resp Cockpit err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetCockpitMetrics: Retrieve metrics from your Cockpit specified by the ID of the Project the Cockpit belongs to. func (s *API) GetCockpitMetrics(req *GetCockpitMetricsRequest, opts ...scw.RequestOption) (*CockpitMetrics, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } query := url.Values{} parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "start_date", req.StartDate) parameter.AddToQuery(query, "end_date", req.EndDate) parameter.AddToQuery(query, "metric_name", req.MetricName) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/cockpit/v1beta1/cockpit/metrics", Query: query, } var resp CockpitMetrics err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeactivateCockpit: Deactivate the Cockpit of a given Project specified by the Project ID. func (s *API) DeactivateCockpit(req *DeactivateCockpitRequest, opts ...scw.RequestOption) (*Cockpit, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/cockpit/v1beta1/deactivate", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Cockpit err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateDatasource: Create a data source for a given Project specified by the Project ID and the data source type. func (s *API) CreateDatasource(req *CreateDatasourceRequest, opts ...scw.RequestOption) (*Datasource, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/cockpit/v1beta1/datasources", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Datasource err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteDatasource: Delete a given data source specified by the data source ID. func (s *API) DeleteDatasource(req *DeleteDatasourceRequest, opts ...scw.RequestOption) error { var err error if fmt.Sprint(req.DatasourceID) == "" { return errors.New("field DatasourceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/cockpit/v1beta1/datasources/" + fmt.Sprint(req.DatasourceID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListDatasources: Get a list of data sources for the specified Project ID. func (s *API) ListDatasources(req *ListDatasourcesRequest, opts ...scw.RequestOption) (*ListDatasourcesResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "types", req.Types) parameter.AddToQuery(query, "is_managed_by_scaleway", req.IsManagedByScaleway) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/cockpit/v1beta1/datasources", Query: query, } var resp ListDatasourcesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateToken: Create a token in a given Project specified by the Project ID. func (s *API) CreateToken(req *CreateTokenRequest, opts ...scw.RequestOption) (*Token, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if req.Name == "" { req.Name = namegenerator.GetRandomName("token") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/cockpit/v1beta1/tokens", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Token err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListTokens: Get a list of tokens in a given Project specified by the Project ID. func (s *API) ListTokens(req *ListTokensRequest, opts ...scw.RequestOption) (*ListTokensResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "project_id", req.ProjectID) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/cockpit/v1beta1/tokens", Query: query, } var resp ListTokensResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetToken: Retrieve a given token specified by the token ID. func (s *API) GetToken(req *GetTokenRequest, opts ...scw.RequestOption) (*Token, error) { var err error if fmt.Sprint(req.TokenID) == "" { return nil, errors.New("field TokenID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/cockpit/v1beta1/tokens/" + fmt.Sprint(req.TokenID) + "", } var resp Token err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteToken: Delete a given token specified by the token ID. func (s *API) DeleteToken(req *DeleteTokenRequest, opts ...scw.RequestOption) error { var err error if fmt.Sprint(req.TokenID) == "" { return errors.New("field TokenID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/cockpit/v1beta1/tokens/" + fmt.Sprint(req.TokenID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // CreateContactPoint: Create a contact point associated with the default receiver, to receive alerts. func (s *API) CreateContactPoint(req *CreateContactPointRequest, opts ...scw.RequestOption) (*ContactPoint, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/cockpit/v1beta1/contact-points", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp ContactPoint err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListContactPoints: Get a list of contact points created for a given Cockpit, specified by the ID of the Project the Cockpit belongs to. func (s *API) ListContactPoints(req *ListContactPointsRequest, opts ...scw.RequestOption) (*ListContactPointsResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "project_id", req.ProjectID) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/cockpit/v1beta1/contact-points", Query: query, } var resp ListContactPointsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteContactPoint: Delete a contact point associated with the default receiver. func (s *API) DeleteContactPoint(req *DeleteContactPointRequest, opts ...scw.RequestOption) error { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/cockpit/v1beta1/delete-contact-point", } err = scwReq.SetBody(req) if err != nil { return err } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // EnableManagedAlerts: Enable the sending of managed alerts for a given Cockpit, specified by the ID of the Project the Cockpit belongs to. func (s *API) EnableManagedAlerts(req *EnableManagedAlertsRequest, opts ...scw.RequestOption) error { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/cockpit/v1beta1/enable-managed-alerts", } err = scwReq.SetBody(req) if err != nil { return err } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // DisableManagedAlerts: Disable the sending of managed alerts for a given Cockpit, specified by the ID of the Project the Cockpit belongs to. func (s *API) DisableManagedAlerts(req *DisableManagedAlertsRequest, opts ...scw.RequestOption) error { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/cockpit/v1beta1/disable-managed-alerts", } err = scwReq.SetBody(req) if err != nil { return err } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // TriggerTestAlert: Send a test alert to make sure your contact points get notified when an actual alert is triggered. func (s *API) TriggerTestAlert(req *TriggerTestAlertRequest, opts ...scw.RequestOption) error { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/cockpit/v1beta1/trigger-test-alert", } err = scwReq.SetBody(req) if err != nil { return err } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // CreateGrafanaUser: Create a Grafana user for your Cockpit's Grafana. Make sure you save the automatically-generated password and the Grafana user ID. func (s *API) CreateGrafanaUser(req *CreateGrafanaUserRequest, opts ...scw.RequestOption) (*GrafanaUser, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/cockpit/v1beta1/grafana-users", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp GrafanaUser err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListGrafanaUsers: Get a list of all Grafana users created in your Cockpit's Grafana. func (s *API) ListGrafanaUsers(req *ListGrafanaUsersRequest, opts ...scw.RequestOption) (*ListGrafanaUsersResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "project_id", req.ProjectID) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/cockpit/v1beta1/grafana-users", Query: query, } var resp ListGrafanaUsersResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteGrafanaUser: Delete a Grafana user from your Cockpit's Grafana, specified by the ID of the Project the Cockpit belongs to, and the ID of the Grafana user. func (s *API) DeleteGrafanaUser(req *DeleteGrafanaUserRequest, opts ...scw.RequestOption) error { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.GrafanaUserID) == "" { return errors.New("field GrafanaUserID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/cockpit/v1beta1/grafana-users/" + fmt.Sprint(req.GrafanaUserID) + "/delete", } err = scwReq.SetBody(req) if err != nil { return err } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ResetGrafanaUserPassword: Reset the password of a Grafana user, specified by the ID of the Project the Cockpit belongs to, and the ID of the Grafana user. func (s *API) ResetGrafanaUserPassword(req *ResetGrafanaUserPasswordRequest, opts ...scw.RequestOption) (*GrafanaUser, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.GrafanaUserID) == "" { return nil, errors.New("field GrafanaUserID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/cockpit/v1beta1/grafana-users/" + fmt.Sprint(req.GrafanaUserID) + "/reset-password", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp GrafanaUser err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListPlans: Get a list of all pricing plans available. func (s *API) ListPlans(req *ListPlansRequest, opts ...scw.RequestOption) (*ListPlansResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/cockpit/v1beta1/plans", Query: query, } var resp ListPlansResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SelectPlan: Select your chosen pricing plan for your Cockpit, specifying the Cockpit's Project ID and the pricing plan's ID in the request. func (s *API) SelectPlan(req *SelectPlanRequest, opts ...scw.RequestOption) (*SelectPlanResponse, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/cockpit/v1beta1/select-plan", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SelectPlanResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListGrafanaProductDashboards: Get a list of available product dashboards. func (s *API) ListGrafanaProductDashboards(req *ListGrafanaProductDashboardsRequest, opts ...scw.RequestOption) (*ListGrafanaProductDashboardsResponse, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "tags", req.Tags) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/cockpit/v1beta1/grafana-product-dashboards", Query: query, } var resp ListGrafanaProductDashboardsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetGrafanaProductDashboard: Get a product dashboard specified by the dashboard ID. func (s *API) GetGrafanaProductDashboard(req *GetGrafanaProductDashboardRequest, opts ...scw.RequestOption) (*GrafanaProductDashboard, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } query := url.Values{} parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.DashboardName) == "" { return nil, errors.New("field DashboardName cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/cockpit/v1beta1/grafana-product-dashboards/" + fmt.Sprint(req.DashboardName) + "", Query: query, } var resp GrafanaProductDashboard err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/cockpit/v1beta1/cockpit_utils.go000066400000000000000000000026571456366605600311430ustar00rootroot00000000000000package cockpit import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) const ( defaultRetryInterval = 3 * time.Second defaultTimeout = 5 * time.Minute ) // WaitForCockpitRequest is used by WaitForCockpit method. type WaitForCockpitRequest struct { ProjectID string Timeout *time.Duration RetryInterval *time.Duration } func (s *API) WaitForCockpit( req *WaitForCockpitRequest, opts ...scw.RequestOption, ) (*Cockpit, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } transientStatus := map[CockpitStatus]struct{}{ CockpitStatusCreating: {}, CockpitStatusUpdating: {}, CockpitStatusDeleting: {}, } res, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { namespace, err := s.GetCockpit(&GetCockpitRequest{ ProjectID: req.ProjectID, }, opts...) if err != nil { return nil, false, err } _, isTransient := transientStatus[namespace.Status] return namespace, !isTransient, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for Cockpit failed") } return res.(*Cockpit), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/container/000077500000000000000000000000001456366605600250115ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/container/v1beta1/000077500000000000000000000000001456366605600262545ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/container/v1beta1/container_helpers.go000066400000000000000000000156561456366605600323240ustar00rootroot00000000000000package container import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) const ( waitForNamespaceDefaultTimeout = 15 * time.Minute waitForCronDefaultTimeout = 15 * time.Minute waitForContainerDefaultTimeout = 15 * time.Minute waitForDomainDefaultTimeout = 15 * time.Minute waitForTriggerDefaultTimeout = 15 * time.Minute defaultRetryInterval = 5 * time.Second ) // WaitForNamespaceRequest is used by WaitForNamespace method. type WaitForNamespaceRequest struct { NamespaceID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForNamespace waits for the Namespace to be in a ready state before returning. func (s *API) WaitForNamespace(req *WaitForNamespaceRequest, opts ...scw.RequestOption) (*Namespace, error) { timeout := waitForNamespaceDefaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[NamespaceStatus]struct{}{ NamespaceStatusError: {}, NamespaceStatusReady: {}, NamespaceStatusLocked: {}, } namespace, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { namespace, err := s.GetNamespace(&GetNamespaceRequest{ NamespaceID: req.NamespaceID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[namespace.Status] return namespace, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for Namespace failed") } return namespace.(*Namespace), nil } // WaitForContainerRequest is used by WaitForNamespace method. type WaitForContainerRequest struct { ContainerID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForContainer waits for the Container to be in a ready state before returning. func (s *API) WaitForContainer(req *WaitForContainerRequest, opts ...scw.RequestOption) (*Container, error) { timeout := waitForContainerDefaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[ContainerStatus]struct{}{ ContainerStatusError: {}, ContainerStatusCreated: {}, ContainerStatusReady: {}, ContainerStatusLocked: {}, } container, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { container, err := s.GetContainer(&GetContainerRequest{ ContainerID: req.ContainerID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[container.Status] return container, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for container failed") } return container.(*Container), nil } // WaitForCronRequest is used by WaitForNamespace method. type WaitForCronRequest struct { CronID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForCron waits for the Cron to be in a ready state before returning. func (s *API) WaitForCron(req *WaitForCronRequest, opts ...scw.RequestOption) (*Cron, error) { timeout := waitForCronDefaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[CronStatus]struct{}{ CronStatusError: {}, CronStatusReady: {}, CronStatusLocked: {}, } cron, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { cron, err := s.GetCron(&GetCronRequest{ CronID: req.CronID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[cron.Status] return cron, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for Cron failed") } return cron.(*Cron), nil } // WaitForDomainRequest waits for the Domain to be in a ready state before returning. type WaitForDomainRequest struct { DomainID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForDomain waits for the Domain to be in a ready state before returning. func (s *API) WaitForDomain(req *WaitForDomainRequest, opts ...scw.RequestOption) (*Domain, error) { timeout := waitForDomainDefaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[DomainStatus]struct{}{ DomainStatusError: {}, DomainStatusReady: {}, } domain, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { domain, err := s.GetDomain(&GetDomainRequest{ DomainID: req.DomainID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[domain.Status] return domain, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for Domain failed") } return domain.(*Domain), nil } // WaitForTriggerRequest waits for the Trigger to be in a ready state before returning. type WaitForTriggerRequest struct { TriggerID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForTrigger waits for the Trigger to be in a ready state before returning. func (s *API) WaitForTrigger(req *WaitForTriggerRequest, opts ...scw.RequestOption) (*Trigger, error) { timeout := waitForTriggerDefaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[TriggerStatus]struct{}{ TriggerStatusError: {}, TriggerStatusReady: {}, } trigger, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { trigger, err := s.GetTrigger(&GetTriggerRequest{ TriggerID: req.TriggerID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[trigger.Status] return trigger, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for Trigger failed") } return trigger.(*Trigger), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/container/v1beta1/container_sdk.go000066400000000000000000002313771456366605600314430ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package container provides methods and message types of the container v1beta1 API. package container import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type ContainerHTTPOption string const ( ContainerHTTPOptionUnknownHTTPOption = ContainerHTTPOption("unknown_http_option") ContainerHTTPOptionEnabled = ContainerHTTPOption("enabled") ContainerHTTPOptionRedirected = ContainerHTTPOption("redirected") ) func (enum ContainerHTTPOption) String() string { if enum == "" { // return default value if empty return "unknown_http_option" } return string(enum) } func (enum ContainerHTTPOption) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ContainerHTTPOption) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ContainerHTTPOption(ContainerHTTPOption(tmp).String()) return nil } type ContainerPrivacy string const ( ContainerPrivacyUnknownPrivacy = ContainerPrivacy("unknown_privacy") ContainerPrivacyPublic = ContainerPrivacy("public") ContainerPrivacyPrivate = ContainerPrivacy("private") ) func (enum ContainerPrivacy) String() string { if enum == "" { // return default value if empty return "unknown_privacy" } return string(enum) } func (enum ContainerPrivacy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ContainerPrivacy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ContainerPrivacy(ContainerPrivacy(tmp).String()) return nil } type ContainerProtocol string const ( ContainerProtocolUnknownProtocol = ContainerProtocol("unknown_protocol") ContainerProtocolHTTP1 = ContainerProtocol("http1") ContainerProtocolH2c = ContainerProtocol("h2c") ) func (enum ContainerProtocol) String() string { if enum == "" { // return default value if empty return "unknown_protocol" } return string(enum) } func (enum ContainerProtocol) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ContainerProtocol) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ContainerProtocol(ContainerProtocol(tmp).String()) return nil } type ContainerStatus string const ( ContainerStatusUnknown = ContainerStatus("unknown") ContainerStatusReady = ContainerStatus("ready") ContainerStatusDeleting = ContainerStatus("deleting") ContainerStatusError = ContainerStatus("error") ContainerStatusLocked = ContainerStatus("locked") ContainerStatusCreating = ContainerStatus("creating") ContainerStatusPending = ContainerStatus("pending") ContainerStatusCreated = ContainerStatus("created") ) func (enum ContainerStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum ContainerStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ContainerStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ContainerStatus(ContainerStatus(tmp).String()) return nil } type CronStatus string const ( CronStatusUnknown = CronStatus("unknown") CronStatusReady = CronStatus("ready") CronStatusDeleting = CronStatus("deleting") CronStatusError = CronStatus("error") CronStatusLocked = CronStatus("locked") CronStatusCreating = CronStatus("creating") CronStatusPending = CronStatus("pending") ) func (enum CronStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum CronStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *CronStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = CronStatus(CronStatus(tmp).String()) return nil } type DomainStatus string const ( DomainStatusUnknown = DomainStatus("unknown") DomainStatusReady = DomainStatus("ready") DomainStatusDeleting = DomainStatus("deleting") DomainStatusError = DomainStatus("error") DomainStatusCreating = DomainStatus("creating") DomainStatusPending = DomainStatus("pending") ) func (enum DomainStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum DomainStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DomainStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DomainStatus(DomainStatus(tmp).String()) return nil } type ListContainersRequestOrderBy string const ( ListContainersRequestOrderByCreatedAtAsc = ListContainersRequestOrderBy("created_at_asc") ListContainersRequestOrderByCreatedAtDesc = ListContainersRequestOrderBy("created_at_desc") ListContainersRequestOrderByNameAsc = ListContainersRequestOrderBy("name_asc") ListContainersRequestOrderByNameDesc = ListContainersRequestOrderBy("name_desc") ) func (enum ListContainersRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListContainersRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListContainersRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListContainersRequestOrderBy(ListContainersRequestOrderBy(tmp).String()) return nil } type ListCronsRequestOrderBy string const ( ListCronsRequestOrderByCreatedAtAsc = ListCronsRequestOrderBy("created_at_asc") ListCronsRequestOrderByCreatedAtDesc = ListCronsRequestOrderBy("created_at_desc") ) func (enum ListCronsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListCronsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListCronsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListCronsRequestOrderBy(ListCronsRequestOrderBy(tmp).String()) return nil } type ListDomainsRequestOrderBy string const ( ListDomainsRequestOrderByCreatedAtAsc = ListDomainsRequestOrderBy("created_at_asc") ListDomainsRequestOrderByCreatedAtDesc = ListDomainsRequestOrderBy("created_at_desc") ListDomainsRequestOrderByHostnameAsc = ListDomainsRequestOrderBy("hostname_asc") ListDomainsRequestOrderByHostnameDesc = ListDomainsRequestOrderBy("hostname_desc") ) func (enum ListDomainsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListDomainsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListDomainsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListDomainsRequestOrderBy(ListDomainsRequestOrderBy(tmp).String()) return nil } type ListLogsRequestOrderBy string const ( ListLogsRequestOrderByTimestampDesc = ListLogsRequestOrderBy("timestamp_desc") ListLogsRequestOrderByTimestampAsc = ListLogsRequestOrderBy("timestamp_asc") ) func (enum ListLogsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "timestamp_desc" } return string(enum) } func (enum ListLogsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListLogsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListLogsRequestOrderBy(ListLogsRequestOrderBy(tmp).String()) return nil } type ListNamespacesRequestOrderBy string const ( ListNamespacesRequestOrderByCreatedAtAsc = ListNamespacesRequestOrderBy("created_at_asc") ListNamespacesRequestOrderByCreatedAtDesc = ListNamespacesRequestOrderBy("created_at_desc") ListNamespacesRequestOrderByNameAsc = ListNamespacesRequestOrderBy("name_asc") ListNamespacesRequestOrderByNameDesc = ListNamespacesRequestOrderBy("name_desc") ) func (enum ListNamespacesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListNamespacesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListNamespacesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListNamespacesRequestOrderBy(ListNamespacesRequestOrderBy(tmp).String()) return nil } type ListTokensRequestOrderBy string const ( ListTokensRequestOrderByCreatedAtAsc = ListTokensRequestOrderBy("created_at_asc") ListTokensRequestOrderByCreatedAtDesc = ListTokensRequestOrderBy("created_at_desc") ) func (enum ListTokensRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListTokensRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListTokensRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListTokensRequestOrderBy(ListTokensRequestOrderBy(tmp).String()) return nil } type ListTriggersRequestOrderBy string const ( // Order by creation date ascending. ListTriggersRequestOrderByCreatedAtAsc = ListTriggersRequestOrderBy("created_at_asc") // Order by creation date descending. ListTriggersRequestOrderByCreatedAtDesc = ListTriggersRequestOrderBy("created_at_desc") ) func (enum ListTriggersRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListTriggersRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListTriggersRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListTriggersRequestOrderBy(ListTriggersRequestOrderBy(tmp).String()) return nil } type LogStream string const ( LogStreamUnknown = LogStream("unknown") LogStreamStdout = LogStream("stdout") LogStreamStderr = LogStream("stderr") ) func (enum LogStream) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum LogStream) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *LogStream) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = LogStream(LogStream(tmp).String()) return nil } type NamespaceStatus string const ( NamespaceStatusUnknown = NamespaceStatus("unknown") NamespaceStatusReady = NamespaceStatus("ready") NamespaceStatusDeleting = NamespaceStatus("deleting") NamespaceStatusError = NamespaceStatus("error") NamespaceStatusLocked = NamespaceStatus("locked") NamespaceStatusCreating = NamespaceStatus("creating") NamespaceStatusPending = NamespaceStatus("pending") ) func (enum NamespaceStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum NamespaceStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *NamespaceStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = NamespaceStatus(NamespaceStatus(tmp).String()) return nil } type TokenStatus string const ( TokenStatusUnknown = TokenStatus("unknown") TokenStatusReady = TokenStatus("ready") TokenStatusDeleting = TokenStatus("deleting") TokenStatusError = TokenStatus("error") TokenStatusCreating = TokenStatus("creating") ) func (enum TokenStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum TokenStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *TokenStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = TokenStatus(TokenStatus(tmp).String()) return nil } type TriggerInputType string const ( // Unknown input type. TriggerInputTypeUnknownInputType = TriggerInputType("unknown_input_type") TriggerInputTypeSqs = TriggerInputType("sqs") // Scaleway Messaging and Queuing SQS queue. TriggerInputTypeScwSqs = TriggerInputType("scw_sqs") TriggerInputTypeNats = TriggerInputType("nats") // Scaleway Messaging and Queuing NATS subject. TriggerInputTypeScwNats = TriggerInputType("scw_nats") ) func (enum TriggerInputType) String() string { if enum == "" { // return default value if empty return "unknown_input_type" } return string(enum) } func (enum TriggerInputType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *TriggerInputType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = TriggerInputType(TriggerInputType(tmp).String()) return nil } type TriggerStatus string const ( // Unknown status. TriggerStatusUnknownStatus = TriggerStatus("unknown_status") // Ready status. TriggerStatusReady = TriggerStatus("ready") // Deleting status. TriggerStatusDeleting = TriggerStatus("deleting") // Error status. TriggerStatusError = TriggerStatus("error") // Creating status. TriggerStatusCreating = TriggerStatus("creating") // Pending status. TriggerStatusPending = TriggerStatus("pending") ) func (enum TriggerStatus) String() string { if enum == "" { // return default value if empty return "unknown_status" } return string(enum) } func (enum TriggerStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *TriggerStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = TriggerStatus(TriggerStatus(tmp).String()) return nil } // SecretHashedValue: secret hashed value. type SecretHashedValue struct { Key string `json:"key"` HashedValue string `json:"hashed_value"` } // TriggerMnqNatsClientConfig: trigger mnq nats client config. type TriggerMnqNatsClientConfig struct { // Deprecated MnqNamespaceID *string `json:"mnq_namespace_id,omitempty"` // Subject: name of the NATS subject the trigger listens to. Subject string `json:"subject"` // MnqNatsAccountID: ID of the Messaging and Queuing NATS account. MnqNatsAccountID string `json:"mnq_nats_account_id"` // MnqProjectID: ID of the Messaging and Queuing project. MnqProjectID string `json:"mnq_project_id"` // MnqRegion: currently, only the `fr-par` region is available. MnqRegion string `json:"mnq_region"` // MnqCredentialID: ID of the Messaging and Queuing credentials used to subscribe to the NATS subject. MnqCredentialID *string `json:"mnq_credential_id"` } // TriggerMnqSqsClientConfig: trigger mnq sqs client config. type TriggerMnqSqsClientConfig struct { // Deprecated MnqNamespaceID *string `json:"mnq_namespace_id,omitempty"` // Queue: name of the SQS queue the trigger listens to. Queue string `json:"queue"` // MnqProjectID: ID of the Messaging and Queuing project. MnqProjectID string `json:"mnq_project_id"` // MnqRegion: currently, only the `fr-par` region is available. MnqRegion string `json:"mnq_region"` // MnqCredentialID: ID of the Messaging and Queuing credentials used to read from the SQS queue. MnqCredentialID *string `json:"mnq_credential_id"` } // TriggerSqsClientConfig: trigger sqs client config. type TriggerSqsClientConfig struct { Endpoint string `json:"endpoint"` QueueURL string `json:"queue_url"` AccessKey string `json:"access_key"` SecretKey string `json:"secret_key"` } // Secret: secret. type Secret struct { Key string `json:"key"` Value *string `json:"value"` } // CreateTriggerRequestMnqNatsClientConfig: create trigger request mnq nats client config. type CreateTriggerRequestMnqNatsClientConfig struct { // Deprecated MnqNamespaceID *string `json:"mnq_namespace_id,omitempty"` // Subject: name of the NATS subject the trigger should listen to. Subject string `json:"subject"` // MnqNatsAccountID: ID of the Messaging and Queuing NATS account. MnqNatsAccountID string `json:"mnq_nats_account_id"` // MnqProjectID: ID of the Messaging and Queuing project. MnqProjectID string `json:"mnq_project_id"` // MnqRegion: currently, only the `fr-par` region is available. MnqRegion string `json:"mnq_region"` } // CreateTriggerRequestMnqSqsClientConfig: create trigger request mnq sqs client config. type CreateTriggerRequestMnqSqsClientConfig struct { // Deprecated MnqNamespaceID *string `json:"mnq_namespace_id,omitempty"` // Queue: name of the SQS queue the trigger should listen to. Queue string `json:"queue"` // MnqProjectID: you must have activated SQS on this project. MnqProjectID string `json:"mnq_project_id"` // MnqRegion: currently, only the `fr-par` region is available. MnqRegion string `json:"mnq_region"` } // CreateTriggerRequestSqsClientConfig: create trigger request sqs client config. type CreateTriggerRequestSqsClientConfig struct { Endpoint string `json:"endpoint"` QueueURL string `json:"queue_url"` AccessKey string `json:"access_key"` SecretKey string `json:"secret_key"` } // Container: container. type Container struct { // ID: UUID of the container. ID string `json:"id"` // Name: name of the container. Name string `json:"name"` // NamespaceID: UUID of the namespace the container belongs to. NamespaceID string `json:"namespace_id"` // Status: status of the container. // Default value: unknown Status ContainerStatus `json:"status"` // EnvironmentVariables: environment variables of the container. EnvironmentVariables map[string]string `json:"environment_variables"` // MinScale: minimum number of instances to scale the container to. MinScale uint32 `json:"min_scale"` // MaxScale: maximum number of instances to scale the container to. MaxScale uint32 `json:"max_scale"` // MemoryLimit: memory limit of the container in MB. MemoryLimit uint32 `json:"memory_limit"` // CPULimit: CPU limit of the container in mvCPU. CPULimit uint32 `json:"cpu_limit"` // Timeout: processing time limit for the container. Timeout *scw.Duration `json:"timeout"` // ErrorMessage: last error message of the container. ErrorMessage *string `json:"error_message"` // Privacy: privacy setting of the container. // Default value: unknown_privacy Privacy ContainerPrivacy `json:"privacy"` // Description: description of the container. Description *string `json:"description"` // RegistryImage: name of the registry image (e.g. "rg.fr-par.scw.cloud/something/image:tag"). RegistryImage string `json:"registry_image"` // MaxConcurrency: number of maximum concurrent executions of the container. MaxConcurrency uint32 `json:"max_concurrency"` // DomainName: domain name attributed to the contaioner. DomainName string `json:"domain_name"` // Protocol: protocol the container uses. // Default value: unknown_protocol Protocol ContainerProtocol `json:"protocol"` // Port: port the container listens on. Port uint32 `json:"port"` // SecretEnvironmentVariables: secret environment variables of the container. SecretEnvironmentVariables []*SecretHashedValue `json:"secret_environment_variables"` // HTTPOption: possible values: // - redirected: Responds to HTTP request with a 301 redirect to ask the clients to use HTTPS. // - enabled: Serve both HTTP and HTTPS traffic. // Default value: unknown_http_option HTTPOption ContainerHTTPOption `json:"http_option"` // Region: region in which the container will be deployed. Region scw.Region `json:"region"` } // Cron: cron. type Cron struct { // ID: UUID of the cron. ID string `json:"id"` // ContainerID: UUID of the container invoked by this cron. ContainerID string `json:"container_id"` // Schedule: uNIX cron shedule. Schedule string `json:"schedule"` // Args: arguments to pass with the cron. Args *scw.JSONObject `json:"args"` // Status: status of the cron. // Default value: unknown Status CronStatus `json:"status"` // Name: name of the cron. Name string `json:"name"` } // Domain: domain. type Domain struct { // ID: UUID of the domain. ID string `json:"id"` // Hostname: domain assigned to the container. Hostname string `json:"hostname"` // ContainerID: UUID of the container. ContainerID string `json:"container_id"` // URL: URL (TBD). URL string `json:"url"` // Status: status of the domain. // Default value: unknown Status DomainStatus `json:"status"` // ErrorMessage: last error message of the domain. ErrorMessage *string `json:"error_message"` } // Log: log. type Log struct { Message string `json:"message"` Timestamp *time.Time `json:"timestamp"` ID string `json:"id"` // Level: contains the severity of the log (info, debug, error, ...). Level string `json:"level"` // Source: source of the log (core runtime or user code). Source string `json:"source"` // Stream: can be stdout or stderr. // Default value: unknown Stream LogStream `json:"stream"` } // Namespace: namespace. type Namespace struct { // ID: UUID of the namespace. ID string `json:"id"` // Name: name of the namespace. Name string `json:"name"` // EnvironmentVariables: environment variables of the namespace. EnvironmentVariables map[string]string `json:"environment_variables"` // OrganizationID: UUID of the Organization the namespace belongs to. OrganizationID string `json:"organization_id"` // ProjectID: UUID of the Project the namespace belongs to. ProjectID string `json:"project_id"` // Status: status of the namespace. // Default value: unknown Status NamespaceStatus `json:"status"` // RegistryNamespaceID: UUID of the registry namespace. RegistryNamespaceID string `json:"registry_namespace_id"` // ErrorMessage: last error message of the namesace. ErrorMessage *string `json:"error_message"` // RegistryEndpoint: registry endpoint of the namespace. RegistryEndpoint string `json:"registry_endpoint"` // Description: description of the endpoint. Description *string `json:"description"` // SecretEnvironmentVariables: secret environment variables of the namespace. SecretEnvironmentVariables []*SecretHashedValue `json:"secret_environment_variables"` // Region: region in which the namespace will be created. Region scw.Region `json:"region"` } // Token: token. type Token struct { // ID: UUID of the token. ID string `json:"id"` // Token: identifier of the token. Token string `json:"token"` // ContainerID: UUID of the container the token belongs to. // Precisely one of ContainerID, NamespaceID must be set. ContainerID *string `json:"container_id,omitempty"` // NamespaceID: UUID of the namespace the token belongs to. // Precisely one of ContainerID, NamespaceID must be set. NamespaceID *string `json:"namespace_id,omitempty"` // Deprecated: PublicKey: public key of the token. PublicKey *string `json:"public_key,omitempty"` // Status: status of the token. // Default value: unknown Status TokenStatus `json:"status"` // Description: description of the token. Description *string `json:"description"` // ExpiresAt: expiry date of the token. ExpiresAt *time.Time `json:"expires_at"` } // Trigger: trigger. type Trigger struct { // ID: ID of the trigger. ID string `json:"id"` // Name: name of the trigger. Name string `json:"name"` // Description: description of the trigger. Description string `json:"description"` // ContainerID: ID of the container to trigger. ContainerID string `json:"container_id"` // InputType: type of the input. // Default value: unknown_input_type InputType TriggerInputType `json:"input_type"` // Status: status of the trigger. // Default value: unknown_status Status TriggerStatus `json:"status"` // ErrorMessage: error message of the trigger. ErrorMessage *string `json:"error_message"` // ScwSqsConfig: configuration for a Scaleway Messaging and Queuing SQS queue. // Precisely one of ScwSqsConfig, ScwNatsConfig, SqsConfig must be set. ScwSqsConfig *TriggerMnqSqsClientConfig `json:"scw_sqs_config,omitempty"` // ScwNatsConfig: configuration for a Scaleway Messaging and Queuing NATS subject. // Precisely one of ScwSqsConfig, ScwNatsConfig, SqsConfig must be set. ScwNatsConfig *TriggerMnqNatsClientConfig `json:"scw_nats_config,omitempty"` // SqsConfig: configuration for an AWS SQS queue. // Precisely one of ScwSqsConfig, ScwNatsConfig, SqsConfig must be set. SqsConfig *TriggerSqsClientConfig `json:"sqs_config,omitempty"` } // UpdateTriggerRequestSqsClientConfig: update trigger request sqs client config. type UpdateTriggerRequestSqsClientConfig struct { AccessKey *string `json:"access_key"` SecretKey *string `json:"secret_key"` } // CreateContainerRequest: create container request. type CreateContainerRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NamespaceID: UUID of the namespace the container belongs to. NamespaceID string `json:"namespace_id"` // Name: name of the container. Name string `json:"name"` // EnvironmentVariables: environment variables of the container. EnvironmentVariables *map[string]string `json:"environment_variables,omitempty"` // MinScale: minimum number of instances to scale the container to. MinScale *uint32 `json:"min_scale,omitempty"` // MaxScale: maximum number of instances to scale the container to. MaxScale *uint32 `json:"max_scale,omitempty"` // MemoryLimit: memory limit of the container in MB. MemoryLimit *uint32 `json:"memory_limit,omitempty"` // CPULimit: CPU limit of the container in mvCPU. CPULimit *uint32 `json:"cpu_limit,omitempty"` // Timeout: processing time limit for the container. Timeout *scw.Duration `json:"timeout,omitempty"` // Privacy: privacy setting of the container. // Default value: unknown_privacy Privacy ContainerPrivacy `json:"privacy"` // Description: description of the container. Description *string `json:"description,omitempty"` // RegistryImage: name of the registry image (e.g. "rg.fr-par.scw.cloud/something/image:tag"). RegistryImage *string `json:"registry_image,omitempty"` // MaxConcurrency: number of maximum concurrent executions of the container. MaxConcurrency *uint32 `json:"max_concurrency,omitempty"` // Protocol: protocol the container uses. // Default value: unknown_protocol Protocol ContainerProtocol `json:"protocol"` // Port: port the container listens on. Port *uint32 `json:"port,omitempty"` // SecretEnvironmentVariables: secret environment variables of the container. SecretEnvironmentVariables []*Secret `json:"secret_environment_variables"` // HTTPOption: possible values: // - redirected: Responds to HTTP request with a 301 redirect to ask the clients to use HTTPS. // - enabled: Serve both HTTP and HTTPS traffic. // Default value: unknown_http_option HTTPOption ContainerHTTPOption `json:"http_option"` } // CreateCronRequest: create cron request. type CreateCronRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ContainerID: UUID of the container to invoke by the cron. ContainerID string `json:"container_id"` // Schedule: uNIX cron shedule. Schedule string `json:"schedule"` // Args: arguments to pass with the cron. Args *scw.JSONObject `json:"args,omitempty"` // Name: name of the cron to create. Name *string `json:"name,omitempty"` } // CreateDomainRequest: create domain request. type CreateDomainRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Hostname: domain to assign. Hostname string `json:"hostname"` // ContainerID: UUID of the container to assign the domain to. ContainerID string `json:"container_id"` } // CreateNamespaceRequest: create namespace request. type CreateNamespaceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Name: name of the namespace to create. Name string `json:"name"` // EnvironmentVariables: environment variables of the namespace to create. EnvironmentVariables *map[string]string `json:"environment_variables,omitempty"` // ProjectID: UUID of the Project in which the namespace will be created. ProjectID string `json:"project_id"` // Description: description of the namespace to create. Description *string `json:"description,omitempty"` // SecretEnvironmentVariables: secret environment variables of the namespace to create. SecretEnvironmentVariables []*Secret `json:"secret_environment_variables"` } // CreateTokenRequest: create token request. type CreateTokenRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ContainerID: UUID of the container to create the token for. // Precisely one of ContainerID, NamespaceID must be set. ContainerID *string `json:"container_id,omitempty"` // NamespaceID: UUID of the namespace to create the token for. // Precisely one of ContainerID, NamespaceID must be set. NamespaceID *string `json:"namespace_id,omitempty"` // Description: description of the token. Description *string `json:"description,omitempty"` // ExpiresAt: expiry date of the token. ExpiresAt *time.Time `json:"expires_at,omitempty"` } // CreateTriggerRequest: create trigger request. type CreateTriggerRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Name: name of the trigger. Name string `json:"name"` // ContainerID: ID of the container to trigger. ContainerID string `json:"container_id"` // Description: description of the trigger. Description *string `json:"description,omitempty"` // ScwSqsConfig: configuration for a Scaleway Messaging and Queuing SQS queue. // Precisely one of ScwSqsConfig, ScwNatsConfig, SqsConfig must be set. ScwSqsConfig *CreateTriggerRequestMnqSqsClientConfig `json:"scw_sqs_config,omitempty"` // ScwNatsConfig: configuration for a Scaleway Messaging and Queuing NATS subject. // Precisely one of ScwSqsConfig, ScwNatsConfig, SqsConfig must be set. ScwNatsConfig *CreateTriggerRequestMnqNatsClientConfig `json:"scw_nats_config,omitempty"` // SqsConfig: configuration for an AWS SQS queue. // Precisely one of ScwSqsConfig, ScwNatsConfig, SqsConfig must be set. SqsConfig *CreateTriggerRequestSqsClientConfig `json:"sqs_config,omitempty"` } // DeleteContainerRequest: delete container request. type DeleteContainerRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ContainerID: UUID of the container to delete. ContainerID string `json:"-"` } // DeleteCronRequest: delete cron request. type DeleteCronRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // CronID: UUID of the cron to delete. CronID string `json:"-"` } // DeleteDomainRequest: delete domain request. type DeleteDomainRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DomainID: UUID of the domain to delete. DomainID string `json:"-"` } // DeleteNamespaceRequest: delete namespace request. type DeleteNamespaceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NamespaceID: UUID of the namespace to delete. NamespaceID string `json:"-"` } // DeleteTokenRequest: delete token request. type DeleteTokenRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // TokenID: UUID of the token to delete. TokenID string `json:"-"` } // DeleteTriggerRequest: delete trigger request. type DeleteTriggerRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // TriggerID: ID of the trigger to delete. TriggerID string `json:"-"` } // DeployContainerRequest: deploy container request. type DeployContainerRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ContainerID: UUID of the container to deploy. ContainerID string `json:"-"` } // GetContainerRequest: get container request. type GetContainerRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ContainerID: UUID of the container to get. ContainerID string `json:"-"` } // GetCronRequest: get cron request. type GetCronRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // CronID: UUID of the cron to get. CronID string `json:"-"` } // GetDomainRequest: get domain request. type GetDomainRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DomainID: UUID of the domain to get. DomainID string `json:"-"` } // GetNamespaceRequest: get namespace request. type GetNamespaceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NamespaceID: UUID of the namespace to get. NamespaceID string `json:"-"` } // GetTokenRequest: get token request. type GetTokenRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // TokenID: UUID of the token to get. TokenID string `json:"-"` } // GetTriggerRequest: get trigger request. type GetTriggerRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // TriggerID: ID of the trigger to get. TriggerID string `json:"-"` } // IssueJWTRequest: issue jwt request. type IssueJWTRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Precisely one of ContainerID, NamespaceID must be set. ContainerID *string `json:"container_id,omitempty"` // Precisely one of ContainerID, NamespaceID must be set. NamespaceID *string `json:"namespace_id,omitempty"` ExpiresAt *time.Time `json:"-"` } // ListContainersRequest: list containers request. type ListContainersRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: number of containers per page. PageSize *uint32 `json:"-"` // OrderBy: order of the containers. // Default value: created_at_asc OrderBy ListContainersRequestOrderBy `json:"-"` // NamespaceID: UUID of the namespace the container belongs to. NamespaceID string `json:"-"` // Name: name of the container. Name *string `json:"-"` // OrganizationID: UUID of the Organization the container belongs to. OrganizationID *string `json:"-"` // ProjectID: UUID of the Project the container belongs to. ProjectID *string `json:"-"` } // ListContainersResponse: list containers response. type ListContainersResponse struct { // Containers: array of containers. Containers []*Container `json:"containers"` // TotalCount: total number of containers. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListContainersResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListContainersResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListContainersResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Containers = append(r.Containers, results.Containers...) r.TotalCount += uint32(len(results.Containers)) return uint32(len(results.Containers)), nil } // ListCronsRequest: list crons request. type ListCronsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: number of crons per page. PageSize *uint32 `json:"-"` // OrderBy: order of the crons. // Default value: created_at_asc OrderBy ListCronsRequestOrderBy `json:"-"` // ContainerID: UUID of the container invoked by the cron. ContainerID string `json:"-"` } // ListCronsResponse: list crons response. type ListCronsResponse struct { // Crons: array of crons. Crons []*Cron `json:"crons"` // TotalCount: total number of crons. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListCronsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListCronsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListCronsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Crons = append(r.Crons, results.Crons...) r.TotalCount += uint32(len(results.Crons)) return uint32(len(results.Crons)), nil } // ListDomainsRequest: list domains request. type ListDomainsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: number of domains per page. PageSize *uint32 `json:"-"` // OrderBy: order of the domains. // Default value: created_at_asc OrderBy ListDomainsRequestOrderBy `json:"-"` // ContainerID: UUID of the container the domain belongs to. ContainerID string `json:"-"` } // ListDomainsResponse: list domains response. type ListDomainsResponse struct { // Domains: array of domains. Domains []*Domain `json:"domains"` // TotalCount: total number of domains. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListDomainsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListDomainsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListDomainsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Domains = append(r.Domains, results.Domains...) r.TotalCount += uint32(len(results.Domains)) return uint32(len(results.Domains)), nil } // ListLogsRequest: list logs request. type ListLogsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ContainerID: UUID of the container. ContainerID string `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: number of logs per page. PageSize *uint32 `json:"-"` // OrderBy: order of the logs. // Default value: timestamp_desc OrderBy ListLogsRequestOrderBy `json:"-"` } // ListLogsResponse: list logs response. type ListLogsResponse struct { Logs []*Log `json:"logs"` TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListLogsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListLogsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListLogsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Logs = append(r.Logs, results.Logs...) r.TotalCount += uint32(len(results.Logs)) return uint32(len(results.Logs)), nil } // ListNamespacesRequest: list namespaces request. type ListNamespacesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: number of namespaces per page. PageSize *uint32 `json:"-"` // OrderBy: order of the namespaces. // Default value: created_at_asc OrderBy ListNamespacesRequestOrderBy `json:"-"` // Name: name of the namespaces. Name *string `json:"-"` // OrganizationID: UUID of the Organization the namespace belongs to. OrganizationID *string `json:"-"` // ProjectID: UUID of the Project the namespace belongs to. ProjectID *string `json:"-"` } // ListNamespacesResponse: list namespaces response. type ListNamespacesResponse struct { // Namespaces: array of the namespaces. Namespaces []*Namespace `json:"namespaces"` // TotalCount: total number of namespaces. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListNamespacesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListNamespacesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListNamespacesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Namespaces = append(r.Namespaces, results.Namespaces...) r.TotalCount += uint32(len(results.Namespaces)) return uint32(len(results.Namespaces)), nil } // ListTokensRequest: list tokens request. type ListTokensRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: number of tokens per page. PageSize *uint32 `json:"-"` // OrderBy: order of the tokens. // Default value: created_at_asc OrderBy ListTokensRequestOrderBy `json:"-"` // ContainerID: UUID of the container the token belongs to. ContainerID *string `json:"-"` // NamespaceID: UUID of the namespace the token belongs to. NamespaceID *string `json:"-"` } // ListTokensResponse: list tokens response. type ListTokensResponse struct { Tokens []*Token `json:"tokens"` TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListTokensResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListTokensResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListTokensResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Tokens = append(r.Tokens, results.Tokens...) r.TotalCount += uint32(len(results.Tokens)) return uint32(len(results.Tokens)), nil } // ListTriggersRequest: list triggers request. type ListTriggersRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: page number to return. Page *int32 `json:"-"` // PageSize: maximum number of triggers to return per page. PageSize *uint32 `json:"-"` // OrderBy: order in which to return results. // Default value: created_at_asc OrderBy ListTriggersRequestOrderBy `json:"-"` // ContainerID: ID of the container the triggers belongs to. // Precisely one of ContainerID, NamespaceID, ProjectID must be set. ContainerID *string `json:"container_id,omitempty"` // NamespaceID: ID of the namespace the triggers belongs to. // Precisely one of ContainerID, NamespaceID, ProjectID must be set. NamespaceID *string `json:"namespace_id,omitempty"` // ProjectID: ID of the project the triggers belongs to. // Precisely one of ContainerID, NamespaceID, ProjectID must be set. ProjectID *string `json:"project_id,omitempty"` } // ListTriggersResponse: list triggers response. type ListTriggersResponse struct { // TotalCount: total count of existing triggers (matching any filters specified). TotalCount uint32 `json:"total_count"` // Triggers: triggers on this page. Triggers []*Trigger `json:"triggers"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListTriggersResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListTriggersResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListTriggersResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Triggers = append(r.Triggers, results.Triggers...) r.TotalCount += uint32(len(results.Triggers)) return uint32(len(results.Triggers)), nil } // UpdateContainerRequest: update container request. type UpdateContainerRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ContainerID: UUID of the container to update. ContainerID string `json:"-"` // EnvironmentVariables: environment variables of the container. EnvironmentVariables *map[string]string `json:"environment_variables,omitempty"` // MinScale: minimum number of instances to scale the container to. MinScale *uint32 `json:"min_scale,omitempty"` // MaxScale: maximum number of instances to scale the container to. MaxScale *uint32 `json:"max_scale,omitempty"` // MemoryLimit: memory limit of the container in MB. MemoryLimit *uint32 `json:"memory_limit,omitempty"` // CPULimit: CPU limit of the container in mvCPU. CPULimit *uint32 `json:"cpu_limit,omitempty"` // Timeout: processing time limit for the container. Timeout *scw.Duration `json:"timeout,omitempty"` // Redeploy: defines whether to redeploy failed containers. Redeploy *bool `json:"redeploy,omitempty"` // Privacy: privacy settings of the container. // Default value: unknown_privacy Privacy ContainerPrivacy `json:"privacy"` // Description: description of the container. Description *string `json:"description,omitempty"` // RegistryImage: name of the registry image (e.g. "rg.fr-par.scw.cloud/something/image:tag"). RegistryImage *string `json:"registry_image,omitempty"` // MaxConcurrency: number of maximum concurrent executions of the container. MaxConcurrency *uint32 `json:"max_concurrency,omitempty"` // Protocol: default value: unknown_protocol Protocol ContainerProtocol `json:"protocol"` Port *uint32 `json:"port,omitempty"` SecretEnvironmentVariables []*Secret `json:"secret_environment_variables"` // HTTPOption: possible values: // - redirected: Responds to HTTP request with a 301 redirect to ask the clients to use HTTPS. // - enabled: Serve both HTTP and HTTPS traffic. // Default value: unknown_http_option HTTPOption ContainerHTTPOption `json:"http_option"` } // UpdateCronRequest: update cron request. type UpdateCronRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // CronID: UUID of the cron to update. CronID string `json:"-"` // ContainerID: UUID of the container invoked by the cron. ContainerID *string `json:"container_id,omitempty"` // Schedule: uNIX cron schedule. Schedule *string `json:"schedule,omitempty"` // Args: arguments to pass with the cron. Args *scw.JSONObject `json:"args,omitempty"` // Name: name of the cron. Name *string `json:"name,omitempty"` } // UpdateNamespaceRequest: update namespace request. type UpdateNamespaceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NamespaceID: UUID of the namespace to update. NamespaceID string `json:"-"` // EnvironmentVariables: environment variables of the namespace to update. EnvironmentVariables *map[string]string `json:"environment_variables,omitempty"` // Description: description of the namespace to update. Description *string `json:"description,omitempty"` // SecretEnvironmentVariables: secret environment variables of the namespace to update. SecretEnvironmentVariables []*Secret `json:"secret_environment_variables"` } // UpdateTriggerRequest: update trigger request. type UpdateTriggerRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // TriggerID: ID of the trigger to update. TriggerID string `json:"-"` // Name: name of the trigger. Name *string `json:"name,omitempty"` // Description: description of the trigger. Description *string `json:"description,omitempty"` // SqsConfig: configuration for an AWS SQS queue. // Precisely one of SqsConfig must be set. SqsConfig *UpdateTriggerRequestSqsClientConfig `json:"sqs_config,omitempty"` } // Serverless Containers API. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Regions() []scw.Region { return []scw.Region{scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw} } // ListNamespaces: List all namespaces in a specified region. func (s *API) ListNamespaces(req *ListNamespacesRequest, opts ...scw.RequestOption) (*ListNamespacesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/namespaces", Query: query, } var resp ListNamespacesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetNamespace: Get the namespace associated with the specified ID. func (s *API) GetNamespace(req *GetNamespaceRequest, opts ...scw.RequestOption) (*Namespace, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NamespaceID) == "" { return nil, errors.New("field NamespaceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/namespaces/" + fmt.Sprint(req.NamespaceID) + "", } var resp Namespace err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateNamespace: Create a new namespace in a specified region. func (s *API) CreateNamespace(req *CreateNamespaceRequest, opts ...scw.RequestOption) (*Namespace, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if req.Name == "" { req.Name = namegenerator.GetRandomName("cns") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/namespaces", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Namespace err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateNamespace: Update the space associated with the specified ID. func (s *API) UpdateNamespace(req *UpdateNamespaceRequest, opts ...scw.RequestOption) (*Namespace, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NamespaceID) == "" { return nil, errors.New("field NamespaceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/namespaces/" + fmt.Sprint(req.NamespaceID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Namespace err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteNamespace: Delete the namespace associated with the specified ID. func (s *API) DeleteNamespace(req *DeleteNamespaceRequest, opts ...scw.RequestOption) (*Namespace, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NamespaceID) == "" { return nil, errors.New("field NamespaceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/namespaces/" + fmt.Sprint(req.NamespaceID) + "", } var resp Namespace err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListContainers: List all containers for a specified region. func (s *API) ListContainers(req *ListContainersRequest, opts ...scw.RequestOption) (*ListContainersResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "namespace_id", req.NamespaceID) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/containers", Query: query, } var resp ListContainersResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetContainer: Get the container associated with the specified ID. func (s *API) GetContainer(req *GetContainerRequest, opts ...scw.RequestOption) (*Container, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ContainerID) == "" { return nil, errors.New("field ContainerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/containers/" + fmt.Sprint(req.ContainerID) + "", } var resp Container err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateContainer: Create a new container in the specified region. func (s *API) CreateContainer(req *CreateContainerRequest, opts ...scw.RequestOption) (*Container, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/containers", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Container err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateContainer: Update the container associated with the specified ID. func (s *API) UpdateContainer(req *UpdateContainerRequest, opts ...scw.RequestOption) (*Container, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ContainerID) == "" { return nil, errors.New("field ContainerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/containers/" + fmt.Sprint(req.ContainerID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Container err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteContainer: Delete the container associated with the specified ID. func (s *API) DeleteContainer(req *DeleteContainerRequest, opts ...scw.RequestOption) (*Container, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ContainerID) == "" { return nil, errors.New("field ContainerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/containers/" + fmt.Sprint(req.ContainerID) + "", } var resp Container err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeployContainer: Deploy a container associated with the specified ID. func (s *API) DeployContainer(req *DeployContainerRequest, opts ...scw.RequestOption) (*Container, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ContainerID) == "" { return nil, errors.New("field ContainerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/containers/" + fmt.Sprint(req.ContainerID) + "/deploy", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Container err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListCrons: List all your crons. func (s *API) ListCrons(req *ListCronsRequest, opts ...scw.RequestOption) (*ListCronsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "container_id", req.ContainerID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/crons", Query: query, } var resp ListCronsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetCron: Get the cron associated with the specified ID. func (s *API) GetCron(req *GetCronRequest, opts ...scw.RequestOption) (*Cron, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.CronID) == "" { return nil, errors.New("field CronID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/crons/" + fmt.Sprint(req.CronID) + "", } var resp Cron err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateCron: Create a new cron. func (s *API) CreateCron(req *CreateCronRequest, opts ...scw.RequestOption) (*Cron, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/crons", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Cron err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateCron: Update the cron associated with the specified ID. func (s *API) UpdateCron(req *UpdateCronRequest, opts ...scw.RequestOption) (*Cron, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.CronID) == "" { return nil, errors.New("field CronID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/crons/" + fmt.Sprint(req.CronID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Cron err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteCron: Delete the cron associated with the specified ID. func (s *API) DeleteCron(req *DeleteCronRequest, opts ...scw.RequestOption) (*Cron, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.CronID) == "" { return nil, errors.New("field CronID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/crons/" + fmt.Sprint(req.CronID) + "", } var resp Cron err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // Deprecated: ListLogs: Deprecated (replaced by [Cockpit](https://www.scaleway.com/en/developers/api/cockpit/)). List the logs of the container with the specified ID. func (s *API) ListLogs(req *ListLogsRequest, opts ...scw.RequestOption) (*ListLogsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ContainerID) == "" { return nil, errors.New("field ContainerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/containers/" + fmt.Sprint(req.ContainerID) + "/logs", Query: query, } var resp ListLogsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListDomains: List all domain name bindings in a specified region. func (s *API) ListDomains(req *ListDomainsRequest, opts ...scw.RequestOption) (*ListDomainsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "container_id", req.ContainerID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/domains", Query: query, } var resp ListDomainsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetDomain: Get a domain name binding for the container with the specified ID. func (s *API) GetDomain(req *GetDomainRequest, opts ...scw.RequestOption) (*Domain, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DomainID) == "" { return nil, errors.New("field DomainID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/domains/" + fmt.Sprint(req.DomainID) + "", } var resp Domain err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateDomain: Create a domain name binding for the container with the specified ID. func (s *API) CreateDomain(req *CreateDomainRequest, opts ...scw.RequestOption) (*Domain, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/domains", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Domain err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteDomain: Delete the domain name binding with the specific ID. func (s *API) DeleteDomain(req *DeleteDomainRequest, opts ...scw.RequestOption) (*Domain, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DomainID) == "" { return nil, errors.New("field DomainID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/domains/" + fmt.Sprint(req.DomainID) + "", } var resp Domain err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // Deprecated: IssueJWT: Deprecated in favor of CreateToken. func (s *API) IssueJWT(req *IssueJWTRequest, opts ...scw.RequestOption) (*Token, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } query := url.Values{} parameter.AddToQuery(query, "expires_at", req.ExpiresAt) parameter.AddToQuery(query, "container_id", req.ContainerID) parameter.AddToQuery(query, "namespace_id", req.NamespaceID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/issue-jwt", Query: query, } var resp Token err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateToken: Create a new revocable token. func (s *API) CreateToken(req *CreateTokenRequest, opts ...scw.RequestOption) (*Token, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/tokens", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Token err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetToken: Get a token with a specified ID. func (s *API) GetToken(req *GetTokenRequest, opts ...scw.RequestOption) (*Token, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.TokenID) == "" { return nil, errors.New("field TokenID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/tokens/" + fmt.Sprint(req.TokenID) + "", } var resp Token err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListTokens: List all tokens belonging to a specified Organization or Project. func (s *API) ListTokens(req *ListTokensRequest, opts ...scw.RequestOption) (*ListTokensResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "container_id", req.ContainerID) parameter.AddToQuery(query, "namespace_id", req.NamespaceID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/tokens", Query: query, } var resp ListTokensResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteToken: Delete a token with a specified ID. func (s *API) DeleteToken(req *DeleteTokenRequest, opts ...scw.RequestOption) (*Token, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.TokenID) == "" { return nil, errors.New("field TokenID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/tokens/" + fmt.Sprint(req.TokenID) + "", } var resp Token err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateTrigger: Create a new trigger for a specified container. func (s *API) CreateTrigger(req *CreateTriggerRequest, opts ...scw.RequestOption) (*Trigger, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/triggers", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Trigger err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetTrigger: Get a trigger with a specified ID. func (s *API) GetTrigger(req *GetTriggerRequest, opts ...scw.RequestOption) (*Trigger, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.TriggerID) == "" { return nil, errors.New("field TriggerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/triggers/" + fmt.Sprint(req.TriggerID) + "", } var resp Trigger err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListTriggers: List all triggers belonging to a specified Organization or Project. func (s *API) ListTriggers(req *ListTriggersRequest, opts ...scw.RequestOption) (*ListTriggersResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } defaultProjectID, exist := s.client.GetDefaultProjectID() if exist && req.ContainerID == nil && req.NamespaceID == nil && req.ProjectID == nil { req.ProjectID = &defaultProjectID } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "container_id", req.ContainerID) parameter.AddToQuery(query, "namespace_id", req.NamespaceID) parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/triggers", Query: query, } var resp ListTriggersResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateTrigger: Update a trigger with a specified ID. func (s *API) UpdateTrigger(req *UpdateTriggerRequest, opts ...scw.RequestOption) (*Trigger, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.TriggerID) == "" { return nil, errors.New("field TriggerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/triggers/" + fmt.Sprint(req.TriggerID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Trigger err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteTrigger: Delete a trigger with a specified ID. func (s *API) DeleteTrigger(req *DeleteTriggerRequest, opts ...scw.RequestOption) (*Trigger, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.TriggerID) == "" { return nil, errors.New("field TriggerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/containers/v1beta1/regions/" + fmt.Sprint(req.Region) + "/triggers/" + fmt.Sprint(req.TriggerID) + "", } var resp Trigger err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/container/v1beta1/container_sdk_test.go000066400000000000000000000013571456366605600324730ustar00rootroot00000000000000package container import ( "testing" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers/httprecorder" "github.com/scaleway/scaleway-sdk-go/scw" ) func TestListContainerNamespaceMultipleRegions(t *testing.T) { client, r, err := httprecorder.CreateRecordedScwClient("container-list-regions") testhelpers.AssertNoError(t, err) defer func() { testhelpers.AssertNoError(t, r.Stop()) // Make sure recorder is stopped once done with it }() containerAPI := NewAPI(client) // Create server _, err = containerAPI.ListNamespaces(&ListNamespacesRequest{}, scw.WithRegions(containerAPI.Regions()...)) testhelpers.Assert(t, err == nil, "This request should not error: %s", err) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/container/v1beta1/testdata/000077500000000000000000000000001456366605600300655ustar00rootroot00000000000000container-list-regions.yaml000066400000000000000000000057061456366605600353010ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/container/v1beta1/testdata--- version: 1 interactions: - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.20.1; linux; amd64) url: https://api.scaleway.com/containers/v1beta1/regions/fr-par/namespaces?order_by=created_at_asc method: GET response: body: '{"namespaces":[], "total_count":0}' headers: Content-Length: - "34" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Fri, 03 Mar 2023 11:09:20 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 64534ead-60ca-4176-a37c-89f2781ec10e status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.20.1; linux; amd64) url: https://api.scaleway.com/containers/v1beta1/regions/nl-ams/namespaces?order_by=created_at_asc method: GET response: body: '{"namespaces":[{"id":"5113d87a-3a49-4e8d-be27-e1a20b9a59c1", "name":"dfdsffsfsqf", "environment_variables":{}, "organization_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "status":"ready", "registry_namespace_id":"d0afb8a1-6417-4e7e-8a1c-29e348f96f05", "error_message":null, "registry_endpoint":"rg.nl-ams.scw.cloud/funcscwdfdsffsfsqfkvsfbdbr", "description":"", "secret_environment_variables":[], "region":"nl-ams"}], "total_count":1}' headers: Content-Length: - "486" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Fri, 03 Mar 2023 11:09:20 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - ef764335-0239-4aa5-92ca-a91a9a22db3a status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.20.1; linux; amd64) url: https://api.scaleway.com/containers/v1beta1/regions/pl-waw/namespaces?order_by=created_at_asc method: GET response: body: '{"namespaces":[], "total_count":0}' headers: Content-Length: - "34" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Fri, 03 Mar 2023 11:09:20 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 33115f4e-1a87-41cb-8ba4-0ec491271287 status: 200 OK code: 200 duration: "" golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/documentdb/000077500000000000000000000000001456366605600251535ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/documentdb/v1beta1/000077500000000000000000000000001456366605600264165ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/documentdb/v1beta1/documentdb_sdk.go000066400000000000000000003632631456366605600317470ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package documentdb provides methods and message types of the documentdb v1beta1 API. package documentdb import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type ACLRuleAction string const ( ACLRuleActionAllow = ACLRuleAction("allow") ACLRuleActionDeny = ACLRuleAction("deny") ) func (enum ACLRuleAction) String() string { if enum == "" { // return default value if empty return "allow" } return string(enum) } func (enum ACLRuleAction) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ACLRuleAction) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ACLRuleAction(ACLRuleAction(tmp).String()) return nil } type ACLRuleDirection string const ( ACLRuleDirectionInbound = ACLRuleDirection("inbound") ACLRuleDirectionOutbound = ACLRuleDirection("outbound") ) func (enum ACLRuleDirection) String() string { if enum == "" { // return default value if empty return "inbound" } return string(enum) } func (enum ACLRuleDirection) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ACLRuleDirection) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ACLRuleDirection(ACLRuleDirection(tmp).String()) return nil } type ACLRuleProtocol string const ( ACLRuleProtocolTCP = ACLRuleProtocol("tcp") ACLRuleProtocolUDP = ACLRuleProtocol("udp") ACLRuleProtocolIcmp = ACLRuleProtocol("icmp") ) func (enum ACLRuleProtocol) String() string { if enum == "" { // return default value if empty return "tcp" } return string(enum) } func (enum ACLRuleProtocol) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ACLRuleProtocol) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ACLRuleProtocol(ACLRuleProtocol(tmp).String()) return nil } type EngineSettingPropertyType string const ( EngineSettingPropertyTypeBOOLEAN = EngineSettingPropertyType("BOOLEAN") EngineSettingPropertyTypeINT = EngineSettingPropertyType("INT") EngineSettingPropertyTypeSTRING = EngineSettingPropertyType("STRING") EngineSettingPropertyTypeFLOAT = EngineSettingPropertyType("FLOAT") ) func (enum EngineSettingPropertyType) String() string { if enum == "" { // return default value if empty return "BOOLEAN" } return string(enum) } func (enum EngineSettingPropertyType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *EngineSettingPropertyType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = EngineSettingPropertyType(EngineSettingPropertyType(tmp).String()) return nil } type InstanceLogStatus string const ( InstanceLogStatusUnknown = InstanceLogStatus("unknown") InstanceLogStatusReady = InstanceLogStatus("ready") InstanceLogStatusCreating = InstanceLogStatus("creating") InstanceLogStatusError = InstanceLogStatus("error") ) func (enum InstanceLogStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum InstanceLogStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *InstanceLogStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = InstanceLogStatus(InstanceLogStatus(tmp).String()) return nil } type InstanceStatus string const ( InstanceStatusUnknown = InstanceStatus("unknown") InstanceStatusReady = InstanceStatus("ready") InstanceStatusProvisioning = InstanceStatus("provisioning") InstanceStatusConfiguring = InstanceStatus("configuring") InstanceStatusDeleting = InstanceStatus("deleting") InstanceStatusError = InstanceStatus("error") InstanceStatusAutohealing = InstanceStatus("autohealing") InstanceStatusLocked = InstanceStatus("locked") InstanceStatusInitializing = InstanceStatus("initializing") InstanceStatusDiskFull = InstanceStatus("disk_full") InstanceStatusBackuping = InstanceStatus("backuping") InstanceStatusSnapshotting = InstanceStatus("snapshotting") InstanceStatusRestarting = InstanceStatus("restarting") ) func (enum InstanceStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum InstanceStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *InstanceStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = InstanceStatus(InstanceStatus(tmp).String()) return nil } type ListDatabasesRequestOrderBy string const ( ListDatabasesRequestOrderByNameAsc = ListDatabasesRequestOrderBy("name_asc") ListDatabasesRequestOrderByNameDesc = ListDatabasesRequestOrderBy("name_desc") ListDatabasesRequestOrderBySizeAsc = ListDatabasesRequestOrderBy("size_asc") ListDatabasesRequestOrderBySizeDesc = ListDatabasesRequestOrderBy("size_desc") ) func (enum ListDatabasesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "name_asc" } return string(enum) } func (enum ListDatabasesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListDatabasesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListDatabasesRequestOrderBy(ListDatabasesRequestOrderBy(tmp).String()) return nil } type ListInstanceLogsRequestOrderBy string const ( ListInstanceLogsRequestOrderByCreatedAtAsc = ListInstanceLogsRequestOrderBy("created_at_asc") ListInstanceLogsRequestOrderByCreatedAtDesc = ListInstanceLogsRequestOrderBy("created_at_desc") ) func (enum ListInstanceLogsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListInstanceLogsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListInstanceLogsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListInstanceLogsRequestOrderBy(ListInstanceLogsRequestOrderBy(tmp).String()) return nil } type ListInstancesRequestOrderBy string const ( ListInstancesRequestOrderByCreatedAtAsc = ListInstancesRequestOrderBy("created_at_asc") ListInstancesRequestOrderByCreatedAtDesc = ListInstancesRequestOrderBy("created_at_desc") ListInstancesRequestOrderByNameAsc = ListInstancesRequestOrderBy("name_asc") ListInstancesRequestOrderByNameDesc = ListInstancesRequestOrderBy("name_desc") ListInstancesRequestOrderByRegion = ListInstancesRequestOrderBy("region") ListInstancesRequestOrderByStatusAsc = ListInstancesRequestOrderBy("status_asc") ListInstancesRequestOrderByStatusDesc = ListInstancesRequestOrderBy("status_desc") ) func (enum ListInstancesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListInstancesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListInstancesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListInstancesRequestOrderBy(ListInstancesRequestOrderBy(tmp).String()) return nil } type ListPrivilegesRequestOrderBy string const ( ListPrivilegesRequestOrderByUserNameAsc = ListPrivilegesRequestOrderBy("user_name_asc") ListPrivilegesRequestOrderByUserNameDesc = ListPrivilegesRequestOrderBy("user_name_desc") ListPrivilegesRequestOrderByDatabaseNameAsc = ListPrivilegesRequestOrderBy("database_name_asc") ListPrivilegesRequestOrderByDatabaseNameDesc = ListPrivilegesRequestOrderBy("database_name_desc") ) func (enum ListPrivilegesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "user_name_asc" } return string(enum) } func (enum ListPrivilegesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListPrivilegesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListPrivilegesRequestOrderBy(ListPrivilegesRequestOrderBy(tmp).String()) return nil } type ListSnapshotsRequestOrderBy string const ( ListSnapshotsRequestOrderByCreatedAtAsc = ListSnapshotsRequestOrderBy("created_at_asc") ListSnapshotsRequestOrderByCreatedAtDesc = ListSnapshotsRequestOrderBy("created_at_desc") ListSnapshotsRequestOrderByNameAsc = ListSnapshotsRequestOrderBy("name_asc") ListSnapshotsRequestOrderByNameDesc = ListSnapshotsRequestOrderBy("name_desc") ListSnapshotsRequestOrderByExpiresAtAsc = ListSnapshotsRequestOrderBy("expires_at_asc") ListSnapshotsRequestOrderByExpiresAtDesc = ListSnapshotsRequestOrderBy("expires_at_desc") ) func (enum ListSnapshotsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListSnapshotsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListSnapshotsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListSnapshotsRequestOrderBy(ListSnapshotsRequestOrderBy(tmp).String()) return nil } type ListUsersRequestOrderBy string const ( ListUsersRequestOrderByNameAsc = ListUsersRequestOrderBy("name_asc") ListUsersRequestOrderByNameDesc = ListUsersRequestOrderBy("name_desc") ListUsersRequestOrderByIsAdminAsc = ListUsersRequestOrderBy("is_admin_asc") ListUsersRequestOrderByIsAdminDesc = ListUsersRequestOrderBy("is_admin_desc") ) func (enum ListUsersRequestOrderBy) String() string { if enum == "" { // return default value if empty return "name_asc" } return string(enum) } func (enum ListUsersRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListUsersRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListUsersRequestOrderBy(ListUsersRequestOrderBy(tmp).String()) return nil } type MaintenanceStatus string const ( MaintenanceStatusUnknown = MaintenanceStatus("unknown") MaintenanceStatusPending = MaintenanceStatus("pending") MaintenanceStatusDone = MaintenanceStatus("done") MaintenanceStatusCanceled = MaintenanceStatus("canceled") ) func (enum MaintenanceStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum MaintenanceStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *MaintenanceStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = MaintenanceStatus(MaintenanceStatus(tmp).String()) return nil } type NodeTypeGeneration string const ( NodeTypeGenerationUnknownGeneration = NodeTypeGeneration("unknown_generation") NodeTypeGenerationGenerationV1 = NodeTypeGeneration("generation_v1") NodeTypeGenerationGenerationV2 = NodeTypeGeneration("generation_v2") ) func (enum NodeTypeGeneration) String() string { if enum == "" { // return default value if empty return "unknown_generation" } return string(enum) } func (enum NodeTypeGeneration) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *NodeTypeGeneration) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = NodeTypeGeneration(NodeTypeGeneration(tmp).String()) return nil } type NodeTypeStock string const ( NodeTypeStockUnknown = NodeTypeStock("unknown") NodeTypeStockLowStock = NodeTypeStock("low_stock") NodeTypeStockOutOfStock = NodeTypeStock("out_of_stock") NodeTypeStockAvailable = NodeTypeStock("available") ) func (enum NodeTypeStock) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum NodeTypeStock) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *NodeTypeStock) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = NodeTypeStock(NodeTypeStock(tmp).String()) return nil } type Permission string const ( PermissionReadonly = Permission("readonly") PermissionReadwrite = Permission("readwrite") PermissionAll = Permission("all") PermissionCustom = Permission("custom") PermissionNone = Permission("none") ) func (enum Permission) String() string { if enum == "" { // return default value if empty return "readonly" } return string(enum) } func (enum Permission) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *Permission) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = Permission(Permission(tmp).String()) return nil } type ReadReplicaStatus string const ( ReadReplicaStatusUnknown = ReadReplicaStatus("unknown") ReadReplicaStatusProvisioning = ReadReplicaStatus("provisioning") ReadReplicaStatusInitializing = ReadReplicaStatus("initializing") ReadReplicaStatusReady = ReadReplicaStatus("ready") ReadReplicaStatusDeleting = ReadReplicaStatus("deleting") ReadReplicaStatusError = ReadReplicaStatus("error") ReadReplicaStatusLocked = ReadReplicaStatus("locked") ReadReplicaStatusConfiguring = ReadReplicaStatus("configuring") ReadReplicaStatusPromoting = ReadReplicaStatus("promoting") ) func (enum ReadReplicaStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum ReadReplicaStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ReadReplicaStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ReadReplicaStatus(ReadReplicaStatus(tmp).String()) return nil } type SnapshotStatus string const ( SnapshotStatusUnknown = SnapshotStatus("unknown") SnapshotStatusCreating = SnapshotStatus("creating") SnapshotStatusReady = SnapshotStatus("ready") SnapshotStatusRestoring = SnapshotStatus("restoring") SnapshotStatusDeleting = SnapshotStatus("deleting") SnapshotStatusError = SnapshotStatus("error") SnapshotStatusLocked = SnapshotStatus("locked") ) func (enum SnapshotStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum SnapshotStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *SnapshotStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = SnapshotStatus(SnapshotStatus(tmp).String()) return nil } type StorageClass string const ( StorageClassUnknownStorageClass = StorageClass("unknown_storage_class") StorageClassLssd = StorageClass("lssd") StorageClassBssd = StorageClass("bssd") StorageClassSbs = StorageClass("sbs") ) func (enum StorageClass) String() string { if enum == "" { // return default value if empty return "unknown_storage_class" } return string(enum) } func (enum StorageClass) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *StorageClass) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = StorageClass(StorageClass(tmp).String()) return nil } type VolumeType string const ( VolumeTypeLssd = VolumeType("lssd") VolumeTypeBssd = VolumeType("bssd") VolumeTypeSbs5k = VolumeType("sbs_5k") VolumeTypeSbs15k = VolumeType("sbs_15k") ) func (enum VolumeType) String() string { if enum == "" { // return default value if empty return "lssd" } return string(enum) } func (enum VolumeType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *VolumeType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = VolumeType(VolumeType(tmp).String()) return nil } // EndpointDirectAccessDetails: endpoint direct access details. type EndpointDirectAccessDetails struct { } // EndpointLoadBalancerDetails: endpoint load balancer details. type EndpointLoadBalancerDetails struct { } // EndpointPrivateNetworkDetails: endpoint private network details. type EndpointPrivateNetworkDetails struct { // PrivateNetworkID: UUID of the Private Network. PrivateNetworkID string `json:"private_network_id"` // ServiceIP: cIDR notation of the endpoint IPv4 address. ServiceIP scw.IPNet `json:"service_ip"` // Zone: private network zone. Zone scw.Zone `json:"zone"` } // EndpointSpecPrivateNetworkIpamConfig: endpoint spec private network ipam config. type EndpointSpecPrivateNetworkIpamConfig struct { } // ReadReplicaEndpointSpecPrivateNetworkIpamConfig: read replica endpoint spec private network ipam config. type ReadReplicaEndpointSpecPrivateNetworkIpamConfig struct { } // EngineSetting: engine setting. type EngineSetting struct { // Name: setting name from the database engine. Name string `json:"name"` // DefaultValue: value set when not specified. DefaultValue string `json:"default_value"` // HotConfigurable: setting can be applied without restarting. HotConfigurable bool `json:"hot_configurable"` // Description: setting description. Description string `json:"description"` // PropertyType: setting type. // Default value: BOOLEAN PropertyType EngineSettingPropertyType `json:"property_type"` // Unit: setting base unit. Unit *string `json:"unit"` // StringConstraint: validation regex for string type settings. StringConstraint *string `json:"string_constraint"` // IntMin: minimum value for int types. IntMin *int32 `json:"int_min"` // IntMax: maximum value for int types. IntMax *int32 `json:"int_max"` // FloatMin: minimum value for float types. FloatMin *float32 `json:"float_min"` // FloatMax: maximum value for float types. FloatMax *float32 `json:"float_max"` } // Endpoint: endpoint. type Endpoint struct { // ID: UUID of the endpoint. ID string `json:"id"` // IP: iPv4 address of the endpoint. // Precisely one of IP, Hostname must be set. IP *net.IP `json:"ip,omitempty"` // Port: TCP port of the endpoint. Port uint32 `json:"port"` // Name: name of the endpoint. Name *string `json:"name"` // PrivateNetwork: private Network details. One maximum per Database Instance or Read Replica (a Database Instance and its Read Replica can have different Private Networks). Cannot be updated (has to be deleted and recreated). // Precisely one of PrivateNetwork, LoadBalancer, DirectAccess must be set. PrivateNetwork *EndpointPrivateNetworkDetails `json:"private_network,omitempty"` // LoadBalancer: load Balancer details. Public endpoint for Database Instance which is systematically present. One per Database Instance. // Precisely one of PrivateNetwork, LoadBalancer, DirectAccess must be set. LoadBalancer *EndpointLoadBalancerDetails `json:"load_balancer,omitempty"` // DirectAccess: direct access details. Public endpoint reserved for Read Replicas. One per Read Replica. // Precisely one of PrivateNetwork, LoadBalancer, DirectAccess must be set. DirectAccess *EndpointDirectAccessDetails `json:"direct_access,omitempty"` // Hostname: hostname of the endpoint. // Precisely one of IP, Hostname must be set. Hostname *string `json:"hostname,omitempty"` } // EndpointSpecLoadBalancer: endpoint spec load balancer. type EndpointSpecLoadBalancer struct { } // EndpointSpecPrivateNetwork: endpoint spec private network. type EndpointSpecPrivateNetwork struct { // PrivateNetworkID: UUID of the Private Network to be connected to the Database Instance. PrivateNetworkID string `json:"private_network_id"` // ServiceIP: endpoint IPv4 address with a CIDR notation. Refer to the official Scaleway documentation to learn more about IP and subnet limitations. // Precisely one of ServiceIP, IpamConfig must be set. ServiceIP *scw.IPNet `json:"service_ip,omitempty"` // IpamConfig: automated configuration of your Private Network endpoint with Scaleway IPAM service. One at the most per Database Instance or Read Replica (a Database Instance and its Read Replica can have different Private Networks). Cannot be updated (has to be deleted and recreated). // Precisely one of ServiceIP, IpamConfig must be set. IpamConfig *EndpointSpecPrivateNetworkIpamConfig `json:"ipam_config,omitempty"` } // ReadReplicaEndpointSpecDirectAccess: read replica endpoint spec direct access. type ReadReplicaEndpointSpecDirectAccess struct { } // ReadReplicaEndpointSpecPrivateNetwork: read replica endpoint spec private network. type ReadReplicaEndpointSpecPrivateNetwork struct { // PrivateNetworkID: UUID of the Private Network to be connected to the Read Replica. PrivateNetworkID string `json:"private_network_id"` // ServiceIP: endpoint IPv4 address with a CIDR notation. Refer to the official Scaleway documentation to learn more about IP and subnet limitations. // Precisely one of ServiceIP, IpamConfig must be set. ServiceIP *scw.IPNet `json:"service_ip,omitempty"` // IpamConfig: automated configuration of your Private Network endpoint with Scaleway IPAM service. One at the most per Database Instance or Read Replica (a Database Instance and its Read Replica can have different private networks). Cannot be updated (has to be deleted and recreated). // Precisely one of ServiceIP, IpamConfig must be set. IpamConfig *ReadReplicaEndpointSpecPrivateNetworkIpamConfig `json:"ipam_config,omitempty"` } // EngineVersion: engine version. type EngineVersion struct { // Version: database engine version. Version string `json:"version"` // Name: database engine name. Name string `json:"name"` // EndOfLife: end of life date. EndOfLife *time.Time `json:"end_of_life"` // AvailableSettings: engine settings available to be set. AvailableSettings []*EngineSetting `json:"available_settings"` // Disabled: disabled versions cannot be created. Disabled bool `json:"disabled"` // Beta: beta status of engine version. Beta bool `json:"beta"` // AvailableInitSettings: engine settings available to be set at database initialization. AvailableInitSettings []*EngineSetting `json:"available_init_settings"` } // BackupSchedule: backup schedule. type BackupSchedule struct { // Frequency: frequency of the backup schedule (in hours). Frequency uint32 `json:"frequency"` // Retention: default retention period of backups (in days). Retention uint32 `json:"retention"` // Disabled: defines whether the backup schedule feature is disabled. Disabled bool `json:"disabled"` // NextRunAt: next run of the backup schedule (accurate to 10 minutes). NextRunAt *time.Time `json:"next_run_at"` } // InstanceSetting: instance setting. type InstanceSetting struct { Name string `json:"name"` Value string `json:"value"` } // LogsPolicy: logs policy. type LogsPolicy struct { // MaxAgeRetention: max age (in days) of remote logs to keep on the Database Instance. MaxAgeRetention *uint32 `json:"max_age_retention"` // TotalDiskRetention: max disk size of remote logs to keep on the Database Instance. TotalDiskRetention *scw.Size `json:"total_disk_retention"` } // Maintenance: maintenance. type Maintenance struct { // StartsAt: start date of the maintenance window. StartsAt *time.Time `json:"starts_at"` // StopsAt: end date of the maintenance window. StopsAt *time.Time `json:"stops_at"` // ClosedAt: closed maintenance date. ClosedAt *time.Time `json:"closed_at"` // Reason: maintenance information message. Reason string `json:"reason"` // Status: status of the maintenance. // Default value: unknown Status MaintenanceStatus `json:"status"` } // ReadReplica: read replica. type ReadReplica struct { // ID: UUID of the Read Replica. ID string `json:"id"` // Endpoints: display Read Replica connection information. Endpoints []*Endpoint `json:"endpoints"` // Status: read replica status. // Default value: unknown Status ReadReplicaStatus `json:"status"` // Region: region the Read Replica is in. Region scw.Region `json:"region"` // SameZone: whether the replica is in the same Availability Zone as the main Database Instance nodes or not. SameZone bool `json:"same_zone"` } // UpgradableVersion: upgradable version. type UpgradableVersion struct { ID string `json:"id"` Name string `json:"name"` Version string `json:"version"` MinorVersion string `json:"minor_version"` } // Volume: volume. type Volume struct { // Type: default value: lssd Type VolumeType `json:"type"` Size scw.Size `json:"size"` // Class: default value: unknown_storage_class Class StorageClass `json:"class"` } // NodeTypeVolumeConstraintSizes: node type volume constraint sizes. type NodeTypeVolumeConstraintSizes struct { // MinSize: [deprecated] Mimimum size required for the Volume. MinSize scw.Size `json:"min_size"` // MaxSize: [deprecated] Maximum size required for the Volume. MaxSize scw.Size `json:"max_size"` } // NodeTypeVolumeType: node type volume type. type NodeTypeVolumeType struct { // Type: volume Type. // Default value: lssd Type VolumeType `json:"type"` // Description: the description of the Volume. Description string `json:"description"` // MinSize: mimimum size required for the Volume. MinSize scw.Size `json:"min_size"` // MaxSize: maximum size required for the Volume. MaxSize scw.Size `json:"max_size"` // ChunkSize: minimum increment level for a Block Storage volume size. ChunkSize scw.Size `json:"chunk_size"` // Class: the storage class of the volume. // Default value: unknown_storage_class Class StorageClass `json:"class"` } // SnapshotVolumeType: snapshot volume type. type SnapshotVolumeType struct { // Type: default value: lssd Type VolumeType `json:"type"` // Class: default value: unknown_storage_class Class StorageClass `json:"class"` } // ACLRuleRequest: acl rule request. type ACLRuleRequest struct { IP scw.IPNet `json:"ip"` Description string `json:"description"` } // ACLRule: acl rule. type ACLRule struct { IP scw.IPNet `json:"ip"` // Deprecated Port *uint32 `json:"port,omitempty"` // Protocol: default value: tcp Protocol ACLRuleProtocol `json:"protocol"` // Direction: default value: inbound Direction ACLRuleDirection `json:"direction"` // Action: default value: allow Action ACLRuleAction `json:"action"` Description string `json:"description"` } // EndpointSpec: endpoint spec. type EndpointSpec struct { // LoadBalancer: load Balancer endpoint specifications. Public endpoint for Database Instance which is systematically present. One per Document Database Instance. // Precisely one of LoadBalancer, PrivateNetwork must be set. LoadBalancer *EndpointSpecLoadBalancer `json:"load_balancer,omitempty"` // PrivateNetwork: private Network endpoint specifications. One maximum per Database Instance or Read Replica (a Database Instance and its Read Replica can have different Private Networks). Cannot be updated (has to be deleted and recreated). // Precisely one of LoadBalancer, PrivateNetwork must be set. PrivateNetwork *EndpointSpecPrivateNetwork `json:"private_network,omitempty"` } // ReadReplicaEndpointSpec: read replica endpoint spec. type ReadReplicaEndpointSpec struct { // DirectAccess: direct access endpoint specifications. Public endpoint reserved for Read Replicas. One per Read Replica. // Precisely one of DirectAccess, PrivateNetwork must be set. DirectAccess *ReadReplicaEndpointSpecDirectAccess `json:"direct_access,omitempty"` // PrivateNetwork: private Network endpoint specifications. One at most, per Read Replica. Cannot be updated (has to be deleted and recreated). // Precisely one of DirectAccess, PrivateNetwork must be set. PrivateNetwork *ReadReplicaEndpointSpecPrivateNetwork `json:"private_network,omitempty"` } // DatabaseEngine: database engine. type DatabaseEngine struct { // Name: engine name. Name string `json:"name"` // LogoURL: engine logo URL. LogoURL string `json:"logo_url"` // Versions: available versions. Versions []*EngineVersion `json:"versions"` // Region: region of this Database Instance. Region scw.Region `json:"region"` } // Database: database. type Database struct { // Name: name of the database. Name string `json:"name"` // Owner: name of the database owner. Owner string `json:"owner"` // Managed: defines whether the database is managed or not. Managed bool `json:"managed"` // Size: size of the database. Size scw.Size `json:"size"` } // ListInstanceLogsDetailsResponseInstanceLogDetail: list instance logs details response instance log detail. type ListInstanceLogsDetailsResponseInstanceLogDetail struct { LogName string `json:"log_name"` Size uint64 `json:"size"` } // InstanceLog: instance log. type InstanceLog struct { // DownloadURL: presigned S3 URL to download your log file. DownloadURL *string `json:"download_url"` // ID: UUID of the Database Instance log. ID string `json:"id"` // Status: status of the logs in a Database Instance. // Default value: unknown Status InstanceLogStatus `json:"status"` // NodeName: name of the underlying node. NodeName string `json:"node_name"` // ExpiresAt: expiration date (must follow the ISO 8601 format). ExpiresAt *time.Time `json:"expires_at"` // CreatedAt: creation date (must follow the ISO 8601 format). CreatedAt *time.Time `json:"created_at"` // Region: region the Database Instance is in. Region scw.Region `json:"region"` } // Instance: instance. type Instance struct { // CreatedAt: creation date (must follow the ISO 8601 format). CreatedAt *time.Time `json:"created_at"` // Volume: volumes of the Database Instance. Volume *Volume `json:"volume"` // Region: region the Database Instance is in. Region scw.Region `json:"region"` // ID: UUID of the Database Instance. ID string `json:"id"` // Name: name of the Database Instance. Name string `json:"name"` // OrganizationID: organization ID the Database Instance belongs to. OrganizationID string `json:"organization_id"` // ProjectID: project ID the Database Instance belongs to. ProjectID string `json:"project_id"` // Status: status of the Database Instance. // Default value: unknown Status InstanceStatus `json:"status"` // Engine: database engine of the database. Engine string `json:"engine"` // UpgradableVersion: available database engine versions for upgrade. UpgradableVersion []*UpgradableVersion `json:"upgradable_version"` // Deprecated: Endpoint: endpoint of the Database Instance. Endpoint *Endpoint `json:"endpoint,omitempty"` // Tags: list of tags applied to the Database Instance. Tags []string `json:"tags"` // Settings: advanced settings of the Database Instance. Settings []*InstanceSetting `json:"settings"` // BackupSchedule: backup schedule of the Database Instance. BackupSchedule *BackupSchedule `json:"backup_schedule"` // IsHaCluster: defines whether or not High-Availability is enabled. IsHaCluster bool `json:"is_ha_cluster"` // ReadReplicas: read Replicas of the Database Instance. ReadReplicas []*ReadReplica `json:"read_replicas"` // NodeType: node type of the Database Instance. NodeType string `json:"node_type"` // InitSettings: list of engine settings to be set at Database Instance initialization. InitSettings []*InstanceSetting `json:"init_settings"` // Endpoints: list of Database Instance endpoints. Endpoints []*Endpoint `json:"endpoints"` // LogsPolicy: logs policy of the Database Instance. LogsPolicy *LogsPolicy `json:"logs_policy"` // BackupSameRegion: store logical backups in the same region as the Database Instance. BackupSameRegion bool `json:"backup_same_region"` // Maintenances: list of Database Instance maintenance events. Maintenances []*Maintenance `json:"maintenances"` } // NodeType: node type. type NodeType struct { // Name: node Type name identifier. Name string `json:"name"` // StockStatus: current stock status for the Node Type. // Default value: unknown StockStatus NodeTypeStock `json:"stock_status"` // Description: current specs of the offer. Description string `json:"description"` // Vcpus: number of virtual CPUs. Vcpus uint32 `json:"vcpus"` // Memory: quantity of RAM. Memory scw.Size `json:"memory"` // Deprecated: VolumeConstraint: [deprecated] Node Type volume constraints. VolumeConstraint *NodeTypeVolumeConstraintSizes `json:"volume_constraint,omitempty"` // Deprecated: IsBssdCompatible: the Node Type is compliant with Block Storage. IsBssdCompatible *bool `json:"is_bssd_compatible,omitempty"` // Disabled: the Node Type is currently disabled. Disabled bool `json:"disabled"` // Beta: the Node Type is currently in beta. Beta bool `json:"beta"` // AvailableVolumeTypes: available storage options for the Node Type. AvailableVolumeTypes []*NodeTypeVolumeType `json:"available_volume_types"` // IsHaRequired: the Node Type can be used only with the High Availability option. IsHaRequired bool `json:"is_ha_required"` // Generation: generation associated the NodeType offer. // Default value: unknown_generation Generation NodeTypeGeneration `json:"generation"` // InstanceRange: instance range associated with the NodeType offer. InstanceRange string `json:"instance_range"` // Region: region the Node Type is in. Region scw.Region `json:"region"` } // Privilege: privilege. type Privilege struct { // Permission: permission (Read, Read/Write, All, Custom). // Default value: readonly Permission Permission `json:"permission"` // DatabaseName: name of the database. DatabaseName string `json:"database_name"` // UserName: name of the user. UserName string `json:"user_name"` } // Snapshot: snapshot. type Snapshot struct { // ID: UUID of the snapshot. ID string `json:"id"` // InstanceID: UUID of the Database Instance. InstanceID string `json:"instance_id"` // Name: name of the snapshot. Name string `json:"name"` // Status: status of the snapshot. // Default value: unknown Status SnapshotStatus `json:"status"` // Size: size of the snapshot. Size *scw.Size `json:"size"` // ExpiresAt: expiration date (must follow the ISO 8601 format). ExpiresAt *time.Time `json:"expires_at"` // CreatedAt: creation date (must follow the ISO 8601 format). CreatedAt *time.Time `json:"created_at"` // UpdatedAt: updated date (must follow the ISO 8601 format). UpdatedAt *time.Time `json:"updated_at"` // InstanceName: name of the Database Instance of the snapshot. InstanceName string `json:"instance_name"` // NodeType: source node type. NodeType string `json:"node_type"` // VolumeType: type of volume where data is stored (lssd, bssd or sbs). VolumeType *SnapshotVolumeType `json:"volume_type"` // Region: region of this snapshot. Region scw.Region `json:"region"` } // User: user. type User struct { // Name: name of the user (Length must be between 1 and 63 characters. First character must be an alphabet character (a-zA-Z). Your username cannot start with '_rdb' or 'pg_'. Only a-zA-Z0-9_$- characters are accepted). Name string `json:"name"` // IsAdmin: defines whether or not a user got administrative privileges on the Database Instance. IsAdmin bool `json:"is_admin"` } // UpgradeInstanceRequestMajorUpgradeWorkflow: upgrade instance request major upgrade workflow. type UpgradeInstanceRequestMajorUpgradeWorkflow struct { // UpgradableVersionID: this will create a new Database Instance with same specifications as the current one and perform a Database Engine upgrade. UpgradableVersionID string `json:"upgradable_version_id"` // WithEndpoints: at the end of the migration procedure this option let you migrate all your database endpoint to the upgraded instance. WithEndpoints bool `json:"with_endpoints"` } // AddInstanceACLRulesRequest: add instance acl rules request. type AddInstanceACLRulesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you want to add ACL rules to. InstanceID string `json:"-"` // Rules: ACL rules to add to the Database Instance. Rules []*ACLRuleRequest `json:"rules"` } // AddInstanceACLRulesResponse: add instance acl rules response. type AddInstanceACLRulesResponse struct { // Rules: ACL Rules enabled for the Database Instance. Rules []*ACLRule `json:"rules"` } // AddInstanceSettingsRequest: add instance settings request. type AddInstanceSettingsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you want to add settings to. InstanceID string `json:"-"` // Settings: settings to add to the Database Instance. Settings []*InstanceSetting `json:"settings"` } // AddInstanceSettingsResponse: add instance settings response. type AddInstanceSettingsResponse struct { // Settings: settings available on the Database Instance. Settings []*InstanceSetting `json:"settings"` } // CloneInstanceRequest: clone instance request. type CloneInstanceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you want to clone. InstanceID string `json:"-"` // Name: name of the Database Instance clone. Name string `json:"name"` // NodeType: node type of the clone. NodeType *string `json:"node_type,omitempty"` } // CreateDatabaseRequest: create database request. type CreateDatabaseRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance where to create the database. InstanceID string `json:"-"` // Name: name of the database. Name string `json:"name"` } // CreateEndpointRequest: create endpoint request. type CreateEndpointRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you to which you want to add an endpoint. InstanceID string `json:"-"` // EndpointSpec: specification of the endpoint you want to create. EndpointSpec *EndpointSpec `json:"endpoint_spec,omitempty"` } // CreateInstanceFromSnapshotRequest: create instance from snapshot request. type CreateInstanceFromSnapshotRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SnapshotID: block snapshot of the Database Instance. SnapshotID string `json:"-"` // InstanceName: name of the Database Instance created with the snapshot. InstanceName string `json:"instance_name"` // IsHaCluster: defines whether or not High Availability is enabled on the new Database Instance. IsHaCluster *bool `json:"is_ha_cluster,omitempty"` // NodeType: the node type used to restore the snapshot. NodeType *string `json:"node_type,omitempty"` } // CreateInstanceRequest: create instance request. type CreateInstanceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Deprecated: OrganizationID: please use project_id instead. // Precisely one of OrganizationID, ProjectID must be set. OrganizationID *string `json:"organization_id,omitempty"` // ProjectID: the Project ID on which the Database Instance will be created. // Precisely one of OrganizationID, ProjectID must be set. ProjectID *string `json:"project_id,omitempty"` // Name: name of the Database Instance. Name string `json:"name"` // Engine: database engine of the Database Instance. Engine string `json:"engine"` // UserName: username created when the Database Instance is created. UserName string `json:"user_name"` // Password: password of the user. Password string `json:"password"` // NodeType: type of node to use for the Database Instance. NodeType string `json:"node_type"` // IsHaCluster: defines whether or not High-Availability is enabled. IsHaCluster bool `json:"is_ha_cluster"` // DisableBackup: defines whether or not backups are disabled. DisableBackup bool `json:"disable_backup"` // Tags: tags to apply to the Database Instance. Tags []string `json:"tags"` // InitSettings: list of engine settings to be set upon Database Instance initialization. InitSettings []*InstanceSetting `json:"init_settings"` // VolumeType: type of volume where data is stored (lssd, bssd, ...). // Default value: lssd VolumeType VolumeType `json:"volume_type"` // VolumeSize: volume size when volume_type is not lssd. VolumeSize scw.Size `json:"volume_size"` // InitEndpoints: one or multiple EndpointSpec used to expose your Database Instance. A load_balancer public endpoint is systematically created. InitEndpoints []*EndpointSpec `json:"init_endpoints"` // BackupSameRegion: defines whether to or not to store logical backups in the same region as the Database Instance. BackupSameRegion bool `json:"backup_same_region"` } // CreateReadReplicaEndpointRequest: create read replica endpoint request. type CreateReadReplicaEndpointRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ReadReplicaID: UUID of the Read Replica. ReadReplicaID string `json:"-"` // EndpointSpec: specification of the endpoint you want to create. EndpointSpec []*ReadReplicaEndpointSpec `json:"endpoint_spec"` } // CreateReadReplicaRequest: create read replica request. type CreateReadReplicaRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you want to create a Read Replica from. InstanceID string `json:"instance_id"` // EndpointSpec: specification of the endpoint you want to create. EndpointSpec []*ReadReplicaEndpointSpec `json:"endpoint_spec"` // SameZone: defines whether or not to create the replica in the same Availability Zone as the main Database Instance nodes. SameZone *bool `json:"same_zone,omitempty"` } // CreateSnapshotRequest: create snapshot request. type CreateSnapshotRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance. InstanceID string `json:"-"` // Name: name of the snapshot. Name string `json:"name"` // ExpiresAt: expiration date (must follow the ISO 8601 format). ExpiresAt *time.Time `json:"expires_at,omitempty"` } // CreateUserRequest: create user request. type CreateUserRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance in which you want to create a user. InstanceID string `json:"-"` // Name: name of the user you want to create. Name string `json:"name"` // Password: password of the user you want to create. Password string `json:"password"` // IsAdmin: defines whether the user will have administrative privileges. IsAdmin bool `json:"is_admin"` } // DeleteDatabaseRequest: delete database request. type DeleteDatabaseRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance where to delete the database. InstanceID string `json:"-"` // Name: name of the database to delete. Name string `json:"-"` } // DeleteEndpointRequest: delete endpoint request. type DeleteEndpointRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // EndpointID: this endpoint can also be used to delete a Read Replica endpoint. EndpointID string `json:"-"` } // DeleteInstanceACLRulesRequest: delete instance acl rules request. type DeleteInstanceACLRulesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you want to delete an ACL rule from. InstanceID string `json:"-"` // ACLRuleIPs: IP addresses defined in the ACL rules of the Database Instance. ACLRuleIPs []string `json:"acl_rule_ips"` } // DeleteInstanceACLRulesResponse: delete instance acl rules response. type DeleteInstanceACLRulesResponse struct { // Rules: IP addresses defined in the ACL rules of the Database Instance. Rules []*ACLRule `json:"rules"` } // DeleteInstanceRequest: delete instance request. type DeleteInstanceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance to delete. InstanceID string `json:"-"` } // DeleteInstanceSettingsRequest: delete instance settings request. type DeleteInstanceSettingsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance to delete settings from. InstanceID string `json:"-"` // SettingNames: settings names to delete. SettingNames []string `json:"setting_names"` } // DeleteInstanceSettingsResponse: delete instance settings response. type DeleteInstanceSettingsResponse struct { // Settings: settings names to delete from the Database Instance. Settings []*InstanceSetting `json:"settings"` } // DeleteReadReplicaRequest: delete read replica request. type DeleteReadReplicaRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ReadReplicaID: UUID of the Read Replica. ReadReplicaID string `json:"-"` } // DeleteSnapshotRequest: delete snapshot request. type DeleteSnapshotRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SnapshotID: UUID of the snapshot to delete. SnapshotID string `json:"-"` } // DeleteUserRequest: delete user request. type DeleteUserRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance to delete the user from. InstanceID string `json:"-"` // Name: name of the user. Name string `json:"-"` } // GetEndpointRequest: get endpoint request. type GetEndpointRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // EndpointID: UUID of the endpoint you want to get. EndpointID string `json:"-"` } // GetInstanceCertificateRequest: get instance certificate request. type GetInstanceCertificateRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance. InstanceID string `json:"-"` } // GetInstanceLogRequest: get instance log request. type GetInstanceLogRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceLogID: UUID of the instance_log you want. InstanceLogID string `json:"-"` } // GetInstanceMetricsRequest: get instance metrics request. type GetInstanceMetricsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance. InstanceID string `json:"-"` // StartDate: start date to gather metrics from. StartDate *time.Time `json:"-"` // EndDate: end date to gather metrics from. EndDate *time.Time `json:"-"` // MetricName: name of the metric to gather. MetricName *string `json:"-"` } // GetInstanceRequest: get instance request. type GetInstanceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance. InstanceID string `json:"-"` } // GetReadReplicaRequest: get read replica request. type GetReadReplicaRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ReadReplicaID: UUID of the Read Replica. ReadReplicaID string `json:"-"` } // GetSnapshotRequest: get snapshot request. type GetSnapshotRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SnapshotID: UUID of the snapshot. SnapshotID string `json:"-"` } // InstanceMetrics: instance metrics. type InstanceMetrics struct { // Timeseries: time series of metrics of a Database Instance. Timeseries []*scw.TimeSeries `json:"timeseries"` } // ListDatabaseEnginesRequest: list database engines request. type ListDatabaseEnginesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Name: name of the database engine. Name *string `json:"-"` // Version: version of the database engine. Version *string `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` } // ListDatabaseEnginesResponse: list database engines response. type ListDatabaseEnginesResponse struct { // Engines: list of the available database engines. Engines []*DatabaseEngine `json:"engines"` // TotalCount: total count of database engines available. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListDatabaseEnginesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListDatabaseEnginesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListDatabaseEnginesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Engines = append(r.Engines, results.Engines...) r.TotalCount += uint32(len(results.Engines)) return uint32(len(results.Engines)), nil } // ListDatabasesRequest: list databases request. type ListDatabasesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance to list the databases of. InstanceID string `json:"-"` // Name: name of the database. Name *string `json:"-"` // Managed: defines whether or not the database is managed. Managed *bool `json:"-"` // Owner: user that owns this database. Owner *string `json:"-"` // OrderBy: criteria to use when ordering database listing. // Default value: name_asc OrderBy ListDatabasesRequestOrderBy `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` } // ListDatabasesResponse: list databases response. type ListDatabasesResponse struct { // Databases: list of the databases. Databases []*Database `json:"databases"` // TotalCount: total count of databases present on a Database Instance. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListDatabasesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListDatabasesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListDatabasesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Databases = append(r.Databases, results.Databases...) r.TotalCount += uint32(len(results.Databases)) return uint32(len(results.Databases)), nil } // ListInstanceACLRulesRequest: list instance acl rules request. type ListInstanceACLRulesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance. InstanceID string `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` } // ListInstanceACLRulesResponse: list instance acl rules response. type ListInstanceACLRulesResponse struct { // Rules: list of ACL rules present on a Database Instance. Rules []*ACLRule `json:"rules"` // TotalCount: total count of ACL rules present on a Database Instance. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListInstanceACLRulesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListInstanceACLRulesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListInstanceACLRulesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Rules = append(r.Rules, results.Rules...) r.TotalCount += uint32(len(results.Rules)) return uint32(len(results.Rules)), nil } // ListInstanceLogsDetailsRequest: list instance logs details request. type ListInstanceLogsDetailsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you want logs of. InstanceID string `json:"-"` } // ListInstanceLogsDetailsResponse: list instance logs details response. type ListInstanceLogsDetailsResponse struct { // Details: remote Database Instance logs details. Details []*ListInstanceLogsDetailsResponseInstanceLogDetail `json:"details"` } // ListInstanceLogsRequest: list instance logs request. type ListInstanceLogsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you want logs of. InstanceID string `json:"-"` // OrderBy: criteria to use when ordering Database Instance logs listing. // Default value: created_at_asc OrderBy ListInstanceLogsRequestOrderBy `json:"order_by"` } // ListInstanceLogsResponse: list instance logs response. type ListInstanceLogsResponse struct { // InstanceLogs: available logs in a Database Instance. InstanceLogs []*InstanceLog `json:"instance_logs"` } // ListInstancesRequest: list instances request. type ListInstancesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Tags: list Database Instances that have a given tag. Tags []string `json:"-"` // Name: lists Database Instances that match a name pattern. Name *string `json:"-"` // OrderBy: criteria to use when ordering Database Instance listings. // Default value: created_at_asc OrderBy ListInstancesRequestOrderBy `json:"-"` // OrganizationID: please use project_id instead. OrganizationID *string `json:"-"` // ProjectID: project ID to list the Database Instance of. ProjectID *string `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` } // ListInstancesResponse: list instances response. type ListInstancesResponse struct { // Instances: list of all Database Instances available in an Organization or Project. Instances []*Instance `json:"instances"` // TotalCount: total count of Database Instances available in a Organization or Project. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListInstancesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListInstancesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListInstancesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Instances = append(r.Instances, results.Instances...) r.TotalCount += uint32(len(results.Instances)) return uint32(len(results.Instances)), nil } // ListNodeTypesRequest: list node types request. type ListNodeTypesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // IncludeDisabledTypes: defines whether or not to include disabled types. IncludeDisabledTypes bool `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` } // ListNodeTypesResponse: list node types response. type ListNodeTypesResponse struct { // NodeTypes: types of the node. NodeTypes []*NodeType `json:"node_types"` // TotalCount: total count of node-types available. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListNodeTypesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListNodeTypesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListNodeTypesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.NodeTypes = append(r.NodeTypes, results.NodeTypes...) r.TotalCount += uint32(len(results.NodeTypes)) return uint32(len(results.NodeTypes)), nil } // ListPrivilegesRequest: list privileges request. type ListPrivilegesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance. InstanceID string `json:"-"` // OrderBy: criteria to use when ordering privileges listing. // Default value: user_name_asc OrderBy ListPrivilegesRequestOrderBy `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` // DatabaseName: name of the database. DatabaseName *string `json:"-"` // UserName: name of the user. UserName *string `json:"-"` } // ListPrivilegesResponse: list privileges response. type ListPrivilegesResponse struct { // Privileges: privileges of a user in a database in a Database Instance. Privileges []*Privilege `json:"privileges"` // TotalCount: total count of privileges present on a database. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListPrivilegesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListPrivilegesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListPrivilegesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Privileges = append(r.Privileges, results.Privileges...) r.TotalCount += uint32(len(results.Privileges)) return uint32(len(results.Privileges)), nil } // ListSnapshotsRequest: list snapshots request. type ListSnapshotsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Name: name of the snapshot. Name *string `json:"-"` // OrderBy: criteria to use when ordering snapshot listing. // Default value: created_at_asc OrderBy ListSnapshotsRequestOrderBy `json:"-"` // InstanceID: UUID of the Database Instance. InstanceID *string `json:"-"` // OrganizationID: organization ID the snapshots belongs to. OrganizationID *string `json:"-"` // ProjectID: project ID the snapshots belongs to. ProjectID *string `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` } // ListSnapshotsResponse: list snapshots response. type ListSnapshotsResponse struct { // Snapshots: list of snapshots. Snapshots []*Snapshot `json:"snapshots"` // TotalCount: total count of snapshots available. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListSnapshotsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListSnapshotsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListSnapshotsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Snapshots = append(r.Snapshots, results.Snapshots...) r.TotalCount += uint32(len(results.Snapshots)) return uint32(len(results.Snapshots)), nil } // ListUsersRequest: list users request. type ListUsersRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance. InstanceID string `json:"-"` // Name: name of the user. Name *string `json:"-"` // OrderBy: criteria to use when requesting user listing. // Default value: name_asc OrderBy ListUsersRequestOrderBy `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` } // ListUsersResponse: list users response. type ListUsersResponse struct { // Users: list of users in a Database Instance. Users []*User `json:"users"` // TotalCount: total count of users present on a Database Instance. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListUsersResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListUsersResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListUsersResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Users = append(r.Users, results.Users...) r.TotalCount += uint32(len(results.Users)) return uint32(len(results.Users)), nil } // MigrateEndpointRequest: migrate endpoint request. type MigrateEndpointRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // EndpointID: UUID of the endpoint you want to migrate. EndpointID string `json:"-"` // InstanceID: UUID of the instance you want to attach the endpoint to. InstanceID string `json:"instance_id"` } // PromoteReadReplicaRequest: promote read replica request. type PromoteReadReplicaRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ReadReplicaID: UUID of the Read Replica. ReadReplicaID string `json:"-"` } // PurgeInstanceLogsRequest: purge instance logs request. type PurgeInstanceLogsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you want logs of. InstanceID string `json:"-"` // LogName: given log name to purge. LogName *string `json:"log_name,omitempty"` } // RenewInstanceCertificateRequest: renew instance certificate request. type RenewInstanceCertificateRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you want logs of. InstanceID string `json:"-"` } // ResetReadReplicaRequest: reset read replica request. type ResetReadReplicaRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ReadReplicaID: UUID of the Read Replica. ReadReplicaID string `json:"-"` } // RestartInstanceRequest: restart instance request. type RestartInstanceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you want to restart. InstanceID string `json:"-"` } // SetInstanceACLRulesRequest: set instance acl rules request. type SetInstanceACLRulesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance where the ACL rules must be set. InstanceID string `json:"-"` // Rules: ACL rules to define for the Database Instance. Rules []*ACLRuleRequest `json:"rules"` } // SetInstanceACLRulesResponse: set instance acl rules response. type SetInstanceACLRulesResponse struct { // Rules: aCLs rules configured for a Database Instance. Rules []*ACLRule `json:"rules"` } // SetInstanceSettingsRequest: set instance settings request. type SetInstanceSettingsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance where the settings must be set. InstanceID string `json:"-"` // Settings: settings to define for the Database Instance. Settings []*InstanceSetting `json:"settings"` } // SetInstanceSettingsResponse: set instance settings response. type SetInstanceSettingsResponse struct { // Settings: settings configured for a Database Instance. Settings []*InstanceSetting `json:"settings"` } // SetPrivilegeRequest: set privilege request. type SetPrivilegeRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance. InstanceID string `json:"-"` // DatabaseName: name of the database. DatabaseName string `json:"database_name"` // UserName: name of the user. UserName string `json:"user_name"` // Permission: permission to set (Read, Read/Write, All, Custom). // Default value: readonly Permission Permission `json:"permission"` } // UpdateInstanceRequest: update instance request. type UpdateInstanceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance to update. InstanceID string `json:"-"` // BackupScheduleFrequency: in hours. BackupScheduleFrequency *uint32 `json:"backup_schedule_frequency,omitempty"` // BackupScheduleRetention: in days. BackupScheduleRetention *uint32 `json:"backup_schedule_retention,omitempty"` // IsBackupScheduleDisabled: defines whether or not the backup schedule is disabled. IsBackupScheduleDisabled *bool `json:"is_backup_schedule_disabled,omitempty"` // Name: name of the Database Instance. Name *string `json:"name,omitempty"` // Tags: tags of a Database Instance. Tags *[]string `json:"tags,omitempty"` // LogsPolicy: logs policy of the Database Instance. LogsPolicy *LogsPolicy `json:"logs_policy,omitempty"` // BackupSameRegion: store logical backups in the same region as the Database Instance. BackupSameRegion *bool `json:"backup_same_region,omitempty"` // BackupScheduleStartHour: defines the start time of the autobackup. BackupScheduleStartHour *uint32 `json:"backup_schedule_start_hour,omitempty"` } // UpdateSnapshotRequest: update snapshot request. type UpdateSnapshotRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SnapshotID: UUID of the snapshot to update. SnapshotID string `json:"-"` // Name: name of the snapshot. Name *string `json:"name,omitempty"` // ExpiresAt: expiration date (must follow the ISO 8601 format). ExpiresAt *time.Time `json:"expires_at,omitempty"` } // UpdateUserRequest: update user request. type UpdateUserRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance the user belongs to. InstanceID string `json:"-"` // Name: name of the database user. Name string `json:"-"` // Password: password of the database user. Password *string `json:"password,omitempty"` // IsAdmin: defines whether or not this user got administrative privileges. IsAdmin *bool `json:"is_admin,omitempty"` } // UpgradeInstanceRequest: upgrade instance request. type UpgradeInstanceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you want to upgrade. InstanceID string `json:"-"` // NodeType: node type of the Database Instance you want to upgrade to. // Precisely one of NodeType, EnableHa, VolumeSize, VolumeType, UpgradableVersionID, MajorUpgradeWorkflow must be set. NodeType *string `json:"node_type,omitempty"` // EnableHa: defines whether or not High Availability should be enabled on the Database Instance. // Precisely one of NodeType, EnableHa, VolumeSize, VolumeType, UpgradableVersionID, MajorUpgradeWorkflow must be set. EnableHa *bool `json:"enable_ha,omitempty"` // VolumeSize: increase your Block volume size. // Precisely one of NodeType, EnableHa, VolumeSize, VolumeType, UpgradableVersionID, MajorUpgradeWorkflow must be set. VolumeSize *uint64 `json:"volume_size,omitempty"` // VolumeType: change your Database Instance storage type. // Default value: lssd // Precisely one of NodeType, EnableHa, VolumeSize, VolumeType, UpgradableVersionID, MajorUpgradeWorkflow must be set. VolumeType *VolumeType `json:"volume_type,omitempty"` // UpgradableVersionID: this will create a new Database Instance with same specifications as the current one and perform a Database Engine upgrade. // Precisely one of NodeType, EnableHa, VolumeSize, VolumeType, UpgradableVersionID, MajorUpgradeWorkflow must be set. UpgradableVersionID *string `json:"upgradable_version_id,omitempty"` // MajorUpgradeWorkflow: upgrade your database engine to a new major version including instance endpoints. // Precisely one of NodeType, EnableHa, VolumeSize, VolumeType, UpgradableVersionID, MajorUpgradeWorkflow must be set. MajorUpgradeWorkflow *UpgradeInstanceRequestMajorUpgradeWorkflow `json:"major_upgrade_workflow,omitempty"` } type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Regions() []scw.Region { return []scw.Region{scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw} } // ListDatabaseEngines: List the FerretDB database engines available at Scaleway. func (s *API) ListDatabaseEngines(req *ListDatabaseEnginesRequest, opts ...scw.RequestOption) (*ListDatabaseEnginesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "version", req.Version) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/database-engines", Query: query, } var resp ListDatabaseEnginesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListNodeTypes: List all available node types. By default, the node types returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. func (s *API) ListNodeTypes(req *ListNodeTypesRequest, opts ...scw.RequestOption) (*ListNodeTypesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "include_disabled_types", req.IncludeDisabledTypes) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/node-types", Query: query, } var resp ListNodeTypesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpgradeInstance: Upgrade your current Database Instance specifications like node type, high availability, volume, or the database engine version. Note that upon upgrade the `enable_ha` parameter can only be set to `true`. func (s *API) UpgradeInstance(req *UpgradeInstanceRequest, opts ...scw.RequestOption) (*Instance, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/upgrade", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Instance err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListInstances: List all Database Instances in the specified region, for a given Scaleway Organization or Scaleway Project. By default, the Database Instances returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. You can define additional parameters for your query, such as `tags` and `name`. For the `name` parameter, the value you include will be checked against the whole name string to see if it includes the string you put in the parameter. func (s *API) ListInstances(req *ListInstancesRequest, opts ...scw.RequestOption) (*ListInstancesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "tags", req.Tags) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances", Query: query, } var resp ListInstancesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetInstance: Retrieve information about a given Database Instance, specified by the `region` and `instance_id` parameters. Its full details, including name, status, IP address and port, are returned in the response object. func (s *API) GetInstance(req *GetInstanceRequest, opts ...scw.RequestOption) (*Instance, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "", } var resp Instance err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateInstance: Create a new Database Instance. You must set the `engine`, `user_name`, `password` and `node_type` parameters. Optionally, you can specify the volume type and size. func (s *API) CreateInstance(req *CreateInstanceRequest, opts ...scw.RequestOption) (*Instance, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultOrganizationID, exist := s.client.GetDefaultOrganizationID() if exist && req.OrganizationID == nil && req.ProjectID == nil { req.OrganizationID = &defaultOrganizationID } defaultProjectID, exist := s.client.GetDefaultProjectID() if exist && req.OrganizationID == nil && req.ProjectID == nil { req.ProjectID = &defaultProjectID } if req.Name == "" { req.Name = namegenerator.GetRandomName("ins") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Instance err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateInstance: Update the parameters of a Database Instance, including name, tags and backup schedule details. func (s *API) UpdateInstance(req *UpdateInstanceRequest, opts ...scw.RequestOption) (*Instance, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Instance err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteInstance: Delete a given Database Instance, specified by the `region` and `instance_id` parameters. Deleting a Database Instance is permanent, and cannot be undone. Note that upon deletion all your data will be lost. func (s *API) DeleteInstance(req *DeleteInstanceRequest, opts ...scw.RequestOption) (*Instance, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "", } var resp Instance err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CloneInstance: Clone a given Database Instance, specified by the `region` and `instance_id` parameters. The clone feature allows you to create a new Database Instance from an existing one. The clone includes all existing databases, users and permissions. You can create a clone on a Database Instance bigger than your current one. func (s *API) CloneInstance(req *CloneInstanceRequest, opts ...scw.RequestOption) (*Instance, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/clone", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Instance err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // RestartInstance: Restart a given Database Instance, specified by the `region` and `instance_id` parameters. The status of the Database Instance returned in the response. func (s *API) RestartInstance(req *RestartInstanceRequest, opts ...scw.RequestOption) (*Instance, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/restart", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Instance err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetInstanceCertificate: Retrieve information about the TLS certificate of a given Database Instance. Details like name and content are returned in the response. func (s *API) GetInstanceCertificate(req *GetInstanceCertificateRequest, opts ...scw.RequestOption) (*scw.File, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/certificate", } var resp scw.File err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // RenewInstanceCertificate: Renew a TLS for a Database Instance. Renewing a certificate means that you will not be able to connect to your Database Instance using the previous certificate. You will also need to download and update the new certificate for all database clients. func (s *API) RenewInstanceCertificate(req *RenewInstanceCertificateRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/renew-certificate", } err = scwReq.SetBody(req) if err != nil { return err } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // GetInstanceMetrics: Retrieve the time series metrics of a given Database Instance. You can define the period from which to retrieve metrics by specifying the `start_date` and `end_date`. func (s *API) GetInstanceMetrics(req *GetInstanceMetricsRequest, opts ...scw.RequestOption) (*InstanceMetrics, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } query := url.Values{} parameter.AddToQuery(query, "start_date", req.StartDate) parameter.AddToQuery(query, "end_date", req.EndDate) parameter.AddToQuery(query, "metric_name", req.MetricName) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/metrics", Query: query, } var resp InstanceMetrics err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateReadReplica: Create a new Read Replica of a Database Instance. You must specify the `region` and the `instance_id`. You can only create a maximum of 3 Read Replicas per Database Instance. func (s *API) CreateReadReplica(req *CreateReadReplicaRequest, opts ...scw.RequestOption) (*ReadReplica, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/read-replicas", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp ReadReplica err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetReadReplica: Retrieve information about a Database Instance Read Replica. Full details about the Read Replica, like `endpoints`, `status` and `region` are returned in the response. func (s *API) GetReadReplica(req *GetReadReplicaRequest, opts ...scw.RequestOption) (*ReadReplica, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ReadReplicaID) == "" { return nil, errors.New("field ReadReplicaID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/read-replicas/" + fmt.Sprint(req.ReadReplicaID) + "", } var resp ReadReplica err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteReadReplica: Delete a Read Replica of a Database Instance. You must specify the `region` and `read_replica_id` parameters of the Read Replica you want to delete. func (s *API) DeleteReadReplica(req *DeleteReadReplicaRequest, opts ...scw.RequestOption) (*ReadReplica, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ReadReplicaID) == "" { return nil, errors.New("field ReadReplicaID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/read-replicas/" + fmt.Sprint(req.ReadReplicaID) + "", } var resp ReadReplica err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ResetReadReplica: When you resync a Read Replica, first it is reset, then its data is resynchronized from the primary node. Your Read Replica remains unavailable during the resync process. The duration of this process is proportional to the size of your Database Instance. // The configured endpoints do not change. func (s *API) ResetReadReplica(req *ResetReadReplicaRequest, opts ...scw.RequestOption) (*ReadReplica, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ReadReplicaID) == "" { return nil, errors.New("field ReadReplicaID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/read-replicas/" + fmt.Sprint(req.ReadReplicaID) + "/reset", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp ReadReplica err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // PromoteReadReplica: Promote a Read Replica to Database Instance automatically. func (s *API) PromoteReadReplica(req *PromoteReadReplicaRequest, opts ...scw.RequestOption) (*Instance, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ReadReplicaID) == "" { return nil, errors.New("field ReadReplicaID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/read-replicas/" + fmt.Sprint(req.ReadReplicaID) + "/promote", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Instance err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateReadReplicaEndpoint: Create a new endpoint for a Read Replica. Read Replicas can have at most one direct access and one Private Network endpoint. func (s *API) CreateReadReplicaEndpoint(req *CreateReadReplicaEndpointRequest, opts ...scw.RequestOption) (*ReadReplica, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ReadReplicaID) == "" { return nil, errors.New("field ReadReplicaID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/read-replicas/" + fmt.Sprint(req.ReadReplicaID) + "/endpoints", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp ReadReplica err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListInstanceLogs: List the available logs of a Database Instance. By default, the logs returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. func (s *API) ListInstanceLogs(req *ListInstanceLogsRequest, opts ...scw.RequestOption) (*ListInstanceLogsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/logs", Query: query, } var resp ListInstanceLogsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetInstanceLog: Retrieve information about the logs of a Database Instance. Specify the `instance_log_id` and `region` in your request to get information such as `download_url`, `status`, `expires_at` and `created_at` about your logs in the response. func (s *API) GetInstanceLog(req *GetInstanceLogRequest, opts ...scw.RequestOption) (*InstanceLog, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceLogID) == "" { return nil, errors.New("field InstanceLogID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/logs/" + fmt.Sprint(req.InstanceLogID) + "", } var resp InstanceLog err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // PurgeInstanceLogs: Purge a given remote log from a Database Instance. You can specify the `log_name` of the log you wish to clean from your Database Instance. func (s *API) PurgeInstanceLogs(req *PurgeInstanceLogsRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/purge-logs", } err = scwReq.SetBody(req) if err != nil { return err } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListInstanceLogsDetails: List remote log details. By default, the details returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. func (s *API) ListInstanceLogsDetails(req *ListInstanceLogsDetailsRequest, opts ...scw.RequestOption) (*ListInstanceLogsDetailsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/logs-details", } var resp ListInstanceLogsDetailsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // AddInstanceSettings: Add an advanced setting to a Database Instance. You must set the `name` and the `value` of each setting. func (s *API) AddInstanceSettings(req *AddInstanceSettingsRequest, opts ...scw.RequestOption) (*AddInstanceSettingsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/settings", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp AddInstanceSettingsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteInstanceSettings: Delete an advanced setting in a Database Instance. You must specify the names of the settings you want to delete in the request. func (s *API) DeleteInstanceSettings(req *DeleteInstanceSettingsRequest, opts ...scw.RequestOption) (*DeleteInstanceSettingsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/settings", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp DeleteInstanceSettingsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SetInstanceSettings: Update an advanced setting for a Database Instance. Settings added upon database engine initalization can only be defined once, and cannot, therefore, be updated. func (s *API) SetInstanceSettings(req *SetInstanceSettingsRequest, opts ...scw.RequestOption) (*SetInstanceSettingsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/settings", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SetInstanceSettingsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListInstanceACLRules: List the ACL rules for a given Database Instance. The response is an array of ACL objects, each one representing an ACL that denies, allows or redirects traffic based on certain conditions. func (s *API) ListInstanceACLRules(req *ListInstanceACLRulesRequest, opts ...scw.RequestOption) (*ListInstanceACLRulesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/acls", Query: query, } var resp ListInstanceACLRulesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // AddInstanceACLRules: Add an additional ACL rule to a Database Instance. func (s *API) AddInstanceACLRules(req *AddInstanceACLRulesRequest, opts ...scw.RequestOption) (*AddInstanceACLRulesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/acls", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp AddInstanceACLRulesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SetInstanceACLRules: Replace all the ACL rules of a Database Instance. func (s *API) SetInstanceACLRules(req *SetInstanceACLRulesRequest, opts ...scw.RequestOption) (*SetInstanceACLRulesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/acls", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SetInstanceACLRulesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteInstanceACLRules: Delete one or more ACL rules of a Database Instance. func (s *API) DeleteInstanceACLRules(req *DeleteInstanceACLRulesRequest, opts ...scw.RequestOption) (*DeleteInstanceACLRulesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/acls", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp DeleteInstanceACLRulesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListUsers: List all users of a given Database Instance. By default, the users returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. func (s *API) ListUsers(req *ListUsersRequest, opts ...scw.RequestOption) (*ListUsersResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/users", Query: query, } var resp ListUsersResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateUser: Create a new user for a Database Instance. You must define the `name`, `password` and `is_admin` parameters. func (s *API) CreateUser(req *CreateUserRequest, opts ...scw.RequestOption) (*User, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/users", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp User err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateUser: Update the parameters of a user on a Database Instance. You can update the `password` and `is_admin` parameters, but you cannot change the name of the user. func (s *API) UpdateUser(req *UpdateUserRequest, opts ...scw.RequestOption) (*User, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } if fmt.Sprint(req.Name) == "" { return nil, errors.New("field Name cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/users/" + fmt.Sprint(req.Name) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp User err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteUser: Delete a given user on a Database Instance. You must specify, in the endpoint, the `region`, `instance_id` and `name` parameters of the user you want to delete. func (s *API) DeleteUser(req *DeleteUserRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return errors.New("field InstanceID cannot be empty in request") } if fmt.Sprint(req.Name) == "" { return errors.New("field Name cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/users/" + fmt.Sprint(req.Name) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListDatabases: List all databases of a given Database Instance. By default, the databases returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. You can define additional parameters for your query, such as `name`, `managed` and `owner`. func (s *API) ListDatabases(req *ListDatabasesRequest, opts ...scw.RequestOption) (*ListDatabasesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "managed", req.Managed) parameter.AddToQuery(query, "owner", req.Owner) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/databases", Query: query, } var resp ListDatabasesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateDatabase: Create a new database. You must define the `name` parameter in the request. func (s *API) CreateDatabase(req *CreateDatabaseRequest, opts ...scw.RequestOption) (*Database, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/databases", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Database err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteDatabase: Delete a given database on a Database Instance. You must specify, in the endpoint, the `region`, `instance_id` and `name` parameters of the database you want to delete. func (s *API) DeleteDatabase(req *DeleteDatabaseRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return errors.New("field InstanceID cannot be empty in request") } if fmt.Sprint(req.Name) == "" { return errors.New("field Name cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/databases/" + fmt.Sprint(req.Name) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListPrivileges: List privileges of a user on a database. By default, the details returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. You can define additional parameters for your query, such as `database_name` and `user_name`. func (s *API) ListPrivileges(req *ListPrivilegesRequest, opts ...scw.RequestOption) (*ListPrivilegesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "database_name", req.DatabaseName) parameter.AddToQuery(query, "user_name", req.UserName) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/privileges", Query: query, } var resp ListPrivilegesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SetPrivilege: Set the privileges of a user on a database. You must define `database_name`, `user_name` and `permission` in the request body. func (s *API) SetPrivilege(req *SetPrivilegeRequest, opts ...scw.RequestOption) (*Privilege, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/privileges", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Privilege err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListSnapshots: List snapshots. You can include the `instance_id` or `project_id` in your query to get the list of snapshots for specific Database Instances and/or Projects. By default, the details returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. func (s *API) ListSnapshots(req *ListSnapshotsRequest, opts ...scw.RequestOption) (*ListSnapshotsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "instance_id", req.InstanceID) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/snapshots", Query: query, } var resp ListSnapshotsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetSnapshot: Retrieve information about a given snapshot, specified by its `snapshot_id` and `region`. Full details about the snapshot, like size and expiration date, are returned in the response. func (s *API) GetSnapshot(req *GetSnapshotRequest, opts ...scw.RequestOption) (*Snapshot, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SnapshotID) == "" { return nil, errors.New("field SnapshotID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/snapshots/" + fmt.Sprint(req.SnapshotID) + "", } var resp Snapshot err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateSnapshot: Create a new snapshot of a Database Instance. You must define the `name` parameter in the request. func (s *API) CreateSnapshot(req *CreateSnapshotRequest, opts ...scw.RequestOption) (*Snapshot, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.Name == "" { req.Name = namegenerator.GetRandomName("snp") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/snapshots", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Snapshot err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateSnapshot: Update the parameters of a snapshot of a Database Instance. You can update the `name` and `expires_at` parameters. func (s *API) UpdateSnapshot(req *UpdateSnapshotRequest, opts ...scw.RequestOption) (*Snapshot, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SnapshotID) == "" { return nil, errors.New("field SnapshotID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/snapshots/" + fmt.Sprint(req.SnapshotID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Snapshot err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteSnapshot: Delete a given snapshot of a Database Instance. You must specify, in the endpoint, the `region` and `snapshot_id` parameters of the snapshot you want to delete. func (s *API) DeleteSnapshot(req *DeleteSnapshotRequest, opts ...scw.RequestOption) (*Snapshot, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SnapshotID) == "" { return nil, errors.New("field SnapshotID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/snapshots/" + fmt.Sprint(req.SnapshotID) + "", } var resp Snapshot err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateInstanceFromSnapshot: Restore a snapshot. When you restore a snapshot, a new Instance is created and billed to your account. Note that is possible to select a larger node type for your new Database Instance. However, the Block volume size will be the same as the size of the restored snapshot. All Instance settings will be restored if you chose a node type with the same or more memory size than the initial Instance. Settings will be reset to the default if your node type has less memory. func (s *API) CreateInstanceFromSnapshot(req *CreateInstanceFromSnapshotRequest, opts ...scw.RequestOption) (*Instance, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SnapshotID) == "" { return nil, errors.New("field SnapshotID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/snapshots/" + fmt.Sprint(req.SnapshotID) + "/create-instance", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Instance err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateEndpoint: Create a new endpoint for a Database Instance. You can add `load_balancer` and `private_network` specifications to the body of the request. func (s *API) CreateEndpoint(req *CreateEndpointRequest, opts ...scw.RequestOption) (*Endpoint, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/endpoints", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Endpoint err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteEndpoint: Delete the endpoint of a Database Instance. You must specify the `region` and `endpoint_id` parameters of the endpoint you want to delete. Note that might need to update any environment configurations that point to the deleted endpoint. func (s *API) DeleteEndpoint(req *DeleteEndpointRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.EndpointID) == "" { return errors.New("field EndpointID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/endpoints/" + fmt.Sprint(req.EndpointID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // GetEndpoint: Retrieve information about a Database Instance endpoint. Full details about the endpoint, like `ip`, `port`, `private_network` and `load_balancer` specifications are returned in the response. func (s *API) GetEndpoint(req *GetEndpointRequest, opts ...scw.RequestOption) (*Endpoint, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.EndpointID) == "" { return nil, errors.New("field EndpointID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/endpoints/" + fmt.Sprint(req.EndpointID) + "", } var resp Endpoint err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // MigrateEndpoint: Migrate an existing Database Instance endpoint to another Database Instance. func (s *API) MigrateEndpoint(req *MigrateEndpointRequest, opts ...scw.RequestOption) (*Endpoint, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.EndpointID) == "" { return nil, errors.New("field EndpointID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/document-db/v1beta1/regions/" + fmt.Sprint(req.Region) + "/endpoints/" + fmt.Sprint(req.EndpointID) + "/migrate", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Endpoint err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/documentdb/v1beta1/documentdb_utils.go000066400000000000000000000104551456366605600323160ustar00rootroot00000000000000package documentdb import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) const ( defaultRetryInterval = 15 * time.Second defaultTimeout = 15 * time.Minute ) // WaitForInstanceRequest is used by WaitForInstance method. type WaitForInstanceRequest struct { InstanceID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForInstance waits for the instance to be in a "terminal state" before returning. // This function can be used to wait for an instance to be ready for example. func (s *API) WaitForInstance(req *WaitForInstanceRequest, opts ...scw.RequestOption) (*Instance, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[InstanceStatus]struct{}{ InstanceStatusReady: {}, InstanceStatusDiskFull: {}, InstanceStatusError: {}, } instance, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetInstance(&GetInstanceRequest{ InstanceID: req.InstanceID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.Status] return res, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for instance failed") } return instance.(*Instance), nil } type WaitForInstanceLogRequest struct { InstanceLogID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForInstanceLog waits for the instance logs to be in a "terminal state" before returning. // This function can be used to wait for an instance logs to be ready for example. func (s *API) WaitForInstanceLog(req *WaitForInstanceLogRequest, opts ...scw.RequestOption) (*InstanceLog, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[InstanceLogStatus]struct{}{ InstanceLogStatusReady: {}, InstanceLogStatusError: {}, } logs, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetInstanceLog(&GetInstanceLogRequest{ Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.Status] return res, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for instance logs failed") } return logs.(*InstanceLog), nil } // WaitForReadReplicaRequest is used by WaitForReadReplica method. type WaitForReadReplicaRequest struct { ReadReplicaID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForReadReplica waits for the read replica to be in a "terminal state" before returning. // This function can be used to wait for a read replica to be ready for example. func (s *API) WaitForReadReplica(req *WaitForReadReplicaRequest, opts ...scw.RequestOption) (*ReadReplica, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[ReadReplicaStatus]struct{}{ ReadReplicaStatusReady: {}, ReadReplicaStatusError: {}, } readReplica, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetReadReplica(&GetReadReplicaRequest{ ReadReplicaID: req.ReadReplicaID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.Status] return res, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for read replica failed") } return readReplica.(*ReadReplica), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/domain/000077500000000000000000000000001456366605600242765ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/domain/v2beta1/000077500000000000000000000000001456366605600255425ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/domain/v2beta1/domain_sdk.go000066400000000000000000003764461456366605600302250ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package domain provides methods and message types of the domain v2beta1 API. package domain import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" std "github.com/scaleway/scaleway-sdk-go/api/std" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type ContactEmailStatus string const ( // If unspecified, the status is unknown by default. ContactEmailStatusEmailStatusUnknown = ContactEmailStatus("email_status_unknown") // The contact email has been validated. ContactEmailStatusValidated = ContactEmailStatus("validated") // The contact email has not been validated. ContactEmailStatusNotValidated = ContactEmailStatus("not_validated") // The contact email is invalid. ContactEmailStatusInvalidEmail = ContactEmailStatus("invalid_email") ) func (enum ContactEmailStatus) String() string { if enum == "" { // return default value if empty return "email_status_unknown" } return string(enum) } func (enum ContactEmailStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ContactEmailStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ContactEmailStatus(ContactEmailStatus(tmp).String()) return nil } type ContactExtensionFRMode string const ( // If unspecified, the status is unknown by default. ContactExtensionFRModeModeUnknown = ContactExtensionFRMode("mode_unknown") // The contact is a physical person (only for .fr domains). ContactExtensionFRModeIndividual = ContactExtensionFRMode("individual") // The contact is a company with a SIRET/SIREN code (only for .fr domains). ContactExtensionFRModeCompanyIdentificationCode = ContactExtensionFRMode("company_identification_code") // The contact has a Data Universal Numbering System code (only for .fr domains). ContactExtensionFRModeDuns = ContactExtensionFRMode("duns") // The contact has a local or a country ID (only for .fr domains). ContactExtensionFRModeLocal = ContactExtensionFRMode("local") // The contact is an association (only for .fr domains). ContactExtensionFRModeAssociation = ContactExtensionFRMode("association") // The contact is a brand (only for .fr domains). ContactExtensionFRModeTrademark = ContactExtensionFRMode("trademark") // The contact has an intervention code (DSIA) from AFNIC (only for .fr domains). ContactExtensionFRModeCodeAuthAfnic = ContactExtensionFRMode("code_auth_afnic") ) func (enum ContactExtensionFRMode) String() string { if enum == "" { // return default value if empty return "mode_unknown" } return string(enum) } func (enum ContactExtensionFRMode) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ContactExtensionFRMode) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ContactExtensionFRMode(ContactExtensionFRMode(tmp).String()) return nil } type ContactExtensionNLLegalForm string const ( // If unspecified, the status is unknown by default. ContactExtensionNLLegalFormLegalFormUnknown = ContactExtensionNLLegalForm("legal_form_unknown") // The contact's legal form is not listed below (only for .nl domains). ContactExtensionNLLegalFormOther = ContactExtensionNLLegalForm("other") // The contact is a non-Dutch EC company (only for .nl domains). ContactExtensionNLLegalFormNonDutchEuCompany = ContactExtensionNLLegalForm("non_dutch_eu_company") // The contact is a non-Dutch legal form/enterprise/subsidiary (only for .nl domains). ContactExtensionNLLegalFormNonDutchLegalFormEnterpriseSubsidiary = ContactExtensionNLLegalForm("non_dutch_legal_form_enterprise_subsidiary") // The contact is a limited company (only for .nl domains). ContactExtensionNLLegalFormLimitedCompany = ContactExtensionNLLegalForm("limited_company") // The contact is a limited company in formation (only for .nl domains). ContactExtensionNLLegalFormLimitedCompanyInFormation = ContactExtensionNLLegalForm("limited_company_in_formation") // The contact is a cooperative (only for .nl domains). ContactExtensionNLLegalFormCooperative = ContactExtensionNLLegalForm("cooperative") // The contact is a limited Partnership (only for .nl domains). ContactExtensionNLLegalFormLimitedPartnership = ContactExtensionNLLegalForm("limited_partnership") // The contact is a sole trader (only for .nl domains). ContactExtensionNLLegalFormSoleCompany = ContactExtensionNLLegalForm("sole_company") // The contact is a European Economic Interest Group (only for .nl domains). ContactExtensionNLLegalFormEuropeanEconomicInterestGroup = ContactExtensionNLLegalForm("european_economic_interest_group") // The contact is a religious society (only for .nl domains). ContactExtensionNLLegalFormReligiousEntity = ContactExtensionNLLegalForm("religious_entity") // The contact is a partnership (only for .nl domains). ContactExtensionNLLegalFormPartnership = ContactExtensionNLLegalForm("partnership") // The contact is a public Company (only for .nl domains). ContactExtensionNLLegalFormPublicCompany = ContactExtensionNLLegalForm("public_company") // The contact is a mutual benefit company (only for .nl domains). ContactExtensionNLLegalFormMutualBenefitCompany = ContactExtensionNLLegalForm("mutual_benefit_company") // The contact is a natural person (only for .nl domains). ContactExtensionNLLegalFormResidential = ContactExtensionNLLegalForm("residential") // The contact is a shipping company (only for .nl domains). ContactExtensionNLLegalFormShippingCompany = ContactExtensionNLLegalForm("shipping_company") // The contact is a foundation (only for .nl domains). ContactExtensionNLLegalFormFoundation = ContactExtensionNLLegalForm("foundation") // The contact is a association (only for .nl domains). ContactExtensionNLLegalFormAssociation = ContactExtensionNLLegalForm("association") // The contact is a trading partnership (only for .nl domains). ContactExtensionNLLegalFormTradingPartnership = ContactExtensionNLLegalForm("trading_partnership") // The contact is a physical person (only for .nl domains). ContactExtensionNLLegalFormNaturalPerson = ContactExtensionNLLegalForm("natural_person") ) func (enum ContactExtensionNLLegalForm) String() string { if enum == "" { // return default value if empty return "legal_form_unknown" } return string(enum) } func (enum ContactExtensionNLLegalForm) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ContactExtensionNLLegalForm) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ContactExtensionNLLegalForm(ContactExtensionNLLegalForm(tmp).String()) return nil } type ContactLegalForm string const ( // If unspecified, the status is unknown by default. ContactLegalFormLegalFormUnknown = ContactLegalForm("legal_form_unknown") // The contact is a physical person. ContactLegalFormIndividual = ContactLegalForm("individual") // The contact is a corporate or a society. ContactLegalFormCorporate = ContactLegalForm("corporate") // The contact is an association. ContactLegalFormAssociation = ContactLegalForm("association") // The contact is not represented by a physical person, a corporate or an association. ContactLegalFormOther = ContactLegalForm("other") ) func (enum ContactLegalForm) String() string { if enum == "" { // return default value if empty return "legal_form_unknown" } return string(enum) } func (enum ContactLegalForm) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ContactLegalForm) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ContactLegalForm(ContactLegalForm(tmp).String()) return nil } type ContactStatus string const ( // If unspecified, the status is unknown by default. ContactStatusStatusUnknown = ContactStatus("status_unknown") // The contact is active and can be edited. ContactStatusActive = ContactStatus("active") // The contact is temporarily locked (ie. while being edited). ContactStatusPending = ContactStatus("pending") ) func (enum ContactStatus) String() string { if enum == "" { // return default value if empty return "status_unknown" } return string(enum) } func (enum ContactStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ContactStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ContactStatus(ContactStatus(tmp).String()) return nil } type DNSZoneStatus string const ( // If unspecified, the DNS zone's status is unknown by default. DNSZoneStatusUnknown = DNSZoneStatus("unknown") // The DNS zone is active and healthy. DNSZoneStatusActive = DNSZoneStatus("active") // The DNS zone is updating. DNSZoneStatusPending = DNSZoneStatus("pending") // An error occurred after updating the DNS zone. DNSZoneStatusError = DNSZoneStatus("error") // The DNS zone is locked and cannot be updated anymore. DNSZoneStatusLocked = DNSZoneStatus("locked") ) func (enum DNSZoneStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum DNSZoneStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DNSZoneStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DNSZoneStatus(DNSZoneStatus(tmp).String()) return nil } type DSRecordAlgorithm string const ( // Code 1, algorithm: 'RSAMD5'. DSRecordAlgorithmRsamd5 = DSRecordAlgorithm("rsamd5") // Code 2, algorithm: 'DIFFIE_HELLMAN'. DSRecordAlgorithmDh = DSRecordAlgorithm("dh") // Code 3, algorithm: 'DSA_SHA1'. DSRecordAlgorithmDsa = DSRecordAlgorithm("dsa") // Code 5, algorithm: 'RSA_SHA1'. DSRecordAlgorithmRsasha1 = DSRecordAlgorithm("rsasha1") // Code 6, algorithm: 'DSA_NSEC3_SHA1'. DSRecordAlgorithmDsaNsec3Sha1 = DSRecordAlgorithm("dsa_nsec3_sha1") // Code 7, algorithm: 'RSASHA1_NSEC3_SHA1'. DSRecordAlgorithmRsasha1Nsec3Sha1 = DSRecordAlgorithm("rsasha1_nsec3_sha1") // Code 8, algorithm: 'RSASHA256'. DSRecordAlgorithmRsasha256 = DSRecordAlgorithm("rsasha256") // Code 10, algorithm: 'RSASHA512'. DSRecordAlgorithmRsasha512 = DSRecordAlgorithm("rsasha512") // Code 12, algorithm: 'ECC_GOST'. DSRecordAlgorithmEccGost = DSRecordAlgorithm("ecc_gost") // Code 13, algorithm: 'ECDSAP256SHA256'. DSRecordAlgorithmEcdsap256sha256 = DSRecordAlgorithm("ecdsap256sha256") // Code 14, algorithm: 'ECDSAP384SHA384'. DSRecordAlgorithmEcdsap384sha384 = DSRecordAlgorithm("ecdsap384sha384") // Code 15, algorithm: 'ED25519'. DSRecordAlgorithmEd25519 = DSRecordAlgorithm("ed25519") // Code 16, algorithm: 'ED448'. DSRecordAlgorithmEd448 = DSRecordAlgorithm("ed448") ) func (enum DSRecordAlgorithm) String() string { if enum == "" { // return default value if empty return "rsamd5" } return string(enum) } func (enum DSRecordAlgorithm) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DSRecordAlgorithm) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DSRecordAlgorithm(DSRecordAlgorithm(tmp).String()) return nil } type DSRecordDigestType string const ( // Code 1, digest type: 'SHA_1'. DSRecordDigestTypeSha1 = DSRecordDigestType("sha_1") // Code 2, digest type: 'SHA_256'. DSRecordDigestTypeSha256 = DSRecordDigestType("sha_256") // Code 3, digest type: 'GOST_R_34_11_94'. DSRecordDigestTypeGostR34_11_94 = DSRecordDigestType("gost_r_34_11_94") // Code 4, digest type: 'SHA_384'. DSRecordDigestTypeSha384 = DSRecordDigestType("sha_384") ) func (enum DSRecordDigestType) String() string { if enum == "" { // return default value if empty return "sha_1" } return string(enum) } func (enum DSRecordDigestType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DSRecordDigestType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DSRecordDigestType(DSRecordDigestType(tmp).String()) return nil } type DomainFeatureStatus string const ( // Default unknown status. DomainFeatureStatusFeatureStatusUnknown = DomainFeatureStatus("feature_status_unknown") // A feature (auto renew, DNSSEC) is being enabled. DomainFeatureStatusEnabling = DomainFeatureStatus("enabling") // A feature (auto renew, DNSSEC) has been enabled. DomainFeatureStatusEnabled = DomainFeatureStatus("enabled") // A feature (auto renew, DNSSEC) is being disabled. DomainFeatureStatusDisabling = DomainFeatureStatus("disabling") // A feature (auto renew, DNSSEC) has been disabled. DomainFeatureStatusDisabled = DomainFeatureStatus("disabled") ) func (enum DomainFeatureStatus) String() string { if enum == "" { // return default value if empty return "feature_status_unknown" } return string(enum) } func (enum DomainFeatureStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DomainFeatureStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DomainFeatureStatus(DomainFeatureStatus(tmp).String()) return nil } type DomainRegistrationStatusTransferStatus string const ( // If unspecified, the status is unknown by default. DomainRegistrationStatusTransferStatusStatusUnknown = DomainRegistrationStatusTransferStatus("status_unknown") // The domain transfer is being initialized. DomainRegistrationStatusTransferStatusPending = DomainRegistrationStatusTransferStatus("pending") // The domain transfer has started. The process can be accelerated if you accept the vote. DomainRegistrationStatusTransferStatusWaitingVote = DomainRegistrationStatusTransferStatus("waiting_vote") // The domain transfer has been rejected. DomainRegistrationStatusTransferStatusRejected = DomainRegistrationStatusTransferStatus("rejected") // The domain transfer has been accepted. Your resources are being created. DomainRegistrationStatusTransferStatusProcessing = DomainRegistrationStatusTransferStatus("processing") // The domain transfer is complete. DomainRegistrationStatusTransferStatusDone = DomainRegistrationStatusTransferStatus("done") ) func (enum DomainRegistrationStatusTransferStatus) String() string { if enum == "" { // return default value if empty return "status_unknown" } return string(enum) } func (enum DomainRegistrationStatusTransferStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DomainRegistrationStatusTransferStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DomainRegistrationStatusTransferStatus(DomainRegistrationStatusTransferStatus(tmp).String()) return nil } type DomainStatus string const ( // If unspecified, the status is unknown by default. DomainStatusStatusUnknown = DomainStatus("status_unknown") // The domain is active. DomainStatusActive = DomainStatus("active") // The domain is in the process of being created. DomainStatusCreating = DomainStatus("creating") // An error occurred during the domain's creation process. DomainStatusCreateError = DomainStatus("create_error") // The domain is being renewed. DomainStatusRenewing = DomainStatus("renewing") // An error occurred during the domain's renewal process. DomainStatusRenewError = DomainStatus("renew_error") // The domain is being transferred to Scaleway Domains and DNS. DomainStatusXfering = DomainStatus("xfering") // An error occurred during the domain's transfer process. DomainStatusXferError = DomainStatus("xfer_error") // The domain is expired but it can be renewed. DomainStatusExpired = DomainStatus("expired") // The domain is expiring but it is still renewable. DomainStatusExpiring = DomainStatus("expiring") // The domain's information is updating. DomainStatusUpdating = DomainStatus("updating") // The external domain has not yet been validated. It will be automatically removed after 48 hours if it still has not been validated by then. DomainStatusChecking = DomainStatus("checking") // The domain is locked. Contact Scaleway's support team for more information. DomainStatusLocked = DomainStatus("locked") // The domain will be deleted soon. This process cannot be canceled. DomainStatusDeleting = DomainStatus("deleting") ) func (enum DomainStatus) String() string { if enum == "" { // return default value if empty return "status_unknown" } return string(enum) } func (enum DomainStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DomainStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DomainStatus(DomainStatus(tmp).String()) return nil } type HostStatus string const ( // If unspecified, the status is unknown by default. HostStatusUnknownStatus = HostStatus("unknown_status") // The host is active. HostStatusActive = HostStatus("active") // The host is being updated. HostStatusUpdating = HostStatus("updating") // The host is being deleted. HostStatusDeleting = HostStatus("deleting") ) func (enum HostStatus) String() string { if enum == "" { // return default value if empty return "unknown_status" } return string(enum) } func (enum HostStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *HostStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = HostStatus(HostStatus(tmp).String()) return nil } type LinkedProduct string const ( // If unspecified, no Scaleway product uses the resources. LinkedProductUnknownProduct = LinkedProduct("unknown_product") // Resources are used by Scaleway VPC. LinkedProductVpc = LinkedProduct("vpc") ) func (enum LinkedProduct) String() string { if enum == "" { // return default value if empty return "unknown_product" } return string(enum) } func (enum LinkedProduct) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *LinkedProduct) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = LinkedProduct(LinkedProduct(tmp).String()) return nil } type ListContactsRequestRole string const ( ListContactsRequestRoleUnknownRole = ListContactsRequestRole("unknown_role") // The contact is a domain's owner. ListContactsRequestRoleOwner = ListContactsRequestRole("owner") // The contact is a domain's administrative contact. ListContactsRequestRoleAdministrative = ListContactsRequestRole("administrative") // The contact is a domain's technical contact. ListContactsRequestRoleTechnical = ListContactsRequestRole("technical") ) func (enum ListContactsRequestRole) String() string { if enum == "" { // return default value if empty return "unknown_role" } return string(enum) } func (enum ListContactsRequestRole) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListContactsRequestRole) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListContactsRequestRole(ListContactsRequestRole(tmp).String()) return nil } type ListDNSZoneRecordsRequestOrderBy string const ( // Order by record name (ascending). ListDNSZoneRecordsRequestOrderByNameAsc = ListDNSZoneRecordsRequestOrderBy("name_asc") // Order by record name (descending). ListDNSZoneRecordsRequestOrderByNameDesc = ListDNSZoneRecordsRequestOrderBy("name_desc") ) func (enum ListDNSZoneRecordsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "name_asc" } return string(enum) } func (enum ListDNSZoneRecordsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListDNSZoneRecordsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListDNSZoneRecordsRequestOrderBy(ListDNSZoneRecordsRequestOrderBy(tmp).String()) return nil } type ListDNSZonesRequestOrderBy string const ( // Order by domain name (ascending). ListDNSZonesRequestOrderByDomainAsc = ListDNSZonesRequestOrderBy("domain_asc") // Order by domain name (descending). ListDNSZonesRequestOrderByDomainDesc = ListDNSZonesRequestOrderBy("domain_desc") // Order by subdomain name (ascending). ListDNSZonesRequestOrderBySubdomainAsc = ListDNSZonesRequestOrderBy("subdomain_asc") // Order by subdomain name (descending). ListDNSZonesRequestOrderBySubdomainDesc = ListDNSZonesRequestOrderBy("subdomain_desc") // Order by created date (ascending). ListDNSZonesRequestOrderByCreatedAtAsc = ListDNSZonesRequestOrderBy("created_at_asc") // Order by created date (descending). ListDNSZonesRequestOrderByCreatedAtDesc = ListDNSZonesRequestOrderBy("created_at_desc") // Order by updated date (ascending). ListDNSZonesRequestOrderByUpdatedAtAsc = ListDNSZonesRequestOrderBy("updated_at_asc") // Order by updated date (descending). ListDNSZonesRequestOrderByUpdatedAtDesc = ListDNSZonesRequestOrderBy("updated_at_desc") ) func (enum ListDNSZonesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "domain_asc" } return string(enum) } func (enum ListDNSZonesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListDNSZonesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListDNSZonesRequestOrderBy(ListDNSZonesRequestOrderBy(tmp).String()) return nil } type ListDomainsRequestOrderBy string const ( // Order by domain name (ascending). ListDomainsRequestOrderByDomainAsc = ListDomainsRequestOrderBy("domain_asc") // Order by domain name (descending). ListDomainsRequestOrderByDomainDesc = ListDomainsRequestOrderBy("domain_desc") ) func (enum ListDomainsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "domain_asc" } return string(enum) } func (enum ListDomainsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListDomainsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListDomainsRequestOrderBy(ListDomainsRequestOrderBy(tmp).String()) return nil } type ListRenewableDomainsRequestOrderBy string const ( // Order by domain name (ascending). ListRenewableDomainsRequestOrderByDomainAsc = ListRenewableDomainsRequestOrderBy("domain_asc") // Order by domain name (descending). ListRenewableDomainsRequestOrderByDomainDesc = ListRenewableDomainsRequestOrderBy("domain_desc") ) func (enum ListRenewableDomainsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "domain_asc" } return string(enum) } func (enum ListRenewableDomainsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListRenewableDomainsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListRenewableDomainsRequestOrderBy(ListRenewableDomainsRequestOrderBy(tmp).String()) return nil } type ListTasksRequestOrderBy string const ( // Order by domain name (descending). ListTasksRequestOrderByDomainDesc = ListTasksRequestOrderBy("domain_desc") // Order by domain name (ascending). ListTasksRequestOrderByDomainAsc = ListTasksRequestOrderBy("domain_asc") // Order by type (ascending). ListTasksRequestOrderByTypeAsc = ListTasksRequestOrderBy("type_asc") // Order by type (descending). ListTasksRequestOrderByTypeDesc = ListTasksRequestOrderBy("type_desc") // Order by status (ascending). ListTasksRequestOrderByStatusAsc = ListTasksRequestOrderBy("status_asc") // Order by status (descending). ListTasksRequestOrderByStatusDesc = ListTasksRequestOrderBy("status_desc") // Order by updated date (ascending). ListTasksRequestOrderByUpdatedAtAsc = ListTasksRequestOrderBy("updated_at_asc") // Order by updated date (descending). ListTasksRequestOrderByUpdatedAtDesc = ListTasksRequestOrderBy("updated_at_desc") ) func (enum ListTasksRequestOrderBy) String() string { if enum == "" { // return default value if empty return "domain_desc" } return string(enum) } func (enum ListTasksRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListTasksRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListTasksRequestOrderBy(ListTasksRequestOrderBy(tmp).String()) return nil } type ListTldsRequestOrderBy string const ( // Order by TLD name (ascending). ListTldsRequestOrderByNameAsc = ListTldsRequestOrderBy("name_asc") // Order by TLD name (descending). ListTldsRequestOrderByNameDesc = ListTldsRequestOrderBy("name_desc") ) func (enum ListTldsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "name_asc" } return string(enum) } func (enum ListTldsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListTldsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListTldsRequestOrderBy(ListTldsRequestOrderBy(tmp).String()) return nil } type RawFormat string const ( // If unspecified, the format is unknown by default. RawFormatUnknownRawFormat = RawFormat("unknown_raw_format") // Export the DNS zone in text bind format. RawFormatBind = RawFormat("bind") ) func (enum RawFormat) String() string { if enum == "" { // return default value if empty return "unknown_raw_format" } return string(enum) } func (enum RawFormat) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *RawFormat) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = RawFormat(RawFormat(tmp).String()) return nil } type RecordHTTPServiceConfigStrategy string const ( // Returns a random IP based of the list of IPs available. RecordHTTPServiceConfigStrategyRandom = RecordHTTPServiceConfigStrategy("random") // Based on the hash of bestwho, returns a random functioning IP out of the best IPs available. RecordHTTPServiceConfigStrategyHashed = RecordHTTPServiceConfigStrategy("hashed") // Return all functioning IPs available. RecordHTTPServiceConfigStrategyAll = RecordHTTPServiceConfigStrategy("all") ) func (enum RecordHTTPServiceConfigStrategy) String() string { if enum == "" { // return default value if empty return "random" } return string(enum) } func (enum RecordHTTPServiceConfigStrategy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *RecordHTTPServiceConfigStrategy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = RecordHTTPServiceConfigStrategy(RecordHTTPServiceConfigStrategy(tmp).String()) return nil } type RecordType string const ( // If unspecified, the record's type is unknown by default. RecordTypeUnknown = RecordType("unknown") // An A record contains an IP address. Example: '203.0.113.210'. RecordTypeA = RecordType("A") // An AAAA record contains an IPv6 address. Example: '2001:DB8:2000:bf0::1'. RecordTypeAAAA = RecordType("AAAA") // A CNAME record specifies the canonical name of a record. Example 'webserver-01.yourcompany.com'. RecordTypeCNAME = RecordType("CNAME") // A TXT record can be used to attach textual data to a domain. Example 'v=spf1 include:_spf.tem.scw.cloud -all'. RecordTypeTXT = RecordType("TXT") // SRV records can be used to encode the location and port of services on a domain name. Example : '20 443 sipdir.scaleway.example.com'. RecordTypeSRV = RecordType("SRV") // TLSA records are used to bind SSL/TLS certificates to named hosts and ports. RecordTypeTLSA = RecordType("TLSA") // An MX record specifies a mail exchanger host for a domain. Example '10 mx.example.net.'. RecordTypeMX = RecordType("MX") // Specifies nameservers for a domain. Example: 'ns1.yourcompany.com'. RecordTypeNS = RecordType("NS") // A reverse pointer is used to specify the hostname that belongs to an IP or an IPv6 address. Example: 'www.yourcompany.com.'. RecordTypePTR = RecordType("PTR") // A 'Certification Authority Authorization' record is used to specify certificate authorities that may issue certificates for a domain. Example: '0 issue ca.yourcompany.com'. RecordTypeCAA = RecordType("CAA") // The ALIAS pseudo-record type is supported to provide CNAME-like mechanisms on a zone's apex. RecordTypeALIAS = RecordType("ALIAS") // A LOC record is a way of expressing geographic location information for a domain name. It contains WGS84 latitude, longitude and altitude. Example: '51 56 0.123 N 5 54 0.000 E 4.00m 1.00m 10000.00m 10.00m'. RecordTypeLOC = RecordType("LOC") // An SSHFP record type is used for storing Secure Shell (SSH) fingerprints. Example: '2 1 123456789abcdef67890123456789abcdef67890'. RecordTypeSSHFP = RecordType("SSHFP") // A Hardware Info record is used to specify the CPU and operating system you are using. Example: 'i386 Linux'. RecordTypeHINFO = RecordType("HINFO") // A Responsible Person record stores the mailbox name and the more-information pointer. Example: 'michel.yourcompany.com michel.people.yourcompany.com', to indicate that michel@yourcompany.com is responsible and that more information about Michel is available by querying the `TXT` record of 'michel.people.yourcompany.com'. RecordTypeRP = RecordType("RP") // A URI record, is used to publish mappings from hostnames to URIs. Example: '10 1 'ftp://ftp.yourcompany.com/public'. RecordTypeURI = RecordType("URI") // DS records (Delegation Signer) are used to secure delegations (DNSSEC). Example: '2371 13 2 1F987CC6583E92DF0890718C42'. RecordTypeDS = RecordType("DS") // A Naming Authority Pointer record is used to set rules for how websites process requests. Example: '100 50 "s" "z3950+I2L+I2C" "" _z3950._tcp.yourcompany.com'. RecordTypeNAPTR = RecordType("NAPTR") // A DNAME record provides redirection from one part of the DNS name tree to another part of the DNS name tree. DNAME and CNAME records both cause a lookup to (potentially) return data corresponding to a different domain name from the queried domain name. Example: 'yourcompany.com'. RecordTypeDNAME = RecordType("DNAME") ) func (enum RecordType) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum RecordType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *RecordType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = RecordType(RecordType(tmp).String()) return nil } type RenewableDomainStatus string const ( // If unspecified, the status is unknown by default. RenewableDomainStatusUnknown = RenewableDomainStatus("unknown") // The domain can be renewed. RenewableDomainStatusRenewable = RenewableDomainStatus("renewable") // The domain is expired, but it still can be late renewed. RenewableDomainStatusLateReneweable = RenewableDomainStatus("late_reneweable") // The domain cannot be renewed. RenewableDomainStatusNotRenewable = RenewableDomainStatus("not_renewable") ) func (enum RenewableDomainStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum RenewableDomainStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *RenewableDomainStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = RenewableDomainStatus(RenewableDomainStatus(tmp).String()) return nil } type SSLCertificateStatus string const ( // If unspecified, the SSL certificate's status is unknown by default. SSLCertificateStatusUnknown = SSLCertificateStatus("unknown") // The SSL certificate has been created but it has not been processed yet. SSLCertificateStatusNew = SSLCertificateStatus("new") // The SSL certificate's status is pending. SSLCertificateStatusPending = SSLCertificateStatus("pending") // The SSL certificate has been created and processed. SSLCertificateStatusSuccess = SSLCertificateStatus("success") // An error occurred during the SSL certificate's creation. SSLCertificateStatusError = SSLCertificateStatus("error") ) func (enum SSLCertificateStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum SSLCertificateStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *SSLCertificateStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = SSLCertificateStatus(SSLCertificateStatus(tmp).String()) return nil } type TaskStatus string const ( // If unspecified, the status is unavailable by default. TaskStatusUnavailable = TaskStatus("unavailable") // The task has been created but it has not yet started. TaskStatusNew = TaskStatus("new") // The task is waiting for a payment to be validated. TaskStatusWaitingPayment = TaskStatus("waiting_payment") // The task is pending. TaskStatusPending = TaskStatus("pending") // The task has been completed. TaskStatusSuccess = TaskStatus("success") // The task is in an error state. TaskStatusError = TaskStatus("error") ) func (enum TaskStatus) String() string { if enum == "" { // return default value if empty return "unavailable" } return string(enum) } func (enum TaskStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *TaskStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = TaskStatus(TaskStatus(tmp).String()) return nil } type TaskType string const ( // If unspecified, the status is unknown by default. TaskTypeUnknown = TaskType("unknown") // Create a new internal domain. TaskTypeCreateDomain = TaskType("create_domain") // Create a new external domain. TaskTypeCreateExternalDomain = TaskType("create_external_domain") // Renew a domain. TaskTypeRenewDomain = TaskType("renew_domain") // Transfer a domain to Scaleway Domains and DNS. TaskTypeTransferDomain = TaskType("transfer_domain") // Trade a domain to a new owner. TaskTypeTradeDomain = TaskType("trade_domain") // Lock the transfer of a domain for protection. TaskTypeLockDomainTransfer = TaskType("lock_domain_transfer") // Unlock the transfer of a domain. TaskTypeUnlockDomainTransfer = TaskType("unlock_domain_transfer") // Enable DNSSEC for a domain. TaskTypeEnableDnssec = TaskType("enable_dnssec") // Disable DNSSEC for a domain. TaskTypeDisableDnssec = TaskType("disable_dnssec") // Update the domain's information. TaskTypeUpdateDomain = TaskType("update_domain") // Change the technical or administrative contact. TaskTypeUpdateContact = TaskType("update_contact") // Delete a domain and destroy its zone versions, zones, and SSL certificates. TaskTypeDeleteDomain = TaskType("delete_domain") // Cancel a task that has not yet started. TaskTypeCancelTask = TaskType("cancel_task") // Generate a new SSL certificate. TaskTypeGenerateSslCertificate = TaskType("generate_ssl_certificate") // Renew an SSL certificate. TaskTypeRenewSslCertificate = TaskType("renew_ssl_certificate") // Send a message. For most cases, it will be followed by an email. TaskTypeSendMessage = TaskType("send_message") // Delete a domain that has expired and not been restored for at least 3 months. TaskTypeDeleteDomainExpired = TaskType("delete_domain_expired") // Delete a newly registered external domain that has not been validated after 48 hours or when the external domain fails to point to our name servers for more than 14 days. TaskTypeDeleteExternalDomain = TaskType("delete_external_domain") // Create domain's hostname with glue IPs. TaskTypeCreateHost = TaskType("create_host") // Update domain's hostname with glue IPs. TaskTypeUpdateHost = TaskType("update_host") // Delete domain's hostname. TaskTypeDeleteHost = TaskType("delete_host") // Move a domain to another Project. TaskTypeMoveProject = TaskType("move_project") // Transfer a domain from Online to Scaleway Domains and DNS. TaskTypeTransferOnlineDomain = TaskType("transfer_online_domain") ) func (enum TaskType) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum TaskType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *TaskType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = TaskType(TaskType(tmp).String()) return nil } // RecordGeoIPConfigMatch: record geo ip config match. type RecordGeoIPConfigMatch struct { Countries []string `json:"countries"` Continents []string `json:"continents"` Data string `json:"data"` } // RecordViewConfigView: record view config view. type RecordViewConfigView struct { Subnet string `json:"subnet"` Data string `json:"data"` } // RecordWeightedConfigWeightedIP: record weighted config weighted ip. type RecordWeightedConfigWeightedIP struct { IP net.IP `json:"ip"` Weight uint32 `json:"weight"` } // DSRecordPublicKey: ds record public key. type DSRecordPublicKey struct { Key string `json:"key"` } // RecordGeoIPConfig: record geo ip config. type RecordGeoIPConfig struct { Matches []*RecordGeoIPConfigMatch `json:"matches"` Default string `json:"default"` } // RecordHTTPServiceConfig: record http service config. type RecordHTTPServiceConfig struct { IPs []net.IP `json:"ips"` MustContain *string `json:"must_contain"` URL string `json:"url"` UserAgent *string `json:"user_agent"` // Strategy: default value: random Strategy RecordHTTPServiceConfigStrategy `json:"strategy"` } // RecordViewConfig: record view config. type RecordViewConfig struct { Views []*RecordViewConfigView `json:"views"` } // RecordWeightedConfig: record weighted config. type RecordWeightedConfig struct { WeightedIPs []*RecordWeightedConfigWeightedIP `json:"weighted_ips"` } // ContactExtensionFRAssociationInfo: contact extension fr association info. type ContactExtensionFRAssociationInfo struct { PublicationJo *time.Time `json:"publication_jo"` PublicationJoPage uint32 `json:"publication_jo_page"` } // ContactExtensionFRCodeAuthAfnicInfo: contact extension fr code auth afnic info. type ContactExtensionFRCodeAuthAfnicInfo struct { CodeAuthAfnic string `json:"code_auth_afnic"` } // ContactExtensionFRDunsInfo: contact extension fr duns info. type ContactExtensionFRDunsInfo struct { DunsID string `json:"duns_id"` LocalID string `json:"local_id"` } // ContactExtensionFRIndividualInfo: contact extension fr individual info. type ContactExtensionFRIndividualInfo struct { WhoisOptIn bool `json:"whois_opt_in"` } // ContactExtensionFRTrademarkInfo: contact extension fr trademark info. type ContactExtensionFRTrademarkInfo struct { TrademarkInpi string `json:"trademark_inpi"` } // DSRecordDigest: ds record digest. type DSRecordDigest struct { // Type: default value: sha_1 Type DSRecordDigestType `json:"type"` Digest string `json:"digest"` PublicKey *DSRecordPublicKey `json:"public_key"` } // Record: record. type Record struct { Data string `json:"data"` Name string `json:"name"` Priority uint32 `json:"priority"` TTL uint32 `json:"ttl"` // Type: default value: unknown Type RecordType `json:"type"` Comment *string `json:"comment"` // Precisely one of GeoIPConfig, HTTPServiceConfig, WeightedConfig, ViewConfig must be set. GeoIPConfig *RecordGeoIPConfig `json:"geo_ip_config,omitempty"` // Precisely one of GeoIPConfig, HTTPServiceConfig, WeightedConfig, ViewConfig must be set. HTTPServiceConfig *RecordHTTPServiceConfig `json:"http_service_config,omitempty"` // Precisely one of GeoIPConfig, HTTPServiceConfig, WeightedConfig, ViewConfig must be set. WeightedConfig *RecordWeightedConfig `json:"weighted_config,omitempty"` // Precisely one of GeoIPConfig, HTTPServiceConfig, WeightedConfig, ViewConfig must be set. ViewConfig *RecordViewConfig `json:"view_config,omitempty"` ID string `json:"id"` } // RecordIdentifier: record identifier. type RecordIdentifier struct { Name string `json:"name"` // Type: default value: unknown Type RecordType `json:"type"` Data *string `json:"data"` TTL *uint32 `json:"ttl"` } // ContactExtensionEU: contact extension eu. type ContactExtensionEU struct { EuropeanCitizenship string `json:"european_citizenship"` } // ContactExtensionFR: contact extension fr. type ContactExtensionFR struct { // Mode: default value: mode_unknown Mode ContactExtensionFRMode `json:"mode"` // Precisely one of IndividualInfo, DunsInfo, AssociationInfo, TrademarkInfo, CodeAuthAfnicInfo must be set. IndividualInfo *ContactExtensionFRIndividualInfo `json:"individual_info,omitempty"` // Precisely one of IndividualInfo, DunsInfo, AssociationInfo, TrademarkInfo, CodeAuthAfnicInfo must be set. DunsInfo *ContactExtensionFRDunsInfo `json:"duns_info,omitempty"` // Precisely one of IndividualInfo, DunsInfo, AssociationInfo, TrademarkInfo, CodeAuthAfnicInfo must be set. AssociationInfo *ContactExtensionFRAssociationInfo `json:"association_info,omitempty"` // Precisely one of IndividualInfo, DunsInfo, AssociationInfo, TrademarkInfo, CodeAuthAfnicInfo must be set. TrademarkInfo *ContactExtensionFRTrademarkInfo `json:"trademark_info,omitempty"` // Precisely one of IndividualInfo, DunsInfo, AssociationInfo, TrademarkInfo, CodeAuthAfnicInfo must be set. CodeAuthAfnicInfo *ContactExtensionFRCodeAuthAfnicInfo `json:"code_auth_afnic_info,omitempty"` } // ContactExtensionNL: contact extension nl. type ContactExtensionNL struct { // LegalForm: default value: legal_form_unknown LegalForm ContactExtensionNLLegalForm `json:"legal_form"` LegalFormRegistrationNumber string `json:"legal_form_registration_number"` } // ContactQuestion: contact question. type ContactQuestion struct { Question string `json:"question"` Answer string `json:"answer"` } // TldOffer: tld offer. type TldOffer struct { Action string `json:"action"` OperationPath string `json:"operation_path"` Price *scw.Money `json:"price"` } // DSRecord: ds record. type DSRecord struct { KeyID uint32 `json:"key_id"` // Algorithm: default value: rsamd5 Algorithm DSRecordAlgorithm `json:"algorithm"` // Precisely one of Digest, PublicKey must be set. Digest *DSRecordDigest `json:"digest,omitempty"` // Precisely one of Digest, PublicKey must be set. PublicKey *DSRecordPublicKey `json:"public_key,omitempty"` } // RecordChangeAdd: record change add. type RecordChangeAdd struct { Records []*Record `json:"records"` } // RecordChangeClear: record change clear. type RecordChangeClear struct { } // RecordChangeDelete: record change delete. type RecordChangeDelete struct { // Precisely one of ID, IDFields must be set. ID *string `json:"id,omitempty"` // Precisely one of ID, IDFields must be set. IDFields *RecordIdentifier `json:"id_fields,omitempty"` } // RecordChangeSet: record change set. type RecordChangeSet struct { // Precisely one of ID, IDFields must be set. ID *string `json:"id,omitempty"` // Precisely one of ID, IDFields must be set. IDFields *RecordIdentifier `json:"id_fields,omitempty"` Records []*Record `json:"records"` } // ImportRawDNSZoneRequestTsigKey: import raw dns zone request tsig key. type ImportRawDNSZoneRequestTsigKey struct { Name string `json:"name"` Key string `json:"key"` Algorithm string `json:"algorithm"` } // Contact: contact. type Contact struct { ID string `json:"id"` // LegalForm: default value: legal_form_unknown LegalForm ContactLegalForm `json:"legal_form"` Firstname string `json:"firstname"` Lastname string `json:"lastname"` CompanyName string `json:"company_name"` Email string `json:"email"` EmailAlt string `json:"email_alt"` PhoneNumber string `json:"phone_number"` FaxNumber string `json:"fax_number"` AddressLine1 string `json:"address_line_1"` AddressLine2 string `json:"address_line_2"` Zip string `json:"zip"` City string `json:"city"` Country string `json:"country"` VatIDentificationCode string `json:"vat_identification_code"` CompanyIDentificationCode string `json:"company_identification_code"` // Lang: default value: unknown_language_code Lang std.LanguageCode `json:"lang"` Resale bool `json:"resale"` // Deprecated Questions *[]*ContactQuestion `json:"questions,omitempty"` ExtensionFr *ContactExtensionFR `json:"extension_fr"` ExtensionEu *ContactExtensionEU `json:"extension_eu"` WhoisOptIn bool `json:"whois_opt_in"` // EmailStatus: default value: email_status_unknown EmailStatus ContactEmailStatus `json:"email_status"` State string `json:"state"` ExtensionNl *ContactExtensionNL `json:"extension_nl"` // Status: default value: status_unknown Status ContactStatus `json:"status"` } // ContactRolesRoles: contact roles roles. type ContactRolesRoles struct { IsOwner bool `json:"is_owner"` IsAdministrative bool `json:"is_administrative"` IsTechnical bool `json:"is_technical"` } // DomainRegistrationStatusExternalDomain: domain registration status external domain. type DomainRegistrationStatusExternalDomain struct { ValidationToken string `json:"validation_token"` } // DomainRegistrationStatusTransfer: domain registration status transfer. type DomainRegistrationStatusTransfer struct { // Status: default value: status_unknown Status DomainRegistrationStatusTransferStatus `json:"status"` VoteCurrentOwner bool `json:"vote_current_owner"` VoteNewOwner bool `json:"vote_new_owner"` } // Tld: tld. type Tld struct { Name string `json:"name"` DnssecSupport bool `json:"dnssec_support"` DurationInYearsMin uint32 `json:"duration_in_years_min"` DurationInYearsMax uint32 `json:"duration_in_years_max"` IDnSupport bool `json:"idn_support"` Offers map[string]*TldOffer `json:"offers"` Specifications map[string]string `json:"specifications"` } // NewContact: new contact. type NewContact struct { // LegalForm: default value: legal_form_unknown LegalForm ContactLegalForm `json:"legal_form"` Firstname string `json:"firstname"` Lastname string `json:"lastname"` CompanyName *string `json:"company_name"` Email string `json:"email"` EmailAlt *string `json:"email_alt"` PhoneNumber string `json:"phone_number"` FaxNumber *string `json:"fax_number"` AddressLine1 string `json:"address_line_1"` AddressLine2 *string `json:"address_line_2"` Zip string `json:"zip"` City string `json:"city"` Country string `json:"country"` VatIDentificationCode *string `json:"vat_identification_code"` CompanyIDentificationCode *string `json:"company_identification_code"` // Lang: default value: unknown_language_code Lang std.LanguageCode `json:"lang"` Resale bool `json:"resale"` // Deprecated Questions *[]*ContactQuestion `json:"questions,omitempty"` ExtensionFr *ContactExtensionFR `json:"extension_fr"` ExtensionEu *ContactExtensionEU `json:"extension_eu"` WhoisOptIn bool `json:"whois_opt_in"` State *string `json:"state"` ExtensionNl *ContactExtensionNL `json:"extension_nl"` } // CheckContactsCompatibilityResponseContactCheckResult: check contacts compatibility response contact check result. type CheckContactsCompatibilityResponseContactCheckResult struct { Compatible bool `json:"compatible"` ErrorMessage *string `json:"error_message"` } // DNSZone: dns zone. type DNSZone struct { Domain string `json:"domain"` Subdomain string `json:"subdomain"` Ns []string `json:"ns"` NsDefault []string `json:"ns_default"` NsMaster []string `json:"ns_master"` // Status: default value: unknown Status DNSZoneStatus `json:"status"` Message *string `json:"message"` UpdatedAt *time.Time `json:"updated_at"` ProjectID string `json:"project_id"` LinkedProducts []LinkedProduct `json:"linked_products"` } // DomainDNSSEC: domain dnssec. type DomainDNSSEC struct { // Status: default value: feature_status_unknown Status DomainFeatureStatus `json:"status"` DsRecords []*DSRecord `json:"ds_records"` } // RecordChange: record change. type RecordChange struct { // Precisely one of Add, Set, Delete, Clear must be set. Add *RecordChangeAdd `json:"add,omitempty"` // Precisely one of Add, Set, Delete, Clear must be set. Set *RecordChangeSet `json:"set,omitempty"` // Precisely one of Add, Set, Delete, Clear must be set. Delete *RecordChangeDelete `json:"delete,omitempty"` // Precisely one of Add, Set, Delete, Clear must be set. Clear *RecordChangeClear `json:"clear,omitempty"` } // ImportProviderDNSZoneRequestOnlineV1: import provider dns zone request online v1. type ImportProviderDNSZoneRequestOnlineV1 struct { Token string `json:"token"` } // ImportRawDNSZoneRequestAXFRSource: import raw dns zone request axfr source. type ImportRawDNSZoneRequestAXFRSource struct { NameServer string `json:"name_server"` TsigKey *ImportRawDNSZoneRequestTsigKey `json:"tsig_key"` } // ImportRawDNSZoneRequestBindSource: import raw dns zone request bind source. type ImportRawDNSZoneRequestBindSource struct { Content string `json:"content"` } // ContactRoles: contact roles. type ContactRoles struct { Contact *Contact `json:"contact"` Roles map[string]*ContactRolesRoles `json:"roles"` } // Nameserver: nameserver. type Nameserver struct { Name string `json:"name"` IP []string `json:"ip"` } // DNSZoneVersion: dns zone version. type DNSZoneVersion struct { ID string `json:"id"` CreatedAt *time.Time `json:"created_at"` } // Host: host. type Host struct { Domain string `json:"domain"` Name string `json:"name"` IPs []net.IP `json:"ips"` // Status: default value: unknown_status Status HostStatus `json:"status"` } // DomainSummary: domain summary. type DomainSummary struct { Domain string `json:"domain"` ProjectID string `json:"project_id"` // AutoRenewStatus: default value: feature_status_unknown AutoRenewStatus DomainFeatureStatus `json:"auto_renew_status"` // DnssecStatus: default value: feature_status_unknown DnssecStatus DomainFeatureStatus `json:"dnssec_status"` EppCode []string `json:"epp_code"` ExpiredAt *time.Time `json:"expired_at"` UpdatedAt *time.Time `json:"updated_at"` Registrar string `json:"registrar"` IsExternal bool `json:"is_external"` // Status: default value: status_unknown Status DomainStatus `json:"status"` // Precisely one of ExternalDomainRegistrationStatus, TransferRegistrationStatus must be set. ExternalDomainRegistrationStatus *DomainRegistrationStatusExternalDomain `json:"external_domain_registration_status,omitempty"` // Precisely one of ExternalDomainRegistrationStatus, TransferRegistrationStatus must be set. TransferRegistrationStatus *DomainRegistrationStatusTransfer `json:"transfer_registration_status,omitempty"` OrganizationID string `json:"organization_id"` } // RenewableDomain: renewable domain. type RenewableDomain struct { Domain string `json:"domain"` ProjectID string `json:"project_id"` OrganizationID string `json:"organization_id"` // Status: default value: unknown Status RenewableDomainStatus `json:"status"` RenewableDurationInYears *int32 `json:"renewable_duration_in_years"` ExpiredAt *time.Time `json:"expired_at"` LimitRenewAt *time.Time `json:"limit_renew_at"` LimitRedemptionAt *time.Time `json:"limit_redemption_at"` EstimatedDeleteAt *time.Time `json:"estimated_delete_at"` Tld *Tld `json:"tld"` } // SSLCertificate: ssl certificate. type SSLCertificate struct { DNSZone string `json:"dns_zone"` AlternativeDNSZones []string `json:"alternative_dns_zones"` // Status: default value: unknown Status SSLCertificateStatus `json:"status"` PrivateKey string `json:"private_key"` CertificateChain string `json:"certificate_chain"` CreatedAt *time.Time `json:"created_at"` ExpiredAt *time.Time `json:"expired_at"` } // Task: task. type Task struct { // ID: the unique identifier of the task. ID string `json:"id"` // ProjectID: the project ID associated to the task. ProjectID string `json:"project_id"` // OrganizationID: the organization ID associated to the task. OrganizationID string `json:"organization_id"` // Domain: the domain name associated to the task. Domain *string `json:"domain"` // Type: the type of the task. // Default value: unknown Type TaskType `json:"type"` // Status: the status of the task. // Default value: unavailable Status TaskStatus `json:"status"` // StartedAt: start date of the task. StartedAt *time.Time `json:"started_at"` // UpdatedAt: last update of the task. UpdatedAt *time.Time `json:"updated_at"` // Message: error message associated to the task. Message *string `json:"message"` // ContactIDentifier: human-friendly contact identifier used when the task concerns a contact. ContactIDentifier *string `json:"contact_identifier"` } // TransferInDomainRequestTransferRequest: transfer in domain request transfer request. type TransferInDomainRequestTransferRequest struct { Domain string `json:"domain"` AuthCode string `json:"auth_code"` } // UpdateContactRequestQuestion: update contact request question. type UpdateContactRequestQuestion struct { Question *string `json:"question"` Answer *string `json:"answer"` } // AvailableDomain: available domain. type AvailableDomain struct { Domain string `json:"domain"` Available bool `json:"available"` Tld *Tld `json:"tld"` } // CheckContactsCompatibilityResponse: check contacts compatibility response. type CheckContactsCompatibilityResponse struct { Compatible bool `json:"compatible"` OwnerCheckResult *CheckContactsCompatibilityResponseContactCheckResult `json:"owner_check_result"` AdministrativeCheckResult *CheckContactsCompatibilityResponseContactCheckResult `json:"administrative_check_result"` TechnicalCheckResult *CheckContactsCompatibilityResponseContactCheckResult `json:"technical_check_result"` } // ClearDNSZoneRecordsRequest: clear dns zone records request. type ClearDNSZoneRecordsRequest struct { // DNSZone: DNS zone to clear. DNSZone string `json:"-"` } // ClearDNSZoneRecordsResponse: clear dns zone records response. type ClearDNSZoneRecordsResponse struct { } // CloneDNSZoneRequest: clone dns zone request. type CloneDNSZoneRequest struct { // DNSZone: DNS zone to clone. DNSZone string `json:"-"` // DestDNSZone: destination DNS zone in which to clone the chosen DNS zone. DestDNSZone string `json:"dest_dns_zone"` // Overwrite: specifies whether or not the destination DNS zone will be overwritten. Overwrite bool `json:"overwrite"` // ProjectID: project ID of the destination DNS zone. ProjectID *string `json:"project_id,omitempty"` } // CreateDNSZoneRequest: create dns zone request. type CreateDNSZoneRequest struct { // Domain: domain in which to crreate the DNS zone. Domain string `json:"domain"` // Subdomain: subdomain of the DNS zone to create. Subdomain string `json:"subdomain"` // ProjectID: project ID in which to create the DNS zone. ProjectID string `json:"project_id"` } // CreateSSLCertificateRequest: create ssl certificate request. type CreateSSLCertificateRequest struct { DNSZone string `json:"dns_zone"` AlternativeDNSZones []string `json:"alternative_dns_zones"` } // DeleteDNSZoneRequest: delete dns zone request. type DeleteDNSZoneRequest struct { // DNSZone: DNS zone to delete. DNSZone string `json:"-"` // ProjectID: project ID of the DNS zone to delete. ProjectID string `json:"-"` } // DeleteDNSZoneResponse: delete dns zone response. type DeleteDNSZoneResponse struct { } // DeleteDNSZoneTsigKeyRequest: delete dns zone tsig key request. type DeleteDNSZoneTsigKeyRequest struct { DNSZone string `json:"-"` } // DeleteExternalDomainResponse: delete external domain response. type DeleteExternalDomainResponse struct { } // DeleteSSLCertificateRequest: delete ssl certificate request. type DeleteSSLCertificateRequest struct { DNSZone string `json:"-"` } // DeleteSSLCertificateResponse: delete ssl certificate response. type DeleteSSLCertificateResponse struct { } // Domain: domain. type Domain struct { Domain string `json:"domain"` OrganizationID string `json:"organization_id"` ProjectID string `json:"project_id"` // AutoRenewStatus: default value: feature_status_unknown AutoRenewStatus DomainFeatureStatus `json:"auto_renew_status"` Dnssec *DomainDNSSEC `json:"dnssec"` EppCode []string `json:"epp_code"` ExpiredAt *time.Time `json:"expired_at"` UpdatedAt *time.Time `json:"updated_at"` Registrar string `json:"registrar"` IsExternal bool `json:"is_external"` // Status: default value: status_unknown Status DomainStatus `json:"status"` DNSZones []*DNSZone `json:"dns_zones"` OwnerContact *Contact `json:"owner_contact"` TechnicalContact *Contact `json:"technical_contact"` AdministrativeContact *Contact `json:"administrative_contact"` // Precisely one of ExternalDomainRegistrationStatus, TransferRegistrationStatus must be set. ExternalDomainRegistrationStatus *DomainRegistrationStatusExternalDomain `json:"external_domain_registration_status,omitempty"` // Precisely one of ExternalDomainRegistrationStatus, TransferRegistrationStatus must be set. TransferRegistrationStatus *DomainRegistrationStatusTransfer `json:"transfer_registration_status,omitempty"` Tld *Tld `json:"tld"` LinkedProducts []LinkedProduct `json:"linked_products"` } // ExportRawDNSZoneRequest: export raw dns zone request. type ExportRawDNSZoneRequest struct { // DNSZone: DNS zone to export. DNSZone string `json:"-"` // Format: DNS zone format. // Default value: unknown_raw_format Format RawFormat `json:"-"` } // GetDNSZoneTsigKeyRequest: get dns zone tsig key request. type GetDNSZoneTsigKeyRequest struct { DNSZone string `json:"-"` } // GetDNSZoneTsigKeyResponse: get dns zone tsig key response. type GetDNSZoneTsigKeyResponse struct { Name string `json:"name"` Key string `json:"key"` Algorithm string `json:"algorithm"` } // GetDNSZoneVersionDiffRequest: get dns zone version diff request. type GetDNSZoneVersionDiffRequest struct { DNSZoneVersionID string `json:"-"` } // GetDNSZoneVersionDiffResponse: get dns zone version diff response. type GetDNSZoneVersionDiffResponse struct { Changes []*RecordChange `json:"changes"` } // GetDomainAuthCodeResponse: get domain auth code response. type GetDomainAuthCodeResponse struct { AuthCode string `json:"auth_code"` } // GetSSLCertificateRequest: get ssl certificate request. type GetSSLCertificateRequest struct { DNSZone string `json:"-"` } // ImportProviderDNSZoneRequest: import provider dns zone request. type ImportProviderDNSZoneRequest struct { DNSZone string `json:"-"` // Precisely one of OnlineV1 must be set. OnlineV1 *ImportProviderDNSZoneRequestOnlineV1 `json:"online_v1,omitempty"` } // ImportProviderDNSZoneResponse: import provider dns zone response. type ImportProviderDNSZoneResponse struct { Records []*Record `json:"records"` } // ImportRawDNSZoneRequest: import raw dns zone request. type ImportRawDNSZoneRequest struct { // DNSZone: DNS zone to import. DNSZone string `json:"-"` // Deprecated Content *string `json:"content,omitempty"` ProjectID string `json:"project_id"` // Deprecated: Format: default value: unknown_raw_format Format *RawFormat `json:"format,omitempty"` // BindSource: import a bind file format. // Precisely one of BindSource, AxfrSource must be set. BindSource *ImportRawDNSZoneRequestBindSource `json:"bind_source,omitempty"` // AxfrSource: import from the name server given with TSIG, to use or not. // Precisely one of BindSource, AxfrSource must be set. AxfrSource *ImportRawDNSZoneRequestAXFRSource `json:"axfr_source,omitempty"` } // ImportRawDNSZoneResponse: import raw dns zone response. type ImportRawDNSZoneResponse struct { Records []*Record `json:"records"` } // ListContactsResponse: list contacts response. type ListContactsResponse struct { TotalCount uint32 `json:"total_count"` Contacts []*ContactRoles `json:"contacts"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListContactsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListContactsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListContactsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Contacts = append(r.Contacts, results.Contacts...) r.TotalCount += uint32(len(results.Contacts)) return uint32(len(results.Contacts)), nil } // ListDNSZoneNameserversRequest: list dns zone nameservers request. type ListDNSZoneNameserversRequest struct { // DNSZone: DNS zone on which to filter the returned DNS zone name servers. DNSZone string `json:"-"` // ProjectID: project ID on which to filter the returned DNS zone name servers. ProjectID *string `json:"-"` } // ListDNSZoneNameserversResponse: list dns zone nameservers response. type ListDNSZoneNameserversResponse struct { // Ns: DNS zone name servers returned. Ns []*Nameserver `json:"ns"` } // ListDNSZoneRecordsRequest: list dns zone records request. type ListDNSZoneRecordsRequest struct { // DNSZone: DNS zone on which to filter the returned DNS zone records. DNSZone string `json:"-"` // ProjectID: project ID on which to filter the returned DNS zone records. ProjectID *string `json:"-"` // OrderBy: sort order of the returned DNS zone records. // Default value: name_asc OrderBy ListDNSZoneRecordsRequestOrderBy `json:"-"` // Page: page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: maximum number of DNS zone records per page. PageSize *uint32 `json:"-"` // Name: name on which to filter the returned DNS zone records. Name string `json:"-"` // Type: record type on which to filter the returned DNS zone records. // Default value: unknown Type RecordType `json:"-"` // ID: record ID on which to filter the returned DNS zone records. ID *string `json:"-"` } // ListDNSZoneRecordsResponse: list dns zone records response. type ListDNSZoneRecordsResponse struct { // TotalCount: total number of DNS zone records. TotalCount uint32 `json:"total_count"` // Records: paginated returned DNS zone records. Records []*Record `json:"records"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListDNSZoneRecordsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListDNSZoneRecordsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListDNSZoneRecordsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Records = append(r.Records, results.Records...) r.TotalCount += uint32(len(results.Records)) return uint32(len(results.Records)), nil } // ListDNSZoneVersionRecordsRequest: list dns zone version records request. type ListDNSZoneVersionRecordsRequest struct { DNSZoneVersionID string `json:"-"` // Page: page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: maximum number of DNS zones versions records per page. PageSize *uint32 `json:"-"` } // ListDNSZoneVersionRecordsResponse: list dns zone version records response. type ListDNSZoneVersionRecordsResponse struct { // TotalCount: total number of DNS zones versions records. TotalCount uint32 `json:"total_count"` Records []*Record `json:"records"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListDNSZoneVersionRecordsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListDNSZoneVersionRecordsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListDNSZoneVersionRecordsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Records = append(r.Records, results.Records...) r.TotalCount += uint32(len(results.Records)) return uint32(len(results.Records)), nil } // ListDNSZoneVersionsRequest: list dns zone versions request. type ListDNSZoneVersionsRequest struct { DNSZone string `json:"-"` // Page: page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: maximum number of DNS zones versions per page. PageSize *uint32 `json:"-"` } // ListDNSZoneVersionsResponse: list dns zone versions response. type ListDNSZoneVersionsResponse struct { // TotalCount: total number of DNS zones versions. TotalCount uint32 `json:"total_count"` Versions []*DNSZoneVersion `json:"versions"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListDNSZoneVersionsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListDNSZoneVersionsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListDNSZoneVersionsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Versions = append(r.Versions, results.Versions...) r.TotalCount += uint32(len(results.Versions)) return uint32(len(results.Versions)), nil } // ListDNSZonesRequest: list dns zones request. type ListDNSZonesRequest struct { // OrganizationID: organization ID on which to filter the returned DNS zones. OrganizationID *string `json:"-"` // ProjectID: project ID on which to filter the returned DNS zones. ProjectID *string `json:"-"` // OrderBy: sort order of the returned DNS zones. // Default value: domain_asc OrderBy ListDNSZonesRequestOrderBy `json:"-"` // Page: page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: maximum number of DNS zones to return per page. PageSize *uint32 `json:"-"` // Domain: domain on which to filter the returned DNS zones. Domain string `json:"-"` // Deprecated: DNSZone: DNS zone on which to filter the returned DNS zones. DNSZone *string `json:"-"` // DNSZones: DNS zones on which to filter the returned DNS zones. DNSZones []string `json:"-"` // CreatedAfter: only list DNS zones created after this date. CreatedAfter *time.Time `json:"-"` // CreatedBefore: only list DNS zones created before this date. CreatedBefore *time.Time `json:"-"` // UpdatedAfter: only list DNS zones updated after this date. UpdatedAfter *time.Time `json:"-"` // UpdatedBefore: only list DNS zones updated before this date. UpdatedBefore *time.Time `json:"-"` } // ListDNSZonesResponse: list dns zones response. type ListDNSZonesResponse struct { // TotalCount: total number of DNS zones matching the requested criteria. TotalCount uint32 `json:"total_count"` // DNSZones: paginated returned DNS zones. DNSZones []*DNSZone `json:"dns_zones"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListDNSZonesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListDNSZonesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListDNSZonesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.DNSZones = append(r.DNSZones, results.DNSZones...) r.TotalCount += uint32(len(results.DNSZones)) return uint32(len(results.DNSZones)), nil } // ListDomainHostsResponse: list domain hosts response. type ListDomainHostsResponse struct { TotalCount uint32 `json:"total_count"` Hosts []*Host `json:"hosts"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListDomainHostsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListDomainHostsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListDomainHostsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Hosts = append(r.Hosts, results.Hosts...) r.TotalCount += uint32(len(results.Hosts)) return uint32(len(results.Hosts)), nil } // ListDomainsResponse: list domains response. type ListDomainsResponse struct { TotalCount uint32 `json:"total_count"` Domains []*DomainSummary `json:"domains"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListDomainsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListDomainsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListDomainsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Domains = append(r.Domains, results.Domains...) r.TotalCount += uint32(len(results.Domains)) return uint32(len(results.Domains)), nil } // ListRenewableDomainsResponse: list renewable domains response. type ListRenewableDomainsResponse struct { TotalCount uint32 `json:"total_count"` Domains []*RenewableDomain `json:"domains"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListRenewableDomainsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListRenewableDomainsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListRenewableDomainsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Domains = append(r.Domains, results.Domains...) r.TotalCount += uint32(len(results.Domains)) return uint32(len(results.Domains)), nil } // ListSSLCertificatesRequest: list ssl certificates request. type ListSSLCertificatesRequest struct { DNSZone string `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` ProjectID *string `json:"-"` } // ListSSLCertificatesResponse: list ssl certificates response. type ListSSLCertificatesResponse struct { TotalCount uint32 `json:"total_count"` Certificates []*SSLCertificate `json:"certificates"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListSSLCertificatesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListSSLCertificatesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListSSLCertificatesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Certificates = append(r.Certificates, results.Certificates...) r.TotalCount += uint32(len(results.Certificates)) return uint32(len(results.Certificates)), nil } // ListTasksResponse: list tasks response. type ListTasksResponse struct { TotalCount uint32 `json:"total_count"` Tasks []*Task `json:"tasks"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListTasksResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListTasksResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListTasksResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Tasks = append(r.Tasks, results.Tasks...) r.TotalCount += uint32(len(results.Tasks)) return uint32(len(results.Tasks)), nil } // ListTldsResponse: list tlds response. type ListTldsResponse struct { // Tlds: array of TLDs. Tlds []*Tld `json:"tlds"` // TotalCount: total count of TLDs returned. TotalCount uint64 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListTldsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListTldsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListTldsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Tlds = append(r.Tlds, results.Tlds...) r.TotalCount += uint64(len(results.Tlds)) return uint64(len(results.Tlds)), nil } // OrderResponse: order response. type OrderResponse struct { Domains []string `json:"domains"` OrganizationID string `json:"organization_id"` ProjectID string `json:"project_id"` TaskID string `json:"task_id"` CreatedAt *time.Time `json:"created_at"` } // RefreshDNSZoneRequest: refresh dns zone request. type RefreshDNSZoneRequest struct { // DNSZone: DNS zone to refresh. DNSZone string `json:"-"` // RecreateDNSZone: specifies whether or not to recreate the DNS zone. RecreateDNSZone bool `json:"recreate_dns_zone"` // RecreateSubDNSZone: specifies whether or not to recreate the sub DNS zone. RecreateSubDNSZone bool `json:"recreate_sub_dns_zone"` } // RefreshDNSZoneResponse: refresh dns zone response. type RefreshDNSZoneResponse struct { // DNSZones: DNS zones returned. DNSZones []*DNSZone `json:"dns_zones"` } // RegisterExternalDomainResponse: register external domain response. type RegisterExternalDomainResponse struct { Domain string `json:"domain"` OrganizationID string `json:"organization_id"` ValidationToken string `json:"validation_token"` CreatedAt *time.Time `json:"created_at"` ProjectID string `json:"project_id"` } // RegistrarAPIBuyDomainsRequest: registrar api buy domains request. type RegistrarAPIBuyDomainsRequest struct { Domains []string `json:"domains"` DurationInYears uint32 `json:"duration_in_years"` ProjectID string `json:"project_id"` // Precisely one of OwnerContactID, OwnerContact must be set. OwnerContactID *string `json:"owner_contact_id,omitempty"` // Precisely one of OwnerContactID, OwnerContact must be set. OwnerContact *NewContact `json:"owner_contact,omitempty"` // Precisely one of AdministrativeContactID, AdministrativeContact must be set. AdministrativeContactID *string `json:"administrative_contact_id,omitempty"` // Precisely one of AdministrativeContactID, AdministrativeContact must be set. AdministrativeContact *NewContact `json:"administrative_contact,omitempty"` // Precisely one of TechnicalContactID, TechnicalContact must be set. TechnicalContactID *string `json:"technical_contact_id,omitempty"` // Precisely one of TechnicalContactID, TechnicalContact must be set. TechnicalContact *NewContact `json:"technical_contact,omitempty"` } // RegistrarAPICheckContactsCompatibilityRequest: registrar api check contacts compatibility request. type RegistrarAPICheckContactsCompatibilityRequest struct { Domains []string `json:"domains"` Tlds []string `json:"tlds"` // Precisely one of OwnerContactID, OwnerContact must be set. OwnerContactID *string `json:"owner_contact_id,omitempty"` // Precisely one of OwnerContactID, OwnerContact must be set. OwnerContact *NewContact `json:"owner_contact,omitempty"` // Precisely one of AdministrativeContactID, AdministrativeContact must be set. AdministrativeContactID *string `json:"administrative_contact_id,omitempty"` // Precisely one of AdministrativeContactID, AdministrativeContact must be set. AdministrativeContact *NewContact `json:"administrative_contact,omitempty"` // Precisely one of TechnicalContactID, TechnicalContact must be set. TechnicalContactID *string `json:"technical_contact_id,omitempty"` // Precisely one of TechnicalContactID, TechnicalContact must be set. TechnicalContact *NewContact `json:"technical_contact,omitempty"` } // RegistrarAPICreateDomainHostRequest: registrar api create domain host request. type RegistrarAPICreateDomainHostRequest struct { Domain string `json:"-"` Name string `json:"name"` IPs []net.IP `json:"ips"` } // RegistrarAPIDeleteDomainHostRequest: registrar api delete domain host request. type RegistrarAPIDeleteDomainHostRequest struct { Domain string `json:"-"` Name string `json:"-"` } // RegistrarAPIDeleteExternalDomainRequest: registrar api delete external domain request. type RegistrarAPIDeleteExternalDomainRequest struct { Domain string `json:"-"` } // RegistrarAPIDisableDomainAutoRenewRequest: registrar api disable domain auto renew request. type RegistrarAPIDisableDomainAutoRenewRequest struct { Domain string `json:"-"` } // RegistrarAPIDisableDomainDNSSECRequest: registrar api disable domain dnssec request. type RegistrarAPIDisableDomainDNSSECRequest struct { Domain string `json:"-"` } // RegistrarAPIEnableDomainAutoRenewRequest: registrar api enable domain auto renew request. type RegistrarAPIEnableDomainAutoRenewRequest struct { Domain string `json:"-"` } // RegistrarAPIEnableDomainDNSSECRequest: registrar api enable domain dnssec request. type RegistrarAPIEnableDomainDNSSECRequest struct { Domain string `json:"-"` DsRecord *DSRecord `json:"ds_record,omitempty"` } // RegistrarAPIGetContactRequest: registrar api get contact request. type RegistrarAPIGetContactRequest struct { ContactID string `json:"-"` } // RegistrarAPIGetDomainAuthCodeRequest: registrar api get domain auth code request. type RegistrarAPIGetDomainAuthCodeRequest struct { Domain string `json:"-"` } // RegistrarAPIGetDomainRequest: registrar api get domain request. type RegistrarAPIGetDomainRequest struct { Domain string `json:"-"` } // RegistrarAPIListContactsRequest: registrar api list contacts request. type RegistrarAPIListContactsRequest struct { Page *int32 `json:"-"` PageSize *uint32 `json:"-"` Domain *string `json:"-"` ProjectID *string `json:"-"` OrganizationID *string `json:"-"` // Role: default value: unknown_role Role ListContactsRequestRole `json:"-"` // EmailStatus: default value: email_status_unknown EmailStatus ContactEmailStatus `json:"-"` } // RegistrarAPIListDomainHostsRequest: registrar api list domain hosts request. type RegistrarAPIListDomainHostsRequest struct { Domain string `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` } // RegistrarAPIListDomainsRequest: registrar api list domains request. type RegistrarAPIListDomainsRequest struct { Page *int32 `json:"-"` PageSize *uint32 `json:"-"` // OrderBy: default value: domain_asc OrderBy ListDomainsRequestOrderBy `json:"-"` Registrar *string `json:"-"` // Status: default value: status_unknown Status DomainStatus `json:"-"` ProjectID *string `json:"-"` OrganizationID *string `json:"-"` IsExternal *bool `json:"-"` Domain *string `json:"-"` } // RegistrarAPIListRenewableDomainsRequest: registrar api list renewable domains request. type RegistrarAPIListRenewableDomainsRequest struct { Page *int32 `json:"-"` PageSize *uint32 `json:"-"` // OrderBy: default value: domain_asc OrderBy ListRenewableDomainsRequestOrderBy `json:"-"` ProjectID *string `json:"-"` OrganizationID *string `json:"-"` } // RegistrarAPIListTasksRequest: registrar api list tasks request. type RegistrarAPIListTasksRequest struct { Page *int32 `json:"-"` PageSize *uint32 `json:"-"` ProjectID *string `json:"-"` OrganizationID *string `json:"-"` Domain *string `json:"-"` Types []TaskType `json:"-"` Statuses []TaskStatus `json:"-"` // OrderBy: default value: domain_desc OrderBy ListTasksRequestOrderBy `json:"-"` } // RegistrarAPIListTldsRequest: registrar api list tlds request. type RegistrarAPIListTldsRequest struct { // Tlds: array of TLDs to return. Tlds []string `json:"-"` // Page: page number for the returned Projects. Page *int32 `json:"-"` // PageSize: maximum number of Project per page. PageSize *uint32 `json:"-"` // OrderBy: sort order of the returned TLDs. // Default value: name_asc OrderBy ListTldsRequestOrderBy `json:"-"` } // RegistrarAPILockDomainTransferRequest: registrar api lock domain transfer request. type RegistrarAPILockDomainTransferRequest struct { Domain string `json:"-"` } // RegistrarAPIRegisterExternalDomainRequest: registrar api register external domain request. type RegistrarAPIRegisterExternalDomainRequest struct { Domain string `json:"domain"` ProjectID string `json:"project_id"` } // RegistrarAPIRenewDomainsRequest: registrar api renew domains request. type RegistrarAPIRenewDomainsRequest struct { Domains []string `json:"domains"` DurationInYears uint32 `json:"duration_in_years"` ForceLateRenewal *bool `json:"force_late_renewal,omitempty"` } // RegistrarAPISearchAvailableDomainsRequest: registrar api search available domains request. type RegistrarAPISearchAvailableDomainsRequest struct { // Domains: a list of domain to search, TLD is optional. Domains []string `json:"-"` // Tlds: array of tlds to search on. Tlds []string `json:"-"` // StrictSearch: search exact match. StrictSearch bool `json:"-"` } // RegistrarAPITradeDomainRequest: registrar api trade domain request. type RegistrarAPITradeDomainRequest struct { Domain string `json:"-"` ProjectID *string `json:"project_id,omitempty"` // Precisely one of NewOwnerContactID, NewOwnerContact must be set. NewOwnerContactID *string `json:"new_owner_contact_id,omitempty"` // Precisely one of NewOwnerContactID, NewOwnerContact must be set. NewOwnerContact *NewContact `json:"new_owner_contact,omitempty"` } // RegistrarAPITransferInDomainRequest: registrar api transfer in domain request. type RegistrarAPITransferInDomainRequest struct { Domains []*TransferInDomainRequestTransferRequest `json:"domains"` ProjectID string `json:"project_id"` // Precisely one of OwnerContactID, OwnerContact must be set. OwnerContactID *string `json:"owner_contact_id,omitempty"` // Precisely one of OwnerContactID, OwnerContact must be set. OwnerContact *NewContact `json:"owner_contact,omitempty"` // Precisely one of AdministrativeContactID, AdministrativeContact must be set. AdministrativeContactID *string `json:"administrative_contact_id,omitempty"` // Precisely one of AdministrativeContactID, AdministrativeContact must be set. AdministrativeContact *NewContact `json:"administrative_contact,omitempty"` // Precisely one of TechnicalContactID, TechnicalContact must be set. TechnicalContactID *string `json:"technical_contact_id,omitempty"` // Precisely one of TechnicalContactID, TechnicalContact must be set. TechnicalContact *NewContact `json:"technical_contact,omitempty"` } // RegistrarAPIUnlockDomainTransferRequest: registrar api unlock domain transfer request. type RegistrarAPIUnlockDomainTransferRequest struct { Domain string `json:"-"` } // RegistrarAPIUpdateContactRequest: registrar api update contact request. type RegistrarAPIUpdateContactRequest struct { ContactID string `json:"-"` Email *string `json:"email,omitempty"` EmailAlt *string `json:"email_alt,omitempty"` PhoneNumber *string `json:"phone_number,omitempty"` FaxNumber *string `json:"fax_number,omitempty"` AddressLine1 *string `json:"address_line_1,omitempty"` AddressLine2 *string `json:"address_line_2,omitempty"` Zip *string `json:"zip,omitempty"` City *string `json:"city,omitempty"` Country *string `json:"country,omitempty"` VatIDentificationCode *string `json:"vat_identification_code,omitempty"` CompanyIDentificationCode *string `json:"company_identification_code,omitempty"` // Lang: default value: unknown_language_code Lang std.LanguageCode `json:"lang"` Resale *bool `json:"resale,omitempty"` // Deprecated Questions *[]*UpdateContactRequestQuestion `json:"questions,omitempty"` ExtensionFr *ContactExtensionFR `json:"extension_fr,omitempty"` ExtensionEu *ContactExtensionEU `json:"extension_eu,omitempty"` WhoisOptIn *bool `json:"whois_opt_in,omitempty"` State *string `json:"state,omitempty"` ExtensionNl *ContactExtensionNL `json:"extension_nl,omitempty"` } // RegistrarAPIUpdateDomainHostRequest: registrar api update domain host request. type RegistrarAPIUpdateDomainHostRequest struct { Domain string `json:"-"` Name string `json:"-"` IPs *[]string `json:"ips,omitempty"` } // RegistrarAPIUpdateDomainRequest: registrar api update domain request. type RegistrarAPIUpdateDomainRequest struct { Domain string `json:"-"` // Precisely one of TechnicalContactID, TechnicalContact must be set. TechnicalContactID *string `json:"technical_contact_id,omitempty"` // Precisely one of TechnicalContactID, TechnicalContact must be set. TechnicalContact *NewContact `json:"technical_contact,omitempty"` // Deprecated // Precisely one of OwnerContactID, OwnerContact must be set. OwnerContactID *string `json:"owner_contact_id,omitempty"` // Deprecated // Precisely one of OwnerContactID, OwnerContact must be set. OwnerContact *NewContact `json:"owner_contact,omitempty"` // Precisely one of AdministrativeContactID, AdministrativeContact must be set. AdministrativeContactID *string `json:"administrative_contact_id,omitempty"` // Precisely one of AdministrativeContactID, AdministrativeContact must be set. AdministrativeContact *NewContact `json:"administrative_contact,omitempty"` } // RestoreDNSZoneVersionRequest: restore dns zone version request. type RestoreDNSZoneVersionRequest struct { DNSZoneVersionID string `json:"-"` } // RestoreDNSZoneVersionResponse: restore dns zone version response. type RestoreDNSZoneVersionResponse struct { } // SearchAvailableDomainsResponse: search available domains response. type SearchAvailableDomainsResponse struct { // AvailableDomains: array of available domains. AvailableDomains []*AvailableDomain `json:"available_domains"` } // UpdateDNSZoneNameserversRequest: update dns zone nameservers request. type UpdateDNSZoneNameserversRequest struct { // DNSZone: DNS zone in which to update the DNS zone name servers. DNSZone string `json:"-"` // Ns: new DNS zone name servers. Ns []*Nameserver `json:"ns"` } // UpdateDNSZoneNameserversResponse: update dns zone nameservers response. type UpdateDNSZoneNameserversResponse struct { // Ns: DNS zone name servers returned. Ns []*Nameserver `json:"ns"` } // UpdateDNSZoneRecordsRequest: update dns zone records request. type UpdateDNSZoneRecordsRequest struct { // DNSZone: DNS zone in which to update the DNS zone records. DNSZone string `json:"-"` // Changes: changes made to the records. Changes []*RecordChange `json:"changes"` // ReturnAllRecords: specifies whether or not to return all the records. ReturnAllRecords *bool `json:"return_all_records,omitempty"` // DisallowNewZoneCreation: disable the creation of the target zone if it does not exist. Target zone creation is disabled by default. DisallowNewZoneCreation bool `json:"disallow_new_zone_creation"` // Serial: use the provided serial (0) instead of the auto-increment serial. Serial *uint64 `json:"serial,omitempty"` } // UpdateDNSZoneRecordsResponse: update dns zone records response. type UpdateDNSZoneRecordsResponse struct { // Records: DNS zone records returned. Records []*Record `json:"records"` } // UpdateDNSZoneRequest: update dns zone request. type UpdateDNSZoneRequest struct { // DNSZone: DNS zone to update. DNSZone string `json:"-"` // NewDNSZone: name of the new DNS zone to create. NewDNSZone *string `json:"new_dns_zone,omitempty"` // ProjectID: project ID in which to create the new DNS zone. ProjectID string `json:"project_id"` } // Manage your domains, DNS zones and records with the Domains and DNS API. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } // ListDNSZones: Retrieve the list of DNS zones you can manage and filter DNS zones associated with specific domain names. func (s *API) ListDNSZones(req *ListDNSZonesRequest, opts ...scw.RequestOption) (*ListDNSZonesResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "domain", req.Domain) parameter.AddToQuery(query, "dns_zone", req.DNSZone) parameter.AddToQuery(query, "dns_zones", req.DNSZones) parameter.AddToQuery(query, "created_after", req.CreatedAfter) parameter.AddToQuery(query, "created_before", req.CreatedBefore) parameter.AddToQuery(query, "updated_after", req.UpdatedAfter) parameter.AddToQuery(query, "updated_before", req.UpdatedBefore) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/domain/v2beta1/dns-zones", Query: query, } var resp ListDNSZonesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateDNSZone: Create a new DNS zone specified by the domain name, the subdomain and the Project ID. func (s *API) CreateDNSZone(req *CreateDNSZoneRequest, opts ...scw.RequestOption) (*DNSZone, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/domain/v2beta1/dns-zones", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp DNSZone err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateDNSZone: Update the name and/or the Organizations for a DNS zone. func (s *API) UpdateDNSZone(req *UpdateDNSZoneRequest, opts ...scw.RequestOption) (*DNSZone, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.DNSZone) == "" { return nil, errors.New("field DNSZone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/domain/v2beta1/dns-zones/" + fmt.Sprint(req.DNSZone) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp DNSZone err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CloneDNSZone: Clone an existing DNS zone with all its records into a new DNS zone. func (s *API) CloneDNSZone(req *CloneDNSZoneRequest, opts ...scw.RequestOption) (*DNSZone, error) { var err error if fmt.Sprint(req.DNSZone) == "" { return nil, errors.New("field DNSZone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/domain/v2beta1/dns-zones/" + fmt.Sprint(req.DNSZone) + "/clone", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp DNSZone err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteDNSZone: Delete a DNS zone and all its records. func (s *API) DeleteDNSZone(req *DeleteDNSZoneRequest, opts ...scw.RequestOption) (*DeleteDNSZoneResponse, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } query := url.Values{} parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.DNSZone) == "" { return nil, errors.New("field DNSZone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/domain/v2beta1/dns-zones/" + fmt.Sprint(req.DNSZone) + "", Query: query, } var resp DeleteDNSZoneResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListDNSZoneRecords: Retrieve a list of DNS records within a DNS zone that has default name servers. // You can filter records by type and name. func (s *API) ListDNSZoneRecords(req *ListDNSZoneRecordsRequest, opts ...scw.RequestOption) (*ListDNSZoneRecordsResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "type", req.Type) parameter.AddToQuery(query, "id", req.ID) if fmt.Sprint(req.DNSZone) == "" { return nil, errors.New("field DNSZone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/domain/v2beta1/dns-zones/" + fmt.Sprint(req.DNSZone) + "/records", Query: query, } var resp ListDNSZoneRecordsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateDNSZoneRecords: Update records within a DNS zone that has default name servers and perform several actions on your records. // // Actions include: // - add: allows you to add a new record or add a new IP to an existing A record, for example // - set: allows you to edit a record or edit an IP from an existing A record, for example // - delete: allows you to delete a record or delete an IP from an existing A record, for example // - clear: allows you to delete all records from a DNS zone // // All edits will be versioned. func (s *API) UpdateDNSZoneRecords(req *UpdateDNSZoneRecordsRequest, opts ...scw.RequestOption) (*UpdateDNSZoneRecordsResponse, error) { var err error if fmt.Sprint(req.DNSZone) == "" { return nil, errors.New("field DNSZone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/domain/v2beta1/dns-zones/" + fmt.Sprint(req.DNSZone) + "/records", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp UpdateDNSZoneRecordsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListDNSZoneNameservers: Retrieve a list of name servers within a DNS zone and their optional glue records. func (s *API) ListDNSZoneNameservers(req *ListDNSZoneNameserversRequest, opts ...scw.RequestOption) (*ListDNSZoneNameserversResponse, error) { var err error query := url.Values{} parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.DNSZone) == "" { return nil, errors.New("field DNSZone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/domain/v2beta1/dns-zones/" + fmt.Sprint(req.DNSZone) + "/nameservers", Query: query, } var resp ListDNSZoneNameserversResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateDNSZoneNameservers: Update name servers within a DNS zone and set optional glue records. func (s *API) UpdateDNSZoneNameservers(req *UpdateDNSZoneNameserversRequest, opts ...scw.RequestOption) (*UpdateDNSZoneNameserversResponse, error) { var err error if fmt.Sprint(req.DNSZone) == "" { return nil, errors.New("field DNSZone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/domain/v2beta1/dns-zones/" + fmt.Sprint(req.DNSZone) + "/nameservers", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp UpdateDNSZoneNameserversResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ClearDNSZoneRecords: Delete all records within a DNS zone that has default name servers.
// All edits will be versioned. func (s *API) ClearDNSZoneRecords(req *ClearDNSZoneRecordsRequest, opts ...scw.RequestOption) (*ClearDNSZoneRecordsResponse, error) { var err error if fmt.Sprint(req.DNSZone) == "" { return nil, errors.New("field DNSZone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/domain/v2beta1/dns-zones/" + fmt.Sprint(req.DNSZone) + "/records", } var resp ClearDNSZoneRecordsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ExportRawDNSZone: Export a DNS zone with default name servers, in a specific format. func (s *API) ExportRawDNSZone(req *ExportRawDNSZoneRequest, opts ...scw.RequestOption) (*scw.File, error) { var err error query := url.Values{} parameter.AddToQuery(query, "format", req.Format) if fmt.Sprint(req.DNSZone) == "" { return nil, errors.New("field DNSZone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/domain/v2beta1/dns-zones/" + fmt.Sprint(req.DNSZone) + "/raw", Query: query, } var resp scw.File err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ImportRawDNSZone: Import and replace the format of records from a given provider, with default name servers. func (s *API) ImportRawDNSZone(req *ImportRawDNSZoneRequest, opts ...scw.RequestOption) (*ImportRawDNSZoneResponse, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.DNSZone) == "" { return nil, errors.New("field DNSZone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/domain/v2beta1/dns-zones/" + fmt.Sprint(req.DNSZone) + "/raw", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp ImportRawDNSZoneResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ImportProviderDNSZone: Import and replace the format of records from a given provider, with default name servers. func (s *API) ImportProviderDNSZone(req *ImportProviderDNSZoneRequest, opts ...scw.RequestOption) (*ImportProviderDNSZoneResponse, error) { var err error if fmt.Sprint(req.DNSZone) == "" { return nil, errors.New("field DNSZone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/domain/v2beta1/dns-zones/" + fmt.Sprint(req.DNSZone) + "/import-provider", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp ImportProviderDNSZoneResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // RefreshDNSZone: Refresh an SOA DNS zone to reload the records in the DNS zone and update the SOA serial. // You can recreate the given DNS zone and its sub DNS zone if needed. func (s *API) RefreshDNSZone(req *RefreshDNSZoneRequest, opts ...scw.RequestOption) (*RefreshDNSZoneResponse, error) { var err error if fmt.Sprint(req.DNSZone) == "" { return nil, errors.New("field DNSZone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/domain/v2beta1/dns-zones/" + fmt.Sprint(req.DNSZone) + "/refresh", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp RefreshDNSZoneResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListDNSZoneVersions: Retrieve a list of a DNS zone's versions.
// The maximum version count is 100. If the count reaches this limit, the oldest version will be deleted after each new modification. func (s *API) ListDNSZoneVersions(req *ListDNSZoneVersionsRequest, opts ...scw.RequestOption) (*ListDNSZoneVersionsResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.DNSZone) == "" { return nil, errors.New("field DNSZone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/domain/v2beta1/dns-zones/" + fmt.Sprint(req.DNSZone) + "/versions", Query: query, } var resp ListDNSZoneVersionsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListDNSZoneVersionRecords: Retrieve a list of records from a specific DNS zone version. func (s *API) ListDNSZoneVersionRecords(req *ListDNSZoneVersionRecordsRequest, opts ...scw.RequestOption) (*ListDNSZoneVersionRecordsResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.DNSZoneVersionID) == "" { return nil, errors.New("field DNSZoneVersionID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/domain/v2beta1/dns-zones/version/" + fmt.Sprint(req.DNSZoneVersionID) + "", Query: query, } var resp ListDNSZoneVersionRecordsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetDNSZoneVersionDiff: Access a previous DNS zone version to see the differences from another specific version. func (s *API) GetDNSZoneVersionDiff(req *GetDNSZoneVersionDiffRequest, opts ...scw.RequestOption) (*GetDNSZoneVersionDiffResponse, error) { var err error if fmt.Sprint(req.DNSZoneVersionID) == "" { return nil, errors.New("field DNSZoneVersionID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/domain/v2beta1/dns-zones/version/" + fmt.Sprint(req.DNSZoneVersionID) + "/diff", } var resp GetDNSZoneVersionDiffResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // RestoreDNSZoneVersion: Restore and activate a version of a specific DNS zone. func (s *API) RestoreDNSZoneVersion(req *RestoreDNSZoneVersionRequest, opts ...scw.RequestOption) (*RestoreDNSZoneVersionResponse, error) { var err error if fmt.Sprint(req.DNSZoneVersionID) == "" { return nil, errors.New("field DNSZoneVersionID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/domain/v2beta1/dns-zones/version/" + fmt.Sprint(req.DNSZoneVersionID) + "/restore", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp RestoreDNSZoneVersionResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetSSLCertificate: Get the DNS zone's TLS certificate. If you do not have a certificate, the ouptut returns `no certificate found`. func (s *API) GetSSLCertificate(req *GetSSLCertificateRequest, opts ...scw.RequestOption) (*SSLCertificate, error) { var err error if fmt.Sprint(req.DNSZone) == "" { return nil, errors.New("field DNSZone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/domain/v2beta1/ssl-certificates/" + fmt.Sprint(req.DNSZone) + "", } var resp SSLCertificate err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateSSLCertificate: Create a new TLS certificate or retrieve information about an existing TLS certificate. func (s *API) CreateSSLCertificate(req *CreateSSLCertificateRequest, opts ...scw.RequestOption) (*SSLCertificate, error) { var err error scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/domain/v2beta1/ssl-certificates", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SSLCertificate err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListSSLCertificates: List all the TLS certificates a user has created, specified by the user's Project ID and the DNS zone. func (s *API) ListSSLCertificates(req *ListSSLCertificatesRequest, opts ...scw.RequestOption) (*ListSSLCertificatesResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "dns_zone", req.DNSZone) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "project_id", req.ProjectID) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/domain/v2beta1/ssl-certificates", Query: query, } var resp ListSSLCertificatesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteSSLCertificate: Delete an existing TLS certificate specified by its DNS zone. Deleting a TLS certificate is permanent and cannot be undone. func (s *API) DeleteSSLCertificate(req *DeleteSSLCertificateRequest, opts ...scw.RequestOption) (*DeleteSSLCertificateResponse, error) { var err error if fmt.Sprint(req.DNSZone) == "" { return nil, errors.New("field DNSZone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/domain/v2beta1/ssl-certificates/" + fmt.Sprint(req.DNSZone) + "", } var resp DeleteSSLCertificateResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetDNSZoneTsigKey: Retrieve information about the TSIG key of a given DNS zone to allow AXFR requests. func (s *API) GetDNSZoneTsigKey(req *GetDNSZoneTsigKeyRequest, opts ...scw.RequestOption) (*GetDNSZoneTsigKeyResponse, error) { var err error if fmt.Sprint(req.DNSZone) == "" { return nil, errors.New("field DNSZone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/domain/v2beta1/dns-zones/" + fmt.Sprint(req.DNSZone) + "/tsig-key", } var resp GetDNSZoneTsigKeyResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteDNSZoneTsigKey: Delete an existing TSIG key specified by its DNS zone. Deleting a TSIG key is permanent and cannot be undone. func (s *API) DeleteDNSZoneTsigKey(req *DeleteDNSZoneTsigKeyRequest, opts ...scw.RequestOption) error { var err error if fmt.Sprint(req.DNSZone) == "" { return errors.New("field DNSZone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/domain/v2beta1/dns-zones/" + fmt.Sprint(req.DNSZone) + "/tsig-key", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // Manage your domains and contacts. type RegistrarAPI struct { client *scw.Client } // NewRegistrarAPI returns a RegistrarAPI object from a Scaleway client. func NewRegistrarAPI(client *scw.Client) *RegistrarAPI { return &RegistrarAPI{ client: client, } } // ListTasks: List all operations performed on the account. // You can filter the list of tasks by domain name. func (s *RegistrarAPI) ListTasks(req *RegistrarAPIListTasksRequest, opts ...scw.RequestOption) (*ListTasksResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "domain", req.Domain) parameter.AddToQuery(query, "types", req.Types) parameter.AddToQuery(query, "statuses", req.Statuses) parameter.AddToQuery(query, "order_by", req.OrderBy) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/domain/v2beta1/tasks", Query: query, } var resp ListTasksResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // BuyDomains: Request the registration of domain names. // You can provide a domain's already existing contact or a new contact. func (s *RegistrarAPI) BuyDomains(req *RegistrarAPIBuyDomainsRequest, opts ...scw.RequestOption) (*OrderResponse, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/domain/v2beta1/buy-domains", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp OrderResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // RenewDomains: Request the renewal of one or more domain names. func (s *RegistrarAPI) RenewDomains(req *RegistrarAPIRenewDomainsRequest, opts ...scw.RequestOption) (*OrderResponse, error) { var err error scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/domain/v2beta1/renew-domains", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp OrderResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // TransferInDomain: Request the transfer of a domain from another registrar to Scaleway Domains and DNS. func (s *RegistrarAPI) TransferInDomain(req *RegistrarAPITransferInDomainRequest, opts ...scw.RequestOption) (*OrderResponse, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/domain/v2beta1/domains/transfer-domains", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp OrderResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // TradeDomain: Request to change a domain's contact owner.
// If you specify the `organization_id` of the domain's new owner, the contact will change from the current owner's Scaleway account to the new owner's Scaleway account.
// If the new owner's current contact information is not available, the first ever contact they have created for previous domains is taken into account to operate the change.
// If the new owner has never created a contact to register domains before, an error message displays. func (s *RegistrarAPI) TradeDomain(req *RegistrarAPITradeDomainRequest, opts ...scw.RequestOption) (*OrderResponse, error) { var err error if fmt.Sprint(req.Domain) == "" { return nil, errors.New("field Domain cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/domain/v2beta1/domains/" + fmt.Sprint(req.Domain) + "/trade", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp OrderResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // RegisterExternalDomain: Request the registration of an external domain name. func (s *RegistrarAPI) RegisterExternalDomain(req *RegistrarAPIRegisterExternalDomainRequest, opts ...scw.RequestOption) (*RegisterExternalDomainResponse, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/domain/v2beta1/external-domains", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp RegisterExternalDomainResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteExternalDomain: Delete an external domain name. func (s *RegistrarAPI) DeleteExternalDomain(req *RegistrarAPIDeleteExternalDomainRequest, opts ...scw.RequestOption) (*DeleteExternalDomainResponse, error) { var err error if fmt.Sprint(req.Domain) == "" { return nil, errors.New("field Domain cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/domain/v2beta1/external-domains/" + fmt.Sprint(req.Domain) + "", } var resp DeleteExternalDomainResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CheckContactsCompatibility: Check whether contacts are compatible with a domain or a TLD. // If contacts are not compatible with either the domain or the TLD, the information that needs to be corrected is returned. func (s *RegistrarAPI) CheckContactsCompatibility(req *RegistrarAPICheckContactsCompatibilityRequest, opts ...scw.RequestOption) (*CheckContactsCompatibilityResponse, error) { var err error scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/domain/v2beta1/check-contacts-compatibility", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp CheckContactsCompatibilityResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListContacts: Retrieve the list of contacts and their associated domains and roles. // You can filter the list by domain name. func (s *RegistrarAPI) ListContacts(req *RegistrarAPIListContactsRequest, opts ...scw.RequestOption) (*ListContactsResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "domain", req.Domain) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "role", req.Role) parameter.AddToQuery(query, "email_status", req.EmailStatus) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/domain/v2beta1/contacts", Query: query, } var resp ListContactsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetContact: Retrieve a contact's details from the registrar using the given contact's ID. func (s *RegistrarAPI) GetContact(req *RegistrarAPIGetContactRequest, opts ...scw.RequestOption) (*Contact, error) { var err error if fmt.Sprint(req.ContactID) == "" { return nil, errors.New("field ContactID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/domain/v2beta1/contacts/" + fmt.Sprint(req.ContactID) + "", } var resp Contact err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateContact: Edit the contact's information. func (s *RegistrarAPI) UpdateContact(req *RegistrarAPIUpdateContactRequest, opts ...scw.RequestOption) (*Contact, error) { var err error if fmt.Sprint(req.ContactID) == "" { return nil, errors.New("field ContactID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/domain/v2beta1/contacts/" + fmt.Sprint(req.ContactID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Contact err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListDomains: Retrieve the list of domains you own. func (s *RegistrarAPI) ListDomains(req *RegistrarAPIListDomainsRequest, opts ...scw.RequestOption) (*ListDomainsResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "registrar", req.Registrar) parameter.AddToQuery(query, "status", req.Status) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "is_external", req.IsExternal) parameter.AddToQuery(query, "domain", req.Domain) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/domain/v2beta1/domains", Query: query, } var resp ListDomainsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListRenewableDomains: Retrieve the list of domains you own that can be renewed. You can also see the maximum renewal duration in years for your domains that are renewable. func (s *RegistrarAPI) ListRenewableDomains(req *RegistrarAPIListRenewableDomainsRequest, opts ...scw.RequestOption) (*ListRenewableDomainsResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "organization_id", req.OrganizationID) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/domain/v2beta1/renewable-domains", Query: query, } var resp ListRenewableDomainsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetDomain: Retrieve a specific domain and display the domain's information. func (s *RegistrarAPI) GetDomain(req *RegistrarAPIGetDomainRequest, opts ...scw.RequestOption) (*Domain, error) { var err error if fmt.Sprint(req.Domain) == "" { return nil, errors.New("field Domain cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/domain/v2beta1/domains/" + fmt.Sprint(req.Domain) + "", } var resp Domain err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateDomain: Update contacts for a specific domain or create a new contact.
// If you add the same contact for multiple roles (owner, administrative, technical), only one ID will be created and used for all of the roles. func (s *RegistrarAPI) UpdateDomain(req *RegistrarAPIUpdateDomainRequest, opts ...scw.RequestOption) (*Domain, error) { var err error if fmt.Sprint(req.Domain) == "" { return nil, errors.New("field Domain cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/domain/v2beta1/domains/" + fmt.Sprint(req.Domain) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Domain err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // LockDomainTransfer: Lock the transfer of a domain. This means that the domain cannot be transferred and the authorization code cannot be requested to your current registrar. func (s *RegistrarAPI) LockDomainTransfer(req *RegistrarAPILockDomainTransferRequest, opts ...scw.RequestOption) (*Domain, error) { var err error if fmt.Sprint(req.Domain) == "" { return nil, errors.New("field Domain cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/domain/v2beta1/domains/" + fmt.Sprint(req.Domain) + "/lock-transfer", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Domain err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UnlockDomainTransfer: Unlock the transfer of a domain. This means that the domain can be transferred and the authorization code can be requested to your current registrar. func (s *RegistrarAPI) UnlockDomainTransfer(req *RegistrarAPIUnlockDomainTransferRequest, opts ...scw.RequestOption) (*Domain, error) { var err error if fmt.Sprint(req.Domain) == "" { return nil, errors.New("field Domain cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/domain/v2beta1/domains/" + fmt.Sprint(req.Domain) + "/unlock-transfer", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Domain err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // EnableDomainAutoRenew: Enable the `auto renew` feature for a domain. This means the domain will be automatically renewed before its expiry date. func (s *RegistrarAPI) EnableDomainAutoRenew(req *RegistrarAPIEnableDomainAutoRenewRequest, opts ...scw.RequestOption) (*Domain, error) { var err error if fmt.Sprint(req.Domain) == "" { return nil, errors.New("field Domain cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/domain/v2beta1/domains/" + fmt.Sprint(req.Domain) + "/enable-auto-renew", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Domain err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DisableDomainAutoRenew: Disable the `auto renew` feature for a domain. This means the domain will not be renewed before its expiry date. func (s *RegistrarAPI) DisableDomainAutoRenew(req *RegistrarAPIDisableDomainAutoRenewRequest, opts ...scw.RequestOption) (*Domain, error) { var err error if fmt.Sprint(req.Domain) == "" { return nil, errors.New("field Domain cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/domain/v2beta1/domains/" + fmt.Sprint(req.Domain) + "/disable-auto-renew", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Domain err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetDomainAuthCode: Retrieve the authorization code to tranfer an unlocked domain. The output returns an error if the domain is locked. // Some TLDs may have a different procedure to retrieve the authorization code. In that case, the information displays in the message field. func (s *RegistrarAPI) GetDomainAuthCode(req *RegistrarAPIGetDomainAuthCodeRequest, opts ...scw.RequestOption) (*GetDomainAuthCodeResponse, error) { var err error if fmt.Sprint(req.Domain) == "" { return nil, errors.New("field Domain cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/domain/v2beta1/domains/" + fmt.Sprint(req.Domain) + "/auth-code", } var resp GetDomainAuthCodeResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // EnableDomainDNSSEC: If your domain has the default Scaleway NS and uses another registrar, you have to update the DS record manually. func (s *RegistrarAPI) EnableDomainDNSSEC(req *RegistrarAPIEnableDomainDNSSECRequest, opts ...scw.RequestOption) (*Domain, error) { var err error if fmt.Sprint(req.Domain) == "" { return nil, errors.New("field Domain cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/domain/v2beta1/domains/" + fmt.Sprint(req.Domain) + "/enable-dnssec", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Domain err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DisableDomainDNSSEC: Disable DNSSEC for a domain. func (s *RegistrarAPI) DisableDomainDNSSEC(req *RegistrarAPIDisableDomainDNSSECRequest, opts ...scw.RequestOption) (*Domain, error) { var err error if fmt.Sprint(req.Domain) == "" { return nil, errors.New("field Domain cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/domain/v2beta1/domains/" + fmt.Sprint(req.Domain) + "/disable-dnssec", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Domain err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SearchAvailableDomains: Search a domain or a maximum of 10 domains that are available. // // If the TLD list is empty or not set, the search returns the results from the most popular TLDs. func (s *RegistrarAPI) SearchAvailableDomains(req *RegistrarAPISearchAvailableDomainsRequest, opts ...scw.RequestOption) (*SearchAvailableDomainsResponse, error) { var err error query := url.Values{} parameter.AddToQuery(query, "domains", req.Domains) parameter.AddToQuery(query, "tlds", req.Tlds) parameter.AddToQuery(query, "strict_search", req.StrictSearch) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/domain/v2beta1/search-domains", Query: query, } var resp SearchAvailableDomainsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListTlds: Retrieve the list of TLDs and offers associated with them. func (s *RegistrarAPI) ListTlds(req *RegistrarAPIListTldsRequest, opts ...scw.RequestOption) (*ListTldsResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "tlds", req.Tlds) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/domain/v2beta1/tlds", Query: query, } var resp ListTldsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateDomainHost: Create a hostname for a domain with glue IPs. func (s *RegistrarAPI) CreateDomainHost(req *RegistrarAPICreateDomainHostRequest, opts ...scw.RequestOption) (*Host, error) { var err error if fmt.Sprint(req.Domain) == "" { return nil, errors.New("field Domain cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/domain/v2beta1/domains/" + fmt.Sprint(req.Domain) + "/hosts", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Host err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListDomainHosts: List a domain's hostnames using their glue IPs. func (s *RegistrarAPI) ListDomainHosts(req *RegistrarAPIListDomainHostsRequest, opts ...scw.RequestOption) (*ListDomainHostsResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Domain) == "" { return nil, errors.New("field Domain cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/domain/v2beta1/domains/" + fmt.Sprint(req.Domain) + "/hosts", Query: query, } var resp ListDomainHostsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateDomainHost: Update a domain's hostname with glue IPs. func (s *RegistrarAPI) UpdateDomainHost(req *RegistrarAPIUpdateDomainHostRequest, opts ...scw.RequestOption) (*Host, error) { var err error if fmt.Sprint(req.Domain) == "" { return nil, errors.New("field Domain cannot be empty in request") } if fmt.Sprint(req.Name) == "" { return nil, errors.New("field Name cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/domain/v2beta1/domains/" + fmt.Sprint(req.Domain) + "/hosts/" + fmt.Sprint(req.Name) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Host err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteDomainHost: Delete a domain's hostname. func (s *RegistrarAPI) DeleteDomainHost(req *RegistrarAPIDeleteDomainHostRequest, opts ...scw.RequestOption) (*Host, error) { var err error if fmt.Sprint(req.Domain) == "" { return nil, errors.New("field Domain cannot be empty in request") } if fmt.Sprint(req.Name) == "" { return nil, errors.New("field Name cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/domain/v2beta1/domains/" + fmt.Sprint(req.Domain) + "/hosts/" + fmt.Sprint(req.Name) + "", } var resp Host err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/domain/v2beta1/domain_utils.go000066400000000000000000000062611456366605600305650ustar00rootroot00000000000000package domain import ( "fmt" "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) const ( defaultRetryInterval = 15 * time.Second defaultTimeout = 5 * time.Minute ) const ( // ErrCodeNoSuchDNSZone for service response error code // // The specified dns zone does not exist. ErrCodeNoSuchDNSZone = "NoSuchDNSZone" ErrCodeNoSuchDNSRecord = "NoSuchDNSRecord" ) // WaitForDNSZoneRequest is used by WaitForDNSZone method. type WaitForDNSZoneRequest struct { DNSZone string DNSZones []string Timeout *time.Duration RetryInterval *time.Duration } func (s *API) WaitForDNSZone( req *WaitForDNSZoneRequest, opts ...scw.RequestOption, ) (*DNSZone, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[DNSZoneStatus]struct{}{ DNSZoneStatusActive: {}, DNSZoneStatusLocked: {}, DNSZoneStatusError: {}, } dns, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { listReq := &ListDNSZonesRequest{ DNSZones: req.DNSZones, } if req.DNSZone != "" { listReq.DNSZone = &req.DNSZone } // listing dns zones and take the first one DNSZones, err := s.ListDNSZones(listReq, opts...) if err != nil { return nil, false, err } if len(DNSZones.DNSZones) == 0 { return nil, true, fmt.Errorf(ErrCodeNoSuchDNSZone) } Dns := DNSZones.DNSZones[0] _, isTerminal := terminalStatus[Dns.Status] return Dns, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for DNS failed") } return dns.(*DNSZone), nil } // WaitForDNSRecordExistRequest is used by WaitForDNSRecordExist method. type WaitForDNSRecordExistRequest struct { DNSZone string RecordName string RecordType RecordType Timeout *time.Duration RetryInterval *time.Duration } func (s *API) WaitForDNSRecordExist( req *WaitForDNSRecordExistRequest, opts ...scw.RequestOption, ) (*Record, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } dns, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { // listing dns zone records and take the first one DNSRecords, err := s.ListDNSZoneRecords(&ListDNSZoneRecordsRequest{ Name: req.RecordName, Type: req.RecordType, DNSZone: req.DNSZone, }, opts...) if err != nil { return nil, false, err } if DNSRecords.TotalCount == 0 { return nil, false, fmt.Errorf(ErrCodeNoSuchDNSRecord) } record := DNSRecords.Records[0] return record, true, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "check for DNS Record exist failed") } return dns.(*Record), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/flexibleip/000077500000000000000000000000001456366605600251525ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/flexibleip/v1alpha1/000077500000000000000000000000001456366605600265675ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/flexibleip/v1alpha1/flexibleip_helpers.go000066400000000000000000000040441456366605600327650ustar00rootroot00000000000000package flexibleip import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) const ( waitForFlexibleIPDefaultTimeout = 15 * time.Minute defaultRetryInterval = 5 * time.Second ) // WaitForFlexibleIPRequest is used by WaitForFlexibleIP method. type WaitForFlexibleIPRequest struct { FipID string Zone scw.Zone Timeout *time.Duration RetryInterval *time.Duration } // WaitForFlexibleIP waits for the FlexibleIP to be in a ready state before returning. func (s *API) WaitForFlexibleIP(req *WaitForFlexibleIPRequest, opts ...scw.RequestOption) (*FlexibleIP, error) { timeout := waitForFlexibleIPDefaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } fipTerminalStatus := map[FlexibleIPStatus]struct{}{ FlexibleIPStatusError: {}, FlexibleIPStatusReady: {}, FlexibleIPStatusAttached: {}, FlexibleIPStatusLocked: {}, } macAddressTerminalStatus := map[MACAddressStatus]struct{}{ MACAddressStatusUnknown: {}, MACAddressStatusReady: {}, MACAddressStatusUsed: {}, MACAddressStatusError: {}, } fip, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { fip, err := s.GetFlexibleIP(&GetFlexibleIPRequest{ FipID: req.FipID, Zone: req.Zone, }, opts...) if err != nil { return nil, false, err } // Check if the MACAddress is in a terminal state isMacAddressTerminal := true if fip.MacAddress != nil { _, isMacAddressTerminal = macAddressTerminalStatus[fip.MacAddress.Status] } _, isTerminal := fipTerminalStatus[fip.Status] return fip, isTerminal && isMacAddressTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for FlexibleIP failed") } return fip.(*FlexibleIP), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/flexibleip/v1alpha1/flexibleip_sdk.go000066400000000000000000000601771456366605600321150ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package flexibleip provides methods and message types of the flexibleip v1alpha1 API. package flexibleip import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type FlexibleIPStatus string const ( FlexibleIPStatusUnknown = FlexibleIPStatus("unknown") FlexibleIPStatusReady = FlexibleIPStatus("ready") FlexibleIPStatusUpdating = FlexibleIPStatus("updating") FlexibleIPStatusAttached = FlexibleIPStatus("attached") FlexibleIPStatusError = FlexibleIPStatus("error") FlexibleIPStatusDetaching = FlexibleIPStatus("detaching") FlexibleIPStatusLocked = FlexibleIPStatus("locked") ) func (enum FlexibleIPStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum FlexibleIPStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *FlexibleIPStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = FlexibleIPStatus(FlexibleIPStatus(tmp).String()) return nil } type ListFlexibleIPsRequestOrderBy string const ( ListFlexibleIPsRequestOrderByCreatedAtAsc = ListFlexibleIPsRequestOrderBy("created_at_asc") ListFlexibleIPsRequestOrderByCreatedAtDesc = ListFlexibleIPsRequestOrderBy("created_at_desc") ) func (enum ListFlexibleIPsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListFlexibleIPsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListFlexibleIPsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListFlexibleIPsRequestOrderBy(ListFlexibleIPsRequestOrderBy(tmp).String()) return nil } type MACAddressStatus string const ( MACAddressStatusUnknown = MACAddressStatus("unknown") MACAddressStatusReady = MACAddressStatus("ready") MACAddressStatusUpdating = MACAddressStatus("updating") MACAddressStatusUsed = MACAddressStatus("used") MACAddressStatusError = MACAddressStatus("error") MACAddressStatusDeleting = MACAddressStatus("deleting") ) func (enum MACAddressStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum MACAddressStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *MACAddressStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = MACAddressStatus(MACAddressStatus(tmp).String()) return nil } type MACAddressType string const ( MACAddressTypeUnknownType = MACAddressType("unknown_type") MACAddressTypeVmware = MACAddressType("vmware") MACAddressTypeXen = MACAddressType("xen") MACAddressTypeKvm = MACAddressType("kvm") ) func (enum MACAddressType) String() string { if enum == "" { // return default value if empty return "unknown_type" } return string(enum) } func (enum MACAddressType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *MACAddressType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = MACAddressType(MACAddressType(tmp).String()) return nil } // MACAddress: mac address. type MACAddress struct { // ID: ID of the flexible IP. ID string `json:"id"` // MacAddress: mAC address of the Virtual MAC. MacAddress string `json:"mac_address"` // MacType: type of virtual MAC. // Default value: unknown_type MacType MACAddressType `json:"mac_type"` // Status: status of virtual MAC. // Default value: unknown Status MACAddressStatus `json:"status"` // UpdatedAt: date on which the virtual MAC was last updated. UpdatedAt *time.Time `json:"updated_at"` // CreatedAt: date on which the virtual MAC was created. CreatedAt *time.Time `json:"created_at"` // Zone: mAC address IP Availability Zone. Zone scw.Zone `json:"zone"` } // FlexibleIP: flexible ip. type FlexibleIP struct { // ID: ID of the flexible IP. ID string `json:"id"` // OrganizationID: ID of the Organization the flexible IP is attached to. OrganizationID string `json:"organization_id"` // ProjectID: ID of the Project the flexible IP is attached to. ProjectID string `json:"project_id"` // Description: flexible IP description. Description string `json:"description"` // Tags: flexible IP tags. Tags []string `json:"tags"` // UpdatedAt: date on which the flexible IP was last updated. UpdatedAt *time.Time `json:"updated_at"` // CreatedAt: date on which the flexible IP was created. CreatedAt *time.Time `json:"created_at"` // Status: - ready : flexible IP is created and ready to be attached to a server or to be associated with a virtual MAC. // - updating: flexible IP is being attached to a server or a virtual MAC operation is ongoing // - attached: flexible IP is attached to a server // - error: a flexible IP operation resulted in an error // - detaching: flexible IP is being detached from a server // - locked: the resource of the flexible IP is locked. // Default value: unknown Status FlexibleIPStatus `json:"status"` // IPAddress: IP of the flexible IP. IPAddress scw.IPNet `json:"ip_address"` // MacAddress: mAC address of the flexible IP. MacAddress *MACAddress `json:"mac_address"` // ServerID: ID of the server linked to the flexible IP. ServerID *string `json:"server_id"` // Reverse: reverse DNS value. Reverse string `json:"reverse"` // Zone: availability Zone of the flexible IP. Zone scw.Zone `json:"zone"` } // AttachFlexibleIPRequest: attach flexible ip request. type AttachFlexibleIPRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // FipsIDs: multiple IDs can be provided, but note that flexible IPs must belong to the same MAC group (see details about MAC groups). FipsIDs []string `json:"fips_ids"` // ServerID: ID of the server on which to attach the flexible IPs. ServerID string `json:"server_id"` } // AttachFlexibleIPsResponse: attach flexible i ps response. type AttachFlexibleIPsResponse struct { // TotalCount: total count of flexible IPs that are being updated. TotalCount uint32 `json:"total_count"` // FlexibleIPs: list of flexible IPs in an updating state. FlexibleIPs []*FlexibleIP `json:"flexible_ips"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *AttachFlexibleIPsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *AttachFlexibleIPsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*AttachFlexibleIPsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.FlexibleIPs = append(r.FlexibleIPs, results.FlexibleIPs...) r.TotalCount += uint32(len(results.FlexibleIPs)) return uint32(len(results.FlexibleIPs)), nil } // CreateFlexibleIPRequest: create flexible ip request. type CreateFlexibleIPRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ProjectID: ID of the project to associate with the Flexible IP. ProjectID string `json:"project_id"` // Description: flexible IP description (max. of 255 characters). Description string `json:"description"` // Tags: tags to associate to the flexible IP. Tags []string `json:"tags"` // ServerID: ID of the server to which the newly created flexible IP will be attached. ServerID *string `json:"server_id,omitempty"` // Reverse: value of the reverse DNS. Reverse *string `json:"reverse,omitempty"` // IsIPv6: defines whether the flexible IP has an IPv6 address. IsIPv6 bool `json:"is_ipv6"` } // DeleteFlexibleIPRequest: delete flexible ip request. type DeleteFlexibleIPRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // FipID: ID of the flexible IP to delete. FipID string `json:"-"` } // DeleteMACAddrRequest: delete mac addr request. type DeleteMACAddrRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // FipID: if the flexible IP belongs to a MAC group, the MAC will be removed from both the MAC group and flexible IP. FipID string `json:"-"` } // DetachFlexibleIPRequest: detach flexible ip request. type DetachFlexibleIPRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // FipsIDs: list of flexible IP IDs to detach from a server. Multiple IDs can be provided. Note that flexible IPs must belong to the same MAC group. FipsIDs []string `json:"fips_ids"` } // DetachFlexibleIPsResponse: detach flexible i ps response. type DetachFlexibleIPsResponse struct { // TotalCount: total count of flexible IPs that are being detached. TotalCount uint32 `json:"total_count"` // FlexibleIPs: list of flexible IPs in a detaching state. FlexibleIPs []*FlexibleIP `json:"flexible_ips"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *DetachFlexibleIPsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *DetachFlexibleIPsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*DetachFlexibleIPsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.FlexibleIPs = append(r.FlexibleIPs, results.FlexibleIPs...) r.TotalCount += uint32(len(results.FlexibleIPs)) return uint32(len(results.FlexibleIPs)), nil } // DuplicateMACAddrRequest: duplicate mac addr request. type DuplicateMACAddrRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // FipID: note that the flexible IPs need to be attached to the same server. FipID string `json:"-"` // DuplicateFromFipID: note that flexible IPs need to be attached to the same server. DuplicateFromFipID string `json:"duplicate_from_fip_id"` } // GenerateMACAddrRequest: generate mac addr request. type GenerateMACAddrRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // FipID: ID of the flexible IP for which to generate a virtual MAC. FipID string `json:"-"` // MacType: tODO. // Default value: unknown_type MacType MACAddressType `json:"mac_type"` } // GetFlexibleIPRequest: get flexible ip request. type GetFlexibleIPRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // FipID: ID of the flexible IP. FipID string `json:"-"` } // ListFlexibleIPsRequest: list flexible i ps request. type ListFlexibleIPsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // OrderBy: sort order of the returned flexible IPs. // Default value: created_at_asc OrderBy ListFlexibleIPsRequestOrderBy `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: maximum number of flexible IPs per page. PageSize *uint32 `json:"-"` // Tags: filter by tag, only flexible IPs with one or more matching tags will be returned. Tags []string `json:"-"` // Status: filter by status, only flexible IPs with this status will be returned. Status []FlexibleIPStatus `json:"-"` // ServerIDs: filter by server IDs, only flexible IPs with these server IDs will be returned. ServerIDs []string `json:"-"` // OrganizationID: filter by Organization ID, only flexible IPs from this Organization will be returned. OrganizationID *string `json:"-"` // ProjectID: filter by Project ID, only flexible IPs from this Project will be returned. ProjectID *string `json:"-"` } // ListFlexibleIPsResponse: list flexible i ps response. type ListFlexibleIPsResponse struct { // TotalCount: total count of matching flexible IPs. TotalCount uint32 `json:"total_count"` // FlexibleIPs: list of all flexible IPs. FlexibleIPs []*FlexibleIP `json:"flexible_ips"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListFlexibleIPsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListFlexibleIPsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListFlexibleIPsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.FlexibleIPs = append(r.FlexibleIPs, results.FlexibleIPs...) r.TotalCount += uint32(len(results.FlexibleIPs)) return uint32(len(results.FlexibleIPs)), nil } // MoveMACAddrRequest: move mac addr request. type MoveMACAddrRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` FipID string `json:"-"` DstFipID string `json:"dst_fip_id"` } // UpdateFlexibleIPRequest: update flexible ip request. type UpdateFlexibleIPRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // FipID: ID of the flexible IP to update. FipID string `json:"-"` // Description: flexible IP description (max. 255 characters). Description *string `json:"description,omitempty"` // Tags: tags associated with the flexible IP. Tags *[]string `json:"tags,omitempty"` // Reverse: value of the reverse DNS. Reverse *string `json:"reverse,omitempty"` } // Elastic Metal - Flexible IP API. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Zones() []scw.Zone { return []scw.Zone{scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1} } // CreateFlexibleIP: Generate a new flexible IP within a given zone, specifying its configuration including Project ID and description. func (s *API) CreateFlexibleIP(req *CreateFlexibleIPRequest, opts ...scw.RequestOption) (*FlexibleIP, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/flexible-ip/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/fips", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp FlexibleIP err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetFlexibleIP: Retrieve information about an existing flexible IP, specified by its ID and zone. Its full details, including Project ID, description and status, are returned in the response object. func (s *API) GetFlexibleIP(req *GetFlexibleIPRequest, opts ...scw.RequestOption) (*FlexibleIP, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.FipID) == "" { return nil, errors.New("field FipID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/flexible-ip/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/fips/" + fmt.Sprint(req.FipID) + "", } var resp FlexibleIP err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListFlexibleIPs: List all flexible IPs within a given zone. func (s *API) ListFlexibleIPs(req *ListFlexibleIPsRequest, opts ...scw.RequestOption) (*ListFlexibleIPsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "tags", req.Tags) parameter.AddToQuery(query, "status", req.Status) parameter.AddToQuery(query, "server_ids", req.ServerIDs) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/flexible-ip/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/fips", Query: query, } var resp ListFlexibleIPsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateFlexibleIP: Update the parameters of an existing flexible IP, specified by its ID and zone. These parameters include tags and description. func (s *API) UpdateFlexibleIP(req *UpdateFlexibleIPRequest, opts ...scw.RequestOption) (*FlexibleIP, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.FipID) == "" { return nil, errors.New("field FipID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/flexible-ip/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/fips/" + fmt.Sprint(req.FipID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp FlexibleIP err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteFlexibleIP: Delete an existing flexible IP, specified by its ID and zone. Note that deleting a flexible IP is permanent and cannot be undone. func (s *API) DeleteFlexibleIP(req *DeleteFlexibleIPRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.FipID) == "" { return errors.New("field FipID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/flexible-ip/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/fips/" + fmt.Sprint(req.FipID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // AttachFlexibleIP: Attach an existing flexible IP to a specified Elastic Metal server. func (s *API) AttachFlexibleIP(req *AttachFlexibleIPRequest, opts ...scw.RequestOption) (*AttachFlexibleIPsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/flexible-ip/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/fips/attach", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp AttachFlexibleIPsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DetachFlexibleIP: Detach an existing flexible IP from a specified Elastic Metal server. func (s *API) DetachFlexibleIP(req *DetachFlexibleIPRequest, opts ...scw.RequestOption) (*DetachFlexibleIPsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/flexible-ip/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/fips/detach", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp DetachFlexibleIPsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GenerateMACAddr: Generate a virtual MAC (Media Access Control) address on an existing flexible IP. func (s *API) GenerateMACAddr(req *GenerateMACAddrRequest, opts ...scw.RequestOption) (*FlexibleIP, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.FipID) == "" { return nil, errors.New("field FipID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/flexible-ip/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/fips/" + fmt.Sprint(req.FipID) + "/mac", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp FlexibleIP err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DuplicateMACAddr: Duplicate a virtual MAC address from a given flexible IP to another flexible IP attached to the same server. func (s *API) DuplicateMACAddr(req *DuplicateMACAddrRequest, opts ...scw.RequestOption) (*FlexibleIP, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.FipID) == "" { return nil, errors.New("field FipID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/flexible-ip/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/fips/" + fmt.Sprint(req.FipID) + "/mac/duplicate", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp FlexibleIP err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // MoveMACAddr: Relocate a virtual MAC (Media Access Control) address from an existing flexible IP to a different flexible IP. func (s *API) MoveMACAddr(req *MoveMACAddrRequest, opts ...scw.RequestOption) (*FlexibleIP, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.FipID) == "" { return nil, errors.New("field FipID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/flexible-ip/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/fips/" + fmt.Sprint(req.FipID) + "/mac/move", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp FlexibleIP err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteMACAddr: Detach a given MAC (Media Access Control) address from an existing flexible IP. func (s *API) DeleteMACAddr(req *DeleteMACAddrRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.FipID) == "" { return errors.New("field FipID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/flexible-ip/v1alpha1/zones/" + fmt.Sprint(req.Zone) + "/fips/" + fmt.Sprint(req.FipID) + "/mac", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/function/000077500000000000000000000000001456366605600246545ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/function/v1beta1/000077500000000000000000000000001456366605600261175ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/function/v1beta1/function_helpers.go000066400000000000000000000156241456366605600320250ustar00rootroot00000000000000package function import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) const ( waitForNamespaceDefaultTimeout = 15 * time.Minute waitForCronDefaultTimeout = 15 * time.Minute waitForDomainDefaultTimeout = 15 * time.Minute waitForFunctionDefaultTimeout = 15 * time.Minute waitForTriggerDefaultTimeout = 15 * time.Minute defaultRetryInterval = 5 * time.Second ) // WaitForNamespaceRequest is used by WaitForNamespace method. type WaitForNamespaceRequest struct { NamespaceID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForNamespace waits for the Namespace to be in a ready state before returning. func (s *API) WaitForNamespace(req *WaitForNamespaceRequest, opts ...scw.RequestOption) (*Namespace, error) { timeout := waitForNamespaceDefaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[NamespaceStatus]struct{}{ NamespaceStatusError: {}, NamespaceStatusReady: {}, NamespaceStatusLocked: {}, } namespace, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { namespace, err := s.GetNamespace(&GetNamespaceRequest{ NamespaceID: req.NamespaceID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[namespace.Status] return namespace, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for Namespace failed") } return namespace.(*Namespace), nil } // WaitForFunctionRequest is used by WaitForNamespace method. type WaitForFunctionRequest struct { FunctionID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForFunction waits for the Function to be in a ready state before returning. func (s *API) WaitForFunction(req *WaitForFunctionRequest, opts ...scw.RequestOption) (*Function, error) { timeout := waitForFunctionDefaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[FunctionStatus]struct{}{ FunctionStatusCreated: {}, FunctionStatusError: {}, FunctionStatusLocked: {}, FunctionStatusReady: {}, } function, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { function, err := s.GetFunction(&GetFunctionRequest{ FunctionID: req.FunctionID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[function.Status] return function, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for function failed") } return function.(*Function), nil } // WaitForCronRequest is used by WaitForNamespace method. type WaitForCronRequest struct { CronID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForCron waits for the Cron to be in a ready state before returning. func (s *API) WaitForCron(req *WaitForCronRequest, opts ...scw.RequestOption) (*Cron, error) { timeout := waitForCronDefaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[CronStatus]struct{}{ CronStatusError: {}, CronStatusReady: {}, CronStatusLocked: {}, } cron, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { cron, err := s.GetCron(&GetCronRequest{ CronID: req.CronID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[cron.Status] return cron, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for Cron failed") } return cron.(*Cron), nil } // WaitForDomainRequest waits for the Domain to be in a ready state before returning. type WaitForDomainRequest struct { DomainID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForDomain waits for the Domain to be in a ready state before returning. func (s *API) WaitForDomain(req *WaitForDomainRequest, opts ...scw.RequestOption) (*Domain, error) { timeout := waitForDomainDefaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[DomainStatus]struct{}{ DomainStatusError: {}, DomainStatusReady: {}, } domain, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { domain, err := s.GetDomain(&GetDomainRequest{ DomainID: req.DomainID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[domain.Status] return domain, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for Domain failed") } return domain.(*Domain), nil } // WaitForTriggerRequest waits for the Trigger to be in a ready state before returning. type WaitForTriggerRequest struct { TriggerID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForTrigger waits for the Trigger to be in a ready state before returning. func (s *API) WaitForTrigger(req *WaitForTriggerRequest, opts ...scw.RequestOption) (*Trigger, error) { timeout := waitForTriggerDefaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[TriggerStatus]struct{}{ TriggerStatusError: {}, TriggerStatusReady: {}, } trigger, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { trigger, err := s.GetTrigger(&GetTriggerRequest{ TriggerID: req.TriggerID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[trigger.Status] return trigger, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for Trigger failed") } return trigger.(*Trigger), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/function/v1beta1/function_sdk.go000066400000000000000000002461211456366605600311420ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package function provides methods and message types of the function v1beta1 API. package function import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type CronStatus string const ( CronStatusUnknown = CronStatus("unknown") CronStatusReady = CronStatus("ready") CronStatusDeleting = CronStatus("deleting") CronStatusError = CronStatus("error") CronStatusLocked = CronStatus("locked") CronStatusCreating = CronStatus("creating") CronStatusPending = CronStatus("pending") ) func (enum CronStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum CronStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *CronStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = CronStatus(CronStatus(tmp).String()) return nil } type DomainStatus string const ( DomainStatusUnknown = DomainStatus("unknown") DomainStatusReady = DomainStatus("ready") DomainStatusDeleting = DomainStatus("deleting") DomainStatusError = DomainStatus("error") DomainStatusCreating = DomainStatus("creating") DomainStatusPending = DomainStatus("pending") ) func (enum DomainStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum DomainStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DomainStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DomainStatus(DomainStatus(tmp).String()) return nil } type FunctionHTTPOption string const ( FunctionHTTPOptionUnknownHTTPOption = FunctionHTTPOption("unknown_http_option") FunctionHTTPOptionEnabled = FunctionHTTPOption("enabled") FunctionHTTPOptionRedirected = FunctionHTTPOption("redirected") ) func (enum FunctionHTTPOption) String() string { if enum == "" { // return default value if empty return "unknown_http_option" } return string(enum) } func (enum FunctionHTTPOption) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *FunctionHTTPOption) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = FunctionHTTPOption(FunctionHTTPOption(tmp).String()) return nil } type FunctionPrivacy string const ( FunctionPrivacyUnknownPrivacy = FunctionPrivacy("unknown_privacy") FunctionPrivacyPublic = FunctionPrivacy("public") FunctionPrivacyPrivate = FunctionPrivacy("private") ) func (enum FunctionPrivacy) String() string { if enum == "" { // return default value if empty return "unknown_privacy" } return string(enum) } func (enum FunctionPrivacy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *FunctionPrivacy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = FunctionPrivacy(FunctionPrivacy(tmp).String()) return nil } type FunctionRuntime string const ( FunctionRuntimeUnknownRuntime = FunctionRuntime("unknown_runtime") FunctionRuntimeGolang = FunctionRuntime("golang") FunctionRuntimePython = FunctionRuntime("python") FunctionRuntimePython3 = FunctionRuntime("python3") FunctionRuntimeNode8 = FunctionRuntime("node8") FunctionRuntimeNode10 = FunctionRuntime("node10") FunctionRuntimeNode14 = FunctionRuntime("node14") FunctionRuntimeNode16 = FunctionRuntime("node16") FunctionRuntimeNode17 = FunctionRuntime("node17") FunctionRuntimePython37 = FunctionRuntime("python37") FunctionRuntimePython38 = FunctionRuntime("python38") FunctionRuntimePython39 = FunctionRuntime("python39") FunctionRuntimePython310 = FunctionRuntime("python310") FunctionRuntimeGo113 = FunctionRuntime("go113") FunctionRuntimeGo117 = FunctionRuntime("go117") FunctionRuntimeGo118 = FunctionRuntime("go118") FunctionRuntimeNode18 = FunctionRuntime("node18") FunctionRuntimeRust165 = FunctionRuntime("rust165") FunctionRuntimeGo119 = FunctionRuntime("go119") FunctionRuntimePython311 = FunctionRuntime("python311") FunctionRuntimePhp82 = FunctionRuntime("php82") FunctionRuntimeNode19 = FunctionRuntime("node19") FunctionRuntimeGo120 = FunctionRuntime("go120") FunctionRuntimeNode20 = FunctionRuntime("node20") FunctionRuntimeGo121 = FunctionRuntime("go121") ) func (enum FunctionRuntime) String() string { if enum == "" { // return default value if empty return "unknown_runtime" } return string(enum) } func (enum FunctionRuntime) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *FunctionRuntime) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = FunctionRuntime(FunctionRuntime(tmp).String()) return nil } type FunctionStatus string const ( FunctionStatusUnknown = FunctionStatus("unknown") FunctionStatusReady = FunctionStatus("ready") FunctionStatusDeleting = FunctionStatus("deleting") FunctionStatusError = FunctionStatus("error") FunctionStatusLocked = FunctionStatus("locked") FunctionStatusCreating = FunctionStatus("creating") FunctionStatusPending = FunctionStatus("pending") FunctionStatusCreated = FunctionStatus("created") ) func (enum FunctionStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum FunctionStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *FunctionStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = FunctionStatus(FunctionStatus(tmp).String()) return nil } type ListCronsRequestOrderBy string const ( ListCronsRequestOrderByCreatedAtAsc = ListCronsRequestOrderBy("created_at_asc") ListCronsRequestOrderByCreatedAtDesc = ListCronsRequestOrderBy("created_at_desc") ) func (enum ListCronsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListCronsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListCronsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListCronsRequestOrderBy(ListCronsRequestOrderBy(tmp).String()) return nil } type ListDomainsRequestOrderBy string const ( ListDomainsRequestOrderByCreatedAtAsc = ListDomainsRequestOrderBy("created_at_asc") ListDomainsRequestOrderByCreatedAtDesc = ListDomainsRequestOrderBy("created_at_desc") ListDomainsRequestOrderByHostnameAsc = ListDomainsRequestOrderBy("hostname_asc") ListDomainsRequestOrderByHostnameDesc = ListDomainsRequestOrderBy("hostname_desc") ) func (enum ListDomainsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListDomainsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListDomainsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListDomainsRequestOrderBy(ListDomainsRequestOrderBy(tmp).String()) return nil } type ListFunctionsRequestOrderBy string const ( ListFunctionsRequestOrderByCreatedAtAsc = ListFunctionsRequestOrderBy("created_at_asc") ListFunctionsRequestOrderByCreatedAtDesc = ListFunctionsRequestOrderBy("created_at_desc") ListFunctionsRequestOrderByNameAsc = ListFunctionsRequestOrderBy("name_asc") ListFunctionsRequestOrderByNameDesc = ListFunctionsRequestOrderBy("name_desc") ) func (enum ListFunctionsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListFunctionsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListFunctionsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListFunctionsRequestOrderBy(ListFunctionsRequestOrderBy(tmp).String()) return nil } type ListLogsRequestOrderBy string const ( ListLogsRequestOrderByTimestampDesc = ListLogsRequestOrderBy("timestamp_desc") ListLogsRequestOrderByTimestampAsc = ListLogsRequestOrderBy("timestamp_asc") ) func (enum ListLogsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "timestamp_desc" } return string(enum) } func (enum ListLogsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListLogsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListLogsRequestOrderBy(ListLogsRequestOrderBy(tmp).String()) return nil } type ListNamespacesRequestOrderBy string const ( ListNamespacesRequestOrderByCreatedAtAsc = ListNamespacesRequestOrderBy("created_at_asc") ListNamespacesRequestOrderByCreatedAtDesc = ListNamespacesRequestOrderBy("created_at_desc") ListNamespacesRequestOrderByNameAsc = ListNamespacesRequestOrderBy("name_asc") ListNamespacesRequestOrderByNameDesc = ListNamespacesRequestOrderBy("name_desc") ) func (enum ListNamespacesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListNamespacesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListNamespacesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListNamespacesRequestOrderBy(ListNamespacesRequestOrderBy(tmp).String()) return nil } type ListTokensRequestOrderBy string const ( ListTokensRequestOrderByCreatedAtAsc = ListTokensRequestOrderBy("created_at_asc") ListTokensRequestOrderByCreatedAtDesc = ListTokensRequestOrderBy("created_at_desc") ) func (enum ListTokensRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListTokensRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListTokensRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListTokensRequestOrderBy(ListTokensRequestOrderBy(tmp).String()) return nil } type ListTriggersRequestOrderBy string const ( // Order by creation date ascending. ListTriggersRequestOrderByCreatedAtAsc = ListTriggersRequestOrderBy("created_at_asc") // Order by creation date descending. ListTriggersRequestOrderByCreatedAtDesc = ListTriggersRequestOrderBy("created_at_desc") ) func (enum ListTriggersRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListTriggersRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListTriggersRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListTriggersRequestOrderBy(ListTriggersRequestOrderBy(tmp).String()) return nil } type LogStream string const ( LogStreamUnknown = LogStream("unknown") LogStreamStdout = LogStream("stdout") LogStreamStderr = LogStream("stderr") ) func (enum LogStream) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum LogStream) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *LogStream) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = LogStream(LogStream(tmp).String()) return nil } type NamespaceStatus string const ( NamespaceStatusUnknown = NamespaceStatus("unknown") NamespaceStatusReady = NamespaceStatus("ready") NamespaceStatusDeleting = NamespaceStatus("deleting") NamespaceStatusError = NamespaceStatus("error") NamespaceStatusLocked = NamespaceStatus("locked") NamespaceStatusCreating = NamespaceStatus("creating") NamespaceStatusPending = NamespaceStatus("pending") ) func (enum NamespaceStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum NamespaceStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *NamespaceStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = NamespaceStatus(NamespaceStatus(tmp).String()) return nil } type RuntimeStatus string const ( RuntimeStatusUnknownStatus = RuntimeStatus("unknown_status") RuntimeStatusBeta = RuntimeStatus("beta") RuntimeStatusAvailable = RuntimeStatus("available") RuntimeStatusDeprecated = RuntimeStatus("deprecated") RuntimeStatusEndOfSupport = RuntimeStatus("end_of_support") RuntimeStatusEndOfLife = RuntimeStatus("end_of_life") ) func (enum RuntimeStatus) String() string { if enum == "" { // return default value if empty return "unknown_status" } return string(enum) } func (enum RuntimeStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *RuntimeStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = RuntimeStatus(RuntimeStatus(tmp).String()) return nil } type TokenStatus string const ( TokenStatusUnknown = TokenStatus("unknown") TokenStatusReady = TokenStatus("ready") TokenStatusDeleting = TokenStatus("deleting") TokenStatusError = TokenStatus("error") TokenStatusCreating = TokenStatus("creating") ) func (enum TokenStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum TokenStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *TokenStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = TokenStatus(TokenStatus(tmp).String()) return nil } type TriggerInputType string const ( // Unknown input type. TriggerInputTypeUnknownInputType = TriggerInputType("unknown_input_type") TriggerInputTypeSqs = TriggerInputType("sqs") // Scaleway Messaging and Queuing SQS queue. TriggerInputTypeScwSqs = TriggerInputType("scw_sqs") TriggerInputTypeNats = TriggerInputType("nats") // Scaleway Messaging and Queuing NATS subject. TriggerInputTypeScwNats = TriggerInputType("scw_nats") ) func (enum TriggerInputType) String() string { if enum == "" { // return default value if empty return "unknown_input_type" } return string(enum) } func (enum TriggerInputType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *TriggerInputType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = TriggerInputType(TriggerInputType(tmp).String()) return nil } type TriggerStatus string const ( // Unknown status. TriggerStatusUnknownStatus = TriggerStatus("unknown_status") // Ready status. TriggerStatusReady = TriggerStatus("ready") // Deleting status. TriggerStatusDeleting = TriggerStatus("deleting") // Error status. TriggerStatusError = TriggerStatus("error") // Creating status. TriggerStatusCreating = TriggerStatus("creating") // Pending status. TriggerStatusPending = TriggerStatus("pending") ) func (enum TriggerStatus) String() string { if enum == "" { // return default value if empty return "unknown_status" } return string(enum) } func (enum TriggerStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *TriggerStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = TriggerStatus(TriggerStatus(tmp).String()) return nil } // SecretHashedValue: secret hashed value. type SecretHashedValue struct { Key string `json:"key"` HashedValue string `json:"hashed_value"` } // TriggerMnqNatsClientConfig: trigger mnq nats client config. type TriggerMnqNatsClientConfig struct { // Deprecated MnqNamespaceID *string `json:"mnq_namespace_id,omitempty"` // Subject: name of the NATS subject the trigger listens to. Subject string `json:"subject"` // MnqNatsAccountID: ID of the Messaging and Queuing NATS account. MnqNatsAccountID string `json:"mnq_nats_account_id"` // MnqProjectID: ID of the Messaging and Queuing project. MnqProjectID string `json:"mnq_project_id"` // MnqRegion: currently, only the `fr-par` region is available. MnqRegion string `json:"mnq_region"` // MnqCredentialID: ID of the Messaging and Queuing credentials used to subscribe to the NATS subject. MnqCredentialID *string `json:"mnq_credential_id"` } // TriggerMnqSqsClientConfig: trigger mnq sqs client config. type TriggerMnqSqsClientConfig struct { // Deprecated MnqNamespaceID *string `json:"mnq_namespace_id,omitempty"` // Queue: name of the SQS queue the trigger listens to. Queue string `json:"queue"` // MnqProjectID: ID of the Messaging and Queuing project. MnqProjectID string `json:"mnq_project_id"` // MnqRegion: currently, only the `fr-par` region is available. MnqRegion string `json:"mnq_region"` // MnqCredentialID: ID of the Messaging and Queuing credentials used to read from the SQS queue. MnqCredentialID *string `json:"mnq_credential_id"` } // TriggerSqsClientConfig: trigger sqs client config. type TriggerSqsClientConfig struct { Endpoint string `json:"endpoint"` QueueURL string `json:"queue_url"` AccessKey string `json:"access_key"` SecretKey string `json:"secret_key"` } // Secret: secret. type Secret struct { Key string `json:"key"` Value *string `json:"value"` } // CreateTriggerRequestMnqNatsClientConfig: create trigger request mnq nats client config. type CreateTriggerRequestMnqNatsClientConfig struct { // Deprecated MnqNamespaceID *string `json:"mnq_namespace_id,omitempty"` // Subject: name of the NATS subject the trigger should listen to. Subject string `json:"subject"` // MnqNatsAccountID: ID of the Messaging and Queuing NATS account. MnqNatsAccountID string `json:"mnq_nats_account_id"` // MnqProjectID: ID of the Messaging and Queuing project. MnqProjectID string `json:"mnq_project_id"` // MnqRegion: currently, only the `fr-par` region is available. MnqRegion string `json:"mnq_region"` } // CreateTriggerRequestMnqSqsClientConfig: create trigger request mnq sqs client config. type CreateTriggerRequestMnqSqsClientConfig struct { // Deprecated MnqNamespaceID *string `json:"mnq_namespace_id,omitempty"` // Queue: name of the SQS queue the trigger should listen to. Queue string `json:"queue"` // MnqProjectID: you must have activated SQS on this project. MnqProjectID string `json:"mnq_project_id"` // MnqRegion: currently, only the `fr-par` region is available. MnqRegion string `json:"mnq_region"` } // CreateTriggerRequestSqsClientConfig: create trigger request sqs client config. type CreateTriggerRequestSqsClientConfig struct { Endpoint string `json:"endpoint"` QueueURL string `json:"queue_url"` AccessKey string `json:"access_key"` SecretKey string `json:"secret_key"` } // Cron: cron. type Cron struct { // ID: UUID of the cron. ID string `json:"id"` // FunctionID: UUID of the function the cron applies to. FunctionID string `json:"function_id"` // Schedule: schedule of the cron. Schedule string `json:"schedule"` // Args: arguments to pass with the cron. Args *scw.JSONObject `json:"args"` // Status: status of the cron. // Default value: unknown Status CronStatus `json:"status"` // Name: name of the cron. Name string `json:"name"` } // Domain: domain. type Domain struct { // ID: UUID of the domain. ID string `json:"id"` // Hostname: hostname associated with the function. Hostname string `json:"hostname"` // FunctionID: UUID of the function the domain is associated with. FunctionID string `json:"function_id"` // URL: URL of the function. URL string `json:"url"` // Status: state of the doamin. // Default value: unknown Status DomainStatus `json:"status"` // ErrorMessage: error message if the domain is in "error" state. ErrorMessage *string `json:"error_message"` } // Runtime: runtime. type Runtime struct { Name string `json:"name"` Language string `json:"language"` Version string `json:"version"` DefaultHandler string `json:"default_handler"` CodeSample string `json:"code_sample"` // Status: default value: unknown_status Status RuntimeStatus `json:"status"` StatusMessage string `json:"status_message"` Extension string `json:"extension"` Implementation string `json:"implementation"` LogoURL string `json:"logo_url"` } // Function: function. type Function struct { // ID: UUID of the function. ID string `json:"id"` // Name: name of the function. Name string `json:"name"` // NamespaceID: UUID of the namespace the function belongs to. NamespaceID string `json:"namespace_id"` // Status: status of the function. // Default value: unknown Status FunctionStatus `json:"status"` // EnvironmentVariables: environment variables of the function. EnvironmentVariables map[string]string `json:"environment_variables"` // MinScale: minimum number of instances to scale the function to. MinScale uint32 `json:"min_scale"` // MaxScale: maximum number of instances to scale the function to. MaxScale uint32 `json:"max_scale"` // Runtime: runtime of the function. // Default value: unknown_runtime Runtime FunctionRuntime `json:"runtime"` // MemoryLimit: memory limit of the function in MB. MemoryLimit uint32 `json:"memory_limit"` // CPULimit: CPU limit of the function. CPULimit uint32 `json:"cpu_limit"` // Timeout: request processing time limit for the function. Timeout *scw.Duration `json:"timeout"` // Handler: handler to use for the function. Handler string `json:"handler"` // ErrorMessage: error message if the function is in "error" state. ErrorMessage *string `json:"error_message"` // BuildMessage: description of the current build step. BuildMessage *string `json:"build_message"` // Privacy: privacy setting of the function. // Default value: unknown_privacy Privacy FunctionPrivacy `json:"privacy"` // Description: description of the function. Description *string `json:"description"` // DomainName: domain name associated with the function. DomainName string `json:"domain_name"` // SecretEnvironmentVariables: secret environment variables of the function. SecretEnvironmentVariables []*SecretHashedValue `json:"secret_environment_variables"` // Region: region in which the function is deployed. Region scw.Region `json:"region"` // HTTPOption: possible values: // - redirected: Responds to HTTP request with a 301 redirect to ask the clients to use HTTPS. // - enabled: Serve both HTTP and HTTPS traffic. // Default value: unknown_http_option HTTPOption FunctionHTTPOption `json:"http_option"` RuntimeMessage string `json:"runtime_message"` } // Log: log. type Log struct { // Message: message of the log. Message string `json:"message"` // Timestamp: timestamp of the log. Timestamp *time.Time `json:"timestamp"` // ID: UUID of the log. ID string `json:"id"` // Level: severity of the log (info, debug, error etc.). Level string `json:"level"` // Source: source of the log (core runtime or user code). Source string `json:"source"` // Stream: can be stdout or stderr. // Default value: unknown Stream LogStream `json:"stream"` } // Namespace: namespace. type Namespace struct { // ID: UUID of the namespace. ID string `json:"id"` // Name: name of the namespace. Name string `json:"name"` // EnvironmentVariables: environment variables of the namespace. EnvironmentVariables map[string]string `json:"environment_variables"` // OrganizationID: UUID of the Organization the namespace belongs to. OrganizationID string `json:"organization_id"` // ProjectID: UUID of the Project the namespace belongs to. ProjectID string `json:"project_id"` // Status: status of the namespace. // Default value: unknown Status NamespaceStatus `json:"status"` // RegistryNamespaceID: UUID of the registry namespace. RegistryNamespaceID string `json:"registry_namespace_id"` // ErrorMessage: error message if the namespace is in "error" state. ErrorMessage *string `json:"error_message"` // RegistryEndpoint: registry endpoint of the namespace. RegistryEndpoint string `json:"registry_endpoint"` // Description: description of the namespace. Description *string `json:"description"` // SecretEnvironmentVariables: secret environment variables of the namespace. SecretEnvironmentVariables []*SecretHashedValue `json:"secret_environment_variables"` // Region: region in which the namespace is located. Region scw.Region `json:"region"` } // Token: token. type Token struct { // ID: UUID of the token. ID string `json:"id"` // Token: string of the token. Token string `json:"token"` // FunctionID: UUID of the function the token is associated with. // Precisely one of FunctionID, NamespaceID must be set. FunctionID *string `json:"function_id,omitempty"` // NamespaceID: UUID of the namespace the token is assoicated with. // Precisely one of FunctionID, NamespaceID must be set. NamespaceID *string `json:"namespace_id,omitempty"` // Deprecated: PublicKey: public key of the token. PublicKey *string `json:"public_key,omitempty"` // Status: status of the token. // Default value: unknown Status TokenStatus `json:"status"` // Description: description of the token. Description *string `json:"description"` // ExpiresAt: date on which the token expires. ExpiresAt *time.Time `json:"expires_at"` } // Trigger: trigger. type Trigger struct { // ID: ID of the trigger. ID string `json:"id"` // Name: name of the trigger. Name string `json:"name"` // Description: description of the trigger. Description string `json:"description"` // FunctionID: ID of the function to trigger. FunctionID string `json:"function_id"` // InputType: type of the input. // Default value: unknown_input_type InputType TriggerInputType `json:"input_type"` // Status: status of the trigger. // Default value: unknown_status Status TriggerStatus `json:"status"` // ErrorMessage: error message of the trigger. ErrorMessage *string `json:"error_message"` // ScwSqsConfig: configuration for a Scaleway Messaging and Queuing SQS queue. // Precisely one of ScwSqsConfig, ScwNatsConfig, SqsConfig must be set. ScwSqsConfig *TriggerMnqSqsClientConfig `json:"scw_sqs_config,omitempty"` // ScwNatsConfig: configuration for a Scaleway Messaging and Queuing NATS subject. // Precisely one of ScwSqsConfig, ScwNatsConfig, SqsConfig must be set. ScwNatsConfig *TriggerMnqNatsClientConfig `json:"scw_nats_config,omitempty"` // SqsConfig: configuration for an AWS SQS queue. // Precisely one of ScwSqsConfig, ScwNatsConfig, SqsConfig must be set. SqsConfig *TriggerSqsClientConfig `json:"sqs_config,omitempty"` } // UpdateTriggerRequestSqsClientConfig: update trigger request sqs client config. type UpdateTriggerRequestSqsClientConfig struct { AccessKey *string `json:"access_key"` SecretKey *string `json:"secret_key"` } // CreateCronRequest: create cron request. type CreateCronRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // FunctionID: UUID of the function to use the cron with. FunctionID string `json:"function_id"` // Schedule: schedule of the cron in UNIX cron format. Schedule string `json:"schedule"` // Args: arguments to use with the cron. Args *scw.JSONObject `json:"args,omitempty"` // Name: name of the cron. Name *string `json:"name,omitempty"` } // CreateDomainRequest: create domain request. type CreateDomainRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Hostname: hostame to create. Hostname string `json:"hostname"` // FunctionID: UUID of the function to associate the domain with. FunctionID string `json:"function_id"` } // CreateFunctionRequest: create function request. type CreateFunctionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Name: name of the function to create. Name string `json:"name"` // NamespaceID: UUID of the namespace the function will be created in. NamespaceID string `json:"namespace_id"` // EnvironmentVariables: environment variables of the function. EnvironmentVariables *map[string]string `json:"environment_variables,omitempty"` // MinScale: minumum number of instances to scale the function to. MinScale *uint32 `json:"min_scale,omitempty"` // MaxScale: maximum number of instances to scale the function to. MaxScale *uint32 `json:"max_scale,omitempty"` // Runtime: runtime to use with the function. // Default value: unknown_runtime Runtime FunctionRuntime `json:"runtime"` // MemoryLimit: memory limit of the function in MB. MemoryLimit *uint32 `json:"memory_limit,omitempty"` // Timeout: request processing time limit for the function. Timeout *scw.Duration `json:"timeout,omitempty"` // Handler: handler to use with the function. Handler *string `json:"handler,omitempty"` // Privacy: privacy setting of the function. // Default value: unknown_privacy Privacy FunctionPrivacy `json:"privacy"` // Description: description of the function. Description *string `json:"description,omitempty"` SecretEnvironmentVariables []*Secret `json:"secret_environment_variables"` // HTTPOption: possible values: // - redirected: Responds to HTTP request with a 301 redirect to ask the clients to use HTTPS. // - enabled: Serve both HTTP and HTTPS traffic. // Default value: unknown_http_option HTTPOption FunctionHTTPOption `json:"http_option"` } // CreateNamespaceRequest: create namespace request. type CreateNamespaceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` Name string `json:"name"` // EnvironmentVariables: environment variables of the namespace. EnvironmentVariables *map[string]string `json:"environment_variables,omitempty"` // ProjectID: UUID of the project in which the namespace will be created. ProjectID string `json:"project_id"` // Description: description of the namespace. Description *string `json:"description,omitempty"` // SecretEnvironmentVariables: secret environment variables of the namespace. SecretEnvironmentVariables []*Secret `json:"secret_environment_variables"` } // CreateTokenRequest: create token request. type CreateTokenRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // FunctionID: UUID of the function to associate the token with. // Precisely one of FunctionID, NamespaceID must be set. FunctionID *string `json:"function_id,omitempty"` // NamespaceID: UUID of the namespace to associate the token with. // Precisely one of FunctionID, NamespaceID must be set. NamespaceID *string `json:"namespace_id,omitempty"` // Description: description of the token. Description *string `json:"description,omitempty"` // ExpiresAt: date on which the token expires. ExpiresAt *time.Time `json:"expires_at,omitempty"` } // CreateTriggerRequest: create trigger request. type CreateTriggerRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Name: name of the trigger. Name string `json:"name"` // FunctionID: ID of the function to trigger. FunctionID string `json:"function_id"` // Description: description of the trigger. Description *string `json:"description,omitempty"` // ScwSqsConfig: configuration for a Scaleway Messaging and Queuing SQS queue. // Precisely one of ScwSqsConfig, ScwNatsConfig, SqsConfig must be set. ScwSqsConfig *CreateTriggerRequestMnqSqsClientConfig `json:"scw_sqs_config,omitempty"` // ScwNatsConfig: configuration for a Scaleway Messaging and Queuing NATS subject. // Precisely one of ScwSqsConfig, ScwNatsConfig, SqsConfig must be set. ScwNatsConfig *CreateTriggerRequestMnqNatsClientConfig `json:"scw_nats_config,omitempty"` // SqsConfig: configuration for an AWS SQS queue. // Precisely one of ScwSqsConfig, ScwNatsConfig, SqsConfig must be set. SqsConfig *CreateTriggerRequestSqsClientConfig `json:"sqs_config,omitempty"` } // DeleteCronRequest: delete cron request. type DeleteCronRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // CronID: UUID of the cron to delete. CronID string `json:"-"` } // DeleteDomainRequest: delete domain request. type DeleteDomainRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DomainID: UUID of the domain to delete. DomainID string `json:"-"` } // DeleteFunctionRequest: delete function request. type DeleteFunctionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // FunctionID: UUID of the function to delete. FunctionID string `json:"-"` } // DeleteNamespaceRequest: delete namespace request. type DeleteNamespaceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NamespaceID: UUID of the namespace. NamespaceID string `json:"-"` } // DeleteTokenRequest: delete token request. type DeleteTokenRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // TokenID: UUID of the token to delete. TokenID string `json:"-"` } // DeleteTriggerRequest: delete trigger request. type DeleteTriggerRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // TriggerID: ID of the trigger to delete. TriggerID string `json:"-"` } // DeployFunctionRequest: deploy function request. type DeployFunctionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // FunctionID: UUID of the function to deploy. FunctionID string `json:"-"` } // DownloadURL: download url. type DownloadURL struct { URL string `json:"url"` Headers map[string]*[]string `json:"headers"` } // GetCronRequest: get cron request. type GetCronRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // CronID: UUID of the cron to get. CronID string `json:"-"` } // GetDomainRequest: get domain request. type GetDomainRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DomainID: UUID of the domain to get. DomainID string `json:"-"` } // GetFunctionDownloadURLRequest: get function download url request. type GetFunctionDownloadURLRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // FunctionID: UUID of the function to get the the download URL for. FunctionID string `json:"-"` } // GetFunctionRequest: get function request. type GetFunctionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // FunctionID: UUID of the function. FunctionID string `json:"-"` } // GetFunctionUploadURLRequest: get function upload url request. type GetFunctionUploadURLRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // FunctionID: UUID of the function to get the upload URL for. FunctionID string `json:"-"` // ContentLength: size of the archive to upload in bytes. ContentLength uint64 `json:"content_length"` } // GetNamespaceRequest: get namespace request. type GetNamespaceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NamespaceID: UUID of the namespace. NamespaceID string `json:"-"` } // GetTokenRequest: get token request. type GetTokenRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // TokenID: UUID of the token to get. TokenID string `json:"-"` } // GetTriggerRequest: get trigger request. type GetTriggerRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // TriggerID: ID of the trigger to get. TriggerID string `json:"-"` } // IssueJWTRequest: issue jwt request. type IssueJWTRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Precisely one of FunctionID, NamespaceID must be set. FunctionID *string `json:"function_id,omitempty"` // Precisely one of FunctionID, NamespaceID must be set. NamespaceID *string `json:"namespace_id,omitempty"` ExpiresAt *time.Time `json:"-"` } // ListCronsRequest: list crons request. type ListCronsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: number of crons per page. PageSize *uint32 `json:"-"` // OrderBy: order of the crons. // Default value: created_at_asc OrderBy ListCronsRequestOrderBy `json:"-"` // FunctionID: UUID of the function. FunctionID string `json:"-"` } // ListCronsResponse: list crons response. type ListCronsResponse struct { // Crons: array of crons. Crons []*Cron `json:"crons"` // TotalCount: total number of crons. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListCronsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListCronsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListCronsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Crons = append(r.Crons, results.Crons...) r.TotalCount += uint32(len(results.Crons)) return uint32(len(results.Crons)), nil } // ListDomainsRequest: list domains request. type ListDomainsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: number of domains per page. PageSize *uint32 `json:"-"` // OrderBy: order of the domains. // Default value: created_at_asc OrderBy ListDomainsRequestOrderBy `json:"-"` // FunctionID: UUID of the function the domain is assoicated with. FunctionID string `json:"-"` } // ListDomainsResponse: list domains response. type ListDomainsResponse struct { // Domains: array of domains. Domains []*Domain `json:"domains"` // TotalCount: total number of domains. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListDomainsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListDomainsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListDomainsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Domains = append(r.Domains, results.Domains...) r.TotalCount += uint32(len(results.Domains)) return uint32(len(results.Domains)), nil } // ListFunctionRuntimesRequest: list function runtimes request. type ListFunctionRuntimesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` } // ListFunctionRuntimesResponse: list function runtimes response. type ListFunctionRuntimesResponse struct { // Runtimes: array of runtimes available. Runtimes []*Runtime `json:"runtimes"` // TotalCount: total number of runtimes. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListFunctionRuntimesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListFunctionRuntimesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListFunctionRuntimesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Runtimes = append(r.Runtimes, results.Runtimes...) r.TotalCount += uint32(len(results.Runtimes)) return uint32(len(results.Runtimes)), nil } // ListFunctionsRequest: list functions request. type ListFunctionsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: number of functions per page. PageSize *uint32 `json:"-"` // OrderBy: order of the functions. // Default value: created_at_asc OrderBy ListFunctionsRequestOrderBy `json:"-"` // NamespaceID: UUID of the namespace the function belongs to. NamespaceID string `json:"-"` // Name: name of the function. Name *string `json:"-"` // OrganizationID: UUID of the Organziation the function belongs to. OrganizationID *string `json:"-"` // ProjectID: UUID of the Project the function belongs to. ProjectID *string `json:"-"` } // ListFunctionsResponse: list functions response. type ListFunctionsResponse struct { // Functions: array of functions. Functions []*Function `json:"functions"` // TotalCount: total number of functions. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListFunctionsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListFunctionsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListFunctionsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Functions = append(r.Functions, results.Functions...) r.TotalCount += uint32(len(results.Functions)) return uint32(len(results.Functions)), nil } // ListLogsRequest: list logs request. type ListLogsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // FunctionID: UUID of the function to get the logs for. FunctionID string `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: number of logs per page. PageSize *uint32 `json:"-"` // OrderBy: order of the logs. // Default value: timestamp_desc OrderBy ListLogsRequestOrderBy `json:"-"` } // ListLogsResponse: list logs response. type ListLogsResponse struct { // Logs: array of logs. Logs []*Log `json:"logs"` // TotalCount: total number of logs. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListLogsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListLogsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListLogsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Logs = append(r.Logs, results.Logs...) r.TotalCount += uint32(len(results.Logs)) return uint32(len(results.Logs)), nil } // ListNamespacesRequest: list namespaces request. type ListNamespacesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: number of namespaces per page. PageSize *uint32 `json:"-"` // OrderBy: order of the namespaces. // Default value: created_at_asc OrderBy ListNamespacesRequestOrderBy `json:"-"` // Name: name of the namespace. Name *string `json:"-"` // OrganizationID: UUID of the Organization the namespace belongs to. OrganizationID *string `json:"-"` // ProjectID: UUID of the Project the namespace belongs to. ProjectID *string `json:"-"` } // ListNamespacesResponse: list namespaces response. type ListNamespacesResponse struct { Namespaces []*Namespace `json:"namespaces"` // TotalCount: total number of namespaces. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListNamespacesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListNamespacesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListNamespacesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Namespaces = append(r.Namespaces, results.Namespaces...) r.TotalCount += uint32(len(results.Namespaces)) return uint32(len(results.Namespaces)), nil } // ListTokensRequest: list tokens request. type ListTokensRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: number of tokens per page. PageSize *uint32 `json:"-"` // OrderBy: sort order for the tokens. // Default value: created_at_asc OrderBy ListTokensRequestOrderBy `json:"-"` // FunctionID: UUID of the function the token is assoicated with. FunctionID *string `json:"-"` // NamespaceID: UUID of the namespace the token is associated with. NamespaceID *string `json:"-"` } // ListTokensResponse: list tokens response. type ListTokensResponse struct { Tokens []*Token `json:"tokens"` TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListTokensResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListTokensResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListTokensResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Tokens = append(r.Tokens, results.Tokens...) r.TotalCount += uint32(len(results.Tokens)) return uint32(len(results.Tokens)), nil } // ListTriggersRequest: list triggers request. type ListTriggersRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: page number to return. Page *int32 `json:"-"` // PageSize: maximum number of triggers to return per page. PageSize *uint32 `json:"-"` // OrderBy: order in which to return results. // Default value: created_at_asc OrderBy ListTriggersRequestOrderBy `json:"-"` // FunctionID: ID of the function the triggers belongs to. // Precisely one of FunctionID, NamespaceID, ProjectID must be set. FunctionID *string `json:"function_id,omitempty"` // NamespaceID: ID of the namespace the triggers belongs to. // Precisely one of FunctionID, NamespaceID, ProjectID must be set. NamespaceID *string `json:"namespace_id,omitempty"` // ProjectID: ID of the project the triggers belongs to. // Precisely one of FunctionID, NamespaceID, ProjectID must be set. ProjectID *string `json:"project_id,omitempty"` } // ListTriggersResponse: list triggers response. type ListTriggersResponse struct { // TotalCount: total count of existing triggers (matching any filters specified). TotalCount uint32 `json:"total_count"` // Triggers: triggers on this page. Triggers []*Trigger `json:"triggers"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListTriggersResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListTriggersResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListTriggersResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Triggers = append(r.Triggers, results.Triggers...) r.TotalCount += uint32(len(results.Triggers)) return uint32(len(results.Triggers)), nil } // UpdateCronRequest: update cron request. type UpdateCronRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // CronID: UUID of the cron to update. CronID string `json:"-"` // FunctionID: UUID of the function to use the cron with. FunctionID *string `json:"function_id,omitempty"` // Schedule: schedule of the cron in UNIX cron format. Schedule *string `json:"schedule,omitempty"` // Args: arguments to use with the cron. Args *scw.JSONObject `json:"args,omitempty"` // Name: name of the cron. Name *string `json:"name,omitempty"` } // UpdateFunctionRequest: update function request. type UpdateFunctionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // FunctionID: UUID of the function to update. FunctionID string `json:"-"` // EnvironmentVariables: environment variables of the function to update. EnvironmentVariables *map[string]string `json:"environment_variables,omitempty"` // MinScale: minumum number of instances to scale the function to. MinScale *uint32 `json:"min_scale,omitempty"` // MaxScale: maximum number of instances to scale the function to. MaxScale *uint32 `json:"max_scale,omitempty"` // Runtime: runtime to use with the function. // Default value: unknown_runtime Runtime FunctionRuntime `json:"runtime"` // MemoryLimit: memory limit of the function in MB. MemoryLimit *uint32 `json:"memory_limit,omitempty"` // Timeout: processing time limit for the function. Timeout *scw.Duration `json:"timeout,omitempty"` // Redeploy: redeploy failed function. Redeploy *bool `json:"redeploy,omitempty"` // Handler: handler to use with the function. Handler *string `json:"handler,omitempty"` // Privacy: privacy setting of the function. // Default value: unknown_privacy Privacy FunctionPrivacy `json:"privacy"` // Description: description of the function. Description *string `json:"description,omitempty"` // SecretEnvironmentVariables: secret environment variables of the function. SecretEnvironmentVariables []*Secret `json:"secret_environment_variables"` // HTTPOption: possible values: // - redirected: Responds to HTTP request with a 301 redirect to ask the clients to use HTTPS. // - enabled: Serve both HTTP and HTTPS traffic. // Default value: unknown_http_option HTTPOption FunctionHTTPOption `json:"http_option"` } // UpdateNamespaceRequest: update namespace request. type UpdateNamespaceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NamespaceID: UUID of the namespapce. NamespaceID string `json:"-"` // EnvironmentVariables: environment variables of the namespace. EnvironmentVariables *map[string]string `json:"environment_variables,omitempty"` // Description: description of the namespace. Description *string `json:"description,omitempty"` // SecretEnvironmentVariables: secret environment variables of the namespace. SecretEnvironmentVariables []*Secret `json:"secret_environment_variables"` } // UpdateTriggerRequest: update trigger request. type UpdateTriggerRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // TriggerID: ID of the trigger to update. TriggerID string `json:"-"` // Name: name of the trigger. Name *string `json:"name,omitempty"` // Description: description of the trigger. Description *string `json:"description,omitempty"` // SqsConfig: configuration for an AWS SQS queue. // Precisely one of SqsConfig must be set. SqsConfig *UpdateTriggerRequestSqsClientConfig `json:"sqs_config,omitempty"` } // UploadURL: upload url. type UploadURL struct { // URL: upload URL to upload the function to. URL string `json:"url"` // Headers: HTTP headers. Headers map[string]*[]string `json:"headers"` } type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Regions() []scw.Region { return []scw.Region{scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw} } // ListNamespaces: List all existing namespaces in the specified region. func (s *API) ListNamespaces(req *ListNamespacesRequest, opts ...scw.RequestOption) (*ListNamespacesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/namespaces", Query: query, } var resp ListNamespacesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetNamespace: Get the namespace associated with the specified ID. func (s *API) GetNamespace(req *GetNamespaceRequest, opts ...scw.RequestOption) (*Namespace, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NamespaceID) == "" { return nil, errors.New("field NamespaceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/namespaces/" + fmt.Sprint(req.NamespaceID) + "", } var resp Namespace err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateNamespace: Create a new namespace in a specified Organization or Project. func (s *API) CreateNamespace(req *CreateNamespaceRequest, opts ...scw.RequestOption) (*Namespace, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if req.Name == "" { req.Name = namegenerator.GetRandomName("ns") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/namespaces", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Namespace err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateNamespace: Update the namespace associated with the specified ID. func (s *API) UpdateNamespace(req *UpdateNamespaceRequest, opts ...scw.RequestOption) (*Namespace, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NamespaceID) == "" { return nil, errors.New("field NamespaceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/namespaces/" + fmt.Sprint(req.NamespaceID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Namespace err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteNamespace: Delete the namespace associated with the specified ID. func (s *API) DeleteNamespace(req *DeleteNamespaceRequest, opts ...scw.RequestOption) (*Namespace, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NamespaceID) == "" { return nil, errors.New("field NamespaceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/namespaces/" + fmt.Sprint(req.NamespaceID) + "", } var resp Namespace err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListFunctions: List all your functions. func (s *API) ListFunctions(req *ListFunctionsRequest, opts ...scw.RequestOption) (*ListFunctionsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "namespace_id", req.NamespaceID) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/functions", Query: query, } var resp ListFunctionsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetFunction: Get the function associated with the specified ID. func (s *API) GetFunction(req *GetFunctionRequest, opts ...scw.RequestOption) (*Function, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.FunctionID) == "" { return nil, errors.New("field FunctionID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/functions/" + fmt.Sprint(req.FunctionID) + "", } var resp Function err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateFunction: Create a new function in the specified region for a specified Organization or Project. func (s *API) CreateFunction(req *CreateFunctionRequest, opts ...scw.RequestOption) (*Function, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.Name == "" { req.Name = namegenerator.GetRandomName("fn") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/functions", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Function err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateFunction: Update the function associated with the specified ID. func (s *API) UpdateFunction(req *UpdateFunctionRequest, opts ...scw.RequestOption) (*Function, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.FunctionID) == "" { return nil, errors.New("field FunctionID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/functions/" + fmt.Sprint(req.FunctionID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Function err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteFunction: Delete the function associated with the specified ID. func (s *API) DeleteFunction(req *DeleteFunctionRequest, opts ...scw.RequestOption) (*Function, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.FunctionID) == "" { return nil, errors.New("field FunctionID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/functions/" + fmt.Sprint(req.FunctionID) + "", } var resp Function err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeployFunction: Deploy a function associated with the specified ID. func (s *API) DeployFunction(req *DeployFunctionRequest, opts ...scw.RequestOption) (*Function, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.FunctionID) == "" { return nil, errors.New("field FunctionID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/functions/" + fmt.Sprint(req.FunctionID) + "/deploy", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Function err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListFunctionRuntimes: List available function runtimes. func (s *API) ListFunctionRuntimes(req *ListFunctionRuntimesRequest, opts ...scw.RequestOption) (*ListFunctionRuntimesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/runtimes", } var resp ListFunctionRuntimesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetFunctionUploadURL: Get an upload URL of a function associated with the specified ID. func (s *API) GetFunctionUploadURL(req *GetFunctionUploadURLRequest, opts ...scw.RequestOption) (*UploadURL, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } query := url.Values{} parameter.AddToQuery(query, "content_length", req.ContentLength) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.FunctionID) == "" { return nil, errors.New("field FunctionID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/functions/" + fmt.Sprint(req.FunctionID) + "/upload-url", Query: query, } var resp UploadURL err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetFunctionDownloadURL: Get a download URL for a function associated with the specified ID. func (s *API) GetFunctionDownloadURL(req *GetFunctionDownloadURLRequest, opts ...scw.RequestOption) (*DownloadURL, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.FunctionID) == "" { return nil, errors.New("field FunctionID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/functions/" + fmt.Sprint(req.FunctionID) + "/download-url", } var resp DownloadURL err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListCrons: List all the cronjobs in a specified region. func (s *API) ListCrons(req *ListCronsRequest, opts ...scw.RequestOption) (*ListCronsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "function_id", req.FunctionID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/crons", Query: query, } var resp ListCronsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetCron: Get the cron associated with the specified ID. func (s *API) GetCron(req *GetCronRequest, opts ...scw.RequestOption) (*Cron, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.CronID) == "" { return nil, errors.New("field CronID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/crons/" + fmt.Sprint(req.CronID) + "", } var resp Cron err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateCron: Create a new cronjob for a function with the specified ID. func (s *API) CreateCron(req *CreateCronRequest, opts ...scw.RequestOption) (*Cron, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/crons", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Cron err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateCron: Update the cron associated with the specified ID. func (s *API) UpdateCron(req *UpdateCronRequest, opts ...scw.RequestOption) (*Cron, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.CronID) == "" { return nil, errors.New("field CronID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/crons/" + fmt.Sprint(req.CronID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Cron err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteCron: Delete the cron associated with the specified ID. func (s *API) DeleteCron(req *DeleteCronRequest, opts ...scw.RequestOption) (*Cron, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.CronID) == "" { return nil, errors.New("field CronID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/crons/" + fmt.Sprint(req.CronID) + "", } var resp Cron err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // Deprecated: ListLogs: Deprecated (replaced by [Cockpit](https://www.scaleway.com/en/developers/api/cockpit/)). List the application logs of the function with the specified ID. func (s *API) ListLogs(req *ListLogsRequest, opts ...scw.RequestOption) (*ListLogsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.FunctionID) == "" { return nil, errors.New("field FunctionID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/functions/" + fmt.Sprint(req.FunctionID) + "/logs", Query: query, } var resp ListLogsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListDomains: List all domain name bindings in a specified region. func (s *API) ListDomains(req *ListDomainsRequest, opts ...scw.RequestOption) (*ListDomainsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "function_id", req.FunctionID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/domains", Query: query, } var resp ListDomainsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetDomain: Get a domain name binding for the function with the specified ID. func (s *API) GetDomain(req *GetDomainRequest, opts ...scw.RequestOption) (*Domain, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DomainID) == "" { return nil, errors.New("field DomainID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/domains/" + fmt.Sprint(req.DomainID) + "", } var resp Domain err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateDomain: Create a domain name binding for the function with the specified ID. func (s *API) CreateDomain(req *CreateDomainRequest, opts ...scw.RequestOption) (*Domain, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/domains", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Domain err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteDomain: Delete a domain name binding for the function with the specified ID. func (s *API) DeleteDomain(req *DeleteDomainRequest, opts ...scw.RequestOption) (*Domain, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DomainID) == "" { return nil, errors.New("field DomainID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/domains/" + fmt.Sprint(req.DomainID) + "", } var resp Domain err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // Deprecated: IssueJWT: Deprecated in favor of CreateToken. func (s *API) IssueJWT(req *IssueJWTRequest, opts ...scw.RequestOption) (*Token, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } query := url.Values{} parameter.AddToQuery(query, "expires_at", req.ExpiresAt) parameter.AddToQuery(query, "function_id", req.FunctionID) parameter.AddToQuery(query, "namespace_id", req.NamespaceID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/issue-jwt", Query: query, } var resp Token err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateToken: Create a new revocable token. func (s *API) CreateToken(req *CreateTokenRequest, opts ...scw.RequestOption) (*Token, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/tokens", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Token err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetToken: Get a token. func (s *API) GetToken(req *GetTokenRequest, opts ...scw.RequestOption) (*Token, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.TokenID) == "" { return nil, errors.New("field TokenID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/tokens/" + fmt.Sprint(req.TokenID) + "", } var resp Token err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListTokens: List all tokens. func (s *API) ListTokens(req *ListTokensRequest, opts ...scw.RequestOption) (*ListTokensResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "function_id", req.FunctionID) parameter.AddToQuery(query, "namespace_id", req.NamespaceID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/tokens", Query: query, } var resp ListTokensResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteToken: Delete a token. func (s *API) DeleteToken(req *DeleteTokenRequest, opts ...scw.RequestOption) (*Token, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.TokenID) == "" { return nil, errors.New("field TokenID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/tokens/" + fmt.Sprint(req.TokenID) + "", } var resp Token err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateTrigger: Create a new trigger for a specified function. func (s *API) CreateTrigger(req *CreateTriggerRequest, opts ...scw.RequestOption) (*Trigger, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/triggers", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Trigger err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetTrigger: Get a trigger with a specified ID. func (s *API) GetTrigger(req *GetTriggerRequest, opts ...scw.RequestOption) (*Trigger, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.TriggerID) == "" { return nil, errors.New("field TriggerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/triggers/" + fmt.Sprint(req.TriggerID) + "", } var resp Trigger err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListTriggers: List all triggers belonging to a specified Organization or Project. func (s *API) ListTriggers(req *ListTriggersRequest, opts ...scw.RequestOption) (*ListTriggersResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } defaultProjectID, exist := s.client.GetDefaultProjectID() if exist && req.FunctionID == nil && req.NamespaceID == nil && req.ProjectID == nil { req.ProjectID = &defaultProjectID } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "function_id", req.FunctionID) parameter.AddToQuery(query, "namespace_id", req.NamespaceID) parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/triggers", Query: query, } var resp ListTriggersResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateTrigger: Update a trigger with a specified ID. func (s *API) UpdateTrigger(req *UpdateTriggerRequest, opts ...scw.RequestOption) (*Trigger, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.TriggerID) == "" { return nil, errors.New("field TriggerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/triggers/" + fmt.Sprint(req.TriggerID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Trigger err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteTrigger: Delete a trigger with a specified ID. func (s *API) DeleteTrigger(req *DeleteTriggerRequest, opts ...scw.RequestOption) (*Trigger, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.TriggerID) == "" { return nil, errors.New("field TriggerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/functions/v1beta1/regions/" + fmt.Sprint(req.Region) + "/triggers/" + fmt.Sprint(req.TriggerID) + "", } var resp Trigger err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/iam/000077500000000000000000000000001456366605600235755ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/iam/v1alpha1/000077500000000000000000000000001456366605600252125ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/iam/v1alpha1/iam_sdk.go000066400000000000000000002673721456366605600271710ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package iam provides methods and message types of the iam v1alpha1 API. package iam import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type BearerType string const ( // Unknown bearer type. BearerTypeUnknownBearerType = BearerType("unknown_bearer_type") // User. BearerTypeUser = BearerType("user") // Application. BearerTypeApplication = BearerType("application") ) func (enum BearerType) String() string { if enum == "" { // return default value if empty return "unknown_bearer_type" } return string(enum) } func (enum BearerType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *BearerType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = BearerType(BearerType(tmp).String()) return nil } type ListAPIKeysRequestOrderBy string const ( // Creation date ascending. ListAPIKeysRequestOrderByCreatedAtAsc = ListAPIKeysRequestOrderBy("created_at_asc") // Creation date descending. ListAPIKeysRequestOrderByCreatedAtDesc = ListAPIKeysRequestOrderBy("created_at_desc") // Update date ascending. ListAPIKeysRequestOrderByUpdatedAtAsc = ListAPIKeysRequestOrderBy("updated_at_asc") // Update date descending. ListAPIKeysRequestOrderByUpdatedAtDesc = ListAPIKeysRequestOrderBy("updated_at_desc") // Expiration date ascending. ListAPIKeysRequestOrderByExpiresAtAsc = ListAPIKeysRequestOrderBy("expires_at_asc") // Expiration date descending. ListAPIKeysRequestOrderByExpiresAtDesc = ListAPIKeysRequestOrderBy("expires_at_desc") // Access key ascending. ListAPIKeysRequestOrderByAccessKeyAsc = ListAPIKeysRequestOrderBy("access_key_asc") // Access key descending. ListAPIKeysRequestOrderByAccessKeyDesc = ListAPIKeysRequestOrderBy("access_key_desc") ) func (enum ListAPIKeysRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListAPIKeysRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListAPIKeysRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListAPIKeysRequestOrderBy(ListAPIKeysRequestOrderBy(tmp).String()) return nil } type ListApplicationsRequestOrderBy string const ( // Creation date ascending. ListApplicationsRequestOrderByCreatedAtAsc = ListApplicationsRequestOrderBy("created_at_asc") // Creation date descending. ListApplicationsRequestOrderByCreatedAtDesc = ListApplicationsRequestOrderBy("created_at_desc") // Update date ascending. ListApplicationsRequestOrderByUpdatedAtAsc = ListApplicationsRequestOrderBy("updated_at_asc") // Update date descending. ListApplicationsRequestOrderByUpdatedAtDesc = ListApplicationsRequestOrderBy("updated_at_desc") // Name ascending. ListApplicationsRequestOrderByNameAsc = ListApplicationsRequestOrderBy("name_asc") // Name descending. ListApplicationsRequestOrderByNameDesc = ListApplicationsRequestOrderBy("name_desc") ) func (enum ListApplicationsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListApplicationsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListApplicationsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListApplicationsRequestOrderBy(ListApplicationsRequestOrderBy(tmp).String()) return nil } type ListGroupsRequestOrderBy string const ( // Creation date ascending. ListGroupsRequestOrderByCreatedAtAsc = ListGroupsRequestOrderBy("created_at_asc") // Creation date descending. ListGroupsRequestOrderByCreatedAtDesc = ListGroupsRequestOrderBy("created_at_desc") // Update date ascending. ListGroupsRequestOrderByUpdatedAtAsc = ListGroupsRequestOrderBy("updated_at_asc") // Update date descending. ListGroupsRequestOrderByUpdatedAtDesc = ListGroupsRequestOrderBy("updated_at_desc") // Name ascending. ListGroupsRequestOrderByNameAsc = ListGroupsRequestOrderBy("name_asc") // Name descending. ListGroupsRequestOrderByNameDesc = ListGroupsRequestOrderBy("name_desc") ) func (enum ListGroupsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListGroupsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListGroupsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListGroupsRequestOrderBy(ListGroupsRequestOrderBy(tmp).String()) return nil } type ListJWTsRequestOrderBy string const ( // Creation date ascending. ListJWTsRequestOrderByCreatedAtAsc = ListJWTsRequestOrderBy("created_at_asc") // Creation date descending. ListJWTsRequestOrderByCreatedAtDesc = ListJWTsRequestOrderBy("created_at_desc") // Update date ascending. ListJWTsRequestOrderByUpdatedAtAsc = ListJWTsRequestOrderBy("updated_at_asc") // Update date descending. ListJWTsRequestOrderByUpdatedAtDesc = ListJWTsRequestOrderBy("updated_at_desc") ) func (enum ListJWTsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListJWTsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListJWTsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListJWTsRequestOrderBy(ListJWTsRequestOrderBy(tmp).String()) return nil } type ListLogsRequestOrderBy string const ( // Creation date ascending. ListLogsRequestOrderByCreatedAtAsc = ListLogsRequestOrderBy("created_at_asc") // Creation date descending. ListLogsRequestOrderByCreatedAtDesc = ListLogsRequestOrderBy("created_at_desc") ) func (enum ListLogsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListLogsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListLogsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListLogsRequestOrderBy(ListLogsRequestOrderBy(tmp).String()) return nil } type ListPermissionSetsRequestOrderBy string const ( // Name ascending. ListPermissionSetsRequestOrderByNameAsc = ListPermissionSetsRequestOrderBy("name_asc") // Name descending. ListPermissionSetsRequestOrderByNameDesc = ListPermissionSetsRequestOrderBy("name_desc") // Creation date ascending. ListPermissionSetsRequestOrderByCreatedAtAsc = ListPermissionSetsRequestOrderBy("created_at_asc") // Creation date descending. ListPermissionSetsRequestOrderByCreatedAtDesc = ListPermissionSetsRequestOrderBy("created_at_desc") ) func (enum ListPermissionSetsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "name_asc" } return string(enum) } func (enum ListPermissionSetsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListPermissionSetsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListPermissionSetsRequestOrderBy(ListPermissionSetsRequestOrderBy(tmp).String()) return nil } type ListPoliciesRequestOrderBy string const ( // Policy name ascending. ListPoliciesRequestOrderByPolicyNameAsc = ListPoliciesRequestOrderBy("policy_name_asc") // Policy name descending. ListPoliciesRequestOrderByPolicyNameDesc = ListPoliciesRequestOrderBy("policy_name_desc") // Creation date ascending. ListPoliciesRequestOrderByCreatedAtAsc = ListPoliciesRequestOrderBy("created_at_asc") // Creation date descending. ListPoliciesRequestOrderByCreatedAtDesc = ListPoliciesRequestOrderBy("created_at_desc") ) func (enum ListPoliciesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "policy_name_asc" } return string(enum) } func (enum ListPoliciesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListPoliciesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListPoliciesRequestOrderBy(ListPoliciesRequestOrderBy(tmp).String()) return nil } type ListQuotaRequestOrderBy string const ( // Name ascending. ListQuotaRequestOrderByNameAsc = ListQuotaRequestOrderBy("name_asc") // Name descending. ListQuotaRequestOrderByNameDesc = ListQuotaRequestOrderBy("name_desc") ) func (enum ListQuotaRequestOrderBy) String() string { if enum == "" { // return default value if empty return "name_asc" } return string(enum) } func (enum ListQuotaRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListQuotaRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListQuotaRequestOrderBy(ListQuotaRequestOrderBy(tmp).String()) return nil } type ListSSHKeysRequestOrderBy string const ( // Creation date ascending. ListSSHKeysRequestOrderByCreatedAtAsc = ListSSHKeysRequestOrderBy("created_at_asc") // Creation date descending. ListSSHKeysRequestOrderByCreatedAtDesc = ListSSHKeysRequestOrderBy("created_at_desc") // Update date ascending. ListSSHKeysRequestOrderByUpdatedAtAsc = ListSSHKeysRequestOrderBy("updated_at_asc") // Update date descending. ListSSHKeysRequestOrderByUpdatedAtDesc = ListSSHKeysRequestOrderBy("updated_at_desc") // Name ascending. ListSSHKeysRequestOrderByNameAsc = ListSSHKeysRequestOrderBy("name_asc") // Name descending. ListSSHKeysRequestOrderByNameDesc = ListSSHKeysRequestOrderBy("name_desc") ) func (enum ListSSHKeysRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListSSHKeysRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListSSHKeysRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListSSHKeysRequestOrderBy(ListSSHKeysRequestOrderBy(tmp).String()) return nil } type ListUsersRequestOrderBy string const ( // Creation date ascending. ListUsersRequestOrderByCreatedAtAsc = ListUsersRequestOrderBy("created_at_asc") // Creation date descending. ListUsersRequestOrderByCreatedAtDesc = ListUsersRequestOrderBy("created_at_desc") // Update date ascending. ListUsersRequestOrderByUpdatedAtAsc = ListUsersRequestOrderBy("updated_at_asc") // Update date descending. ListUsersRequestOrderByUpdatedAtDesc = ListUsersRequestOrderBy("updated_at_desc") // Email ascending. ListUsersRequestOrderByEmailAsc = ListUsersRequestOrderBy("email_asc") // Email descending. ListUsersRequestOrderByEmailDesc = ListUsersRequestOrderBy("email_desc") // Last login ascending. ListUsersRequestOrderByLastLoginAsc = ListUsersRequestOrderBy("last_login_asc") // Last login descending. ListUsersRequestOrderByLastLoginDesc = ListUsersRequestOrderBy("last_login_desc") ) func (enum ListUsersRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListUsersRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListUsersRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListUsersRequestOrderBy(ListUsersRequestOrderBy(tmp).String()) return nil } type LogAction string const ( // Unknown action. LogActionUnknownAction = LogAction("unknown_action") // Created. LogActionCreated = LogAction("created") // Updated. LogActionUpdated = LogAction("updated") // Deleted. LogActionDeleted = LogAction("deleted") ) func (enum LogAction) String() string { if enum == "" { // return default value if empty return "unknown_action" } return string(enum) } func (enum LogAction) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *LogAction) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = LogAction(LogAction(tmp).String()) return nil } type LogResourceType string const ( // Unknown resource type. LogResourceTypeUnknownResourceType = LogResourceType("unknown_resource_type") // API Key. LogResourceTypeAPIKey = LogResourceType("api_key") // User. LogResourceTypeUser = LogResourceType("user") // Application. LogResourceTypeApplication = LogResourceType("application") // Group. LogResourceTypeGroup = LogResourceType("group") // Policy. LogResourceTypePolicy = LogResourceType("policy") ) func (enum LogResourceType) String() string { if enum == "" { // return default value if empty return "unknown_resource_type" } return string(enum) } func (enum LogResourceType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *LogResourceType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = LogResourceType(LogResourceType(tmp).String()) return nil } type PermissionSetScopeType string const ( // Unknown scope type. PermissionSetScopeTypeUnknownScopeType = PermissionSetScopeType("unknown_scope_type") // Projects. PermissionSetScopeTypeProjects = PermissionSetScopeType("projects") // Organization. PermissionSetScopeTypeOrganization = PermissionSetScopeType("organization") // Account root user. PermissionSetScopeTypeAccountRootUser = PermissionSetScopeType("account_root_user") ) func (enum PermissionSetScopeType) String() string { if enum == "" { // return default value if empty return "unknown_scope_type" } return string(enum) } func (enum PermissionSetScopeType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *PermissionSetScopeType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = PermissionSetScopeType(PermissionSetScopeType(tmp).String()) return nil } type UserStatus string const ( // Unknown status. UserStatusUnknownStatus = UserStatus("unknown_status") // Invitation pending. UserStatusInvitationPending = UserStatus("invitation_pending") // Activated. UserStatusActivated = UserStatus("activated") ) func (enum UserStatus) String() string { if enum == "" { // return default value if empty return "unknown_status" } return string(enum) } func (enum UserStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *UserStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = UserStatus(UserStatus(tmp).String()) return nil } type UserType string const ( // Unknown type. UserTypeUnknownType = UserType("unknown_type") // Guest. UserTypeGuest = UserType("guest") // Owner. UserTypeOwner = UserType("owner") ) func (enum UserType) String() string { if enum == "" { // return default value if empty return "unknown_type" } return string(enum) } func (enum UserType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *UserType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = UserType(UserType(tmp).String()) return nil } // RuleSpecs: rule specs. type RuleSpecs struct { // PermissionSetNames: names of permission sets bound to the rule. PermissionSetNames *[]string `json:"permission_set_names"` // ProjectIDs: list of Project IDs the rule is scoped to. // Precisely one of ProjectIDs, OrganizationID must be set. ProjectIDs *[]string `json:"project_ids,omitempty"` // OrganizationID: ID of Organization the rule is scoped to. // Precisely one of ProjectIDs, OrganizationID must be set. OrganizationID *string `json:"organization_id,omitempty"` } // JWT: jwt. type JWT struct { // Jti: jWT ID. Jti string `json:"jti"` // IssuerID: ID of the user who issued the JWT. IssuerID string `json:"issuer_id"` // AudienceID: ID of the user targeted by the JWT. AudienceID string `json:"audience_id"` // CreatedAt: creation date of the JWT. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: last update date of the JWT. UpdatedAt *time.Time `json:"updated_at"` // ExpiresAt: expiration date of the JWT. ExpiresAt *time.Time `json:"expires_at"` // IP: IP address used during the creation of the JWT. IP net.IP `json:"ip"` // UserAgent: user-agent used during the creation of the JWT. UserAgent string `json:"user_agent"` } // APIKey: api key. type APIKey struct { // AccessKey: access key of the API key. AccessKey string `json:"access_key"` // SecretKey: secret key of the API Key. SecretKey *string `json:"secret_key"` // ApplicationID: ID of application that bears the API key. // Precisely one of ApplicationID, UserID must be set. ApplicationID *string `json:"application_id,omitempty"` // UserID: ID of user that bears the API key. // Precisely one of ApplicationID, UserID must be set. UserID *string `json:"user_id,omitempty"` // Description: description of API key. Description string `json:"description"` // CreatedAt: date and time of API key creation. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date and time of last API key update. UpdatedAt *time.Time `json:"updated_at"` // ExpiresAt: date and time of API key expiration. ExpiresAt *time.Time `json:"expires_at"` // DefaultProjectID: default Project ID specified for this API key. DefaultProjectID string `json:"default_project_id"` // Editable: defines whether or not the API key is editable. Editable bool `json:"editable"` // CreationIP: IP address of the device that created the API key. CreationIP string `json:"creation_ip"` } // Application: application. type Application struct { // ID: ID of the application. ID string `json:"id"` // Name: name of the application. Name string `json:"name"` // Description: description of the application. Description string `json:"description"` // CreatedAt: date and time application was created. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date and time of last application update. UpdatedAt *time.Time `json:"updated_at"` // OrganizationID: ID of the Organization. OrganizationID string `json:"organization_id"` // Editable: defines whether or not the application is editable. Editable bool `json:"editable"` // NbAPIKeys: number of API keys attributed to the application. NbAPIKeys uint32 `json:"nb_api_keys"` // Tags: tags associated with the user. Tags []string `json:"tags"` } // Group: group. type Group struct { // ID: ID of the group. ID string `json:"id"` // CreatedAt: date and time of group creation. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date and time of last group update. UpdatedAt *time.Time `json:"updated_at"` // OrganizationID: ID of Organization linked to the group. OrganizationID string `json:"organization_id"` // Name: name of the group. Name string `json:"name"` // Description: description of the group. Description string `json:"description"` // UserIDs: iDs of users attached to this group. UserIDs []string `json:"user_ids"` // ApplicationIDs: iDs of applications attached to this group. ApplicationIDs []string `json:"application_ids"` // Tags: tags associated to the group. Tags []string `json:"tags"` } // Log: log. type Log struct { // ID: log ID. ID string `json:"id"` // CreatedAt: creation date of the log. CreatedAt *time.Time `json:"created_at"` // IP: IP address of the HTTP request linked to the log. IP net.IP `json:"ip"` // UserAgent: user-Agent of the HTTP request linked to the log. UserAgent string `json:"user_agent"` // Action: action linked to the log. // Default value: unknown_action Action LogAction `json:"action"` // BearerID: ID of the principal at the origin of the log. BearerID string `json:"bearer_id"` // OrganizationID: ID of Organization linked to the log. OrganizationID string `json:"organization_id"` // ResourceType: type of the resource linked to the log. // Default value: unknown_resource_type ResourceType LogResourceType `json:"resource_type"` // ResourceID: ID of the resource linked to the log. ResourceID string `json:"resource_id"` } // PermissionSet: permission set. type PermissionSet struct { // ID: id of the permission set. ID string `json:"id"` // Name: name of the permission set. Name string `json:"name"` // ScopeType: scope of the permission set. // Default value: unknown_scope_type ScopeType PermissionSetScopeType `json:"scope_type"` // Description: description of the permission set. Description string `json:"description"` // Categories: categories of the permission set. Categories *[]string `json:"categories"` } // Policy: policy. type Policy struct { // ID: id of the policy. ID string `json:"id"` // Name: name of the policy. Name string `json:"name"` // Description: description of the policy. Description string `json:"description"` // OrganizationID: organization ID of the policy. OrganizationID string `json:"organization_id"` // CreatedAt: date and time of policy creation. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date and time of last policy update. UpdatedAt *time.Time `json:"updated_at"` // Editable: defines whether or not a policy is editable. Editable bool `json:"editable"` // NbRules: number of rules of the policy. NbRules uint32 `json:"nb_rules"` // NbScopes: number of policy scopes. NbScopes uint32 `json:"nb_scopes"` // NbPermissionSets: number of permission sets of the policy. NbPermissionSets uint32 `json:"nb_permission_sets"` // Tags: tags associated with the policy. Tags []string `json:"tags"` // UserID: ID of the user attributed to the policy. // Precisely one of UserID, GroupID, ApplicationID, NoPrincipal must be set. UserID *string `json:"user_id,omitempty"` // GroupID: ID of the group attributed to the policy. // Precisely one of UserID, GroupID, ApplicationID, NoPrincipal must be set. GroupID *string `json:"group_id,omitempty"` // ApplicationID: ID of the application attributed to the policy. // Precisely one of UserID, GroupID, ApplicationID, NoPrincipal must be set. ApplicationID *string `json:"application_id,omitempty"` // NoPrincipal: defines whether or not a policy is attributed to a principal. // Precisely one of UserID, GroupID, ApplicationID, NoPrincipal must be set. NoPrincipal *bool `json:"no_principal,omitempty"` } // Quotum: quotum. type Quotum struct { // Name: name of the quota. Name string `json:"name"` // Limit: maximum limit of the quota. // Precisely one of Limit, Unlimited must be set. Limit *uint64 `json:"limit,omitempty"` // Unlimited: defines whether or not the quota is unlimited. // Precisely one of Limit, Unlimited must be set. Unlimited *bool `json:"unlimited,omitempty"` } // Rule: rule. type Rule struct { // ID: id of rule. ID string `json:"id"` // PermissionSetNames: names of permission sets bound to the rule. PermissionSetNames *[]string `json:"permission_set_names"` // PermissionSetsScopeType: permission_set_names have the same scope_type. // Default value: unknown_scope_type PermissionSetsScopeType PermissionSetScopeType `json:"permission_sets_scope_type"` // ProjectIDs: list of Project IDs the rule is scoped to. // Precisely one of ProjectIDs, OrganizationID, AccountRootUserID must be set. ProjectIDs *[]string `json:"project_ids,omitempty"` // OrganizationID: ID of Organization the rule is scoped to. // Precisely one of ProjectIDs, OrganizationID, AccountRootUserID must be set. OrganizationID *string `json:"organization_id,omitempty"` // AccountRootUserID: ID of account root user the rule is scoped to. // Precisely one of ProjectIDs, OrganizationID, AccountRootUserID must be set. AccountRootUserID *string `json:"account_root_user_id,omitempty"` } // SSHKey: ssh key. type SSHKey struct { // ID: ID of SSH key. ID string `json:"id"` // Name: name of SSH key. Name string `json:"name"` // PublicKey: public key of SSH key. PublicKey string `json:"public_key"` // Fingerprint: fingerprint of the SSH key. Fingerprint string `json:"fingerprint"` // CreatedAt: creation date of SSH key. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: last update date of SSH key. UpdatedAt *time.Time `json:"updated_at"` // OrganizationID: ID of Organization linked to the SSH key. OrganizationID string `json:"organization_id"` // ProjectID: ID of Project linked to the SSH key. ProjectID string `json:"project_id"` // Disabled: SSH key status. Disabled bool `json:"disabled"` } // User: user. type User struct { // ID: ID of user. ID string `json:"id"` // Email: email of user. Email string `json:"email"` // CreatedAt: date user was created. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date of last user update. UpdatedAt *time.Time `json:"updated_at"` // OrganizationID: ID of the Organization. OrganizationID string `json:"organization_id"` // Deletable: deletion status of user. Owners cannot be deleted. Deletable bool `json:"deletable"` // LastLoginAt: date of the last login. LastLoginAt *time.Time `json:"last_login_at"` // Type: type of user. // Default value: unknown_type Type UserType `json:"type"` // Deprecated: TwoFactorEnabled: deprecated, use "mfa" instead. TwoFactorEnabled *bool `json:"two_factor_enabled,omitempty"` // Status: status of user invitation. // Default value: unknown_status Status UserStatus `json:"status"` // Mfa: defines whether MFA is enabled. Mfa bool `json:"mfa"` // AccountRootUserID: ID of the account root user associated with the user. AccountRootUserID string `json:"account_root_user_id"` // Tags: tags associated with the user. Tags []string `json:"tags"` } // AddGroupMemberRequest: add group member request. type AddGroupMemberRequest struct { // GroupID: ID of the group. GroupID string `json:"-"` // UserID: ID of the user to add. // Precisely one of UserID, ApplicationID must be set. UserID *string `json:"user_id,omitempty"` // ApplicationID: ID of the application to add. // Precisely one of UserID, ApplicationID must be set. ApplicationID *string `json:"application_id,omitempty"` } // AddGroupMembersRequest: add group members request. type AddGroupMembersRequest struct { // GroupID: ID of the group. GroupID string `json:"-"` // UserIDs: iDs of the users to add. UserIDs []string `json:"user_ids"` // ApplicationIDs: iDs of the applications to add. ApplicationIDs []string `json:"application_ids"` } // ClonePolicyRequest: clone policy request. type ClonePolicyRequest struct { PolicyID string `json:"-"` } // CreateAPIKeyRequest: create api key request. type CreateAPIKeyRequest struct { // ApplicationID: ID of the application. // Precisely one of ApplicationID, UserID must be set. ApplicationID *string `json:"application_id,omitempty"` // UserID: ID of the user. // Precisely one of ApplicationID, UserID must be set. UserID *string `json:"user_id,omitempty"` // ExpiresAt: expiration date of the API key. ExpiresAt *time.Time `json:"expires_at,omitempty"` // DefaultProjectID: default Project ID to use with Object Storage. DefaultProjectID *string `json:"default_project_id,omitempty"` // Description: description of the API key (max length is 200 characters). Description string `json:"description"` } // CreateApplicationRequest: create application request. type CreateApplicationRequest struct { // Name: name of the application to create (max length is 64 characters). Name string `json:"name"` // OrganizationID: ID of the Organization. OrganizationID string `json:"organization_id"` // Description: description of the application (max length is 200 characters). Description string `json:"description"` // Tags: tags associated with the application (maximum of 10 tags). Tags []string `json:"tags"` } // CreateGroupRequest: create group request. type CreateGroupRequest struct { // OrganizationID: ID of Organization linked to the group. OrganizationID string `json:"organization_id"` // Name: name of the group to create (max length is 64 chars). MUST be unique inside an Organization. Name string `json:"name"` // Description: description of the group to create (max length is 200 chars). Description string `json:"description"` // Tags: tags associated with the group (maximum of 10 tags). Tags []string `json:"tags"` } // CreatePolicyRequest: create policy request. type CreatePolicyRequest struct { // Name: name of the policy to create (max length is 64 characters). Name string `json:"name"` // Description: description of the policy to create (max length is 200 characters). Description string `json:"description"` // OrganizationID: ID of the Organization. OrganizationID string `json:"organization_id"` // Rules: rules of the policy to create. Rules []*RuleSpecs `json:"rules"` // Tags: tags associated with the policy (maximum of 10 tags). Tags []string `json:"tags"` // UserID: ID of user attributed to the policy. // Precisely one of UserID, GroupID, ApplicationID, NoPrincipal must be set. UserID *string `json:"user_id,omitempty"` // GroupID: ID of group attributed to the policy. // Precisely one of UserID, GroupID, ApplicationID, NoPrincipal must be set. GroupID *string `json:"group_id,omitempty"` // ApplicationID: ID of application attributed to the policy. // Precisely one of UserID, GroupID, ApplicationID, NoPrincipal must be set. ApplicationID *string `json:"application_id,omitempty"` // NoPrincipal: defines whether or not a policy is attributed to a principal. // Precisely one of UserID, GroupID, ApplicationID, NoPrincipal must be set. NoPrincipal *bool `json:"no_principal,omitempty"` } // CreateSSHKeyRequest: create ssh key request. type CreateSSHKeyRequest struct { // Name: name of the SSH key. Max length is 1000. Name string `json:"name"` // PublicKey: SSH public key. Currently only the ssh-rsa, ssh-dss (DSA), ssh-ed25519 and ecdsa keys with NIST curves are supported. Max length is 65000. PublicKey string `json:"public_key"` // ProjectID: project the resource is attributed to. ProjectID string `json:"project_id"` } // CreateUserRequest: create user request. type CreateUserRequest struct { // OrganizationID: ID of the Organization. OrganizationID string `json:"organization_id"` // Email: email of the user. Email string `json:"email"` // Tags: tags associated with the user. Tags []string `json:"tags"` } // DeleteAPIKeyRequest: delete api key request. type DeleteAPIKeyRequest struct { // AccessKey: access key to delete. AccessKey string `json:"-"` } // DeleteApplicationRequest: delete application request. type DeleteApplicationRequest struct { // ApplicationID: ID of the application to delete. ApplicationID string `json:"-"` } // DeleteGroupRequest: delete group request. type DeleteGroupRequest struct { // GroupID: ID of the group to delete. GroupID string `json:"-"` } // DeleteJWTRequest: delete jwt request. type DeleteJWTRequest struct { // Jti: jWT ID of the JWT to delete. Jti string `json:"-"` } // DeletePolicyRequest: delete policy request. type DeletePolicyRequest struct { // PolicyID: id of policy to delete. PolicyID string `json:"-"` } // DeleteSSHKeyRequest: delete ssh key request. type DeleteSSHKeyRequest struct { SSHKeyID string `json:"-"` } // DeleteUserRequest: delete user request. type DeleteUserRequest struct { // UserID: ID of the user to delete. UserID string `json:"-"` } // GetAPIKeyRequest: get api key request. type GetAPIKeyRequest struct { // AccessKey: access key to search for. AccessKey string `json:"-"` } // GetApplicationRequest: get application request. type GetApplicationRequest struct { // ApplicationID: ID of the application to find. ApplicationID string `json:"-"` } // GetGroupRequest: get group request. type GetGroupRequest struct { // GroupID: ID of the group. GroupID string `json:"-"` } // GetJWTRequest: get jwt request. type GetJWTRequest struct { // Jti: jWT ID of the JWT to get. Jti string `json:"-"` } // GetLogRequest: get log request. type GetLogRequest struct { // LogID: ID of the log. LogID string `json:"-"` } // GetPolicyRequest: get policy request. type GetPolicyRequest struct { // PolicyID: id of policy to search. PolicyID string `json:"-"` } // GetQuotumRequest: get quotum request. type GetQuotumRequest struct { // QuotumName: name of the quota to get. QuotumName string `json:"-"` // OrganizationID: ID of the Organization. OrganizationID string `json:"-"` } // GetSSHKeyRequest: get ssh key request. type GetSSHKeyRequest struct { // SSHKeyID: ID of the SSH key. SSHKeyID string `json:"-"` } // GetUserRequest: get user request. type GetUserRequest struct { // UserID: ID of the user to find. UserID string `json:"-"` } // ListAPIKeysRequest: list api keys request. type ListAPIKeysRequest struct { // OrderBy: criteria for sorting results. // Default value: created_at_asc OrderBy ListAPIKeysRequestOrderBy `json:"-"` // Page: page number. Value must be greater or equal to 1. Page *int32 `json:"-"` // PageSize: number of results per page. Value must be between 1 and 100. PageSize *uint32 `json:"-"` // OrganizationID: ID of Organization. OrganizationID *string `json:"-"` // Deprecated: ApplicationID: ID of application that bears the API key. // Precisely one of ApplicationID, UserID must be set. ApplicationID *string `json:"application_id,omitempty"` // Deprecated: UserID: ID of user that bears the API key. // Precisely one of ApplicationID, UserID must be set. UserID *string `json:"user_id,omitempty"` // Editable: defines whether to filter out editable API keys or not. Editable *bool `json:"-"` // Expired: defines whether to filter out expired API keys or not. Expired *bool `json:"-"` // Deprecated: AccessKey: filter by access key (deprecated in favor of `access_keys`). AccessKey *string `json:"-"` // Description: filter by description. Description *string `json:"-"` // BearerID: filter by bearer ID. BearerID *string `json:"-"` // BearerType: filter by type of bearer. // Default value: unknown_bearer_type BearerType BearerType `json:"-"` // AccessKeys: filter by a list of access keys. AccessKeys []string `json:"-"` } // ListAPIKeysResponse: list api keys response. type ListAPIKeysResponse struct { // APIKeys: list of API keys. APIKeys []*APIKey `json:"api_keys"` // TotalCount: total count of API Keys. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListAPIKeysResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListAPIKeysResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListAPIKeysResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.APIKeys = append(r.APIKeys, results.APIKeys...) r.TotalCount += uint32(len(results.APIKeys)) return uint32(len(results.APIKeys)), nil } // ListApplicationsRequest: list applications request. type ListApplicationsRequest struct { // OrderBy: criteria for sorting results. // Default value: created_at_asc OrderBy ListApplicationsRequestOrderBy `json:"-"` // PageSize: number of results per page. Value must be between 1 and 100. PageSize *uint32 `json:"-"` // Page: page number. Value must be greater than 1. Page *int32 `json:"-"` // Name: name of the application to filter. Name *string `json:"-"` // OrganizationID: ID of the Organization to filter. OrganizationID string `json:"-"` // Editable: defines whether to filter out editable applications or not. Editable *bool `json:"-"` // ApplicationIDs: filter by list of IDs. ApplicationIDs []string `json:"-"` // Tag: filter by tags containing a given string. Tag *string `json:"-"` } // ListApplicationsResponse: list applications response. type ListApplicationsResponse struct { // Applications: list of applications. Applications []*Application `json:"applications"` // TotalCount: total count of applications. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListApplicationsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListApplicationsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListApplicationsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Applications = append(r.Applications, results.Applications...) r.TotalCount += uint32(len(results.Applications)) return uint32(len(results.Applications)), nil } // ListGroupsRequest: list groups request. type ListGroupsRequest struct { // OrderBy: sort order of groups. // Default value: created_at_asc OrderBy ListGroupsRequestOrderBy `json:"-"` // Page: requested page number. Value must be greater or equal to 1. Page *int32 `json:"-"` // PageSize: number of items per page. Value must be between 1 and 100. PageSize *uint32 `json:"-"` // OrganizationID: filter by Organization ID. OrganizationID string `json:"-"` // Name: name of group to find. Name *string `json:"-"` // ApplicationIDs: filter by a list of application IDs. ApplicationIDs []string `json:"-"` // UserIDs: filter by a list of user IDs. UserIDs []string `json:"-"` // GroupIDs: filter by a list of group IDs. GroupIDs []string `json:"-"` // Tag: filter by tags containing a given string. Tag *string `json:"-"` } // ListGroupsResponse: list groups response. type ListGroupsResponse struct { // Groups: list of groups. Groups []*Group `json:"groups"` // TotalCount: total count of groups. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListGroupsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListGroupsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListGroupsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Groups = append(r.Groups, results.Groups...) r.TotalCount += uint32(len(results.Groups)) return uint32(len(results.Groups)), nil } // ListJWTsRequest: list jw ts request. type ListJWTsRequest struct { // OrderBy: criteria for sorting results. // Default value: created_at_asc OrderBy ListJWTsRequestOrderBy `json:"-"` // AudienceID: ID of the user to search. AudienceID *string `json:"-"` // PageSize: number of results per page. Value must be between 1 and 100. PageSize *uint32 `json:"-"` // Page: page number. Value must be greater to 1. Page *int32 `json:"-"` // Expired: filter out expired JWTs or not. Expired *bool `json:"-"` } // ListJWTsResponse: list jw ts response. type ListJWTsResponse struct { Jwts []*JWT `json:"jwts"` TotalCount uint64 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListJWTsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListJWTsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListJWTsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Jwts = append(r.Jwts, results.Jwts...) r.TotalCount += uint64(len(results.Jwts)) return uint64(len(results.Jwts)), nil } // ListLogsRequest: list logs request. type ListLogsRequest struct { // OrderBy: criteria for sorting results. // Default value: created_at_asc OrderBy ListLogsRequestOrderBy `json:"-"` // OrganizationID: filter by Organization ID. OrganizationID string `json:"-"` // PageSize: number of results per page. Value must be between 1 and 100. PageSize *uint32 `json:"-"` // Page: page number. Value must be greater to 1. Page *int32 `json:"-"` // CreatedAfter: defined whether or not to filter out logs created after this timestamp. CreatedAfter *time.Time `json:"-"` // CreatedBefore: defined whether or not to filter out logs created before this timestamp. CreatedBefore *time.Time `json:"-"` // Action: defined whether or not to filter out by a specific action. // Default value: unknown_action Action LogAction `json:"-"` // ResourceType: defined whether or not to filter out by a specific type of resource. // Default value: unknown_resource_type ResourceType LogResourceType `json:"-"` // Search: defined whether or not to filter out log by bearer ID or resource ID. Search *string `json:"-"` } // ListLogsResponse: list logs response. type ListLogsResponse struct { // Logs: list of logs. Logs []*Log `json:"logs"` // TotalCount: total count of logs. TotalCount uint64 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListLogsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListLogsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListLogsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Logs = append(r.Logs, results.Logs...) r.TotalCount += uint64(len(results.Logs)) return uint64(len(results.Logs)), nil } // ListPermissionSetsRequest: list permission sets request. type ListPermissionSetsRequest struct { // OrderBy: criteria for sorting results. // Default value: name_asc OrderBy ListPermissionSetsRequestOrderBy `json:"-"` // PageSize: number of results per page. Value must be between 1 and 100. PageSize *uint32 `json:"-"` // Page: page number. Value must be greater than 1. Page *int32 `json:"-"` // OrganizationID: filter by Organization ID. OrganizationID string `json:"-"` } // ListPermissionSetsResponse: list permission sets response. type ListPermissionSetsResponse struct { // PermissionSets: list of permission sets. PermissionSets []*PermissionSet `json:"permission_sets"` // TotalCount: total count of permission sets. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListPermissionSetsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListPermissionSetsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListPermissionSetsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.PermissionSets = append(r.PermissionSets, results.PermissionSets...) r.TotalCount += uint32(len(results.PermissionSets)) return uint32(len(results.PermissionSets)), nil } // ListPoliciesRequest: list policies request. type ListPoliciesRequest struct { // OrderBy: criteria for sorting results. // Default value: policy_name_asc OrderBy ListPoliciesRequestOrderBy `json:"-"` // PageSize: number of results per page. Value must be between 1 and 100. PageSize *uint32 `json:"-"` // Page: page number. Value must be greater than 1. Page *int32 `json:"-"` // OrganizationID: ID of the Organization to filter. OrganizationID string `json:"-"` // Editable: defines whether or not filter out editable policies. Editable *bool `json:"-"` // UserIDs: defines whether or not to filter by list of user IDs. UserIDs []string `json:"-"` // GroupIDs: defines whether or not to filter by list of group IDs. GroupIDs []string `json:"-"` // ApplicationIDs: filter by a list of application IDs. ApplicationIDs []string `json:"-"` // NoPrincipal: defines whether or not the policy is attributed to a principal. NoPrincipal *bool `json:"-"` // PolicyName: name of the policy to fetch. PolicyName *string `json:"-"` // Tag: filter by tags containing a given string. Tag *string `json:"-"` // PolicyIDs: filter by a list of IDs. PolicyIDs []string `json:"-"` } // ListPoliciesResponse: list policies response. type ListPoliciesResponse struct { // Policies: list of policies. Policies []*Policy `json:"policies"` // TotalCount: total count of policies. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListPoliciesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListPoliciesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListPoliciesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Policies = append(r.Policies, results.Policies...) r.TotalCount += uint32(len(results.Policies)) return uint32(len(results.Policies)), nil } // ListQuotaRequest: list quota request. type ListQuotaRequest struct { // OrderBy: criteria for sorting results. // Default value: name_asc OrderBy ListQuotaRequestOrderBy `json:"-"` // PageSize: number of results per page. Value must be between 1 and 100. PageSize *uint32 `json:"-"` // Page: page number. Value must be greater than 1. Page *int32 `json:"-"` // OrganizationID: filter by Organization ID. OrganizationID string `json:"-"` } // ListQuotaResponse: list quota response. type ListQuotaResponse struct { // Quota: list of quota. Quota []*Quotum `json:"quota"` // TotalCount: total count of quota. TotalCount uint64 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListQuotaResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListQuotaResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListQuotaResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Quota = append(r.Quota, results.Quota...) r.TotalCount += uint64(len(results.Quota)) return uint64(len(results.Quota)), nil } // ListRulesRequest: list rules request. type ListRulesRequest struct { // PolicyID: id of policy to search. PolicyID string `json:"-"` // PageSize: number of results per page. Value must be between 1 and 100. PageSize *uint32 `json:"-"` // Page: page number. Value must be greater than 1. Page *int32 `json:"-"` } // ListRulesResponse: list rules response. type ListRulesResponse struct { // Rules: rules of the policy. Rules []*Rule `json:"rules"` // TotalCount: total count of rules. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListRulesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListRulesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListRulesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Rules = append(r.Rules, results.Rules...) r.TotalCount += uint32(len(results.Rules)) return uint32(len(results.Rules)), nil } // ListSSHKeysRequest: list ssh keys request. type ListSSHKeysRequest struct { // OrderBy: sort order of the SSH keys. // Default value: created_at_asc OrderBy ListSSHKeysRequestOrderBy `json:"-"` // Page: requested page number. Value must be greater or equal to 1. Page *int32 `json:"-"` // PageSize: number of items per page. Value must be between 1 and 100. PageSize *uint32 `json:"-"` // OrganizationID: filter by Organization ID. OrganizationID *string `json:"-"` // Name: name of group to find. Name *string `json:"-"` // ProjectID: filter by Project ID. ProjectID *string `json:"-"` // Disabled: defines whether to include disabled SSH keys or not. Disabled *bool `json:"-"` } // ListSSHKeysResponse: list ssh keys response. type ListSSHKeysResponse struct { // SSHKeys: list of SSH keys. SSHKeys []*SSHKey `json:"ssh_keys"` // TotalCount: total count of SSH keys. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListSSHKeysResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListSSHKeysResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListSSHKeysResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.SSHKeys = append(r.SSHKeys, results.SSHKeys...) r.TotalCount += uint32(len(results.SSHKeys)) return uint32(len(results.SSHKeys)), nil } // ListUsersRequest: list users request. type ListUsersRequest struct { // OrderBy: criteria for sorting results. // Default value: created_at_asc OrderBy ListUsersRequestOrderBy `json:"-"` // PageSize: number of results per page. Value must be between 1 and 100. PageSize *uint32 `json:"-"` // Page: page number. Value must be greater or equal to 1. Page *int32 `json:"-"` // OrganizationID: ID of the Organization to filter. OrganizationID *string `json:"-"` // UserIDs: filter by list of IDs. UserIDs []string `json:"-"` // Mfa: filter by MFA status. Mfa *bool `json:"-"` // Tag: filter by tags containing a given string. Tag *string `json:"-"` } // ListUsersResponse: list users response. type ListUsersResponse struct { // Users: list of users. Users []*User `json:"users"` // TotalCount: total count of users. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListUsersResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListUsersResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListUsersResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Users = append(r.Users, results.Users...) r.TotalCount += uint32(len(results.Users)) return uint32(len(results.Users)), nil } // RemoveGroupMemberRequest: remove group member request. type RemoveGroupMemberRequest struct { // GroupID: ID of the group. GroupID string `json:"-"` // UserID: ID of the user to remove. // Precisely one of UserID, ApplicationID must be set. UserID *string `json:"user_id,omitempty"` // ApplicationID: ID of the application to remove. // Precisely one of UserID, ApplicationID must be set. ApplicationID *string `json:"application_id,omitempty"` } // SetGroupMembersRequest: set group members request. type SetGroupMembersRequest struct { GroupID string `json:"-"` UserIDs []string `json:"user_ids"` ApplicationIDs []string `json:"application_ids"` } // SetRulesRequest: set rules request. type SetRulesRequest struct { // PolicyID: id of policy to update. PolicyID string `json:"policy_id"` // Rules: rules of the policy to set. Rules []*RuleSpecs `json:"rules"` } // SetRulesResponse: set rules response. type SetRulesResponse struct { // Rules: rules of the policy. Rules []*Rule `json:"rules"` } // UpdateAPIKeyRequest: update api key request. type UpdateAPIKeyRequest struct { // AccessKey: access key to update. AccessKey string `json:"-"` // DefaultProjectID: new default Project ID to set. DefaultProjectID *string `json:"default_project_id,omitempty"` // Description: new description to update. Description *string `json:"description,omitempty"` } // UpdateApplicationRequest: update application request. type UpdateApplicationRequest struct { // ApplicationID: ID of the application to update. ApplicationID string `json:"-"` // Name: new name for the application (max length is 64 chars). Name *string `json:"name,omitempty"` // Description: new description for the application (max length is 200 chars). Description *string `json:"description,omitempty"` // Tags: new tags for the application (maximum of 10 tags). Tags *[]string `json:"tags,omitempty"` } // UpdateGroupRequest: update group request. type UpdateGroupRequest struct { // GroupID: ID of the group to update. GroupID string `json:"-"` // Name: new name for the group (max length is 64 chars). MUST be unique inside an Organization. Name *string `json:"name,omitempty"` // Description: new description for the group (max length is 200 chars). Description *string `json:"description,omitempty"` // Tags: new tags for the group (maximum of 10 tags). Tags *[]string `json:"tags,omitempty"` } // UpdatePolicyRequest: update policy request. type UpdatePolicyRequest struct { // PolicyID: id of policy to update. PolicyID string `json:"-"` // Name: new name for the policy (max length is 64 characters). Name *string `json:"name,omitempty"` // Description: new description of policy (max length is 200 characters). Description *string `json:"description,omitempty"` // Tags: new tags for the policy (maximum of 10 tags). Tags *[]string `json:"tags,omitempty"` // UserID: new ID of user attributed to the policy. // Precisely one of UserID, GroupID, ApplicationID, NoPrincipal must be set. UserID *string `json:"user_id,omitempty"` // GroupID: new ID of group attributed to the policy. // Precisely one of UserID, GroupID, ApplicationID, NoPrincipal must be set. GroupID *string `json:"group_id,omitempty"` // ApplicationID: new ID of application attributed to the policy. // Precisely one of UserID, GroupID, ApplicationID, NoPrincipal must be set. ApplicationID *string `json:"application_id,omitempty"` // NoPrincipal: defines whether or not the policy is attributed to a principal. // Precisely one of UserID, GroupID, ApplicationID, NoPrincipal must be set. NoPrincipal *bool `json:"no_principal,omitempty"` } // UpdateSSHKeyRequest: update ssh key request. type UpdateSSHKeyRequest struct { SSHKeyID string `json:"-"` // Name: name of the SSH key. Max length is 1000. Name *string `json:"name,omitempty"` // Disabled: enable or disable the SSH key. Disabled *bool `json:"disabled,omitempty"` } // UpdateUserRequest: update user request. type UpdateUserRequest struct { // UserID: ID of the user to update. UserID string `json:"-"` // Tags: new tags for the user (maximum of 10 tags). Tags *[]string `json:"tags,omitempty"` } // IAM API. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } // ListSSHKeys: List SSH keys. By default, the SSH keys listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. You can define additional parameters for your query such as `organization_id`, `name`, `project_id` and `disabled`. func (s *API) ListSSHKeys(req *ListSSHKeysRequest, opts ...scw.RequestOption) (*ListSSHKeysResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "disabled", req.Disabled) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iam/v1alpha1/ssh-keys", Query: query, } var resp ListSSHKeysResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateSSHKey: Add a new SSH key to a Scaleway Project. You must specify the `name`, `public_key` and `project_id`. func (s *API) CreateSSHKey(req *CreateSSHKeyRequest, opts ...scw.RequestOption) (*SSHKey, error) { var err error if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if req.Name == "" { req.Name = namegenerator.GetRandomName("key") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/iam/v1alpha1/ssh-keys", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SSHKey err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetSSHKey: Retrieve information about a given SSH key, specified by the `ssh_key_id` parameter. The SSH key's full details, including `id`, `name`, `public_key`, and `project_id` are returned in the response. func (s *API) GetSSHKey(req *GetSSHKeyRequest, opts ...scw.RequestOption) (*SSHKey, error) { var err error if fmt.Sprint(req.SSHKeyID) == "" { return nil, errors.New("field SSHKeyID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iam/v1alpha1/ssh-keys/" + fmt.Sprint(req.SSHKeyID) + "", } var resp SSHKey err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateSSHKey: Update the parameters of an SSH key, including `name` and `disable`. func (s *API) UpdateSSHKey(req *UpdateSSHKeyRequest, opts ...scw.RequestOption) (*SSHKey, error) { var err error if fmt.Sprint(req.SSHKeyID) == "" { return nil, errors.New("field SSHKeyID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/iam/v1alpha1/ssh-keys/" + fmt.Sprint(req.SSHKeyID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SSHKey err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteSSHKey: Delete a given SSH key, specified by the `ssh_key_id`. Deleting an SSH is permanent, and cannot be undone. Note that you might need to update any configurations that used the SSH key. func (s *API) DeleteSSHKey(req *DeleteSSHKeyRequest, opts ...scw.RequestOption) error { var err error if fmt.Sprint(req.SSHKeyID) == "" { return errors.New("field SSHKeyID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/iam/v1alpha1/ssh-keys/" + fmt.Sprint(req.SSHKeyID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListUsers: List the users of an Organization. By default, the users listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. You must define the `organization_id` in the query path of your request. You can also define additional parameters for your query such as `user_ids`. func (s *API) ListUsers(req *ListUsersRequest, opts ...scw.RequestOption) (*ListUsersResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "user_ids", req.UserIDs) parameter.AddToQuery(query, "mfa", req.Mfa) parameter.AddToQuery(query, "tag", req.Tag) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iam/v1alpha1/users", Query: query, } var resp ListUsersResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetUser: Retrieve information about a user, specified by the `user_id` parameter. The user's full details, including `id`, `email`, `organization_id`, `status` and `mfa` are returned in the response. func (s *API) GetUser(req *GetUserRequest, opts ...scw.RequestOption) (*User, error) { var err error if fmt.Sprint(req.UserID) == "" { return nil, errors.New("field UserID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iam/v1alpha1/users/" + fmt.Sprint(req.UserID) + "", } var resp User err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateUser: Update the parameters of a user, including `tags`. func (s *API) UpdateUser(req *UpdateUserRequest, opts ...scw.RequestOption) (*User, error) { var err error if fmt.Sprint(req.UserID) == "" { return nil, errors.New("field UserID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/iam/v1alpha1/users/" + fmt.Sprint(req.UserID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp User err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteUser: Remove a user from an Organization in which they are a guest. You must define the `user_id` in your request. Note that removing a user from an Organization automatically deletes their API keys, and any policies directly attached to them become orphaned. func (s *API) DeleteUser(req *DeleteUserRequest, opts ...scw.RequestOption) error { var err error if fmt.Sprint(req.UserID) == "" { return errors.New("field UserID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/iam/v1alpha1/users/" + fmt.Sprint(req.UserID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // CreateUser: Create a new user. You must define the `organization_id` and the `email` in your request. func (s *API) CreateUser(req *CreateUserRequest, opts ...scw.RequestOption) (*User, error) { var err error if req.OrganizationID == "" { defaultOrganizationID, _ := s.client.GetDefaultOrganizationID() req.OrganizationID = defaultOrganizationID } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/iam/v1alpha1/users", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp User err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListApplications: List the applications of an Organization. By default, the applications listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. You must define the `organization_id` in the query path of your request. You can also define additional parameters for your query such as `application_ids`. func (s *API) ListApplications(req *ListApplicationsRequest, opts ...scw.RequestOption) (*ListApplicationsResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } if req.OrganizationID == "" { defaultOrganizationID, _ := s.client.GetDefaultOrganizationID() req.OrganizationID = defaultOrganizationID } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "editable", req.Editable) parameter.AddToQuery(query, "application_ids", req.ApplicationIDs) parameter.AddToQuery(query, "tag", req.Tag) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iam/v1alpha1/applications", Query: query, } var resp ListApplicationsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateApplication: Create a new application. You must define the `name` parameter in the request. func (s *API) CreateApplication(req *CreateApplicationRequest, opts ...scw.RequestOption) (*Application, error) { var err error if req.OrganizationID == "" { defaultOrganizationID, _ := s.client.GetDefaultOrganizationID() req.OrganizationID = defaultOrganizationID } if req.Name == "" { req.Name = namegenerator.GetRandomName("app") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/iam/v1alpha1/applications", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Application err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetApplication: Retrieve information about an application, specified by the `application_id` parameter. The application's full details, including `id`, `email`, `organization_id`, `status` and `two_factor_enabled` are returned in the response. func (s *API) GetApplication(req *GetApplicationRequest, opts ...scw.RequestOption) (*Application, error) { var err error if fmt.Sprint(req.ApplicationID) == "" { return nil, errors.New("field ApplicationID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iam/v1alpha1/applications/" + fmt.Sprint(req.ApplicationID) + "", } var resp Application err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateApplication: Update the parameters of an application, including `name` and `description`. func (s *API) UpdateApplication(req *UpdateApplicationRequest, opts ...scw.RequestOption) (*Application, error) { var err error if fmt.Sprint(req.ApplicationID) == "" { return nil, errors.New("field ApplicationID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/iam/v1alpha1/applications/" + fmt.Sprint(req.ApplicationID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Application err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteApplication: Delete an application. Note that this action is irreversible and will automatically delete the application's API keys. Policies attached to users and applications via this group will no longer apply. func (s *API) DeleteApplication(req *DeleteApplicationRequest, opts ...scw.RequestOption) error { var err error if fmt.Sprint(req.ApplicationID) == "" { return errors.New("field ApplicationID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/iam/v1alpha1/applications/" + fmt.Sprint(req.ApplicationID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListGroups: List groups. By default, the groups listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. You can define additional parameters to filter your query. Use `user_ids` or `application_ids` to list all groups certain users or applications belong to. func (s *API) ListGroups(req *ListGroupsRequest, opts ...scw.RequestOption) (*ListGroupsResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } if req.OrganizationID == "" { defaultOrganizationID, _ := s.client.GetDefaultOrganizationID() req.OrganizationID = defaultOrganizationID } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "application_ids", req.ApplicationIDs) parameter.AddToQuery(query, "user_ids", req.UserIDs) parameter.AddToQuery(query, "group_ids", req.GroupIDs) parameter.AddToQuery(query, "tag", req.Tag) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iam/v1alpha1/groups", Query: query, } var resp ListGroupsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateGroup: Create a new group. You must define the `name` and `organization_id` parameters in the request. func (s *API) CreateGroup(req *CreateGroupRequest, opts ...scw.RequestOption) (*Group, error) { var err error if req.OrganizationID == "" { defaultOrganizationID, _ := s.client.GetDefaultOrganizationID() req.OrganizationID = defaultOrganizationID } if req.Name == "" { req.Name = namegenerator.GetRandomName("grp") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/iam/v1alpha1/groups", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Group err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetGroup: Retrive information about a given group, specified by the `group_id` parameter. The group's full details, including `user_ids` and `application_ids` are returned in the response. func (s *API) GetGroup(req *GetGroupRequest, opts ...scw.RequestOption) (*Group, error) { var err error if fmt.Sprint(req.GroupID) == "" { return nil, errors.New("field GroupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iam/v1alpha1/groups/" + fmt.Sprint(req.GroupID) + "", } var resp Group err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateGroup: Update the parameters of group, including `name` and `description`. func (s *API) UpdateGroup(req *UpdateGroupRequest, opts ...scw.RequestOption) (*Group, error) { var err error if fmt.Sprint(req.GroupID) == "" { return nil, errors.New("field GroupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/iam/v1alpha1/groups/" + fmt.Sprint(req.GroupID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Group err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SetGroupMembers: Overwrite users and applications configuration in a group. Any information that you add using this command will overwrite the previous configuration. func (s *API) SetGroupMembers(req *SetGroupMembersRequest, opts ...scw.RequestOption) (*Group, error) { var err error if fmt.Sprint(req.GroupID) == "" { return nil, errors.New("field GroupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/iam/v1alpha1/groups/" + fmt.Sprint(req.GroupID) + "/members", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Group err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // AddGroupMember: Add a user or an application to a group. You can specify a `user_id` and and `application_id` in the body of your request. Note that you can only add one of each per request. func (s *API) AddGroupMember(req *AddGroupMemberRequest, opts ...scw.RequestOption) (*Group, error) { var err error if fmt.Sprint(req.GroupID) == "" { return nil, errors.New("field GroupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/iam/v1alpha1/groups/" + fmt.Sprint(req.GroupID) + "/add-member", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Group err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // AddGroupMembers: Add multiple users and applications to a group in a single call. You can specify an array of `user_id`s and `application_id`s. Note that any existing users and applications in the group will remain. To add new users/applications and delete pre-existing ones, use the [Overwrite users and applications of a group](#path-groups-overwrite-users-and-applications-of-a-group) method. func (s *API) AddGroupMembers(req *AddGroupMembersRequest, opts ...scw.RequestOption) (*Group, error) { var err error if fmt.Sprint(req.GroupID) == "" { return nil, errors.New("field GroupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/iam/v1alpha1/groups/" + fmt.Sprint(req.GroupID) + "/add-members", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Group err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // RemoveGroupMember: Remove a user or an application from a group. You can specify a `user_id` and and `application_id` in the body of your request. Note that you can only remove one of each per request. Removing a user from a group means that any permissions given to them via the group (i.e. from an attached policy) will no longer apply. Be sure you want to remove these permissions from the user before proceeding. func (s *API) RemoveGroupMember(req *RemoveGroupMemberRequest, opts ...scw.RequestOption) (*Group, error) { var err error if fmt.Sprint(req.GroupID) == "" { return nil, errors.New("field GroupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/iam/v1alpha1/groups/" + fmt.Sprint(req.GroupID) + "/remove-member", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Group err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteGroup: Delete a group. Note that this action is irreversible and could delete permissions for group members. Policies attached to users and applications via this group will no longer apply. func (s *API) DeleteGroup(req *DeleteGroupRequest, opts ...scw.RequestOption) error { var err error if fmt.Sprint(req.GroupID) == "" { return errors.New("field GroupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/iam/v1alpha1/groups/" + fmt.Sprint(req.GroupID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListPolicies: List the policies of an Organization. By default, the policies listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. You must define the `organization_id` in the query path of your request. You can also define additional parameters to filter your query, such as `user_ids`, `groups_ids`, `application_ids`, and `policy_name`. func (s *API) ListPolicies(req *ListPoliciesRequest, opts ...scw.RequestOption) (*ListPoliciesResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } if req.OrganizationID == "" { defaultOrganizationID, _ := s.client.GetDefaultOrganizationID() req.OrganizationID = defaultOrganizationID } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "editable", req.Editable) parameter.AddToQuery(query, "user_ids", req.UserIDs) parameter.AddToQuery(query, "group_ids", req.GroupIDs) parameter.AddToQuery(query, "application_ids", req.ApplicationIDs) parameter.AddToQuery(query, "no_principal", req.NoPrincipal) parameter.AddToQuery(query, "policy_name", req.PolicyName) parameter.AddToQuery(query, "tag", req.Tag) parameter.AddToQuery(query, "policy_ids", req.PolicyIDs) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iam/v1alpha1/policies", Query: query, } var resp ListPoliciesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreatePolicy: Create a new application. You must define the `name` parameter in the request. You can specify parameters such as `user_id`, `groups_id`, `application_id`, `no_principal`, `rules` and its child attributes. func (s *API) CreatePolicy(req *CreatePolicyRequest, opts ...scw.RequestOption) (*Policy, error) { var err error if req.OrganizationID == "" { defaultOrganizationID, _ := s.client.GetDefaultOrganizationID() req.OrganizationID = defaultOrganizationID } if req.Name == "" { req.Name = namegenerator.GetRandomName("pol") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/iam/v1alpha1/policies", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Policy err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetPolicy: Retrieve information about a policy, speficified by the `policy_id` parameter. The policy's full details, including `id`, `name`, `organization_id`, `nb_rules` and `nb_scopes`, `nb_permission_sets` are returned in the response. func (s *API) GetPolicy(req *GetPolicyRequest, opts ...scw.RequestOption) (*Policy, error) { var err error if fmt.Sprint(req.PolicyID) == "" { return nil, errors.New("field PolicyID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iam/v1alpha1/policies/" + fmt.Sprint(req.PolicyID) + "", } var resp Policy err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdatePolicy: Update the parameters of a policy, including `name`, `description`, `user_id`, `group_id`, `application_id` and `no_principal`. func (s *API) UpdatePolicy(req *UpdatePolicyRequest, opts ...scw.RequestOption) (*Policy, error) { var err error if fmt.Sprint(req.PolicyID) == "" { return nil, errors.New("field PolicyID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/iam/v1alpha1/policies/" + fmt.Sprint(req.PolicyID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Policy err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeletePolicy: Delete a policy. You must define specify the `policy_id` parameter in your request. Note that when deleting a policy, all permissions it gives to its principal (user, group or application) will be revoked. func (s *API) DeletePolicy(req *DeletePolicyRequest, opts ...scw.RequestOption) error { var err error if fmt.Sprint(req.PolicyID) == "" { return errors.New("field PolicyID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/iam/v1alpha1/policies/" + fmt.Sprint(req.PolicyID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ClonePolicy: Clone a policy. You must define specify the `policy_id` parameter in your request. func (s *API) ClonePolicy(req *ClonePolicyRequest, opts ...scw.RequestOption) (*Policy, error) { var err error if fmt.Sprint(req.PolicyID) == "" { return nil, errors.New("field PolicyID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/iam/v1alpha1/policies/" + fmt.Sprint(req.PolicyID) + "/clone", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Policy err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SetRules: Overwrite the rules of a given policy. Any information that you add using this command will overwrite the previous configuration. If you include some of the rules you already had in your previous configuration in your new one, but you change their order, the new order of display will apply. While policy rules are ordered, they have no impact on the access logic of IAM because rules are allow-only. func (s *API) SetRules(req *SetRulesRequest, opts ...scw.RequestOption) (*SetRulesResponse, error) { var err error scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/iam/v1alpha1/rules", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SetRulesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListRules: List the rules of a given policy. By default, the rules listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. You must define the `policy_id` in the query path of your request. func (s *API) ListRules(req *ListRulesRequest, opts ...scw.RequestOption) (*ListRulesResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "policy_id", req.PolicyID) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "page", req.Page) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iam/v1alpha1/rules", Query: query, } var resp ListRulesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListPermissionSets: List permission sets available for given Organization. You must define the `organization_id` in the query path of your request. func (s *API) ListPermissionSets(req *ListPermissionSetsRequest, opts ...scw.RequestOption) (*ListPermissionSetsResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } if req.OrganizationID == "" { defaultOrganizationID, _ := s.client.GetDefaultOrganizationID() req.OrganizationID = defaultOrganizationID } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "organization_id", req.OrganizationID) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iam/v1alpha1/permission-sets", Query: query, } var resp ListPermissionSetsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListAPIKeys: List API keys. By default, the API keys listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. You can define additional parameters for your query such as `editable`, `expired`, `access_key` and `bearer_id`. func (s *API) ListAPIKeys(req *ListAPIKeysRequest, opts ...scw.RequestOption) (*ListAPIKeysResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "editable", req.Editable) parameter.AddToQuery(query, "expired", req.Expired) parameter.AddToQuery(query, "access_key", req.AccessKey) parameter.AddToQuery(query, "description", req.Description) parameter.AddToQuery(query, "bearer_id", req.BearerID) parameter.AddToQuery(query, "bearer_type", req.BearerType) parameter.AddToQuery(query, "access_keys", req.AccessKeys) parameter.AddToQuery(query, "application_id", req.ApplicationID) parameter.AddToQuery(query, "user_id", req.UserID) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iam/v1alpha1/api-keys", Query: query, } var resp ListAPIKeysResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateAPIKey: Create an API key. You must specify the `application_id` or the `user_id` and the description. You can also specify the `default_project_id` which is the Project ID of your preferred Project, to use with Object Storage. The `access_key` and `secret_key` values are returned in the response. Note that he secret key is only showed once. Make sure that you copy and store both keys somewhere safe. func (s *API) CreateAPIKey(req *CreateAPIKeyRequest, opts ...scw.RequestOption) (*APIKey, error) { var err error scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/iam/v1alpha1/api-keys", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp APIKey err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetAPIKey: Retrive information about an API key, specified by the `access_key` parameter. The API key's details, including either the `user_id` or `application_id` of its bearer are returned in the response. Note that the string value for the `secret_key` is nullable, and therefore is not displayed in the response. The `secret_key` value is only displayed upon API key creation. func (s *API) GetAPIKey(req *GetAPIKeyRequest, opts ...scw.RequestOption) (*APIKey, error) { var err error if fmt.Sprint(req.AccessKey) == "" { return nil, errors.New("field AccessKey cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iam/v1alpha1/api-keys/" + fmt.Sprint(req.AccessKey) + "", } var resp APIKey err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateAPIKey: Update the parameters of an API key, including `default_project_id` and `description`. func (s *API) UpdateAPIKey(req *UpdateAPIKeyRequest, opts ...scw.RequestOption) (*APIKey, error) { var err error if fmt.Sprint(req.AccessKey) == "" { return nil, errors.New("field AccessKey cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/iam/v1alpha1/api-keys/" + fmt.Sprint(req.AccessKey) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp APIKey err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteAPIKey: Delete an API key. Note that this action is irreversible and cannot be undone. Make sure you update any configurations using the API keys you delete. func (s *API) DeleteAPIKey(req *DeleteAPIKeyRequest, opts ...scw.RequestOption) error { var err error if fmt.Sprint(req.AccessKey) == "" { return errors.New("field AccessKey cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/iam/v1alpha1/api-keys/" + fmt.Sprint(req.AccessKey) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListQuota: List all product and features quota for an Organization, with their associated limits. By default, the quota listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. You must define the `organization_id` in the query path of your request. func (s *API) ListQuota(req *ListQuotaRequest, opts ...scw.RequestOption) (*ListQuotaResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } if req.OrganizationID == "" { defaultOrganizationID, _ := s.client.GetDefaultOrganizationID() req.OrganizationID = defaultOrganizationID } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "organization_id", req.OrganizationID) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iam/v1alpha1/quota", Query: query, } var resp ListQuotaResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetQuotum: Retrieve information about a resource quota, specified by the `quotum_name` parameter. The quota's `limit`, or whether it is unlimited, is returned in the response. func (s *API) GetQuotum(req *GetQuotumRequest, opts ...scw.RequestOption) (*Quotum, error) { var err error if req.OrganizationID == "" { defaultOrganizationID, _ := s.client.GetDefaultOrganizationID() req.OrganizationID = defaultOrganizationID } query := url.Values{} parameter.AddToQuery(query, "organization_id", req.OrganizationID) if fmt.Sprint(req.QuotumName) == "" { return nil, errors.New("field QuotumName cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iam/v1alpha1/quota/" + fmt.Sprint(req.QuotumName) + "", Query: query, } var resp Quotum err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListJWTs: List JWTs. func (s *API) ListJWTs(req *ListJWTsRequest, opts ...scw.RequestOption) (*ListJWTsResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "audience_id", req.AudienceID) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "expired", req.Expired) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iam/v1alpha1/jwts", Query: query, } var resp ListJWTsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetJWT: Get a JWT. func (s *API) GetJWT(req *GetJWTRequest, opts ...scw.RequestOption) (*JWT, error) { var err error if fmt.Sprint(req.Jti) == "" { return nil, errors.New("field Jti cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iam/v1alpha1/jwts/" + fmt.Sprint(req.Jti) + "", } var resp JWT err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteJWT: Delete a JWT. func (s *API) DeleteJWT(req *DeleteJWTRequest, opts ...scw.RequestOption) error { var err error if fmt.Sprint(req.Jti) == "" { return errors.New("field Jti cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/iam/v1alpha1/jwts/" + fmt.Sprint(req.Jti) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListLogs: List logs available for given Organization. You must define the `organization_id` in the query path of your request. func (s *API) ListLogs(req *ListLogsRequest, opts ...scw.RequestOption) (*ListLogsResponse, error) { var err error if req.OrganizationID == "" { defaultOrganizationID, _ := s.client.GetDefaultOrganizationID() req.OrganizationID = defaultOrganizationID } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "created_after", req.CreatedAfter) parameter.AddToQuery(query, "created_before", req.CreatedBefore) parameter.AddToQuery(query, "action", req.Action) parameter.AddToQuery(query, "resource_type", req.ResourceType) parameter.AddToQuery(query, "search", req.Search) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iam/v1alpha1/logs", Query: query, } var resp ListLogsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetLog: Retrieve information about a log, specified by the `log_id` parameter. The log's full details, including `id`, `ip`, `user_agent`, `action`, `bearer_id`, `resource_type` and `resource_id` are returned in the response. func (s *API) GetLog(req *GetLogRequest, opts ...scw.RequestOption) (*Log, error) { var err error if fmt.Sprint(req.LogID) == "" { return nil, errors.New("field LogID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iam/v1alpha1/logs/" + fmt.Sprint(req.LogID) + "", } var resp Log err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/000077500000000000000000000000001456366605600246335ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/000077500000000000000000000000001456366605600251615ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/image_utils.go000066400000000000000000000026131456366605600300140ustar00rootroot00000000000000package instance import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) // WaitForImageRequest is used by WaitForImage method. type WaitForImageRequest struct { ImageID string Zone scw.Zone Timeout *time.Duration RetryInterval *time.Duration } // WaitForImage wait for the image to be in a "terminal state" before returning. func (s *API) WaitForImage(req *WaitForImageRequest, opts ...scw.RequestOption) (*Image, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[ImageState]struct{}{ ImageStateAvailable: {}, ImageStateError: {}, } image, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetImage(&GetImageRequest{ ImageID: req.ImageID, Zone: req.Zone, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.Image.State] return res.Image, isTerminal, err }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for image failed") } return image.(*Image), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/image_utils_test.go000066400000000000000000000043671456366605600310630ustar00rootroot00000000000000package instance import ( "strings" "testing" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers/httprecorder" ) func TestWaitForImage(t *testing.T) { client, r, err := httprecorder.CreateRecordedScwClient("image-wait-test") testhelpers.AssertNoError(t, err) defer func() { testhelpers.AssertNoError(t, r.Stop()) // Make sure recorder is stopped once done with it }() instanceAPI := NewAPI(client) imageName := "backup" image, cleanup := createImage(t, instanceAPI, imageName) defer cleanup() res, err := instanceAPI.WaitForImage(&WaitForImageRequest{ ImageID: image.ID, }) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, image.ID, res.ID) testhelpers.Equals(t, ImageStateAvailable, res.State) testhelpers.Equals(t, imageName, res.Name) } // createImage cis a helper that create an image. // It return the newly created image and a cleanup function func createImage(t *testing.T, instanceAPI *API, imageName string) (*Image, func()) { serverRes, err := instanceAPI.CreateServer(&CreateServerRequest{ CommercialType: "DEV1-M", Image: "ubuntu_focal", }) testhelpers.AssertNoError(t, err) // Backup will create a snapshot for each volume + an image base on all snapshots. backupRes, err := instanceAPI.ServerAction(&ServerActionRequest{ ServerID: serverRes.Server.ID, Action: ServerActionBackup, Name: &imageName, }) testhelpers.AssertNoError(t, err) tmp := strings.Split(backupRes.Task.HrefResult, "/") imageID := tmp[2] imageRes, err := instanceAPI.GetImage(&GetImageRequest{ ImageID: imageID, }) testhelpers.AssertNoError(t, err) return imageRes.Image, func() { // Delete all created resources err := instanceAPI.DeleteServer(&DeleteServerRequest{ ServerID: serverRes.Server.ID, }) testhelpers.AssertNoError(t, err) err = instanceAPI.DeleteVolume(&DeleteVolumeRequest{ VolumeID: serverRes.Server.Volumes["0"].ID, }) testhelpers.AssertNoError(t, err) err = instanceAPI.DeleteImage(&DeleteImageRequest{ ImageID: imageRes.Image.ID, }) testhelpers.AssertNoError(t, err) err = instanceAPI.DeleteSnapshot(&DeleteSnapshotRequest{ SnapshotID: imageRes.Image.RootVolume.ID, }) testhelpers.AssertNoError(t, err) } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/instance_metadata_sdk.go000066400000000000000000000234571456366605600320300ustar00rootroot00000000000000package instance import ( "bytes" "encoding/json" "io/ioutil" "math/rand" "net" "net/http" "strconv" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" ) var ( metadataRetryBindPort = 200 ) const metadataAPIv4 = "http://169.254.42.42" const metadataAPIv6 = "http://[fd00:42::42]" // MetadataAPI metadata API type MetadataAPI struct { MetadataURL *string } // NewMetadataAPI returns a MetadataAPI object from a Scaleway client. func NewMetadataAPI() *MetadataAPI { return &MetadataAPI{} } func (meta *MetadataAPI) getMetadataUrl() string { if meta.MetadataURL != nil { return *meta.MetadataURL } for _, url := range []string{metadataAPIv4, metadataAPIv6} { http.DefaultClient.Timeout = 3 * time.Second resp, err := http.Get(url) if err == nil && resp.StatusCode == 200 { meta.MetadataURL = &url return url } } return metadataAPIv4 } // GetMetadata returns the metadata available from the server func (meta *MetadataAPI) GetMetadata() (m *Metadata, err error) { resp, err := http.Get(meta.getMetadataUrl() + "/conf?format=json") if err != nil { return nil, errors.Wrap(err, "error getting metadataURL") } defer resp.Body.Close() metadata := &Metadata{} err = json.NewDecoder(resp.Body).Decode(metadata) if err != nil { return nil, errors.Wrap(err, "error decoding metadata") } return metadata, nil } // MetadataIP represents all public IPs attached type MetadataIP struct { ID string `json:"id"` Address string `json:"address"` Dynamic bool `json:"dynamic"` Gateway string `json:"gateway"` Netmask string `json:"netmask"` Family string `json:"family"` ProvisioningMode string `json:"provisioning_mode"` Tags []string `json:"tags"` } // Metadata represents the struct return by the metadata API type Metadata struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Hostname string `json:"hostname,omitempty"` Organization string `json:"organization,omitempty"` Project string `json:"project,omitempty"` CommercialType string `json:"commercial_type,omitempty"` //PublicIP IPv4 only PublicIP struct { ID string `json:"id"` Address string `json:"address"` Dynamic bool `json:"dynamic"` Gateway string `json:"gateway"` Netmask string `json:"netmask"` Family string `json:"family"` ProvisioningMode string `json:"provisioning_mode"` } `json:"public_ip,omitempty"` PublicIpsV4 []MetadataIP `json:"public_ips_v4,omitempty"` PublicIpsV6 []MetadataIP `json:"public_ips_v6,omitempty"` PrivateIP string `json:"private_ip,omitempty"` IPv6 struct { Netmask string `json:"netmask,omitempty"` Gateway string `json:"gateway,omitempty"` Address string `json:"address,omitempty"` } `json:"ipv6,omitempty"` Location struct { PlatformID string `json:"platform_id,omitempty"` HypervisorID string `json:"hypervisor_id,omitempty"` NodeID string `json:"node_id,omitempty"` ClusterID string `json:"cluster_id,omitempty"` ZoneID string `json:"zone_id,omitempty"` } `json:"location,omitempty"` Tags []string `json:"tags,omitempty"` StateDetail string `json:"state_detail,omitempty"` SSHPublicKeys []struct { Description string `json:"description,omitempty"` ModificationDate string `json:"modification_date,omitempty"` IP string `json:"ip,omitempty"` Key string `json:"key,omitempty"` Fingerprint string `json:"fingerprint,omitempty"` ID string `json:"id,omitempty"` CreationDate string `json:"creation_date,omitempty"` } `json:"ssh_public_keys,omitempty"` Timezone string `json:"timezone,omitempty"` Bootscript struct { Kernel string `json:"kernel,omitempty"` Title string `json:"title,omitempty"` Default bool `json:"default,omitempty"` Dtb string `json:"dtb,omitempty"` Public bool `json:"publc,omitempty"` Initrd string `json:"initrd,omitempty"` Bootcmdargs string `json:"bootcmdargs,omitempty"` Architecture string `json:"architecture,omitempty"` Organization string `json:"organization,omitempty"` Project string `json:"project,omitempty"` ID string `json:"id,omitempty"` } `json:"bootscript,omitempty"` Volumes map[string]struct { Name string `json:"name,omitempty"` ModificationDate string `json:"modification_date,omitempty"` ExportURI string `json:"export_uri,omitempty"` VolumeType string `json:"volume_type,omitempty"` CreationDate string `json:"creation_date,omitempty"` State string `json:"state,omitempty"` Organization string `json:"organization,omitempty"` Project string `json:"project,omitempty"` Server struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` } `json:"server,omitempty"` ID string `json:"id,omitempty"` Size int `json:"size,omitempty"` } `json:"volumes,omitempty"` PrivateNICs []struct { ID string `json:"id,omitempty"` PrivateNetworkID string `json:"private_network_id,omitempty"` ServerID string `json:"server_id,omitempty"` MacAddress string `json:"mac_address,omitempty"` CreationDate string `json:"creation_date,omitempty"` Zone string `json:"zone,omitempty"` } `json:"private_nics,omitempty"` } // ListUserData returns the metadata available from the server func (meta *MetadataAPI) ListUserData() (res *UserData, err error) { retries := 0 for retries <= metadataRetryBindPort { port := rand.Intn(1024) localTCPAddr, err := net.ResolveTCPAddr("tcp", ":"+strconv.Itoa(port)) if err != nil { return nil, errors.Wrap(err, "error resolving tcp address") } userdataClient := &http.Client{ Transport: &http.Transport{ DialContext: (&net.Dialer{ LocalAddr: localTCPAddr, DualStack: false, FallbackDelay: time.Second * -1, }).DialContext, }, } resp, err := userdataClient.Get(meta.getMetadataUrl() + "/user_data?format=json") if err != nil { retries++ // retry with a different source port continue } defer resp.Body.Close() userdata := &UserData{} err = json.NewDecoder(resp.Body).Decode(userdata) if err != nil { return nil, errors.Wrap(err, "error decoding userdata") } return userdata, nil } return nil, errors.New("too many bind port retries for ListUserData") } // GetUserData returns the value for the given metadata key func (meta *MetadataAPI) GetUserData(key string) ([]byte, error) { if key == "" { return make([]byte, 0), errors.New("key must not be empty in GetUserData") } retries := 0 for retries <= metadataRetryBindPort { port := rand.Intn(1024) localTCPAddr, err := net.ResolveTCPAddr("tcp", ":"+strconv.Itoa(port)) if err != nil { return make([]byte, 0), errors.Wrap(err, "error resolving tcp address") } userdataClient := &http.Client{ Transport: &http.Transport{ DialContext: (&net.Dialer{ LocalAddr: localTCPAddr, DualStack: false, FallbackDelay: time.Second * -1, }).DialContext, }, } resp, err := userdataClient.Get(meta.getMetadataUrl() + "/user_data/" + key) if err != nil { retries++ // retry with a different source port continue } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { return make([]byte, 0), errors.Wrap(err, "error reading userdata body") } return body, nil } return make([]byte, 0), errors.New("too may bind port retries for GetUserData") } // SetUserData sets the userdata key with the given value func (meta *MetadataAPI) SetUserData(key string, value []byte) error { if key == "" { return errors.New("key must not be empty in SetUserData") } retries := 0 for retries <= metadataRetryBindPort { port := rand.Intn(1024) localTCPAddr, err := net.ResolveTCPAddr("tcp", ":"+strconv.Itoa(port)) if err != nil { return errors.Wrap(err, "error resolving tcp address") } userdataClient := &http.Client{ Transport: &http.Transport{ DialContext: (&net.Dialer{ LocalAddr: localTCPAddr, DualStack: false, FallbackDelay: time.Second * -1, }).DialContext, }, } request, err := http.NewRequest("PATCH", meta.getMetadataUrl()+"/user_data/"+key, bytes.NewBuffer(value)) if err != nil { return errors.Wrap(err, "error creating patch userdata request") } request.Header.Set("Content-Type", "text/plain") _, err = userdataClient.Do(request) if err != nil { retries++ // retry with a different source port continue } return nil } return errors.New("too may bind port retries for SetUserData") } // DeleteUserData deletes the userdata key and the associated value func (meta *MetadataAPI) DeleteUserData(key string) error { if key == "" { return errors.New("key must not be empty in DeleteUserData") } retries := 0 for retries <= metadataRetryBindPort { port := rand.Intn(1024) localTCPAddr, err := net.ResolveTCPAddr("tcp", ":"+strconv.Itoa(port)) if err != nil { return errors.Wrap(err, "error resolving tcp address") } userdataClient := &http.Client{ Transport: &http.Transport{ DialContext: (&net.Dialer{ LocalAddr: localTCPAddr, DualStack: false, FallbackDelay: time.Second * -1, }).DialContext, }, } request, err := http.NewRequest("DELETE", meta.getMetadataUrl()+"/user_data/"+key, bytes.NewBuffer([]byte(""))) if err != nil { return errors.Wrap(err, "error creating delete userdata request") } _, err = userdataClient.Do(request) if err != nil { retries++ // retry with a different source port continue } return nil } return errors.New("too may bind port retries for DeleteUserData") } // UserData represents the user data type UserData struct { UserData []string `json:"user_data,omitempty"` } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/instance_sdk.go000066400000000000000000005460441456366605600301720ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package instance provides methods and message types of the instance v1 API. package instance import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type Arch string const ( ArchUnknownArch = Arch("unknown_arch") ArchX86_64 = Arch("x86_64") ArchArm = Arch("arm") ArchArm64 = Arch("arm64") ) func (enum Arch) String() string { if enum == "" { // return default value if empty return "unknown_arch" } return string(enum) } func (enum Arch) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *Arch) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = Arch(Arch(tmp).String()) return nil } type AttachServerVolumeRequestVolumeType string const ( AttachServerVolumeRequestVolumeTypeUnknownVolumeType = AttachServerVolumeRequestVolumeType("unknown_volume_type") AttachServerVolumeRequestVolumeTypeLSSD = AttachServerVolumeRequestVolumeType("l_ssd") AttachServerVolumeRequestVolumeTypeBSSD = AttachServerVolumeRequestVolumeType("b_ssd") AttachServerVolumeRequestVolumeTypeSbsVolume = AttachServerVolumeRequestVolumeType("sbs_volume") ) func (enum AttachServerVolumeRequestVolumeType) String() string { if enum == "" { // return default value if empty return "unknown_volume_type" } return string(enum) } func (enum AttachServerVolumeRequestVolumeType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *AttachServerVolumeRequestVolumeType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = AttachServerVolumeRequestVolumeType(AttachServerVolumeRequestVolumeType(tmp).String()) return nil } type BootType string const ( BootTypeLocal = BootType("local") BootTypeBootscript = BootType("bootscript") BootTypeRescue = BootType("rescue") ) func (enum BootType) String() string { if enum == "" { // return default value if empty return "local" } return string(enum) } func (enum BootType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *BootType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = BootType(BootType(tmp).String()) return nil } type IPState string const ( IPStateUnknownState = IPState("unknown_state") IPStateDetached = IPState("detached") IPStateAttached = IPState("attached") IPStatePending = IPState("pending") IPStateError = IPState("error") ) func (enum IPState) String() string { if enum == "" { // return default value if empty return "unknown_state" } return string(enum) } func (enum IPState) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *IPState) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = IPState(IPState(tmp).String()) return nil } type IPType string const ( IPTypeUnknownIptype = IPType("unknown_iptype") IPTypeNat = IPType("nat") IPTypeRoutedIPv4 = IPType("routed_ipv4") IPTypeRoutedIPv6 = IPType("routed_ipv6") ) func (enum IPType) String() string { if enum == "" { // return default value if empty return "unknown_iptype" } return string(enum) } func (enum IPType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *IPType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = IPType(IPType(tmp).String()) return nil } type ImageState string const ( ImageStateAvailable = ImageState("available") ImageStateCreating = ImageState("creating") ImageStateError = ImageState("error") ) func (enum ImageState) String() string { if enum == "" { // return default value if empty return "available" } return string(enum) } func (enum ImageState) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ImageState) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ImageState(ImageState(tmp).String()) return nil } type ListServersRequestOrder string const ( ListServersRequestOrderCreationDateDesc = ListServersRequestOrder("creation_date_desc") ListServersRequestOrderCreationDateAsc = ListServersRequestOrder("creation_date_asc") ListServersRequestOrderModificationDateDesc = ListServersRequestOrder("modification_date_desc") ListServersRequestOrderModificationDateAsc = ListServersRequestOrder("modification_date_asc") ) func (enum ListServersRequestOrder) String() string { if enum == "" { // return default value if empty return "creation_date_desc" } return string(enum) } func (enum ListServersRequestOrder) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListServersRequestOrder) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListServersRequestOrder(ListServersRequestOrder(tmp).String()) return nil } type PlacementGroupPolicyMode string const ( PlacementGroupPolicyModeOptional = PlacementGroupPolicyMode("optional") PlacementGroupPolicyModeEnforced = PlacementGroupPolicyMode("enforced") ) func (enum PlacementGroupPolicyMode) String() string { if enum == "" { // return default value if empty return "optional" } return string(enum) } func (enum PlacementGroupPolicyMode) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *PlacementGroupPolicyMode) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = PlacementGroupPolicyMode(PlacementGroupPolicyMode(tmp).String()) return nil } type PlacementGroupPolicyType string const ( PlacementGroupPolicyTypeMaxAvailability = PlacementGroupPolicyType("max_availability") PlacementGroupPolicyTypeLowLatency = PlacementGroupPolicyType("low_latency") ) func (enum PlacementGroupPolicyType) String() string { if enum == "" { // return default value if empty return "max_availability" } return string(enum) } func (enum PlacementGroupPolicyType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *PlacementGroupPolicyType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = PlacementGroupPolicyType(PlacementGroupPolicyType(tmp).String()) return nil } type PrivateNICState string const ( PrivateNICStateAvailable = PrivateNICState("available") PrivateNICStateSyncing = PrivateNICState("syncing") PrivateNICStateSyncingError = PrivateNICState("syncing_error") ) func (enum PrivateNICState) String() string { if enum == "" { // return default value if empty return "available" } return string(enum) } func (enum PrivateNICState) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *PrivateNICState) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = PrivateNICState(PrivateNICState(tmp).String()) return nil } type SecurityGroupPolicy string const ( SecurityGroupPolicyUnknownPolicy = SecurityGroupPolicy("unknown_policy") SecurityGroupPolicyAccept = SecurityGroupPolicy("accept") SecurityGroupPolicyDrop = SecurityGroupPolicy("drop") ) func (enum SecurityGroupPolicy) String() string { if enum == "" { // return default value if empty return "unknown_policy" } return string(enum) } func (enum SecurityGroupPolicy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *SecurityGroupPolicy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = SecurityGroupPolicy(SecurityGroupPolicy(tmp).String()) return nil } type SecurityGroupRuleAction string const ( SecurityGroupRuleActionUnknownAction = SecurityGroupRuleAction("unknown_action") SecurityGroupRuleActionAccept = SecurityGroupRuleAction("accept") SecurityGroupRuleActionDrop = SecurityGroupRuleAction("drop") ) func (enum SecurityGroupRuleAction) String() string { if enum == "" { // return default value if empty return "unknown_action" } return string(enum) } func (enum SecurityGroupRuleAction) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *SecurityGroupRuleAction) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = SecurityGroupRuleAction(SecurityGroupRuleAction(tmp).String()) return nil } type SecurityGroupRuleDirection string const ( SecurityGroupRuleDirectionUnknownDirection = SecurityGroupRuleDirection("unknown_direction") SecurityGroupRuleDirectionInbound = SecurityGroupRuleDirection("inbound") SecurityGroupRuleDirectionOutbound = SecurityGroupRuleDirection("outbound") ) func (enum SecurityGroupRuleDirection) String() string { if enum == "" { // return default value if empty return "unknown_direction" } return string(enum) } func (enum SecurityGroupRuleDirection) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *SecurityGroupRuleDirection) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = SecurityGroupRuleDirection(SecurityGroupRuleDirection(tmp).String()) return nil } type SecurityGroupRuleProtocol string const ( SecurityGroupRuleProtocolUnknownProtocol = SecurityGroupRuleProtocol("unknown_protocol") SecurityGroupRuleProtocolTCP = SecurityGroupRuleProtocol("TCP") SecurityGroupRuleProtocolUDP = SecurityGroupRuleProtocol("UDP") SecurityGroupRuleProtocolICMP = SecurityGroupRuleProtocol("ICMP") SecurityGroupRuleProtocolANY = SecurityGroupRuleProtocol("ANY") ) func (enum SecurityGroupRuleProtocol) String() string { if enum == "" { // return default value if empty return "unknown_protocol" } return string(enum) } func (enum SecurityGroupRuleProtocol) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *SecurityGroupRuleProtocol) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = SecurityGroupRuleProtocol(SecurityGroupRuleProtocol(tmp).String()) return nil } type SecurityGroupState string const ( SecurityGroupStateAvailable = SecurityGroupState("available") SecurityGroupStateSyncing = SecurityGroupState("syncing") SecurityGroupStateSyncingError = SecurityGroupState("syncing_error") ) func (enum SecurityGroupState) String() string { if enum == "" { // return default value if empty return "available" } return string(enum) } func (enum SecurityGroupState) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *SecurityGroupState) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = SecurityGroupState(SecurityGroupState(tmp).String()) return nil } type ServerAction string const ( ServerActionPoweron = ServerAction("poweron") ServerActionBackup = ServerAction("backup") ServerActionStopInPlace = ServerAction("stop_in_place") ServerActionPoweroff = ServerAction("poweroff") ServerActionTerminate = ServerAction("terminate") ServerActionReboot = ServerAction("reboot") ServerActionEnableRoutedIP = ServerAction("enable_routed_ip") ) func (enum ServerAction) String() string { if enum == "" { // return default value if empty return "poweron" } return string(enum) } func (enum ServerAction) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ServerAction) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ServerAction(ServerAction(tmp).String()) return nil } type ServerIPIPFamily string const ( ServerIPIPFamilyInet = ServerIPIPFamily("inet") ServerIPIPFamilyInet6 = ServerIPIPFamily("inet6") ) func (enum ServerIPIPFamily) String() string { if enum == "" { // return default value if empty return "inet" } return string(enum) } func (enum ServerIPIPFamily) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ServerIPIPFamily) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ServerIPIPFamily(ServerIPIPFamily(tmp).String()) return nil } type ServerIPProvisioningMode string const ( ServerIPProvisioningModeManual = ServerIPProvisioningMode("manual") ServerIPProvisioningModeDHCP = ServerIPProvisioningMode("dhcp") ServerIPProvisioningModeSlaac = ServerIPProvisioningMode("slaac") ) func (enum ServerIPProvisioningMode) String() string { if enum == "" { // return default value if empty return "manual" } return string(enum) } func (enum ServerIPProvisioningMode) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ServerIPProvisioningMode) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ServerIPProvisioningMode(ServerIPProvisioningMode(tmp).String()) return nil } type ServerIPState string const ( ServerIPStateUnknownState = ServerIPState("unknown_state") ServerIPStateDetached = ServerIPState("detached") ServerIPStateAttached = ServerIPState("attached") ServerIPStatePending = ServerIPState("pending") ServerIPStateError = ServerIPState("error") ) func (enum ServerIPState) String() string { if enum == "" { // return default value if empty return "unknown_state" } return string(enum) } func (enum ServerIPState) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ServerIPState) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ServerIPState(ServerIPState(tmp).String()) return nil } type ServerState string const ( ServerStateRunning = ServerState("running") ServerStateStopped = ServerState("stopped") ServerStateStoppedInPlace = ServerState("stopped in place") ServerStateStarting = ServerState("starting") ServerStateStopping = ServerState("stopping") ServerStateLocked = ServerState("locked") ) func (enum ServerState) String() string { if enum == "" { // return default value if empty return "running" } return string(enum) } func (enum ServerState) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ServerState) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ServerState(ServerState(tmp).String()) return nil } type ServerTypesAvailability string const ( ServerTypesAvailabilityAvailable = ServerTypesAvailability("available") ServerTypesAvailabilityScarce = ServerTypesAvailability("scarce") ServerTypesAvailabilityShortage = ServerTypesAvailability("shortage") ) func (enum ServerTypesAvailability) String() string { if enum == "" { // return default value if empty return "available" } return string(enum) } func (enum ServerTypesAvailability) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ServerTypesAvailability) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ServerTypesAvailability(ServerTypesAvailability(tmp).String()) return nil } type SnapshotState string const ( SnapshotStateAvailable = SnapshotState("available") SnapshotStateSnapshotting = SnapshotState("snapshotting") SnapshotStateError = SnapshotState("error") SnapshotStateInvalidData = SnapshotState("invalid_data") SnapshotStateImporting = SnapshotState("importing") SnapshotStateExporting = SnapshotState("exporting") ) func (enum SnapshotState) String() string { if enum == "" { // return default value if empty return "available" } return string(enum) } func (enum SnapshotState) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *SnapshotState) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = SnapshotState(SnapshotState(tmp).String()) return nil } type SnapshotVolumeType string const ( SnapshotVolumeTypeUnknownVolumeType = SnapshotVolumeType("unknown_volume_type") SnapshotVolumeTypeLSSD = SnapshotVolumeType("l_ssd") SnapshotVolumeTypeBSSD = SnapshotVolumeType("b_ssd") SnapshotVolumeTypeUnified = SnapshotVolumeType("unified") ) func (enum SnapshotVolumeType) String() string { if enum == "" { // return default value if empty return "unknown_volume_type" } return string(enum) } func (enum SnapshotVolumeType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *SnapshotVolumeType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = SnapshotVolumeType(SnapshotVolumeType(tmp).String()) return nil } type TaskStatus string const ( TaskStatusPending = TaskStatus("pending") TaskStatusStarted = TaskStatus("started") TaskStatusSuccess = TaskStatus("success") TaskStatusFailure = TaskStatus("failure") TaskStatusRetry = TaskStatus("retry") ) func (enum TaskStatus) String() string { if enum == "" { // return default value if empty return "pending" } return string(enum) } func (enum TaskStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *TaskStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = TaskStatus(TaskStatus(tmp).String()) return nil } type VolumeServerState string const ( VolumeServerStateAvailable = VolumeServerState("available") VolumeServerStateSnapshotting = VolumeServerState("snapshotting") VolumeServerStateFetching = VolumeServerState("fetching") VolumeServerStateResizing = VolumeServerState("resizing") VolumeServerStateSaving = VolumeServerState("saving") VolumeServerStateHotsyncing = VolumeServerState("hotsyncing") VolumeServerStateError = VolumeServerState("error") ) func (enum VolumeServerState) String() string { if enum == "" { // return default value if empty return "available" } return string(enum) } func (enum VolumeServerState) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *VolumeServerState) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = VolumeServerState(VolumeServerState(tmp).String()) return nil } type VolumeServerVolumeType string const ( VolumeServerVolumeTypeLSSD = VolumeServerVolumeType("l_ssd") VolumeServerVolumeTypeBSSD = VolumeServerVolumeType("b_ssd") VolumeServerVolumeTypeSbsVolume = VolumeServerVolumeType("sbs_volume") VolumeServerVolumeTypeScratch = VolumeServerVolumeType("scratch") ) func (enum VolumeServerVolumeType) String() string { if enum == "" { // return default value if empty return "l_ssd" } return string(enum) } func (enum VolumeServerVolumeType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *VolumeServerVolumeType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = VolumeServerVolumeType(VolumeServerVolumeType(tmp).String()) return nil } type VolumeState string const ( VolumeStateAvailable = VolumeState("available") VolumeStateSnapshotting = VolumeState("snapshotting") VolumeStateFetching = VolumeState("fetching") VolumeStateResizing = VolumeState("resizing") VolumeStateSaving = VolumeState("saving") VolumeStateHotsyncing = VolumeState("hotsyncing") VolumeStateError = VolumeState("error") ) func (enum VolumeState) String() string { if enum == "" { // return default value if empty return "available" } return string(enum) } func (enum VolumeState) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *VolumeState) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = VolumeState(VolumeState(tmp).String()) return nil } type VolumeVolumeType string const ( VolumeVolumeTypeLSSD = VolumeVolumeType("l_ssd") VolumeVolumeTypeBSSD = VolumeVolumeType("b_ssd") VolumeVolumeTypeUnified = VolumeVolumeType("unified") VolumeVolumeTypeScratch = VolumeVolumeType("scratch") VolumeVolumeTypeSbsVolume = VolumeVolumeType("sbs_volume") VolumeVolumeTypeSbsSnapshot = VolumeVolumeType("sbs_snapshot") ) func (enum VolumeVolumeType) String() string { if enum == "" { // return default value if empty return "l_ssd" } return string(enum) } func (enum VolumeVolumeType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *VolumeVolumeType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = VolumeVolumeType(VolumeVolumeType(tmp).String()) return nil } // ServerSummary: server summary. type ServerSummary struct { ID string `json:"id"` Name string `json:"name"` } // Bootscript: bootscript. type Bootscript struct { // Bootcmdargs: bootscript arguments. Bootcmdargs string `json:"bootcmdargs"` // Default: display if the bootscript is the default bootscript (if no other boot option is configured). Default bool `json:"default"` // Dtb: provide information regarding a Device Tree Binary (DTB) for use with C1 servers. Dtb string `json:"dtb"` // ID: bootscript ID. ID string `json:"id"` // Initrd: initrd (initial ramdisk) configuration. Initrd string `json:"initrd"` // Kernel: instance kernel version. Kernel string `json:"kernel"` // Organization: bootscript Organization ID. Organization string `json:"organization"` // Project: bootscript Project ID. Project string `json:"project"` // Public: provide information if the bootscript is public. Public bool `json:"public"` // Title: bootscript title. Title string `json:"title"` // Arch: bootscript architecture. // Default value: unknown_arch Arch Arch `json:"arch"` // Zone: zone in which the bootscript is located. Zone scw.Zone `json:"zone"` } // Volume: volume. type Volume struct { // ID: volume unique ID. ID string `json:"id"` // Name: volume name. Name string `json:"name"` // Deprecated: ExportURI: show the volume NBD export URI. ExportURI *string `json:"export_uri"` // Size: volume disk size. Size scw.Size `json:"size"` // VolumeType: volume type. // Default value: l_ssd VolumeType VolumeVolumeType `json:"volume_type"` // CreationDate: volume creation date. CreationDate *time.Time `json:"creation_date"` // ModificationDate: volume modification date. ModificationDate *time.Time `json:"modification_date"` // Organization: volume Organization ID. Organization string `json:"organization"` // Project: volume Project ID. Project string `json:"project"` // Tags: volume tags. Tags []string `json:"tags"` // Server: instance attached to the volume. Server *ServerSummary `json:"server"` // State: volume state. // Default value: available State VolumeState `json:"state"` // Zone: zone in which the volume is located. Zone scw.Zone `json:"zone"` } // VolumeSummary: volume summary. type VolumeSummary struct { ID string `json:"id"` Name string `json:"name"` Size scw.Size `json:"size"` // VolumeType: default value: l_ssd VolumeType VolumeVolumeType `json:"volume_type"` } // ServerTypeNetworkInterface: server type network interface. type ServerTypeNetworkInterface struct { // InternalBandwidth: maximum internal bandwidth in bits per seconds. InternalBandwidth *uint64 `json:"internal_bandwidth"` // InternetBandwidth: maximum internet bandwidth in bits per seconds. InternetBandwidth *uint64 `json:"internet_bandwidth"` } // ServerTypeVolumeConstraintSizes: server type volume constraint sizes. type ServerTypeVolumeConstraintSizes struct { // MinSize: minimum volume size in bytes. MinSize scw.Size `json:"min_size"` // MaxSize: maximum volume size in bytes. MaxSize scw.Size `json:"max_size"` } // Image: image. type Image struct { ID string `json:"id"` Name string `json:"name"` // Arch: default value: unknown_arch Arch Arch `json:"arch"` CreationDate *time.Time `json:"creation_date"` ModificationDate *time.Time `json:"modification_date"` // Deprecated DefaultBootscript *Bootscript `json:"default_bootscript"` ExtraVolumes map[string]*Volume `json:"extra_volumes"` FromServer string `json:"from_server"` Organization string `json:"organization"` Public bool `json:"public"` RootVolume *VolumeSummary `json:"root_volume"` // State: default value: available State ImageState `json:"state"` Project string `json:"project"` Tags []string `json:"tags"` // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"zone"` } // PlacementGroup: placement group. type PlacementGroup struct { // ID: placement group unique ID. ID string `json:"id"` // Name: placement group name. Name string `json:"name"` // Organization: placement group Organization ID. Organization string `json:"organization"` // Project: placement group Project ID. Project string `json:"project"` // Tags: placement group tags. Tags []string `json:"tags"` // PolicyMode: select the failure mode when the placement cannot be respected, either optional or enforced. // Default value: optional PolicyMode PlacementGroupPolicyMode `json:"policy_mode"` // PolicyType: select the behavior of the placement group, either low_latency (group) or max_availability (spread). // Default value: max_availability PolicyType PlacementGroupPolicyType `json:"policy_type"` // PolicyRespected: returns true if the policy is respected, false otherwise. PolicyRespected bool `json:"policy_respected"` // Zone: zone in which the placement group is located. Zone scw.Zone `json:"zone"` } // PrivateNIC: private nic. type PrivateNIC struct { // ID: private NIC unique ID. ID string `json:"id"` // ServerID: instance to which the private NIC is attached. ServerID string `json:"server_id"` // PrivateNetworkID: private Network the private NIC is attached to. PrivateNetworkID string `json:"private_network_id"` // MacAddress: private NIC MAC address. MacAddress string `json:"mac_address"` // State: private NIC state. // Default value: available State PrivateNICState `json:"state"` // Tags: private NIC tags. Tags []string `json:"tags"` } // SecurityGroupSummary: security group summary. type SecurityGroupSummary struct { ID string `json:"id"` Name string `json:"name"` } // ServerIP: server ip. type ServerIP struct { // ID: unique ID of the IP address. ID string `json:"id"` // Address: instance's public IP-Address. Address net.IP `json:"address"` // Gateway: gateway's IP address. Gateway net.IP `json:"gateway"` // Netmask: cIDR netmask. Netmask string `json:"netmask"` // Family: IP address family (inet or inet6). // Default value: inet Family ServerIPIPFamily `json:"family"` // Dynamic: true if the IP address is dynamic. Dynamic bool `json:"dynamic"` // ProvisioningMode: information about this address provisioning mode. // Default value: manual ProvisioningMode ServerIPProvisioningMode `json:"provisioning_mode"` // Tags: tags associated with the IP. Tags []string `json:"tags"` // IpamID: the ip_id of an IPAM ip if the ip is created from IPAM, null if not. IpamID string `json:"ipam_id"` // State: IP address state. // Default value: unknown_state State ServerIPState `json:"state"` } // ServerIPv6: server i pv6. type ServerIPv6 struct { // Address: instance IPv6 IP-Address. Address net.IP `json:"address"` // Gateway: iPv6 IP-addresses gateway. Gateway net.IP `json:"gateway"` // Netmask: iPv6 IP-addresses CIDR netmask. Netmask string `json:"netmask"` } // ServerLocation: server location. type ServerLocation struct { ClusterID string `json:"cluster_id"` HypervisorID string `json:"hypervisor_id"` NodeID string `json:"node_id"` PlatformID string `json:"platform_id"` ZoneID string `json:"zone_id"` } // ServerMaintenance: server maintenance. type ServerMaintenance struct { Reason string `json:"reason"` StartDate *time.Time `json:"start_date"` } // VolumeServer: volume server. type VolumeServer struct { ID string `json:"id"` Name string `json:"name"` ExportURI string `json:"export_uri"` Organization string `json:"organization"` Server *ServerSummary `json:"server"` Size scw.Size `json:"size"` // VolumeType: default value: l_ssd VolumeType VolumeServerVolumeType `json:"volume_type"` CreationDate *time.Time `json:"creation_date"` ModificationDate *time.Time `json:"modification_date"` // State: default value: available State VolumeServerState `json:"state"` Project string `json:"project"` Boot bool `json:"boot"` // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"zone"` } // SnapshotBaseVolume: snapshot base volume. type SnapshotBaseVolume struct { // ID: volume ID on which the snapshot is based. ID string `json:"id"` // Name: volume name on which the snapshot is based on. Name string `json:"name"` } // ServerTypeCapabilities: server type capabilities. type ServerTypeCapabilities struct { // BlockStorage: defines whether the Instance supports block storage. BlockStorage *bool `json:"block_storage"` // BootTypes: list of supported boot types. BootTypes []BootType `json:"boot_types"` } // ServerTypeNetwork: server type network. type ServerTypeNetwork struct { // Interfaces: list of available network interfaces. Interfaces []*ServerTypeNetworkInterface `json:"interfaces"` // SumInternalBandwidth: total maximum internal bandwidth in bits per seconds. SumInternalBandwidth *uint64 `json:"sum_internal_bandwidth"` // SumInternetBandwidth: total maximum internet bandwidth in bits per seconds. SumInternetBandwidth *uint64 `json:"sum_internet_bandwidth"` // IPv6Support: true if IPv6 is enabled. IPv6Support bool `json:"ipv6_support"` } // ServerTypeVolumeConstraintsByType: server type volume constraints by type. type ServerTypeVolumeConstraintsByType struct { // LSSD: local SSD volumes. LSSD *ServerTypeVolumeConstraintSizes `json:"l_ssd"` } // VolumeTypeCapabilities: volume type capabilities. type VolumeTypeCapabilities struct { Snapshot bool `json:"snapshot"` } // VolumeTypeConstraints: volume type constraints. type VolumeTypeConstraints struct { Min scw.Size `json:"min"` Max scw.Size `json:"max"` } // Server: server. type Server struct { // ID: instance unique ID. ID string `json:"id"` // Name: instance name. Name string `json:"name"` // Organization: instance Organization ID. Organization string `json:"organization"` // Project: instance Project ID. Project string `json:"project"` // AllowedActions: list of allowed actions on the Instance. AllowedActions []ServerAction `json:"allowed_actions"` // Tags: tags associated with the Instance. Tags []string `json:"tags"` // CommercialType: instance commercial type (eg. GP1-M). CommercialType string `json:"commercial_type"` // CreationDate: instance creation date. CreationDate *time.Time `json:"creation_date"` // DynamicIPRequired: true if a dynamic IPv4 is required. DynamicIPRequired bool `json:"dynamic_ip_required"` // RoutedIPEnabled: true to configure the instance so it uses the new routed IP mode. RoutedIPEnabled bool `json:"routed_ip_enabled"` // EnableIPv6: true if IPv6 is enabled. EnableIPv6 bool `json:"enable_ipv6"` // Hostname: instance host name. Hostname string `json:"hostname"` // Image: information about the Instance image. Image *Image `json:"image"` // Protected: defines whether the Instance protection option is activated. Protected bool `json:"protected"` // PrivateIP: private IP address of the Instance. PrivateIP *string `json:"private_ip"` // PublicIP: information about the public IP. PublicIP *ServerIP `json:"public_ip"` // PublicIPs: information about all the public IPs attached to the server. PublicIPs []*ServerIP `json:"public_ips"` // MacAddress: the server's MAC address. MacAddress string `json:"mac_address"` // ModificationDate: instance modification date. ModificationDate *time.Time `json:"modification_date"` // State: instance state. // Default value: running State ServerState `json:"state"` // Location: instance location. Location *ServerLocation `json:"location"` // IPv6: instance IPv6 address. IPv6 *ServerIPv6 `json:"ipv6"` // Deprecated: Bootscript: instance bootscript. Bootscript *Bootscript `json:"bootscript"` // BootType: instance boot type. // Default value: local BootType BootType `json:"boot_type"` // Volumes: instance volumes. Volumes map[string]*VolumeServer `json:"volumes"` // SecurityGroup: instance security group. SecurityGroup *SecurityGroupSummary `json:"security_group"` // Maintenances: instance planned maintenance. Maintenances []*ServerMaintenance `json:"maintenances"` // StateDetail: detailed information about the Instance state. StateDetail string `json:"state_detail"` // Arch: instance architecture. // Default value: unknown_arch Arch Arch `json:"arch"` // PlacementGroup: instance placement group. PlacementGroup *PlacementGroup `json:"placement_group"` // PrivateNics: instance private NICs. PrivateNics []*PrivateNIC `json:"private_nics"` // Zone: zone in which the Instance is located. Zone scw.Zone `json:"zone"` } // IP: ip. type IP struct { ID string `json:"id"` Address net.IP `json:"address"` Reverse *string `json:"reverse"` Server *ServerSummary `json:"server"` Organization string `json:"organization"` Tags []string `json:"tags"` Project string `json:"project"` // Type: default value: unknown_iptype Type IPType `json:"type"` // State: default value: unknown_state State IPState `json:"state"` Prefix scw.IPNet `json:"prefix"` IpamID string `json:"ipam_id"` // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"zone"` } // VolumeTemplate: volume template. type VolumeTemplate struct { // ID: UUID of the volume. ID string `json:"id,omitempty"` // Name: name of the volume. Name string `json:"name,omitempty"` // Size: disk size of the volume, must be a multiple of 512. Size scw.Size `json:"size,omitempty"` // VolumeType: type of the volume. // Default value: l_ssd VolumeType VolumeVolumeType `json:"volume_type,omitempty"` // Deprecated: Organization: organization ID of the volume. // Precisely one of Project, Organization must be set. Organization *string `json:"organization,omitempty"` // Project: project ID of the volume. // Precisely one of Project, Organization must be set. Project *string `json:"project,omitempty"` } // SecurityGroup: security group. type SecurityGroup struct { // ID: security group unique ID. ID string `json:"id"` // Name: security group name. Name string `json:"name"` // Description: security group description. Description string `json:"description"` // EnableDefaultSecurity: true if SMTP is blocked on IPv4 and IPv6. This feature is read only, please open a support ticket if you need to make it configurable. EnableDefaultSecurity bool `json:"enable_default_security"` // InboundDefaultPolicy: default inbound policy. // Default value: unknown_policy InboundDefaultPolicy SecurityGroupPolicy `json:"inbound_default_policy"` // OutboundDefaultPolicy: default outbound policy. // Default value: unknown_policy OutboundDefaultPolicy SecurityGroupPolicy `json:"outbound_default_policy"` // Organization: security group Organization ID. Organization string `json:"organization"` // Project: security group Project ID. Project string `json:"project"` // Tags: security group tags. Tags []string `json:"tags"` // Deprecated: OrganizationDefault: true if it is your default security group for this Organization ID. OrganizationDefault *bool `json:"organization_default"` // ProjectDefault: true if it is your default security group for this Project ID. ProjectDefault bool `json:"project_default"` // CreationDate: security group creation date. CreationDate *time.Time `json:"creation_date"` // ModificationDate: security group modification date. ModificationDate *time.Time `json:"modification_date"` // Servers: list of Instances attached to this security group. Servers []*ServerSummary `json:"servers"` // Stateful: defines whether the security group is stateful. Stateful bool `json:"stateful"` // State: security group state. // Default value: available State SecurityGroupState `json:"state"` // Zone: zone in which the security group is located. Zone scw.Zone `json:"zone"` } // SecurityGroupRule: security group rule. type SecurityGroupRule struct { ID string `json:"id"` // Protocol: default value: unknown_protocol Protocol SecurityGroupRuleProtocol `json:"protocol"` // Direction: default value: unknown_direction Direction SecurityGroupRuleDirection `json:"direction"` // Action: default value: unknown_action Action SecurityGroupRuleAction `json:"action"` IPRange scw.IPNet `json:"ip_range"` DestPortFrom *uint32 `json:"dest_port_from"` DestPortTo *uint32 `json:"dest_port_to"` Position uint32 `json:"position"` Editable bool `json:"editable"` // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"zone"` } // VolumeServerTemplate: volume server template. type VolumeServerTemplate struct { // ID: UUID of the volume. ID *string `json:"id,omitempty"` // Boot: force the Instance to boot on this volume. Boot *bool `json:"boot,omitempty"` // Name: name of the volume. Name *string `json:"name,omitempty"` // Size: disk size of the volume, must be a multiple of 512. Size *scw.Size `json:"size,omitempty"` // VolumeType: type of the volume. // Default value: l_ssd VolumeType VolumeVolumeType `json:"volume_type,omitempty"` // BaseSnapshot: ID of the snapshot on which this volume will be based. BaseSnapshot *string `json:"base_snapshot,omitempty"` // Organization: organization ID of the volume. Organization *string `json:"organization,omitempty"` // Project: project ID of the volume. Project *string `json:"project,omitempty"` } // Snapshot: snapshot. type Snapshot struct { // ID: snapshot ID. ID string `json:"id"` // Name: snapshot name. Name string `json:"name"` // Organization: snapshot Organization ID. Organization string `json:"organization"` // Project: snapshot Project ID. Project string `json:"project"` // Tags: snapshot tags. Tags []string `json:"tags"` // VolumeType: snapshot volume type. // Default value: l_ssd VolumeType VolumeVolumeType `json:"volume_type"` // Size: snapshot size. Size scw.Size `json:"size"` // State: snapshot state. // Default value: available State SnapshotState `json:"state"` // BaseVolume: volume on which the snapshot is based on. BaseVolume *SnapshotBaseVolume `json:"base_volume"` // CreationDate: snapshot creation date. CreationDate *time.Time `json:"creation_date"` // ModificationDate: snapshot modification date. ModificationDate *time.Time `json:"modification_date"` // Zone: snapshot zone. Zone scw.Zone `json:"zone"` // ErrorReason: reason for the failed snapshot import. ErrorReason *string `json:"error_reason"` } // Task: task. type Task struct { // ID: unique ID of the task. ID string `json:"id"` // Description: description of the task. Description string `json:"description"` // Progress: progress of the task in percent. Progress int32 `json:"progress"` // StartedAt: task start date. StartedAt *time.Time `json:"started_at"` // TerminatedAt: task end date. TerminatedAt *time.Time `json:"terminated_at"` // Status: task status. // Default value: pending Status TaskStatus `json:"status"` HrefFrom string `json:"href_from"` HrefResult string `json:"href_result"` // Zone: zone in which the task is excecuted. Zone scw.Zone `json:"zone"` } // Dashboard: dashboard. type Dashboard struct { VolumesCount uint32 `json:"volumes_count"` RunningServersCount uint32 `json:"running_servers_count"` ServersByTypes map[string]uint32 `json:"servers_by_types"` ImagesCount uint32 `json:"images_count"` SnapshotsCount uint32 `json:"snapshots_count"` ServersCount uint32 `json:"servers_count"` IPsCount uint32 `json:"ips_count"` SecurityGroupsCount uint32 `json:"security_groups_count"` IPsUnused uint32 `json:"ips_unused"` VolumesLSSDCount uint32 `json:"volumes_l_ssd_count"` VolumesBSSDCount uint32 `json:"volumes_b_ssd_count"` VolumesLSSDTotalSize scw.Size `json:"volumes_l_ssd_total_size"` VolumesBSSDTotalSize scw.Size `json:"volumes_b_ssd_total_size"` PrivateNicsCount uint32 `json:"private_nics_count"` PlacementGroupsCount uint32 `json:"placement_groups_count"` } // PlacementGroupServer: placement group server. type PlacementGroupServer struct { // ID: instance UUID. ID string `json:"id"` // Name: instance name. Name string `json:"name"` // PolicyRespected: defines whether the placement group policy is respected (either 1 or 0). PolicyRespected bool `json:"policy_respected"` } // GetServerTypesAvailabilityResponseAvailability: get server types availability response availability. type GetServerTypesAvailabilityResponseAvailability struct { // Availability: default value: available Availability ServerTypesAvailability `json:"availability"` } // ServerType: server type. type ServerType struct { // Deprecated: MonthlyPrice: estimated monthly price, for a 30 days month, in Euro. MonthlyPrice *float32 `json:"monthly_price"` // HourlyPrice: hourly price in Euro. HourlyPrice float32 `json:"hourly_price"` // AltNames: alternative Instance name, if any. AltNames []string `json:"alt_names"` // PerVolumeConstraint: additional volume constraints. PerVolumeConstraint *ServerTypeVolumeConstraintsByType `json:"per_volume_constraint"` // VolumesConstraint: initial volume constraints. VolumesConstraint *ServerTypeVolumeConstraintSizes `json:"volumes_constraint"` // Ncpus: number of CPU. Ncpus uint32 `json:"ncpus"` // Gpu: number of GPU. Gpu *uint64 `json:"gpu"` // RAM: available RAM in bytes. RAM uint64 `json:"ram"` // Arch: CPU architecture. // Default value: unknown_arch Arch Arch `json:"arch"` // Baremetal: true if it is a baremetal Instance. Baremetal bool `json:"baremetal"` // Network: network available for the Instance. Network *ServerTypeNetwork `json:"network"` // Capabilities: capabilities. Capabilities *ServerTypeCapabilities `json:"capabilities"` // ScratchStorageMaxSize: maximum available scratch storage. ScratchStorageMaxSize *scw.Size `json:"scratch_storage_max_size"` } // VolumeType: volume type. type VolumeType struct { DisplayName string `json:"display_name"` Capabilities *VolumeTypeCapabilities `json:"capabilities"` Constraints *VolumeTypeConstraints `json:"constraints"` } // ServerActionRequestVolumeBackupTemplate: server action request volume backup template. type ServerActionRequestVolumeBackupTemplate struct { // VolumeType: overrides the `volume_type` of the snapshot for this volume. // If omitted, the volume type of the original volume will be used. // Default value: unknown_volume_type VolumeType SnapshotVolumeType `json:"volume_type,omitempty"` } // SetSecurityGroupRulesRequestRule: set security group rules request rule. type SetSecurityGroupRulesRequestRule struct { // ID: UUID of the security rule to update. If no value is provided, a new rule will be created. ID *string `json:"id"` // Action: action to apply when the rule matches a packet. // Default value: unknown_action Action SecurityGroupRuleAction `json:"action"` // Protocol: protocol family this rule applies to. // Default value: unknown_protocol Protocol SecurityGroupRuleProtocol `json:"protocol"` // Direction: direction the rule applies to. // Default value: unknown_direction Direction SecurityGroupRuleDirection `json:"direction"` // IPRange: range of IP addresses these rules apply to. IPRange scw.IPNet `json:"ip_range"` // DestPortFrom: beginning of the range of ports this rule applies to (inclusive). This value will be set to null if protocol is ICMP or ANY. DestPortFrom *uint32 `json:"dest_port_from"` // DestPortTo: end of the range of ports this rule applies to (inclusive). This value will be set to null if protocol is ICMP or ANY, or if it is equal to dest_port_from. DestPortTo *uint32 `json:"dest_port_to"` // Position: position of this rule in the security group rules list. If several rules are passed with the same position, the resulting order is undefined. Position uint32 `json:"position"` // Editable: indicates if this rule is editable. Rules with the value false will be ignored. Editable *bool `json:"editable"` // Zone: zone of the rule. This field is ignored. Zone *scw.Zone `json:"zone"` } // NullableStringValue: nullable string value. type NullableStringValue struct { Null bool `json:"null,omitempty"` Value string `json:"value,omitempty"` } // VolumeImageUpdateTemplate: volume image update template. type VolumeImageUpdateTemplate struct { // ID: UUID of the snapshot. ID string `json:"id,omitempty"` } // SecurityGroupTemplate: security group template. type SecurityGroupTemplate struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` } // ApplyBlockMigrationRequest: apply block migration request. type ApplyBlockMigrationRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // VolumeID: the volume to migrate, along with potentially other resources, according to the migration plan generated with a call to PlanBlockMigration. // Precisely one of VolumeID, SnapshotID must be set. VolumeID *string `json:"volume_id,omitempty"` // SnapshotID: the snapshot to migrate, along with potentially other resources, according to the migration plan generated with a call to PlanBlockMigration. // Precisely one of VolumeID, SnapshotID must be set. SnapshotID *string `json:"snapshot_id,omitempty"` // ValidationKey: a value to be retrieved from a call to PlanBlockMigration, to confirm that the volume and/or snapshots specified in said plan should be migrated. ValidationKey string `json:"validation_key,omitempty"` } // AttachServerVolumeRequest: attach server volume request. type AttachServerVolumeRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` ServerID string `json:"-"` VolumeID string `json:"volume_id,omitempty"` // VolumeType: default value: unknown_volume_type VolumeType AttachServerVolumeRequestVolumeType `json:"volume_type,omitempty"` Boot *bool `json:"boot,omitempty"` } // AttachServerVolumeResponse: attach server volume response. type AttachServerVolumeResponse struct { Server *Server `json:"server"` } // CreateIPRequest: create ip request. type CreateIPRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Deprecated: Organization: organization ID in which the IP is reserved. // Precisely one of Project, Organization must be set. Organization *string `json:"organization,omitempty"` // Project: project ID in which the IP is reserved. // Precisely one of Project, Organization must be set. Project *string `json:"project,omitempty"` // Tags: tags of the IP. Tags []string `json:"tags,omitempty"` // Server: UUID of the Instance you want to attach the IP to. Server *string `json:"server,omitempty"` // Type: IP type to reserve (either 'nat', 'routed_ipv4' or 'routed_ipv6'). // Default value: unknown_iptype Type IPType `json:"type,omitempty"` } // CreateIPResponse: create ip response. type CreateIPResponse struct { IP *IP `json:"ip"` } // CreateImageRequest: create image request. type CreateImageRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Name: name of the image. Name string `json:"name,omitempty"` // RootVolume: UUID of the snapshot. RootVolume string `json:"root_volume,omitempty"` // Arch: architecture of the image. // Default value: unknown_arch Arch Arch `json:"arch,omitempty"` // Deprecated: DefaultBootscript: default bootscript of the image. DefaultBootscript *string `json:"default_bootscript,omitempty"` // ExtraVolumes: additional volumes of the image. ExtraVolumes map[string]*VolumeTemplate `json:"extra_volumes,omitempty"` // Deprecated: Organization: organization ID of the image. // Precisely one of Project, Organization must be set. Organization *string `json:"organization,omitempty"` // Project: project ID of the image. // Precisely one of Project, Organization must be set. Project *string `json:"project,omitempty"` // Tags: tags of the image. Tags []string `json:"tags,omitempty"` // Public: true to create a public image. Public *bool `json:"public,omitempty"` } // CreateImageResponse: create image response. type CreateImageResponse struct { Image *Image `json:"image"` } // CreatePlacementGroupRequest: create placement group request. type CreatePlacementGroupRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Name: name of the placement group. Name string `json:"name,omitempty"` // Deprecated: Organization: organization ID of the placement group. // Precisely one of Project, Organization must be set. Organization *string `json:"organization,omitempty"` // Project: project ID of the placement group. // Precisely one of Project, Organization must be set. Project *string `json:"project,omitempty"` // Tags: tags of the placement group. Tags []string `json:"tags,omitempty"` // PolicyMode: operating mode of the placement group. // Default value: optional PolicyMode PlacementGroupPolicyMode `json:"policy_mode,omitempty"` // PolicyType: policy type of the placement group. // Default value: max_availability PolicyType PlacementGroupPolicyType `json:"policy_type,omitempty"` } // CreatePlacementGroupResponse: create placement group response. type CreatePlacementGroupResponse struct { PlacementGroup *PlacementGroup `json:"placement_group"` } // CreatePrivateNICRequest: create private nic request. type CreatePrivateNICRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: UUID of the Instance the private NIC will be attached to. ServerID string `json:"-"` // PrivateNetworkID: UUID of the private network where the private NIC will be attached. PrivateNetworkID string `json:"private_network_id,omitempty"` // Tags: private NIC tags. Tags []string `json:"tags,omitempty"` // IPIDs: ip_ids defined from IPAM. IPIDs []string `json:"ip_ids,omitempty"` } // CreatePrivateNICResponse: create private nic response. type CreatePrivateNICResponse struct { PrivateNic *PrivateNIC `json:"private_nic"` } // CreateSecurityGroupRequest: create security group request. type CreateSecurityGroupRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Name: name of the security group. Name string `json:"name,omitempty"` // Description: description of the security group. Description string `json:"description,omitempty"` // Deprecated: Organization: organization ID the security group belongs to. // Precisely one of Project, Organization must be set. Organization *string `json:"organization,omitempty"` // Project: project ID the security group belong to. // Precisely one of Project, Organization must be set. Project *string `json:"project,omitempty"` // Tags: tags of the security group. Tags []string `json:"tags,omitempty"` // Deprecated: OrganizationDefault: defines whether this security group becomes the default security group for new Instances. // Precisely one of OrganizationDefault, ProjectDefault must be set. OrganizationDefault *bool `json:"organization_default,omitempty"` // ProjectDefault: whether this security group becomes the default security group for new Instances. // Precisely one of OrganizationDefault, ProjectDefault must be set. ProjectDefault *bool `json:"project_default,omitempty"` // Stateful: whether the security group is stateful or not. Stateful bool `json:"stateful,omitempty"` // InboundDefaultPolicy: default policy for inbound rules. // Default value: unknown_policy InboundDefaultPolicy SecurityGroupPolicy `json:"inbound_default_policy,omitempty"` // OutboundDefaultPolicy: default policy for outbound rules. // Default value: unknown_policy OutboundDefaultPolicy SecurityGroupPolicy `json:"outbound_default_policy,omitempty"` // EnableDefaultSecurity: true to block SMTP on IPv4 and IPv6. This feature is read only, please open a support ticket if you need to make it configurable. EnableDefaultSecurity *bool `json:"enable_default_security,omitempty"` } // CreateSecurityGroupResponse: create security group response. type CreateSecurityGroupResponse struct { SecurityGroup *SecurityGroup `json:"security_group"` } // CreateSecurityGroupRuleRequest: create security group rule request. type CreateSecurityGroupRuleRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // SecurityGroupID: UUID of the security group. SecurityGroupID string `json:"-"` // Protocol: default value: unknown_protocol Protocol SecurityGroupRuleProtocol `json:"protocol,omitempty"` // Direction: default value: unknown_direction Direction SecurityGroupRuleDirection `json:"direction,omitempty"` // Action: default value: unknown_action Action SecurityGroupRuleAction `json:"action,omitempty"` IPRange scw.IPNet `json:"ip_range,omitempty"` // DestPortFrom: beginning of the range of ports to apply this rule to (inclusive). DestPortFrom *uint32 `json:"dest_port_from,omitempty"` // DestPortTo: end of the range of ports to apply this rule to (inclusive). DestPortTo *uint32 `json:"dest_port_to,omitempty"` // Position: position of this rule in the security group rules list. Position uint32 `json:"position,omitempty"` // Editable: indicates if this rule is editable (will be ignored). Editable bool `json:"editable,omitempty"` } // CreateSecurityGroupRuleResponse: create security group rule response. type CreateSecurityGroupRuleResponse struct { Rule *SecurityGroupRule `json:"rule"` } // CreateServerRequest: create server request. type CreateServerRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Name: instance name. Name string `json:"name,omitempty"` // DynamicIPRequired: define if a dynamic IPv4 is required for the Instance. DynamicIPRequired *bool `json:"dynamic_ip_required,omitempty"` // RoutedIPEnabled: if true, configure the Instance so it uses the new routed IP mode. RoutedIPEnabled *bool `json:"routed_ip_enabled,omitempty"` // CommercialType: define the Instance commercial type (i.e. GP1-S). CommercialType string `json:"commercial_type,omitempty"` // Image: instance image ID or label. Image string `json:"image,omitempty"` // Volumes: volumes attached to the server. Volumes map[string]*VolumeServerTemplate `json:"volumes,omitempty"` // EnableIPv6: true if IPv6 is enabled on the server. EnableIPv6 bool `json:"enable_ipv6,omitempty"` // PublicIP: ID of the reserved IP to attach to the Instance. PublicIP *string `json:"public_ip,omitempty"` // PublicIPs: a list of reserved IP IDs to attach to the Instance. PublicIPs *[]string `json:"public_ips,omitempty"` // BootType: boot type to use. // Default value: local BootType *BootType `json:"boot_type,omitempty"` // Deprecated: Bootscript: bootscript ID to use when `boot_type` is set to `bootscript`. Bootscript *string `json:"bootscript,omitempty"` // Deprecated: Organization: instance Organization ID. // Precisely one of Project, Organization must be set. Organization *string `json:"organization,omitempty"` // Project: instance Project ID. // Precisely one of Project, Organization must be set. Project *string `json:"project,omitempty"` // Tags: instance tags. Tags []string `json:"tags,omitempty"` // SecurityGroup: security group ID. SecurityGroup *string `json:"security_group,omitempty"` // PlacementGroup: placement group ID if Instance must be part of a placement group. PlacementGroup *string `json:"placement_group,omitempty"` } // CreateServerResponse: create server response. type CreateServerResponse struct { Server *Server `json:"server"` } // CreateSnapshotRequest: create snapshot request. type CreateSnapshotRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Name: name of the snapshot. Name string `json:"name,omitempty"` // VolumeID: UUID of the volume. VolumeID *string `json:"volume_id,omitempty"` // Tags: tags of the snapshot. Tags *[]string `json:"tags,omitempty"` // Deprecated: Organization: organization ID of the snapshot. // Precisely one of Project, Organization must be set. Organization *string `json:"organization,omitempty"` // Project: project ID of the snapshot. // Precisely one of Project, Organization must be set. Project *string `json:"project,omitempty"` // VolumeType: overrides the volume_type of the snapshot. // If omitted, the volume type of the original volume will be used. // Default value: unknown_volume_type VolumeType SnapshotVolumeType `json:"volume_type,omitempty"` // Bucket: bucket name for snapshot imports. Bucket *string `json:"bucket,omitempty"` // Key: object key for snapshot imports. Key *string `json:"key,omitempty"` // Size: imported snapshot size, must be a multiple of 512. Size *scw.Size `json:"size,omitempty"` } // CreateSnapshotResponse: create snapshot response. type CreateSnapshotResponse struct { Snapshot *Snapshot `json:"snapshot"` Task *Task `json:"task"` } // CreateVolumeRequest: create volume request. type CreateVolumeRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Name: volume name. Name string `json:"name,omitempty"` // Deprecated: Organization: volume Organization ID. // Precisely one of Project, Organization must be set. Organization *string `json:"organization,omitempty"` // Project: volume Project ID. // Precisely one of Project, Organization must be set. Project *string `json:"project,omitempty"` // Tags: volume tags. Tags []string `json:"tags,omitempty"` // VolumeType: volume type. // Default value: l_ssd VolumeType VolumeVolumeType `json:"volume_type,omitempty"` // Size: volume disk size, must be a multiple of 512. // Precisely one of Size, BaseSnapshot must be set. Size *scw.Size `json:"size,omitempty"` // BaseSnapshot: ID of the snapshot on which this volume will be based. // Precisely one of Size, BaseSnapshot must be set. BaseSnapshot *string `json:"base_snapshot,omitempty"` } // CreateVolumeResponse: create volume response. type CreateVolumeResponse struct { Volume *Volume `json:"volume"` } // DeleteIPRequest: delete ip request. type DeleteIPRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // IP: ID or address of the IP to delete. IP string `json:"-"` } // DeleteImageRequest: delete image request. type DeleteImageRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ImageID: UUID of the image you want to delete. ImageID string `json:"-"` } // DeletePlacementGroupRequest: delete placement group request. type DeletePlacementGroupRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // PlacementGroupID: UUID of the placement group you want to delete. PlacementGroupID string `json:"-"` } // DeletePrivateNICRequest: delete private nic request. type DeletePrivateNICRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: instance to which the private NIC is attached. ServerID string `json:"-"` // PrivateNicID: private NIC unique ID. PrivateNicID string `json:"-"` } // DeleteSecurityGroupRequest: delete security group request. type DeleteSecurityGroupRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // SecurityGroupID: UUID of the security group you want to delete. SecurityGroupID string `json:"-"` } // DeleteSecurityGroupRuleRequest: delete security group rule request. type DeleteSecurityGroupRuleRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` SecurityGroupID string `json:"-"` SecurityGroupRuleID string `json:"-"` } // DeleteServerRequest: delete server request. type DeleteServerRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` ServerID string `json:"-"` } // DeleteServerUserDataRequest: delete server user data request. type DeleteServerUserDataRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: UUID of the Instance. ServerID string `json:"-"` // Key: key of the user data to delete. Key string `json:"-"` } // DeleteSnapshotRequest: delete snapshot request. type DeleteSnapshotRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // SnapshotID: UUID of the snapshot you want to delete. SnapshotID string `json:"-"` } // DeleteVolumeRequest: delete volume request. type DeleteVolumeRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // VolumeID: UUID of the volume you want to delete. VolumeID string `json:"-"` } // DetachServerVolumeRequest: detach server volume request. type DetachServerVolumeRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` ServerID string `json:"-"` VolumeID string `json:"volume_id,omitempty"` } // DetachServerVolumeResponse: detach server volume response. type DetachServerVolumeResponse struct { Server *Server `json:"server"` } // ExportSnapshotRequest: export snapshot request. type ExportSnapshotRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // SnapshotID: snapshot ID. SnapshotID string `json:"-"` // Bucket: s3 bucket name. Bucket string `json:"bucket,omitempty"` // Key: s3 object key. Key string `json:"key,omitempty"` } // ExportSnapshotResponse: export snapshot response. type ExportSnapshotResponse struct { Task *Task `json:"task"` } // GetBootscriptRequest: get bootscript request. type GetBootscriptRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` BootscriptID string `json:"-"` } // GetBootscriptResponse: get bootscript response. type GetBootscriptResponse struct { Bootscript *Bootscript `json:"bootscript"` } // GetDashboardRequest: get dashboard request. type GetDashboardRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` Organization *string `json:"-"` Project *string `json:"-"` } // GetDashboardResponse: get dashboard response. type GetDashboardResponse struct { Dashboard *Dashboard `json:"dashboard"` } // GetIPRequest: get ip request. type GetIPRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // IP: IP ID or address to get. IP string `json:"-"` } // GetIPResponse: get ip response. type GetIPResponse struct { IP *IP `json:"ip"` } // GetImageRequest: get image request. type GetImageRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ImageID: UUID of the image you want to get. ImageID string `json:"-"` } // GetImageResponse: get image response. type GetImageResponse struct { Image *Image `json:"image"` } // GetPlacementGroupRequest: get placement group request. type GetPlacementGroupRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // PlacementGroupID: UUID of the placement group you want to get. PlacementGroupID string `json:"-"` } // GetPlacementGroupResponse: get placement group response. type GetPlacementGroupResponse struct { PlacementGroup *PlacementGroup `json:"placement_group"` } // GetPlacementGroupServersRequest: get placement group servers request. type GetPlacementGroupServersRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // PlacementGroupID: UUID of the placement group you want to get. PlacementGroupID string `json:"-"` } // GetPlacementGroupServersResponse: get placement group servers response. type GetPlacementGroupServersResponse struct { // Servers: instances attached to the placement group. Servers []*PlacementGroupServer `json:"servers"` } // GetPrivateNICRequest: get private nic request. type GetPrivateNICRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: instance to which the private NIC is attached. ServerID string `json:"-"` // PrivateNicID: private NIC unique ID. PrivateNicID string `json:"-"` } // GetPrivateNICResponse: get private nic response. type GetPrivateNICResponse struct { PrivateNic *PrivateNIC `json:"private_nic"` } // GetSecurityGroupRequest: get security group request. type GetSecurityGroupRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // SecurityGroupID: UUID of the security group you want to get. SecurityGroupID string `json:"-"` } // GetSecurityGroupResponse: get security group response. type GetSecurityGroupResponse struct { SecurityGroup *SecurityGroup `json:"security_group"` } // GetSecurityGroupRuleRequest: get security group rule request. type GetSecurityGroupRuleRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` SecurityGroupID string `json:"-"` SecurityGroupRuleID string `json:"-"` } // GetSecurityGroupRuleResponse: get security group rule response. type GetSecurityGroupRuleResponse struct { Rule *SecurityGroupRule `json:"rule"` } // GetServerRequest: get server request. type GetServerRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: UUID of the Instance you want to get. ServerID string `json:"-"` } // GetServerResponse: get server response. type GetServerResponse struct { Server *Server `json:"server"` } // GetServerTypesAvailabilityRequest: get server types availability request. type GetServerTypesAvailabilityRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // PerPage: a positive integer lower or equal to 100 to select the number of items to return. PerPage *uint32 `json:"-"` // Page: a positive integer to choose the page to return. Page *int32 `json:"-"` } // GetServerTypesAvailabilityResponse: get server types availability response. type GetServerTypesAvailabilityResponse struct { // Servers: map of server types. Servers map[string]*GetServerTypesAvailabilityResponseAvailability `json:"servers"` TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *GetServerTypesAvailabilityResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *GetServerTypesAvailabilityResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*GetServerTypesAvailabilityResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } if r.Servers == nil { r.Servers = make(map[string]*GetServerTypesAvailabilityResponseAvailability) } for k, v := range results.Servers { r.Servers[k] = v } r.TotalCount += uint32(len(results.Servers)) return uint32(len(results.Servers)), nil } // GetSnapshotRequest: get snapshot request. type GetSnapshotRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // SnapshotID: UUID of the snapshot you want to get. SnapshotID string `json:"-"` } // GetSnapshotResponse: get snapshot response. type GetSnapshotResponse struct { Snapshot *Snapshot `json:"snapshot"` } // GetVolumeRequest: get volume request. type GetVolumeRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // VolumeID: UUID of the volume you want to get. VolumeID string `json:"-"` } // GetVolumeResponse: get volume response. type GetVolumeResponse struct { Volume *Volume `json:"volume"` } // ListBootscriptsRequest: list bootscripts request. type ListBootscriptsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` Arch *string `json:"-"` Title *string `json:"-"` Default *bool `json:"-"` Public *bool `json:"-"` PerPage *uint32 `json:"-"` Page *int32 `json:"-"` } // ListBootscriptsResponse: list bootscripts response. type ListBootscriptsResponse struct { // TotalCount: total number of bootscripts. TotalCount uint32 `json:"total_count"` // Bootscripts: list of bootscripts. Bootscripts []*Bootscript `json:"bootscripts"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListBootscriptsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListBootscriptsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListBootscriptsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Bootscripts = append(r.Bootscripts, results.Bootscripts...) r.TotalCount += uint32(len(results.Bootscripts)) return uint32(len(results.Bootscripts)), nil } // ListDefaultSecurityGroupRulesRequest: list default security group rules request. type ListDefaultSecurityGroupRulesRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` } // ListIPsRequest: list i ps request. type ListIPsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Project: project ID in which the IPs are reserved. Project *string `json:"-"` // Organization: organization ID in which the IPs are reserved. Organization *string `json:"-"` // Tags: filter IPs with these exact tags (to filter with several tags, use commas to separate them). Tags []string `json:"-"` // Name: filter on the IP address (Works as a LIKE operation on the IP address). Name *string `json:"-"` // PerPage: a positive integer lower or equal to 100 to select the number of items to return. PerPage *uint32 `json:"-"` // Page: a positive integer to choose the page to return. Page *int32 `json:"-"` // Type: filter on the IP Mobility IP type (whose value should be either 'nat', 'routed_ipv4' or 'routed_ipv6'). Type *string `json:"-"` } // ListIPsResponse: list i ps response. type ListIPsResponse struct { // TotalCount: total number of ips. TotalCount uint32 `json:"total_count"` // IPs: list of ips. IPs []*IP `json:"ips"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListIPsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListIPsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListIPsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.IPs = append(r.IPs, results.IPs...) r.TotalCount += uint32(len(results.IPs)) return uint32(len(results.IPs)), nil } // ListImagesRequest: list images request. type ListImagesRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` Organization *string `json:"-"` PerPage *uint32 `json:"-"` Page *int32 `json:"-"` Name *string `json:"-"` Public *bool `json:"-"` Arch *string `json:"-"` Project *string `json:"-"` Tags *string `json:"-"` } // ListImagesResponse: list images response. type ListImagesResponse struct { // TotalCount: total number of images. TotalCount uint32 `json:"total_count"` // Images: list of images. Images []*Image `json:"images"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListImagesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListImagesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListImagesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Images = append(r.Images, results.Images...) r.TotalCount += uint32(len(results.Images)) return uint32(len(results.Images)), nil } // ListPlacementGroupsRequest: list placement groups request. type ListPlacementGroupsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // PerPage: a positive integer lower or equal to 100 to select the number of items to return. PerPage *uint32 `json:"-"` // Page: a positive integer to choose the page to return. Page *int32 `json:"-"` // Organization: list only placement groups of this Organization ID. Organization *string `json:"-"` // Project: list only placement groups of this Project ID. Project *string `json:"-"` // Tags: list placement groups with these exact tags (to filter with several tags, use commas to separate them). Tags []string `json:"-"` // Name: filter placement groups by name (for eg. "cluster1" will return "cluster100" and "cluster1" but not "foo"). Name *string `json:"-"` } // ListPlacementGroupsResponse: list placement groups response. type ListPlacementGroupsResponse struct { // TotalCount: total number of placement groups. TotalCount uint32 `json:"total_count"` // PlacementGroups: list of placement groups. PlacementGroups []*PlacementGroup `json:"placement_groups"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListPlacementGroupsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListPlacementGroupsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListPlacementGroupsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.PlacementGroups = append(r.PlacementGroups, results.PlacementGroups...) r.TotalCount += uint32(len(results.PlacementGroups)) return uint32(len(results.PlacementGroups)), nil } // ListPrivateNICsRequest: list private ni cs request. type ListPrivateNICsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: instance to which the private NIC is attached. ServerID string `json:"-"` // Tags: private NIC tags. Tags []string `json:"-"` // PerPage: a positive integer lower or equal to 100 to select the number of items to return. PerPage *uint32 `json:"-"` // Page: a positive integer to choose the page to return. Page *int32 `json:"-"` } // ListPrivateNICsResponse: list private ni cs response. type ListPrivateNICsResponse struct { PrivateNics []*PrivateNIC `json:"private_nics"` TotalCount uint64 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListPrivateNICsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListPrivateNICsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListPrivateNICsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.PrivateNics = append(r.PrivateNics, results.PrivateNics...) r.TotalCount += uint64(len(results.PrivateNics)) return uint64(len(results.PrivateNics)), nil } // ListSecurityGroupRulesRequest: list security group rules request. type ListSecurityGroupRulesRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // SecurityGroupID: UUID of the security group. SecurityGroupID string `json:"-"` // PerPage: a positive integer lower or equal to 100 to select the number of items to return. PerPage *uint32 `json:"-"` // Page: a positive integer to choose the page to return. Page *int32 `json:"-"` } // ListSecurityGroupRulesResponse: list security group rules response. type ListSecurityGroupRulesResponse struct { // TotalCount: total number of security groups. TotalCount uint32 `json:"total_count"` // Rules: list of security rules. Rules []*SecurityGroupRule `json:"rules"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListSecurityGroupRulesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListSecurityGroupRulesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListSecurityGroupRulesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Rules = append(r.Rules, results.Rules...) r.TotalCount += uint32(len(results.Rules)) return uint32(len(results.Rules)), nil } // ListSecurityGroupsRequest: list security groups request. type ListSecurityGroupsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Name: name of the security group. Name *string `json:"-"` // Organization: security group Organization ID. Organization *string `json:"-"` // Project: security group Project ID. Project *string `json:"-"` // Tags: list security groups with these exact tags (to filter with several tags, use commas to separate them). Tags []string `json:"-"` // ProjectDefault: filter security groups with this value for project_default. ProjectDefault *bool `json:"-"` // PerPage: a positive integer lower or equal to 100 to select the number of items to return. PerPage *uint32 `json:"-"` // Page: a positive integer to choose the page to return. Page *int32 `json:"-"` } // ListSecurityGroupsResponse: list security groups response. type ListSecurityGroupsResponse struct { // TotalCount: total number of security groups. TotalCount uint32 `json:"total_count"` // SecurityGroups: list of security groups. SecurityGroups []*SecurityGroup `json:"security_groups"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListSecurityGroupsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListSecurityGroupsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListSecurityGroupsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.SecurityGroups = append(r.SecurityGroups, results.SecurityGroups...) r.TotalCount += uint32(len(results.SecurityGroups)) return uint32(len(results.SecurityGroups)), nil } // ListServerActionsRequest: list server actions request. type ListServerActionsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` ServerID string `json:"-"` } // ListServerActionsResponse: list server actions response. type ListServerActionsResponse struct { Actions []ServerAction `json:"actions"` } // ListServerUserDataRequest: list server user data request. type ListServerUserDataRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: UUID of the Instance. ServerID string `json:"-"` } // ListServerUserDataResponse: list server user data response. type ListServerUserDataResponse struct { UserData []string `json:"user_data"` } // ListServersRequest: list servers request. type ListServersRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // PerPage: a positive integer lower or equal to 100 to select the number of items to return. PerPage *uint32 `json:"-"` // Page: a positive integer to choose the page to return. Page *int32 `json:"-"` // Organization: list only Instances of this Organization ID. Organization *string `json:"-"` // Project: list only Instances of this Project ID. Project *string `json:"-"` // Name: filter Instances by name (eg. "server1" will return "server100" and "server1" but not "foo"). Name *string `json:"-"` // PrivateIP: list Instances by private_ip. PrivateIP *net.IP `json:"-"` // WithoutIP: list Instances that are not attached to a public IP. WithoutIP *bool `json:"-"` // CommercialType: list Instances of this commercial type. CommercialType *string `json:"-"` // State: list Instances in this state. // Default value: running State *ServerState `json:"-"` // Tags: list Instances with these exact tags (to filter with several tags, use commas to separate them). Tags []string `json:"-"` // PrivateNetwork: list Instances in this Private Network. PrivateNetwork *string `json:"-"` // Order: define the order of the returned servers. // Default value: creation_date_desc Order ListServersRequestOrder `json:"-"` // PrivateNetworks: list Instances from the given Private Networks (use commas to separate them). PrivateNetworks []string `json:"-"` // PrivateNicMacAddress: list Instances associated with the given private NIC MAC address. PrivateNicMacAddress *string `json:"-"` // Servers: list Instances from these server ids (use commas to separate them). Servers []string `json:"-"` } // ListServersResponse: list servers response. type ListServersResponse struct { // TotalCount: total number of Instances. TotalCount uint32 `json:"total_count"` // Servers: list of Instances. Servers []*Server `json:"servers"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListServersResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListServersResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListServersResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Servers = append(r.Servers, results.Servers...) r.TotalCount += uint32(len(results.Servers)) return uint32(len(results.Servers)), nil } // ListServersTypesRequest: list servers types request. type ListServersTypesRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` PerPage *uint32 `json:"-"` Page *int32 `json:"-"` } // ListServersTypesResponse: list servers types response. type ListServersTypesResponse struct { // TotalCount: total number of Instance types. TotalCount uint32 `json:"total_count"` // Servers: list of Instance types. Servers map[string]*ServerType `json:"servers"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListServersTypesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListServersTypesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListServersTypesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } if r.Servers == nil { r.Servers = make(map[string]*ServerType) } for k, v := range results.Servers { r.Servers[k] = v } r.TotalCount += uint32(len(results.Servers)) return uint32(len(results.Servers)), nil } // ListSnapshotsRequest: list snapshots request. type ListSnapshotsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Organization: list snapshots only for this Organization ID. Organization *string `json:"-"` // Project: list snapshots only for this Project ID. Project *string `json:"-"` // PerPage: number of snapshots returned per page (positive integer lower or equal to 100). PerPage *uint32 `json:"-"` // Page: page to be returned. Page *int32 `json:"-"` // Name: list snapshots of the requested name. Name *string `json:"-"` // Tags: list snapshots that have the requested tag. Tags *string `json:"-"` // BaseVolumeID: list snapshots originating only from this volume. BaseVolumeID *string `json:"-"` } // ListSnapshotsResponse: list snapshots response. type ListSnapshotsResponse struct { // TotalCount: total number of snapshots. TotalCount uint32 `json:"total_count"` // Snapshots: list of snapshots. Snapshots []*Snapshot `json:"snapshots"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListSnapshotsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListSnapshotsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListSnapshotsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Snapshots = append(r.Snapshots, results.Snapshots...) r.TotalCount += uint32(len(results.Snapshots)) return uint32(len(results.Snapshots)), nil } // ListVolumesRequest: list volumes request. type ListVolumesRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // VolumeType: filter by volume type. // Default value: l_ssd VolumeType *VolumeVolumeType `json:"-"` // PerPage: a positive integer lower or equal to 100 to select the number of items to return. PerPage *uint32 `json:"-"` // Page: a positive integer to choose the page to return. Page *int32 `json:"-"` // Organization: filter volume by Organization ID. Organization *string `json:"-"` // Project: filter volume by Project ID. Project *string `json:"-"` // Tags: filter volumes with these exact tags (to filter with several tags, use commas to separate them). Tags []string `json:"-"` // Name: filter volume by name (for eg. "vol" will return "myvolume" but not "data"). Name *string `json:"-"` } // ListVolumesResponse: list volumes response. type ListVolumesResponse struct { // TotalCount: total number of volumes. TotalCount uint32 `json:"total_count"` // Volumes: list of volumes. Volumes []*Volume `json:"volumes"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListVolumesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListVolumesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListVolumesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Volumes = append(r.Volumes, results.Volumes...) r.TotalCount += uint32(len(results.Volumes)) return uint32(len(results.Volumes)), nil } // ListVolumesTypesRequest: list volumes types request. type ListVolumesTypesRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` PerPage *uint32 `json:"-"` Page *int32 `json:"-"` } // ListVolumesTypesResponse: list volumes types response. type ListVolumesTypesResponse struct { // TotalCount: total number of volume types. TotalCount uint32 `json:"total_count"` // Volumes: map of volume types. Volumes map[string]*VolumeType `json:"volumes"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListVolumesTypesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListVolumesTypesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListVolumesTypesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } if r.Volumes == nil { r.Volumes = make(map[string]*VolumeType) } for k, v := range results.Volumes { r.Volumes[k] = v } r.TotalCount += uint32(len(results.Volumes)) return uint32(len(results.Volumes)), nil } // MigrationPlan: migration plan. type MigrationPlan struct { // Volume: a volume which will be migrated to SBS together with the snapshots, if present. Volume *Volume `json:"volume"` // Snapshots: a list of snapshots which will be migrated to SBS together and with the volume, if present. Snapshots []*Snapshot `json:"snapshots"` // ValidationKey: a value to be passed to ApplyBlockMigrationRequest, to confirm that the execution of the plan is being requested. ValidationKey string `json:"validation_key"` } // PlanBlockMigrationRequest: plan block migration request. type PlanBlockMigrationRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // VolumeID: the volume for which the migration plan will be generated. // Precisely one of VolumeID, SnapshotID must be set. VolumeID *string `json:"volume_id,omitempty"` // SnapshotID: the snapshot for which the migration plan will be generated. // Precisely one of VolumeID, SnapshotID must be set. SnapshotID *string `json:"snapshot_id,omitempty"` } // ServerActionRequest: server action request. type ServerActionRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: UUID of the Instance. ServerID string `json:"-"` // Action: action to perform on the Instance. // Default value: poweron Action ServerAction `json:"action,omitempty"` // Name: name of the backup you want to create. // This field should only be specified when performing a backup action. Name *string `json:"name,omitempty"` // Volumes: for each volume UUID, the snapshot parameters of the volume. // This field should only be specified when performing a backup action. Volumes map[string]*ServerActionRequestVolumeBackupTemplate `json:"volumes,omitempty"` } // ServerActionResponse: server action response. type ServerActionResponse struct { Task *Task `json:"task"` } // SetImageRequest: set image request. type SetImageRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` ID string `json:"-"` Name string `json:"name"` // Arch: default value: unknown_arch Arch Arch `json:"arch"` CreationDate *time.Time `json:"creation_date,omitempty"` ModificationDate *time.Time `json:"modification_date,omitempty"` // Deprecated DefaultBootscript *Bootscript `json:"default_bootscript,omitempty"` ExtraVolumes map[string]*Volume `json:"extra_volumes"` FromServer string `json:"from_server"` Organization string `json:"organization"` Public bool `json:"public"` RootVolume *VolumeSummary `json:"root_volume,omitempty"` // State: default value: available State ImageState `json:"state"` Project string `json:"project"` Tags *[]string `json:"tags,omitempty"` } // SetPlacementGroupRequest: set placement group request. type SetPlacementGroupRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` PlacementGroupID string `json:"-"` Name string `json:"name"` Organization string `json:"organization"` // PolicyMode: default value: optional PolicyMode PlacementGroupPolicyMode `json:"policy_mode"` // PolicyType: default value: max_availability PolicyType PlacementGroupPolicyType `json:"policy_type"` Project string `json:"project"` Tags *[]string `json:"tags,omitempty"` } // SetPlacementGroupResponse: set placement group response. type SetPlacementGroupResponse struct { PlacementGroup *PlacementGroup `json:"placement_group"` } // SetPlacementGroupServersRequest: set placement group servers request. type SetPlacementGroupServersRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // PlacementGroupID: UUID of the placement group you want to set. PlacementGroupID string `json:"-"` // Servers: an array of the Instances' UUIDs you want to configure. Servers []string `json:"servers"` } // SetPlacementGroupServersResponse: set placement group servers response. type SetPlacementGroupServersResponse struct { // Servers: instances attached to the placement group. Servers []*PlacementGroupServer `json:"servers"` } // SetSecurityGroupRulesRequest: set security group rules request. type SetSecurityGroupRulesRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // SecurityGroupID: UUID of the security group to update the rules on. SecurityGroupID string `json:"-"` // Rules: list of rules to update in the security group. Rules []*SetSecurityGroupRulesRequestRule `json:"rules"` } // SetSecurityGroupRulesResponse: set security group rules response. type SetSecurityGroupRulesResponse struct { Rules []*SecurityGroupRule `json:"rules"` } // UpdateIPRequest: update ip request. type UpdateIPRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // IP: IP ID or IP address. IP string `json:"-"` // Reverse: reverse domain name. Reverse *NullableStringValue `json:"reverse,omitempty"` // Type: convert a 'nat' IP to a 'routed_ipv4'. // Default value: unknown_iptype Type IPType `json:"type,omitempty"` // Tags: an array of keywords you want to tag this IP with. Tags *[]string `json:"tags,omitempty"` Server *NullableStringValue `json:"server,omitempty"` } // UpdateIPResponse: update ip response. type UpdateIPResponse struct { IP *IP `json:"ip"` } // UpdateImageRequest: update image request. type UpdateImageRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ImageID: UUID of the image. ImageID string `json:"-"` // Name: name of the image. Name *string `json:"name,omitempty"` // Arch: architecture of the image. // Default value: unknown_arch Arch Arch `json:"arch,omitempty"` // ExtraVolumes: additional snapshots of the image, with extra_volumeKey being the position of the snapshot in the image. ExtraVolumes map[string]*VolumeImageUpdateTemplate `json:"extra_volumes,omitempty"` // Tags: tags of the image. Tags *[]string `json:"tags,omitempty"` // Public: true to set the image as public. Public *bool `json:"public,omitempty"` } // UpdateImageResponse: update image response. type UpdateImageResponse struct { Image *Image `json:"image"` } // UpdatePlacementGroupRequest: update placement group request. type UpdatePlacementGroupRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // PlacementGroupID: UUID of the placement group. PlacementGroupID string `json:"-"` // Name: name of the placement group. Name *string `json:"name,omitempty"` // Tags: tags of the placement group. Tags *[]string `json:"tags,omitempty"` // PolicyMode: operating mode of the placement group. // Default value: optional PolicyMode *PlacementGroupPolicyMode `json:"policy_mode,omitempty"` // PolicyType: policy type of the placement group. // Default value: max_availability PolicyType *PlacementGroupPolicyType `json:"policy_type,omitempty"` } // UpdatePlacementGroupResponse: update placement group response. type UpdatePlacementGroupResponse struct { PlacementGroup *PlacementGroup `json:"placement_group"` } // UpdatePlacementGroupServersRequest: update placement group servers request. type UpdatePlacementGroupServersRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // PlacementGroupID: UUID of the placement group you want to update. PlacementGroupID string `json:"-"` // Servers: an array of the Instances' UUIDs you want to configure. Servers []string `json:"servers,omitempty"` } // UpdatePlacementGroupServersResponse: update placement group servers response. type UpdatePlacementGroupServersResponse struct { // Servers: instances attached to the placement group. Servers []*PlacementGroupServer `json:"servers"` } // UpdatePrivateNICRequest: update private nic request. type UpdatePrivateNICRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: UUID of the Instance the private NIC will be attached to. ServerID string `json:"-"` // PrivateNicID: private NIC unique ID. PrivateNicID string `json:"-"` // Tags: tags used to select private NIC/s. Tags *[]string `json:"tags,omitempty"` } // UpdateSecurityGroupRequest: update security group request. type UpdateSecurityGroupRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // SecurityGroupID: UUID of the security group. SecurityGroupID string `json:"-"` // Name: name of the security group. Name *string `json:"name,omitempty"` // Description: description of the security group. Description *string `json:"description,omitempty"` // EnableDefaultSecurity: true to block SMTP on IPv4 and IPv6. This feature is read only, please open a support ticket if you need to make it configurable. EnableDefaultSecurity *bool `json:"enable_default_security,omitempty"` // InboundDefaultPolicy: default inbound policy. // Default value: unknown_policy InboundDefaultPolicy SecurityGroupPolicy `json:"inbound_default_policy,omitempty"` // Tags: tags of the security group. Tags *[]string `json:"tags,omitempty"` // Deprecated: OrganizationDefault: please use project_default instead. OrganizationDefault *bool `json:"organization_default,omitempty"` // ProjectDefault: true use this security group for future Instances created in this project. ProjectDefault *bool `json:"project_default,omitempty"` // OutboundDefaultPolicy: default outbound policy. // Default value: unknown_policy OutboundDefaultPolicy SecurityGroupPolicy `json:"outbound_default_policy,omitempty"` // Stateful: true to set the security group as stateful. Stateful *bool `json:"stateful,omitempty"` } // UpdateSecurityGroupResponse: update security group response. type UpdateSecurityGroupResponse struct { SecurityGroup *SecurityGroup `json:"security_group"` } // UpdateSecurityGroupRuleRequest: update security group rule request. type UpdateSecurityGroupRuleRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // SecurityGroupID: UUID of the security group. SecurityGroupID string `json:"-"` // SecurityGroupRuleID: UUID of the rule. SecurityGroupRuleID string `json:"-"` // Protocol: protocol family this rule applies to. // Default value: unknown_protocol Protocol SecurityGroupRuleProtocol `json:"protocol,omitempty"` // Direction: direction the rule applies to. // Default value: unknown_direction Direction SecurityGroupRuleDirection `json:"direction,omitempty"` // Action: action to apply when the rule matches a packet. // Default value: unknown_action Action SecurityGroupRuleAction `json:"action,omitempty"` // IPRange: range of IP addresses these rules apply to. IPRange *scw.IPNet `json:"ip_range,omitempty"` // DestPortFrom: beginning of the range of ports this rule applies to (inclusive). If 0 is provided, unset the parameter. DestPortFrom *uint32 `json:"dest_port_from,omitempty"` // DestPortTo: end of the range of ports this rule applies to (inclusive). If 0 is provided, unset the parameter. DestPortTo *uint32 `json:"dest_port_to,omitempty"` // Position: position of this rule in the security group rules list. Position *uint32 `json:"position,omitempty"` } // UpdateSecurityGroupRuleResponse: update security group rule response. type UpdateSecurityGroupRuleResponse struct { Rule *SecurityGroupRule `json:"rule"` } // UpdateServerRequest: update server request. type UpdateServerRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ServerID: UUID of the Instance. ServerID string `json:"-"` // Name: name of the Instance. Name *string `json:"name,omitempty"` // BootType: default value: local BootType *BootType `json:"boot_type,omitempty"` // Tags: tags of the Instance. Tags *[]string `json:"tags,omitempty"` Volumes *map[string]*VolumeServerTemplate `json:"volumes,omitempty"` // Deprecated Bootscript *string `json:"bootscript,omitempty"` DynamicIPRequired *bool `json:"dynamic_ip_required,omitempty"` // RoutedIPEnabled: true to configure the instance so it uses the new routed IP mode (once this is set to True you cannot set it back to False). RoutedIPEnabled *bool `json:"routed_ip_enabled,omitempty"` // PublicIPs: a list of reserved IP IDs to attach to the Instance. PublicIPs *[]string `json:"public_ips,omitempty"` EnableIPv6 *bool `json:"enable_ipv6,omitempty"` Protected *bool `json:"protected,omitempty"` SecurityGroup *SecurityGroupTemplate `json:"security_group,omitempty"` // PlacementGroup: placement group ID if Instance must be part of a placement group. PlacementGroup *NullableStringValue `json:"placement_group,omitempty"` // PrivateNics: instance private NICs. PrivateNics *[]string `json:"private_nics,omitempty"` // CommercialType: warning: This field has some restrictions: // - Cannot be changed if the Instance is not in `stopped` state. // - Cannot be changed if the Instance is in a placement group. // - Local storage requirements of the target commercial_types must be fulfilled (i.e. if an Instance has 80GB of local storage, it can be changed into a GP1-XS, which has a maximum of 150GB, but it cannot be changed into a DEV1-S, which has only 20GB). CommercialType *string `json:"commercial_type,omitempty"` } // UpdateServerResponse: update server response. type UpdateServerResponse struct { Server *Server `json:"server"` } // UpdateSnapshotRequest: update snapshot request. type UpdateSnapshotRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // SnapshotID: UUID of the snapshot. SnapshotID string `json:"-"` // Name: name of the snapshot. Name *string `json:"name,omitempty"` // Tags: tags of the snapshot. Tags *[]string `json:"tags,omitempty"` } // UpdateSnapshotResponse: update snapshot response. type UpdateSnapshotResponse struct { Snapshot *Snapshot `json:"snapshot"` } // UpdateVolumeRequest: update volume request. type UpdateVolumeRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // VolumeID: UUID of the volume. VolumeID string `json:"-"` // Name: volume name. Name *string `json:"name,omitempty"` // Tags: tags of the volume. Tags *[]string `json:"tags,omitempty"` // Size: volume disk size, must be a multiple of 512. Size *scw.Size `json:"size,omitempty"` } // UpdateVolumeResponse: update volume response. type UpdateVolumeResponse struct { Volume *Volume `json:"volume"` } // setImageResponse: set image response. type setImageResponse struct { Image *Image `json:"image"` } // setSecurityGroupRequest: set security group request. type setSecurityGroupRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ID: UUID of the security group. ID string `json:"-"` // Name: name of the security group. Name string `json:"name"` // Tags: tags of the security group. Tags *[]string `json:"tags,omitempty"` // CreationDate: creation date of the security group (will be ignored). CreationDate *time.Time `json:"creation_date,omitempty"` // ModificationDate: modification date of the security group (will be ignored). ModificationDate *time.Time `json:"modification_date,omitempty"` // Description: description of the security group. Description string `json:"description"` // EnableDefaultSecurity: true to block SMTP on IPv4 and IPv6. This feature is read only, please open a support ticket if you need to make it configurable. EnableDefaultSecurity bool `json:"enable_default_security"` // InboundDefaultPolicy: default inbound policy. // Default value: unknown_policy InboundDefaultPolicy SecurityGroupPolicy `json:"inbound_default_policy"` // OutboundDefaultPolicy: default outbound policy. // Default value: unknown_policy OutboundDefaultPolicy SecurityGroupPolicy `json:"outbound_default_policy"` // Organization: security groups Organization ID. Organization string `json:"organization"` // Project: security group Project ID. Project string `json:"project"` // Deprecated: OrganizationDefault: please use project_default instead. OrganizationDefault *bool `json:"organization_default,omitempty"` // ProjectDefault: true use this security group for future Instances created in this project. ProjectDefault bool `json:"project_default"` // Servers: instances attached to this security group. Servers []*ServerSummary `json:"servers"` // Stateful: true to set the security group as stateful. Stateful bool `json:"stateful"` } // setSecurityGroupResponse: set security group response. type setSecurityGroupResponse struct { SecurityGroup *SecurityGroup `json:"security_group"` } // setSecurityGroupRuleRequest: set security group rule request. type setSecurityGroupRuleRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` SecurityGroupID string `json:"-"` SecurityGroupRuleID string `json:"-"` ID string `json:"id"` // Protocol: default value: unknown_protocol Protocol SecurityGroupRuleProtocol `json:"protocol"` // Direction: default value: unknown_direction Direction SecurityGroupRuleDirection `json:"direction"` // Action: default value: unknown_action Action SecurityGroupRuleAction `json:"action"` IPRange scw.IPNet `json:"ip_range"` DestPortFrom *uint32 `json:"dest_port_from,omitempty"` DestPortTo *uint32 `json:"dest_port_to,omitempty"` Position uint32 `json:"position"` Editable bool `json:"editable"` } // setSecurityGroupRuleResponse: set security group rule response. type setSecurityGroupRuleResponse struct { Rule *SecurityGroupRule `json:"rule"` } // setServerRequest: set server request. type setServerRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ID: instance unique ID. ID string `json:"-"` // Name: instance name. Name string `json:"name"` // Organization: instance Organization ID. Organization string `json:"organization"` // Project: instance Project ID. Project string `json:"project"` // AllowedActions: provide a list of allowed actions on the server. AllowedActions []ServerAction `json:"allowed_actions"` // Tags: tags associated with the Instance. Tags *[]string `json:"tags,omitempty"` // CommercialType: instance commercial type (eg. GP1-M). CommercialType string `json:"commercial_type"` // CreationDate: instance creation date. CreationDate *time.Time `json:"creation_date,omitempty"` // DynamicIPRequired: true if a dynamic IPv4 is required. DynamicIPRequired bool `json:"dynamic_ip_required"` // RoutedIPEnabled: true to configure the instance so it uses the new routed IP mode (once this is set to True you cannot set it back to False). RoutedIPEnabled *bool `json:"routed_ip_enabled,omitempty"` // EnableIPv6: true if IPv6 is enabled. EnableIPv6 bool `json:"enable_ipv6"` // Hostname: instance host name. Hostname string `json:"hostname"` // Image: provide information on the Instance image. Image *Image `json:"image,omitempty"` // Protected: instance protection option is activated. Protected bool `json:"protected"` // PrivateIP: instance private IP address. PrivateIP *string `json:"private_ip,omitempty"` // PublicIP: information about the public IP. PublicIP *ServerIP `json:"public_ip,omitempty"` // PublicIPs: information about all the public IPs attached to the server. PublicIPs []*ServerIP `json:"public_ips"` // ModificationDate: instance modification date. ModificationDate *time.Time `json:"modification_date,omitempty"` // State: instance state. // Default value: running State ServerState `json:"state"` // Location: instance location. Location *ServerLocation `json:"location,omitempty"` // IPv6: instance IPv6 address. IPv6 *ServerIPv6 `json:"ipv6,omitempty"` // Deprecated: Bootscript: instance bootscript. Bootscript *Bootscript `json:"bootscript,omitempty"` // BootType: instance boot type. // Default value: local BootType BootType `json:"boot_type"` // Volumes: instance volumes. Volumes map[string]*Volume `json:"volumes"` // SecurityGroup: instance security group. SecurityGroup *SecurityGroupSummary `json:"security_group,omitempty"` // Maintenances: instance planned maintenances. Maintenances []*ServerMaintenance `json:"maintenances"` // StateDetail: instance state_detail. StateDetail string `json:"state_detail"` // Arch: instance architecture (refers to the CPU architecture used for the Instance, e.g. x86_64, arm64). // Default value: unknown_arch Arch Arch `json:"arch"` // PlacementGroup: instance placement group. PlacementGroup *PlacementGroup `json:"placement_group,omitempty"` // PrivateNics: instance private NICs. PrivateNics []*PrivateNIC `json:"private_nics"` } // setServerResponse: set server response. type setServerResponse struct { Server *Server `json:"server"` } // setSnapshotRequest: set snapshot request. type setSnapshotRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` SnapshotID string `json:"-"` ID string `json:"id"` Name string `json:"name"` Organization string `json:"organization"` // VolumeType: default value: l_ssd VolumeType VolumeVolumeType `json:"volume_type"` Size scw.Size `json:"size"` // State: default value: available State SnapshotState `json:"state"` BaseVolume *SnapshotBaseVolume `json:"base_volume,omitempty"` CreationDate *time.Time `json:"creation_date,omitempty"` ModificationDate *time.Time `json:"modification_date,omitempty"` Project string `json:"project"` Tags *[]string `json:"tags,omitempty"` } // setSnapshotResponse: set snapshot response. type setSnapshotResponse struct { Snapshot *Snapshot `json:"snapshot"` } // Instance API. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Zones() []scw.Zone { return []scw.Zone{scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.ZonePlWaw3} } // GetServerTypesAvailability: Get availability for all Instance types. func (s *API) GetServerTypesAvailability(req *GetServerTypesAvailabilityRequest, opts ...scw.RequestOption) (*GetServerTypesAvailabilityResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } query := url.Values{} parameter.AddToQuery(query, "per_page", req.PerPage) parameter.AddToQuery(query, "page", req.Page) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/products/servers/availability", Query: query, } var resp GetServerTypesAvailabilityResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListServersTypes: List available Instance types and their technical details. func (s *API) ListServersTypes(req *ListServersTypesRequest, opts ...scw.RequestOption) (*ListServersTypesResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } query := url.Values{} parameter.AddToQuery(query, "per_page", req.PerPage) parameter.AddToQuery(query, "page", req.Page) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/products/servers", Query: query, } var resp ListServersTypesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListVolumesTypes: List all volume types and their technical details. func (s *API) ListVolumesTypes(req *ListVolumesTypesRequest, opts ...scw.RequestOption) (*ListVolumesTypesResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } query := url.Values{} parameter.AddToQuery(query, "per_page", req.PerPage) parameter.AddToQuery(query, "page", req.Page) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/products/volumes", Query: query, } var resp ListVolumesTypesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListServers: List all Instances in a specified Availability Zone, e.g. `fr-par-1`. func (s *API) ListServers(req *ListServersRequest, opts ...scw.RequestOption) (*ListServersResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } query := url.Values{} parameter.AddToQuery(query, "per_page", req.PerPage) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "organization", req.Organization) parameter.AddToQuery(query, "project", req.Project) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "private_ip", req.PrivateIP) parameter.AddToQuery(query, "without_ip", req.WithoutIP) parameter.AddToQuery(query, "commercial_type", req.CommercialType) parameter.AddToQuery(query, "state", req.State) if len(req.Tags) != 0 { parameter.AddToQuery(query, "tags", strings.Join(req.Tags, ",")) } parameter.AddToQuery(query, "private_network", req.PrivateNetwork) parameter.AddToQuery(query, "order", req.Order) if len(req.PrivateNetworks) != 0 { parameter.AddToQuery(query, "private_networks", strings.Join(req.PrivateNetworks, ",")) } parameter.AddToQuery(query, "private_nic_mac_address", req.PrivateNicMacAddress) if len(req.Servers) != 0 { parameter.AddToQuery(query, "servers", strings.Join(req.Servers, ",")) } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/servers", Query: query, } var resp ListServersResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // createServer: Create a new Instance of the specified commercial type in the specified zone. Pay attention to the volumes parameter, which takes an object which can be used in different ways to achieve different behaviors. // Get more information in the [Technical Information](#technical-information) section of the introduction. func (s *API) createServer(req *CreateServerRequest, opts ...scw.RequestOption) (*CreateServerResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultProject, exist := s.client.GetDefaultProjectID() if exist && req.Project == nil && req.Organization == nil { req.Project = &defaultProject } defaultOrganization, exist := s.client.GetDefaultOrganizationID() if exist && req.Project == nil && req.Organization == nil { req.Organization = &defaultOrganization } if req.Name == "" { req.Name = namegenerator.GetRandomName("srv") } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/servers", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp CreateServerResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteServer: Delete the Instance with the specified ID. func (s *API) DeleteServer(req *DeleteServerRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // GetServer: Get the details of a specified Instance. func (s *API) GetServer(req *GetServerRequest, opts ...scw.RequestOption) (*GetServerResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "", } var resp GetServerResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // setServer: func (s *API) setServer(req *setServerRequest, opts ...scw.RequestOption) (*setServerResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if req.Organization == "" { defaultOrganization, _ := s.client.GetDefaultOrganizationID() req.Organization = defaultOrganization } if req.Project == "" { defaultProject, _ := s.client.GetDefaultProjectID() req.Project = defaultProject } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ID) == "" { return nil, errors.New("field ID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp setServerResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // updateServer: Update the Instance information, such as name, boot mode, or tags. func (s *API) updateServer(req *UpdateServerRequest, opts ...scw.RequestOption) (*UpdateServerResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp UpdateServerResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListServerActions: List all actions (e.g. power on, power off, reboot) that can currently be performed on an Instance. func (s *API) ListServerActions(req *ListServerActionsRequest, opts ...scw.RequestOption) (*ListServerActionsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/action", } var resp ListServerActionsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ServerAction: Perform an action on an Instance. // Available actions are: // * `poweron`: Start a stopped Instance. // * `poweroff`: Fully stop the Instance and release the hypervisor slot. // * `stop_in_place`: Stop the Instance, but keep the slot on the hypervisor. // * `reboot`: Stop the instance and restart it. // * `backup`: Create an image with all the volumes of an Instance. // * `terminate`: Delete the Instance along with all attached volumes. // * `enable_routed_ip`: Migrate the Instance to the new network stack. // // Keep in mind that terminating an Instance will result in the deletion of all attached volumes, including local and block storage. // If you want to preserve your local volumes, you should use the `archive` action instead of `terminate`. Similarly, if you want to keep your block storage volumes, you must first detach them before issuing the `terminate` command. // For more information, read the [Volumes](#path-volumes-list-volumes) documentation. func (s *API) ServerAction(req *ServerActionRequest, opts ...scw.RequestOption) (*ServerActionResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/action", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp ServerActionResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListServerUserData: List all user data keys registered on a specified Instance. func (s *API) ListServerUserData(req *ListServerUserDataRequest, opts ...scw.RequestOption) (*ListServerUserDataResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/user_data", } var resp ListServerUserDataResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteServerUserData: Delete the specified key from an Instance's user data. func (s *API) DeleteServerUserData(req *DeleteServerUserDataRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return errors.New("field ServerID cannot be empty in request") } if fmt.Sprint(req.Key) == "" { return errors.New("field Key cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/user_data/" + fmt.Sprint(req.Key) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // AttachServerVolume: func (s *API) AttachServerVolume(req *AttachServerVolumeRequest, opts ...scw.RequestOption) (*AttachServerVolumeResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/attach-volume", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp AttachServerVolumeResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DetachServerVolume: func (s *API) DetachServerVolume(req *DetachServerVolumeRequest, opts ...scw.RequestOption) (*DetachServerVolumeResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/detach-volume", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp DetachServerVolumeResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListImages: List all existing Instance images. func (s *API) ListImages(req *ListImagesRequest, opts ...scw.RequestOption) (*ListImagesResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } query := url.Values{} parameter.AddToQuery(query, "organization", req.Organization) parameter.AddToQuery(query, "per_page", req.PerPage) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "public", req.Public) parameter.AddToQuery(query, "arch", req.Arch) parameter.AddToQuery(query, "project", req.Project) parameter.AddToQuery(query, "tags", req.Tags) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/images", Query: query, } var resp ListImagesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetImage: Get details of an image with the specified ID. func (s *API) GetImage(req *GetImageRequest, opts ...scw.RequestOption) (*GetImageResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ImageID) == "" { return nil, errors.New("field ImageID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/images/" + fmt.Sprint(req.ImageID) + "", } var resp GetImageResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateImage: Create an Instance image from the specified snapshot ID. func (s *API) CreateImage(req *CreateImageRequest, opts ...scw.RequestOption) (*CreateImageResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultProject, exist := s.client.GetDefaultProjectID() if exist && req.Project == nil && req.Organization == nil { req.Project = &defaultProject } defaultOrganization, exist := s.client.GetDefaultOrganizationID() if exist && req.Project == nil && req.Organization == nil { req.Organization = &defaultOrganization } if req.Name == "" { req.Name = namegenerator.GetRandomName("img") } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/images", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp CreateImageResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // setImage: Replace all image properties with an image message. func (s *API) setImage(req *SetImageRequest, opts ...scw.RequestOption) (*setImageResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if req.Organization == "" { defaultOrganization, _ := s.client.GetDefaultOrganizationID() req.Organization = defaultOrganization } if req.Project == "" { defaultProject, _ := s.client.GetDefaultProjectID() req.Project = defaultProject } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ID) == "" { return nil, errors.New("field ID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/images/" + fmt.Sprint(req.ID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp setImageResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateImage: Update the properties of an image. func (s *API) UpdateImage(req *UpdateImageRequest, opts ...scw.RequestOption) (*UpdateImageResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ImageID) == "" { return nil, errors.New("field ImageID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/images/" + fmt.Sprint(req.ImageID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp UpdateImageResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteImage: Delete the image with the specified ID. func (s *API) DeleteImage(req *DeleteImageRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ImageID) == "" { return errors.New("field ImageID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/images/" + fmt.Sprint(req.ImageID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListSnapshots: List all snapshots of an Organization in a specified Availability Zone. func (s *API) ListSnapshots(req *ListSnapshotsRequest, opts ...scw.RequestOption) (*ListSnapshotsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } query := url.Values{} parameter.AddToQuery(query, "organization", req.Organization) parameter.AddToQuery(query, "project", req.Project) parameter.AddToQuery(query, "per_page", req.PerPage) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "tags", req.Tags) parameter.AddToQuery(query, "base_volume_id", req.BaseVolumeID) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/snapshots", Query: query, } var resp ListSnapshotsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateSnapshot: Create a snapshot from a specified volume or from a QCOW2 file in a specified Availability Zone. func (s *API) CreateSnapshot(req *CreateSnapshotRequest, opts ...scw.RequestOption) (*CreateSnapshotResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultProject, exist := s.client.GetDefaultProjectID() if exist && req.Project == nil && req.Organization == nil { req.Project = &defaultProject } defaultOrganization, exist := s.client.GetDefaultOrganizationID() if exist && req.Project == nil && req.Organization == nil { req.Organization = &defaultOrganization } if req.Name == "" { req.Name = namegenerator.GetRandomName("snp") } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/snapshots", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp CreateSnapshotResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetSnapshot: Get details of a snapshot with the specified ID. func (s *API) GetSnapshot(req *GetSnapshotRequest, opts ...scw.RequestOption) (*GetSnapshotResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.SnapshotID) == "" { return nil, errors.New("field SnapshotID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/snapshots/" + fmt.Sprint(req.SnapshotID) + "", } var resp GetSnapshotResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // setSnapshot: Replace all the properties of a snapshot. func (s *API) setSnapshot(req *setSnapshotRequest, opts ...scw.RequestOption) (*setSnapshotResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if req.Organization == "" { defaultOrganization, _ := s.client.GetDefaultOrganizationID() req.Organization = defaultOrganization } if req.Project == "" { defaultProject, _ := s.client.GetDefaultProjectID() req.Project = defaultProject } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.SnapshotID) == "" { return nil, errors.New("field SnapshotID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/snapshots/" + fmt.Sprint(req.SnapshotID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp setSnapshotResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateSnapshot: Update the properties of a snapshot. func (s *API) UpdateSnapshot(req *UpdateSnapshotRequest, opts ...scw.RequestOption) (*UpdateSnapshotResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.SnapshotID) == "" { return nil, errors.New("field SnapshotID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/snapshots/" + fmt.Sprint(req.SnapshotID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp UpdateSnapshotResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteSnapshot: Delete the snapshot with the specified ID. func (s *API) DeleteSnapshot(req *DeleteSnapshotRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.SnapshotID) == "" { return errors.New("field SnapshotID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/snapshots/" + fmt.Sprint(req.SnapshotID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ExportSnapshot: Export a snapshot to a specified S3 bucket in the same region. func (s *API) ExportSnapshot(req *ExportSnapshotRequest, opts ...scw.RequestOption) (*ExportSnapshotResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.SnapshotID) == "" { return nil, errors.New("field SnapshotID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/snapshots/" + fmt.Sprint(req.SnapshotID) + "/export", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp ExportSnapshotResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListVolumes: List volumes in the specified Availability Zone. You can filter the output by volume type. func (s *API) ListVolumes(req *ListVolumesRequest, opts ...scw.RequestOption) (*ListVolumesResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } query := url.Values{} parameter.AddToQuery(query, "volume_type", req.VolumeType) parameter.AddToQuery(query, "per_page", req.PerPage) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "organization", req.Organization) parameter.AddToQuery(query, "project", req.Project) if len(req.Tags) != 0 { parameter.AddToQuery(query, "tags", strings.Join(req.Tags, ",")) } parameter.AddToQuery(query, "name", req.Name) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/volumes", Query: query, } var resp ListVolumesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateVolume: Create a volume of a specified type in an Availability Zone. func (s *API) CreateVolume(req *CreateVolumeRequest, opts ...scw.RequestOption) (*CreateVolumeResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultProject, exist := s.client.GetDefaultProjectID() if exist && req.Project == nil && req.Organization == nil { req.Project = &defaultProject } defaultOrganization, exist := s.client.GetDefaultOrganizationID() if exist && req.Project == nil && req.Organization == nil { req.Organization = &defaultOrganization } if req.Name == "" { req.Name = namegenerator.GetRandomName("vol") } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/volumes", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp CreateVolumeResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetVolume: Get details of a volume with the specified ID. func (s *API) GetVolume(req *GetVolumeRequest, opts ...scw.RequestOption) (*GetVolumeResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.VolumeID) == "" { return nil, errors.New("field VolumeID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/volumes/" + fmt.Sprint(req.VolumeID) + "", } var resp GetVolumeResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateVolume: Replace the name and/or size properties of a volume specified by its ID, with the specified value(s). Any volume name can be changed, however only `b_ssd` volumes can currently be increased in size. func (s *API) UpdateVolume(req *UpdateVolumeRequest, opts ...scw.RequestOption) (*UpdateVolumeResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.VolumeID) == "" { return nil, errors.New("field VolumeID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/volumes/" + fmt.Sprint(req.VolumeID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp UpdateVolumeResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteVolume: Delete the volume with the specified ID. func (s *API) DeleteVolume(req *DeleteVolumeRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.VolumeID) == "" { return errors.New("field VolumeID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/volumes/" + fmt.Sprint(req.VolumeID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListSecurityGroups: List all existing security groups. func (s *API) ListSecurityGroups(req *ListSecurityGroupsRequest, opts ...scw.RequestOption) (*ListSecurityGroupsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } query := url.Values{} parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "organization", req.Organization) parameter.AddToQuery(query, "project", req.Project) if len(req.Tags) != 0 { parameter.AddToQuery(query, "tags", strings.Join(req.Tags, ",")) } parameter.AddToQuery(query, "project_default", req.ProjectDefault) parameter.AddToQuery(query, "per_page", req.PerPage) parameter.AddToQuery(query, "page", req.Page) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/security_groups", Query: query, } var resp ListSecurityGroupsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateSecurityGroup: Create a security group with a specified name and description. func (s *API) CreateSecurityGroup(req *CreateSecurityGroupRequest, opts ...scw.RequestOption) (*CreateSecurityGroupResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultProject, exist := s.client.GetDefaultProjectID() if exist && req.Project == nil && req.Organization == nil { req.Project = &defaultProject } defaultOrganization, exist := s.client.GetDefaultOrganizationID() if exist && req.Project == nil && req.Organization == nil { req.Organization = &defaultOrganization } if req.Name == "" { req.Name = namegenerator.GetRandomName("sg") } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/security_groups", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp CreateSecurityGroupResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetSecurityGroup: Get the details of a security group with the specified ID. func (s *API) GetSecurityGroup(req *GetSecurityGroupRequest, opts ...scw.RequestOption) (*GetSecurityGroupResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.SecurityGroupID) == "" { return nil, errors.New("field SecurityGroupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/security_groups/" + fmt.Sprint(req.SecurityGroupID) + "", } var resp GetSecurityGroupResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteSecurityGroup: Delete a security group with the specified ID. func (s *API) DeleteSecurityGroup(req *DeleteSecurityGroupRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.SecurityGroupID) == "" { return errors.New("field SecurityGroupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/security_groups/" + fmt.Sprint(req.SecurityGroupID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // setSecurityGroup: Replace all security group properties with a security group message. func (s *API) setSecurityGroup(req *setSecurityGroupRequest, opts ...scw.RequestOption) (*setSecurityGroupResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if req.Organization == "" { defaultOrganization, _ := s.client.GetDefaultOrganizationID() req.Organization = defaultOrganization } if req.Project == "" { defaultProject, _ := s.client.GetDefaultProjectID() req.Project = defaultProject } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ID) == "" { return nil, errors.New("field ID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/security_groups/" + fmt.Sprint(req.ID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp setSecurityGroupResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateSecurityGroup: Update the properties of security group. func (s *API) UpdateSecurityGroup(req *UpdateSecurityGroupRequest, opts ...scw.RequestOption) (*UpdateSecurityGroupResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.SecurityGroupID) == "" { return nil, errors.New("field SecurityGroupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/security_groups/" + fmt.Sprint(req.SecurityGroupID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp UpdateSecurityGroupResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListDefaultSecurityGroupRules: Lists the default rules applied to all the security groups. func (s *API) ListDefaultSecurityGroupRules(req *ListDefaultSecurityGroupRulesRequest, opts ...scw.RequestOption) (*ListSecurityGroupRulesResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/security_groups/default/rules", } var resp ListSecurityGroupRulesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListSecurityGroupRules: List the rules of the a specified security group ID. func (s *API) ListSecurityGroupRules(req *ListSecurityGroupRulesRequest, opts ...scw.RequestOption) (*ListSecurityGroupRulesResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } query := url.Values{} parameter.AddToQuery(query, "per_page", req.PerPage) parameter.AddToQuery(query, "page", req.Page) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.SecurityGroupID) == "" { return nil, errors.New("field SecurityGroupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/security_groups/" + fmt.Sprint(req.SecurityGroupID) + "/rules", Query: query, } var resp ListSecurityGroupRulesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateSecurityGroupRule: Create a rule in the specified security group ID. func (s *API) CreateSecurityGroupRule(req *CreateSecurityGroupRuleRequest, opts ...scw.RequestOption) (*CreateSecurityGroupRuleResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.SecurityGroupID) == "" { return nil, errors.New("field SecurityGroupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/security_groups/" + fmt.Sprint(req.SecurityGroupID) + "/rules", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp CreateSecurityGroupRuleResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SetSecurityGroupRules: Replaces the existing rules of the security group with the rules provided. This endpoint supports the update of existing rules, creation of new rules and deletion of existing rules when they are not passed in the request. func (s *API) SetSecurityGroupRules(req *SetSecurityGroupRulesRequest, opts ...scw.RequestOption) (*SetSecurityGroupRulesResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.SecurityGroupID) == "" { return nil, errors.New("field SecurityGroupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/security_groups/" + fmt.Sprint(req.SecurityGroupID) + "/rules", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SetSecurityGroupRulesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteSecurityGroupRule: Delete a security group rule with the specified ID. func (s *API) DeleteSecurityGroupRule(req *DeleteSecurityGroupRuleRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.SecurityGroupID) == "" { return errors.New("field SecurityGroupID cannot be empty in request") } if fmt.Sprint(req.SecurityGroupRuleID) == "" { return errors.New("field SecurityGroupRuleID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/security_groups/" + fmt.Sprint(req.SecurityGroupID) + "/rules/" + fmt.Sprint(req.SecurityGroupRuleID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // GetSecurityGroupRule: Get details of a security group rule with the specified ID. func (s *API) GetSecurityGroupRule(req *GetSecurityGroupRuleRequest, opts ...scw.RequestOption) (*GetSecurityGroupRuleResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.SecurityGroupID) == "" { return nil, errors.New("field SecurityGroupID cannot be empty in request") } if fmt.Sprint(req.SecurityGroupRuleID) == "" { return nil, errors.New("field SecurityGroupRuleID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/security_groups/" + fmt.Sprint(req.SecurityGroupID) + "/rules/" + fmt.Sprint(req.SecurityGroupRuleID) + "", } var resp GetSecurityGroupRuleResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // setSecurityGroupRule: Replace all the properties of a rule from a specified security group. func (s *API) setSecurityGroupRule(req *setSecurityGroupRuleRequest, opts ...scw.RequestOption) (*setSecurityGroupRuleResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.SecurityGroupID) == "" { return nil, errors.New("field SecurityGroupID cannot be empty in request") } if fmt.Sprint(req.SecurityGroupRuleID) == "" { return nil, errors.New("field SecurityGroupRuleID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/security_groups/" + fmt.Sprint(req.SecurityGroupID) + "/rules/" + fmt.Sprint(req.SecurityGroupRuleID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp setSecurityGroupRuleResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateSecurityGroupRule: Update the properties of a rule from a specified security group. func (s *API) UpdateSecurityGroupRule(req *UpdateSecurityGroupRuleRequest, opts ...scw.RequestOption) (*UpdateSecurityGroupRuleResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.SecurityGroupID) == "" { return nil, errors.New("field SecurityGroupID cannot be empty in request") } if fmt.Sprint(req.SecurityGroupRuleID) == "" { return nil, errors.New("field SecurityGroupRuleID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/security_groups/" + fmt.Sprint(req.SecurityGroupID) + "/rules/" + fmt.Sprint(req.SecurityGroupRuleID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp UpdateSecurityGroupRuleResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListPlacementGroups: List all placement groups in a specified Availability Zone. func (s *API) ListPlacementGroups(req *ListPlacementGroupsRequest, opts ...scw.RequestOption) (*ListPlacementGroupsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } query := url.Values{} parameter.AddToQuery(query, "per_page", req.PerPage) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "organization", req.Organization) parameter.AddToQuery(query, "project", req.Project) if len(req.Tags) != 0 { parameter.AddToQuery(query, "tags", strings.Join(req.Tags, ",")) } parameter.AddToQuery(query, "name", req.Name) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/placement_groups", Query: query, } var resp ListPlacementGroupsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreatePlacementGroup: Create a new placement group in a specified Availability Zone. func (s *API) CreatePlacementGroup(req *CreatePlacementGroupRequest, opts ...scw.RequestOption) (*CreatePlacementGroupResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultProject, exist := s.client.GetDefaultProjectID() if exist && req.Project == nil && req.Organization == nil { req.Project = &defaultProject } defaultOrganization, exist := s.client.GetDefaultOrganizationID() if exist && req.Project == nil && req.Organization == nil { req.Organization = &defaultOrganization } if req.Name == "" { req.Name = namegenerator.GetRandomName("pg") } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/placement_groups", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp CreatePlacementGroupResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetPlacementGroup: Get the specified placement group. func (s *API) GetPlacementGroup(req *GetPlacementGroupRequest, opts ...scw.RequestOption) (*GetPlacementGroupResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.PlacementGroupID) == "" { return nil, errors.New("field PlacementGroupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/placement_groups/" + fmt.Sprint(req.PlacementGroupID) + "", } var resp GetPlacementGroupResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SetPlacementGroup: Set all parameters of the specified placement group. func (s *API) SetPlacementGroup(req *SetPlacementGroupRequest, opts ...scw.RequestOption) (*SetPlacementGroupResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if req.Organization == "" { defaultOrganization, _ := s.client.GetDefaultOrganizationID() req.Organization = defaultOrganization } if req.Project == "" { defaultProject, _ := s.client.GetDefaultProjectID() req.Project = defaultProject } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.PlacementGroupID) == "" { return nil, errors.New("field PlacementGroupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/placement_groups/" + fmt.Sprint(req.PlacementGroupID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SetPlacementGroupResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdatePlacementGroup: Update one or more parameter of the specified placement group. func (s *API) UpdatePlacementGroup(req *UpdatePlacementGroupRequest, opts ...scw.RequestOption) (*UpdatePlacementGroupResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.PlacementGroupID) == "" { return nil, errors.New("field PlacementGroupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/placement_groups/" + fmt.Sprint(req.PlacementGroupID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp UpdatePlacementGroupResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeletePlacementGroup: Delete the specified placement group. func (s *API) DeletePlacementGroup(req *DeletePlacementGroupRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.PlacementGroupID) == "" { return errors.New("field PlacementGroupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/placement_groups/" + fmt.Sprint(req.PlacementGroupID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // GetPlacementGroupServers: Get all Instances belonging to the specified placement group. func (s *API) GetPlacementGroupServers(req *GetPlacementGroupServersRequest, opts ...scw.RequestOption) (*GetPlacementGroupServersResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.PlacementGroupID) == "" { return nil, errors.New("field PlacementGroupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/placement_groups/" + fmt.Sprint(req.PlacementGroupID) + "/servers", } var resp GetPlacementGroupServersResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SetPlacementGroupServers: Set all Instances belonging to the specified placement group. func (s *API) SetPlacementGroupServers(req *SetPlacementGroupServersRequest, opts ...scw.RequestOption) (*SetPlacementGroupServersResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.PlacementGroupID) == "" { return nil, errors.New("field PlacementGroupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/placement_groups/" + fmt.Sprint(req.PlacementGroupID) + "/servers", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SetPlacementGroupServersResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdatePlacementGroupServers: Update all Instances belonging to the specified placement group. func (s *API) UpdatePlacementGroupServers(req *UpdatePlacementGroupServersRequest, opts ...scw.RequestOption) (*UpdatePlacementGroupServersResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.PlacementGroupID) == "" { return nil, errors.New("field PlacementGroupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/placement_groups/" + fmt.Sprint(req.PlacementGroupID) + "/servers", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp UpdatePlacementGroupServersResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListIPs: List all flexible IPs in a specified zone. func (s *API) ListIPs(req *ListIPsRequest, opts ...scw.RequestOption) (*ListIPsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } query := url.Values{} parameter.AddToQuery(query, "project", req.Project) parameter.AddToQuery(query, "organization", req.Organization) if len(req.Tags) != 0 { parameter.AddToQuery(query, "tags", strings.Join(req.Tags, ",")) } parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "per_page", req.PerPage) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "type", req.Type) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/ips", Query: query, } var resp ListIPsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateIP: Reserve a flexible IP and attach it to the specified Instance. func (s *API) CreateIP(req *CreateIPRequest, opts ...scw.RequestOption) (*CreateIPResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultProject, exist := s.client.GetDefaultProjectID() if exist && req.Project == nil && req.Organization == nil { req.Project = &defaultProject } defaultOrganization, exist := s.client.GetDefaultOrganizationID() if exist && req.Project == nil && req.Organization == nil { req.Organization = &defaultOrganization } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/ips", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp CreateIPResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetIP: Get details of an IP with the specified ID or address. func (s *API) GetIP(req *GetIPRequest, opts ...scw.RequestOption) (*GetIPResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.IP) == "" { return nil, errors.New("field IP cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/ips/" + fmt.Sprint(req.IP) + "", } var resp GetIPResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateIP: Update a flexible IP in the specified zone with the specified ID. func (s *API) UpdateIP(req *UpdateIPRequest, opts ...scw.RequestOption) (*UpdateIPResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.IP) == "" { return nil, errors.New("field IP cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/ips/" + fmt.Sprint(req.IP) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp UpdateIPResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteIP: Delete the IP with the specified ID. func (s *API) DeleteIP(req *DeleteIPRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.IP) == "" { return errors.New("field IP cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/ips/" + fmt.Sprint(req.IP) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListPrivateNICs: List all private NICs of a specified Instance. func (s *API) ListPrivateNICs(req *ListPrivateNICsRequest, opts ...scw.RequestOption) (*ListPrivateNICsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } query := url.Values{} if len(req.Tags) != 0 { parameter.AddToQuery(query, "tags", strings.Join(req.Tags, ",")) } parameter.AddToQuery(query, "per_page", req.PerPage) parameter.AddToQuery(query, "page", req.Page) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/private_nics", Query: query, } var resp ListPrivateNICsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreatePrivateNIC: Create a private NIC connecting an Instance to a Private Network. func (s *API) CreatePrivateNIC(req *CreatePrivateNICRequest, opts ...scw.RequestOption) (*CreatePrivateNICResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/private_nics", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp CreatePrivateNICResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetPrivateNIC: Get private NIC properties. func (s *API) GetPrivateNIC(req *GetPrivateNICRequest, opts ...scw.RequestOption) (*GetPrivateNICResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } if fmt.Sprint(req.PrivateNicID) == "" { return nil, errors.New("field PrivateNicID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/private_nics/" + fmt.Sprint(req.PrivateNicID) + "", } var resp GetPrivateNICResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdatePrivateNIC: Update one or more parameter(s) of a specified private NIC. func (s *API) UpdatePrivateNIC(req *UpdatePrivateNICRequest, opts ...scw.RequestOption) (*PrivateNIC, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } if fmt.Sprint(req.PrivateNicID) == "" { return nil, errors.New("field PrivateNicID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/private_nics/" + fmt.Sprint(req.PrivateNicID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp PrivateNIC err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeletePrivateNIC: Delete a private NIC. func (s *API) DeletePrivateNIC(req *DeletePrivateNICRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return errors.New("field ServerID cannot be empty in request") } if fmt.Sprint(req.PrivateNicID) == "" { return errors.New("field PrivateNicID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/private_nics/" + fmt.Sprint(req.PrivateNicID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // Deprecated: ListBootscripts: List bootscripts. func (s *API) ListBootscripts(req *ListBootscriptsRequest, opts ...scw.RequestOption) (*ListBootscriptsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } query := url.Values{} parameter.AddToQuery(query, "arch", req.Arch) parameter.AddToQuery(query, "title", req.Title) parameter.AddToQuery(query, "default", req.Default) parameter.AddToQuery(query, "public", req.Public) parameter.AddToQuery(query, "per_page", req.PerPage) parameter.AddToQuery(query, "page", req.Page) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/bootscripts", Query: query, } var resp ListBootscriptsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // Deprecated: GetBootscript: Get details of a bootscript with the specified ID. func (s *API) GetBootscript(req *GetBootscriptRequest, opts ...scw.RequestOption) (*GetBootscriptResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.BootscriptID) == "" { return nil, errors.New("field BootscriptID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/bootscripts/" + fmt.Sprint(req.BootscriptID) + "", } var resp GetBootscriptResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetDashboard: func (s *API) GetDashboard(req *GetDashboardRequest, opts ...scw.RequestOption) (*GetDashboardResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } query := url.Values{} parameter.AddToQuery(query, "organization", req.Organization) parameter.AddToQuery(query, "project", req.Project) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/dashboard", Query: query, } var resp GetDashboardResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // PlanBlockMigration: Given a volume or snapshot, returns the migration plan for a call to the RPC ApplyBlockMigration. This plan will include zero or one volume, and zero or more snapshots, which will need to be migrated together. This RPC does not perform the actual migration itself, ApplyBlockMigration must be used. The validation_key value returned by this call must be provided to the ApplyBlockMigration call to confirm that all resources listed in the plan should be migrated. func (s *API) PlanBlockMigration(req *PlanBlockMigrationRequest, opts ...scw.RequestOption) (*MigrationPlan, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/block-migration/plan", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp MigrationPlan err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ApplyBlockMigration: To be used, this RPC must be preceded by a call to PlanBlockMigration. To migrate all resources mentioned in the MigrationPlan, the validation_key returned in the MigrationPlan must be provided. func (s *API) ApplyBlockMigration(req *ApplyBlockMigrationRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/block-migration/apply", } err = scwReq.SetBody(req) if err != nil { return err } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/instance_sdk_server_test.go000066400000000000000000000144031456366605600326040ustar00rootroot00000000000000package instance import ( "testing" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers/httprecorder" "github.com/scaleway/scaleway-sdk-go/scw" ) func TestServerUpdate(t *testing.T) { client, r, err := httprecorder.CreateRecordedScwClient("server-test") testhelpers.AssertNoError(t, err) defer func() { testhelpers.AssertNoError(t, r.Stop()) // Make sure recorder is stopped once done with it }() instanceAPI := NewAPI(client) var ( serverID string volumeID string zone = scw.ZoneFrPar1 name = "instance_sdk_server_test" dynamicIPRequired = scw.BoolPtr(true) commercialType = "START1-S" image = "f974feac-abae-4365-b988-8ec7d1cec10d" enableIPv6 = true bootType = BootTypeLocal tags = []string{"foo", "bar"} project = "14d2f7ae-9775-414c-9bed-6810e060d500" ) t.Run("create server", func(t *testing.T) { // Create server createServerResponse, err := instanceAPI.CreateServer(&CreateServerRequest{ Zone: zone, Name: name, Project: &project, Image: image, EnableIPv6: enableIPv6, CommercialType: commercialType, Tags: tags, DynamicIPRequired: dynamicIPRequired, BootType: &bootType, }) testhelpers.AssertNoError(t, err) serverID = createServerResponse.Server.ID testhelpers.Assert(t, createServerResponse.Server != nil, "Should have server in response") testhelpers.Assert(t, 1 == len(createServerResponse.Server.Volumes), "should have exactly one volume because we didn't pass volumes map in the requests.") for _, volume := range createServerResponse.Server.Volumes { volumeID = volume.ID } testhelpers.Equals(t, name, createServerResponse.Server.Name) testhelpers.Equals(t, project, createServerResponse.Server.Project) testhelpers.Equals(t, project, createServerResponse.Server.Organization) testhelpers.Equals(t, image, createServerResponse.Server.Image.ID) testhelpers.Equals(t, enableIPv6, createServerResponse.Server.EnableIPv6) testhelpers.Equals(t, bootType, createServerResponse.Server.BootType) testhelpers.Equals(t, commercialType, createServerResponse.Server.CommercialType) testhelpers.Equals(t, tags, createServerResponse.Server.Tags) testhelpers.Equals(t, *dynamicIPRequired, createServerResponse.Server.DynamicIPRequired) }) t.Run("create server with orga (deprecated)", func(t *testing.T) { // Create server createServerResponse, err := instanceAPI.CreateServer(&CreateServerRequest{ Zone: zone, Name: name, Organization: &project, Image: image, }) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, project, createServerResponse.Server.Project) testhelpers.Equals(t, project, createServerResponse.Server.Organization) // Delete Server err = instanceAPI.DeleteServer(&DeleteServerRequest{ Zone: zone, ServerID: createServerResponse.Server.ID, }) testhelpers.AssertNoError(t, err) }) t.Run("update server", func(t *testing.T) { var ( newName = "some_new_name_for_server" updatedTags = []string{} ) // Update server updateServerResponse, err := instanceAPI.updateServer(&UpdateServerRequest{ ServerID: serverID, Zone: zone, Name: &newName, Tags: &updatedTags, }) testhelpers.Assert(t, updateServerResponse.Server != nil, "Should have server in response") testhelpers.AssertNoError(t, err) // Initial values that are not altered in the above request should remaining the same testhelpers.Equals(t, project, updateServerResponse.Server.Project) testhelpers.Equals(t, project, updateServerResponse.Server.Organization) testhelpers.Equals(t, image, updateServerResponse.Server.Image.ID) testhelpers.Equals(t, enableIPv6, updateServerResponse.Server.EnableIPv6) testhelpers.Equals(t, bootType, updateServerResponse.Server.BootType) testhelpers.Equals(t, commercialType, updateServerResponse.Server.CommercialType) testhelpers.Equals(t, *dynamicIPRequired, updateServerResponse.Server.DynamicIPRequired) testhelpers.Assert(t, 1 == len(updateServerResponse.Server.Volumes), "should have exactly one volume because we didn't pass volumes map in the requests.") testhelpers.Equals(t, newName, updateServerResponse.Server.Name) testhelpers.Equals(t, updatedTags, updateServerResponse.Server.Tags) }) t.Run("remove server volumes", func(t *testing.T) { // Remove/detach volumes updateServerResponse, err := instanceAPI.updateServer(&UpdateServerRequest{ ServerID: serverID, Zone: zone, Volumes: &map[string]*VolumeServerTemplate{}, }) testhelpers.AssertNoError(t, err) testhelpers.Assert(t, updateServerResponse.Server != nil, "Should have server in response") testhelpers.Assert(t, 0 == len(updateServerResponse.Server.Volumes), "volume should be detached from server.") }) t.Run("cleanup server and volume", func(t *testing.T) { // Delete Server err = instanceAPI.DeleteServer(&DeleteServerRequest{ Zone: zone, ServerID: serverID, }) testhelpers.AssertNoError(t, err) // Delete Volume err = instanceAPI.DeleteVolume(&DeleteVolumeRequest{ Zone: zone, VolumeID: volumeID, }) testhelpers.AssertNoError(t, err) }) } func TestCreateServerWithIncorrectBody(t *testing.T) { client, r, err := httprecorder.CreateRecordedScwClient("server-incorrect-body") testhelpers.AssertNoError(t, err) defer func() { testhelpers.AssertNoError(t, r.Stop()) // Make sure recorder is stopped once done with it }() instanceAPI := NewAPI(client) var ( zone = scw.ZoneFrPar1 ) // Create server _, err = instanceAPI.CreateServer(&CreateServerRequest{ Zone: zone, }) testhelpers.Assert(t, err != nil, "This request should error") } func TestListServerMultipleZones(t *testing.T) { client, r, err := httprecorder.CreateRecordedScwClient("server-list-zones") testhelpers.AssertNoError(t, err) defer func() { testhelpers.AssertNoError(t, r.Stop()) // Make sure recorder is stopped once done with it }() instanceAPI := NewAPI(client) // Create server _, err = instanceAPI.ListServers(&ListServersRequest{}, scw.WithZones(instanceAPI.Zones()...)) testhelpers.Assert(t, err == nil, "This request should not error: %s", err) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/instance_utils.go000066400000000000000000000267201456366605600305430ustar00rootroot00000000000000package instance import ( "encoding/json" "fmt" "sync" "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) var ( resourceLock sync.Map ) // lockResource locks a resource from a specific resourceID func lockResource(resourceID string) *sync.Mutex { v, _ := resourceLock.LoadOrStore(resourceID, &sync.Mutex{}) mutex := v.(*sync.Mutex) mutex.Lock() return mutex } // lockServer locks a server from its zone and its ID func lockServer(zone scw.Zone, serverID string) *sync.Mutex { return lockResource(fmt.Sprint("server", zone, serverID)) } // AttachIPRequest contains the parameters to attach an IP to a server // // Deprecated: UpdateIPRequest should be used instead type AttachIPRequest struct { Zone scw.Zone `json:"-"` IP string `json:"-"` ServerID string `json:"server_id"` } // AttachIPResponse contains the updated IP after attaching // // Deprecated: UpdateIPResponse should be used instead type AttachIPResponse struct { IP *IP } // AttachIP attaches an IP to a server. // // Deprecated: UpdateIP() should be used instead func (s *API) AttachIP(req *AttachIPRequest, opts ...scw.RequestOption) (*AttachIPResponse, error) { ipResponse, err := s.UpdateIP(&UpdateIPRequest{ Zone: req.Zone, IP: req.IP, Server: &NullableStringValue{Value: req.ServerID}, }) if err != nil { return nil, err } return &AttachIPResponse{IP: ipResponse.IP}, nil } // DetachIPRequest contains the parameters to detach an IP from a server // // Deprecated: UpdateIPRequest should be used instead type DetachIPRequest struct { Zone scw.Zone `json:"-"` IP string `json:"-"` } // DetachIPResponse contains the updated IP after detaching // // Deprecated: UpdateIPResponse should be used instead type DetachIPResponse struct { IP *IP } // DetachIP detaches an IP from a server. // // Deprecated: UpdateIP() should be used instead func (s *API) DetachIP(req *DetachIPRequest, opts ...scw.RequestOption) (*DetachIPResponse, error) { ipResponse, err := s.UpdateIP(&UpdateIPRequest{ Zone: req.Zone, IP: req.IP, Server: &NullableStringValue{Null: true}, }) if err != nil { return nil, err } return &DetachIPResponse{IP: ipResponse.IP}, nil } // AttachVolumeRequest contains the parameters to attach a volume to a server type AttachVolumeRequest struct { Zone scw.Zone `json:"-"` ServerID string `json:"-"` VolumeID string `json:"-"` } // AttachVolumeResponse contains the updated server after attaching a volume type AttachVolumeResponse struct { Server *Server `json:"-"` } // volumesToVolumeTemplates converts a map of *Volume to a map of *VolumeTemplate // so it can be used in a UpdateServer request func volumesToVolumeTemplates(volumes map[string]*VolumeServer) map[string]*VolumeServerTemplate { volumeTemplates := map[string]*VolumeServerTemplate{} for key, volume := range volumes { volumeTemplate := &VolumeServerTemplate{ ID: &volume.ID, } if volume.Name != "" { volumeTemplate.Name = &volume.Name } if volume.VolumeType == VolumeServerVolumeTypeSbsVolume { volumeTemplate.VolumeType = VolumeVolumeTypeSbsVolume } volumeTemplates[key] = volumeTemplate } return volumeTemplates } // AttachVolume attaches a volume to a server // // Note: Implementation is thread-safe. func (s *API) AttachVolume(req *AttachVolumeRequest, opts ...scw.RequestOption) (*AttachVolumeResponse, error) { defer lockServer(req.Zone, req.ServerID).Unlock() // check where the volume comes from volume, err := s.getUnknownVolume(&getUnknownVolumeRequest{ Zone: req.Zone, VolumeID: req.VolumeID, }) if err != nil { return nil, err } // get server with volumes getServerResponse, err := s.GetServer(&GetServerRequest{ Zone: req.Zone, ServerID: req.ServerID, }) if err != nil { return nil, err } volumes := getServerResponse.Server.Volumes newVolumes := volumesToVolumeTemplates(volumes) // add volume to volumes list // We loop through all the possible volume keys (0 to len(volumes)) // to find a non existing key and assign it to the requested volume. // A key should always be found. However we return an error if no keys were found. found := false for i := 0; i <= len(volumes); i++ { key := fmt.Sprintf("%d", i) if _, ok := newVolumes[key]; !ok { newVolumes[key] = &VolumeServerTemplate{ ID: &req.VolumeID, } if volume.Type == VolumeVolumeTypeSbsVolume { newVolumes[key].VolumeType = VolumeVolumeTypeSbsVolume } else { newVolumes[key].Name = &req.VolumeID } found = true break } } if !found { return nil, fmt.Errorf("could not find key to attach volume %s", req.VolumeID) } // update server updateServerResponse, err := s.updateServer(&UpdateServerRequest{ Zone: req.Zone, ServerID: req.ServerID, Volumes: &newVolumes, }) if err != nil { return nil, err } return &AttachVolumeResponse{Server: updateServerResponse.Server}, nil } // DetachVolumeRequest contains the parameters to detach a volume from a server type DetachVolumeRequest struct { Zone scw.Zone `json:"-"` VolumeID string `json:"-"` // IsBlockVolume should be set to true if volume is from block API, // can be set to false if volume is from instance API, // if left nil both API will be tried IsBlockVolume *bool `json:"-"` } // DetachVolumeResponse contains the updated server after detaching a volume type DetachVolumeResponse struct { Server *Server `json:"-"` } // DetachVolume detaches a volume from a server // // Note: Implementation is thread-safe. func (s *API) DetachVolume(req *DetachVolumeRequest, opts ...scw.RequestOption) (*DetachVolumeResponse, error) { volume, err := s.getUnknownVolume(&getUnknownVolumeRequest{ Zone: req.Zone, VolumeID: req.VolumeID, }) if err != nil { return nil, err } if volume.ServerID == nil { return nil, errors.New("volume should be attached to a server") } defer lockServer(req.Zone, *volume.ServerID).Unlock() // get server with volumes getServerResponse, err := s.GetServer(&GetServerRequest{ Zone: req.Zone, ServerID: *volume.ServerID, }) if err != nil { return nil, err } volumes := getServerResponse.Server.Volumes // remove volume from volumes list for key, volume := range volumes { if volume.ID == req.VolumeID { delete(volumes, key) } } newVolumes := volumesToVolumeTemplates(volumes) // update server updateServerResponse, err := s.updateServer(&UpdateServerRequest{ Zone: req.Zone, ServerID: *volume.ServerID, Volumes: &newVolumes, }) if err != nil { return nil, err } return &DetachVolumeResponse{Server: updateServerResponse.Server}, nil } // UnsafeSetTotalCount should not be used // Internal usage only func (r *ListServersResponse) UnsafeSetTotalCount(totalCount int) { r.TotalCount = uint32(totalCount) } // UnsafeSetTotalCount should not be used // Internal usage only func (r *ListBootscriptsResponse) UnsafeSetTotalCount(totalCount int) { r.TotalCount = uint32(totalCount) } // UnsafeSetTotalCount should not be used // Internal usage only func (r *ListIPsResponse) UnsafeSetTotalCount(totalCount int) { r.TotalCount = uint32(totalCount) } // UnsafeSetTotalCount should not be used // Internal usage only func (r *ListSecurityGroupRulesResponse) UnsafeSetTotalCount(totalCount int) { r.TotalCount = uint32(totalCount) } // UnsafeSetTotalCount should not be used // Internal usage only func (r *ListSecurityGroupsResponse) UnsafeSetTotalCount(totalCount int) { r.TotalCount = uint32(totalCount) } // UnsafeSetTotalCount should not be used // Internal usage only func (r *ListServersTypesResponse) UnsafeSetTotalCount(totalCount int) { r.TotalCount = uint32(totalCount) } // UnsafeSetTotalCount should not be used // Internal usage only func (r *ListSnapshotsResponse) UnsafeSetTotalCount(totalCount int) { r.TotalCount = uint32(totalCount) } // UnsafeSetTotalCount should not be used // Internal usage only func (r *ListVolumesResponse) UnsafeSetTotalCount(totalCount int) { r.TotalCount = uint32(totalCount) } // UnsafeSetTotalCount should not be used // Internal usage only func (r *ListImagesResponse) UnsafeSetTotalCount(totalCount int) { r.TotalCount = uint32(totalCount) } func (v *NullableStringValue) UnmarshalJSON(b []byte) error { if string(b) == "null" { v.Null = true return nil } var tmp string if err := json.Unmarshal(b, &tmp); err != nil { return err } v.Null = false v.Value = tmp return nil } func (v *NullableStringValue) MarshalJSON() ([]byte, error) { if v.Null { return []byte("null"), nil } return json.Marshal(v.Value) } // WaitForPrivateNICRequest is used by WaitForPrivateNIC method. type WaitForPrivateNICRequest struct { ServerID string PrivateNicID string Zone scw.Zone Timeout *time.Duration RetryInterval *time.Duration } // WaitForPrivateNIC wait for the private network to be in a "terminal state" before returning. // This function can be used to wait for the private network to be attached for example. func (s *API) WaitForPrivateNIC(req *WaitForPrivateNICRequest, opts ...scw.RequestOption) (*PrivateNIC, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[PrivateNICState]struct{}{ PrivateNICStateAvailable: {}, PrivateNICStateSyncingError: {}, } pn, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetPrivateNIC(&GetPrivateNICRequest{ ServerID: req.ServerID, Zone: req.Zone, PrivateNicID: req.PrivateNicID, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.PrivateNic.State] return res.PrivateNic, isTerminal, err }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for server failed") } return pn.(*PrivateNIC), nil } // WaitForMACAddressRequest is used by WaitForMACAddress method. type WaitForMACAddressRequest struct { ServerID string PrivateNicID string Zone scw.Zone Timeout *time.Duration RetryInterval *time.Duration } // WaitForMACAddress wait for the MAC address be assigned on instance before returning. // This function can be used to wait for the private network to be attached for example. func (s *API) WaitForMACAddress(req *WaitForMACAddressRequest, opts ...scw.RequestOption) (*PrivateNIC, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } pn, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetPrivateNIC(&GetPrivateNICRequest{ ServerID: req.ServerID, Zone: req.Zone, PrivateNicID: req.PrivateNicID, }, opts...) if err != nil { return nil, false, err } if len(res.PrivateNic.MacAddress) > 0 { return res.PrivateNic, true, err } return res.PrivateNic, false, err }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for server failed") } return pn.(*PrivateNIC), nil } // UnsafeSetTotalCount should not be used // Internal usage only func (r *GetServerTypesAvailabilityResponse) UnsafeSetTotalCount(totalCount int) { r.TotalCount = uint32(totalCount) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/instance_utils_test.go000066400000000000000000000200241456366605600315710ustar00rootroot00000000000000package instance import ( "testing" block "github.com/scaleway/scaleway-sdk-go/api/block/v1alpha1" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers/httprecorder" "github.com/scaleway/scaleway-sdk-go/scw" ) func TestInstanceHelpers(t *testing.T) { client, r, err := httprecorder.CreateRecordedScwClient("utils-test") testhelpers.AssertNoError(t, err) defer func() { testhelpers.AssertNoError(t, r.Stop()) // Make sure recorder is stopped once done with it }() instanceAPI := NewAPI(client) var ( serverID string ipID string volumeID string zone = scw.ZoneFrPar1 project = "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b" image = "81b9475d-e1b5-43c2-ac48-4c1a3b640686" ) t.Run("create server", func(t *testing.T) { createServerResponse, err := instanceAPI.CreateServer(&CreateServerRequest{ Zone: zone, Name: "instance_utils_test", Project: &project, Image: image, CommercialType: "PRO2-XXS", }) testhelpers.AssertNoError(t, err) serverID = createServerResponse.Server.ID for _, volume := range createServerResponse.Server.Volumes { volumeID = volume.ID } }) t.Run("test ip related functions", func(t *testing.T) { // Create IP createIPResponse, err := instanceAPI.CreateIP(&CreateIPRequest{ Zone: zone, Project: &project, }) testhelpers.AssertNoError(t, err) ipID = createIPResponse.IP.ID // Attach IP ipAttachResponse, err := instanceAPI.AttachIP(&AttachIPRequest{ IP: ipID, Zone: zone, ServerID: serverID, }) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, serverID, ipAttachResponse.IP.Server.ID) // Detach IP ipDetachResponse, err := instanceAPI.DetachIP(&DetachIPRequest{ IP: ipID, Zone: zone, }) testhelpers.AssertNoError(t, err) testhelpers.Assert(t, nil == ipDetachResponse.IP.Server, "Server object should be nil for detached IP.") // Delete IP err = instanceAPI.DeleteIP(&DeleteIPRequest{ Zone: zone, IP: ipID, }) testhelpers.AssertNoError(t, err) }) t.Run("Test attach and detach volume", func(t *testing.T) { detachVolumeResponse, err := instanceAPI.DetachVolume(&DetachVolumeRequest{ Zone: zone, VolumeID: volumeID, }) testhelpers.AssertNoError(t, err) testhelpers.Assert(t, detachVolumeResponse.Server != nil, "Should have server in response") testhelpers.Assert(t, detachVolumeResponse.Server.Volumes != nil, "Should have volumes in response") testhelpers.Assert(t, len(detachVolumeResponse.Server.Volumes) == 0, "Server should have zero volumes after detaching") attachVolumeResponse, err := instanceAPI.AttachVolume(&AttachVolumeRequest{ Zone: zone, ServerID: serverID, VolumeID: volumeID, }) testhelpers.AssertNoError(t, err) testhelpers.Assert(t, attachVolumeResponse.Server != nil, "Should have server in response") testhelpers.Assert(t, attachVolumeResponse.Server.Volumes != nil, "Should have volumes in response") testhelpers.Assert(t, len(attachVolumeResponse.Server.Volumes) == 1, "Server should have one volumes after attaching") testhelpers.Equals(t, volumeID, attachVolumeResponse.Server.Volumes["0"].ID) }) t.Run("teardown: delete server and volume", func(t *testing.T) { // Delete Server err = instanceAPI.DeleteServer(&DeleteServerRequest{ Zone: zone, ServerID: serverID, }) testhelpers.AssertNoError(t, err) // Delete Volume err = instanceAPI.DeleteVolume(&DeleteVolumeRequest{ Zone: zone, VolumeID: volumeID, }) testhelpers.AssertNoError(t, err) }) } func TestInstanceHelpers_BlockVolume(t *testing.T) { client, r, err := httprecorder.CreateRecordedScwClient("utils-test-block") testhelpers.AssertNoError(t, err) defer func() { testhelpers.AssertNoError(t, r.Stop()) // Make sure recorder is stopped once done with it }() instanceAPI := NewAPI(client) blockAPI := block.NewAPI(client) var ( serverID string volumeID string volumeID2 string zone = scw.ZoneFrPar1 project = "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b" image = "81b9475d-e1b5-43c2-ac48-4c1a3b640686" ) t.Run("create server and volume", func(t *testing.T) { createVolumeResponse, err := blockAPI.CreateVolume(&block.CreateVolumeRequest{ Zone: zone, Name: "instance_utils_test", ProjectID: project, FromEmpty: &block.CreateVolumeRequestFromEmpty{ Size: scw.GB * 20, }, Tags: nil, }) testhelpers.AssertNoError(t, err) volumeID = createVolumeResponse.ID createVolumeResponse, err = blockAPI.CreateVolume(&block.CreateVolumeRequest{ Zone: zone, Name: "instance_utils_test2", ProjectID: project, FromEmpty: &block.CreateVolumeRequestFromEmpty{ Size: scw.GB * 20, }, Tags: nil, }) testhelpers.AssertNoError(t, err) volumeID2 = createVolumeResponse.ID createServerResponse, err := instanceAPI.CreateServer(&CreateServerRequest{ Zone: zone, Name: "instance_utils_test", Project: &project, Image: image, CommercialType: "PRO2-XXS", Volumes: map[string]*VolumeServerTemplate{ "0": { ID: &volumeID, VolumeType: VolumeVolumeTypeSbsVolume, }, }, }) testhelpers.AssertNoError(t, err) serverID = createServerResponse.Server.ID }) t.Run("Test attach and detach volume", func(t *testing.T) { detachVolumeResponse, err := instanceAPI.DetachVolume(&DetachVolumeRequest{ Zone: zone, VolumeID: volumeID, }) testhelpers.AssertNoError(t, err) testhelpers.Assert(t, detachVolumeResponse.Server != nil, "Should have server in response") testhelpers.Assert(t, detachVolumeResponse.Server.Volumes != nil, "Should have volumes in response") testhelpers.Assert(t, len(detachVolumeResponse.Server.Volumes) == 0, "Server should have zero volumes after detaching") attachVolumeResponse, err := instanceAPI.AttachVolume(&AttachVolumeRequest{ Zone: zone, ServerID: serverID, VolumeID: volumeID, }) testhelpers.AssertNoError(t, err) testhelpers.Assert(t, attachVolumeResponse.Server != nil, "Should have server in response") testhelpers.Assert(t, attachVolumeResponse.Server.Volumes != nil, "Should have volumes in response") testhelpers.Assert(t, len(attachVolumeResponse.Server.Volumes) == 1, "Server should have one volumes after attaching") testhelpers.Equals(t, volumeID, attachVolumeResponse.Server.Volumes["0"].ID) attachVolumeResponse, err = instanceAPI.AttachVolume(&AttachVolumeRequest{ Zone: zone, ServerID: serverID, VolumeID: volumeID2, }) testhelpers.AssertNoError(t, err) testhelpers.Assert(t, attachVolumeResponse.Server != nil, "Should have server in response") testhelpers.Assert(t, attachVolumeResponse.Server.Volumes != nil, "Should have volumes in response") testhelpers.Assert(t, len(attachVolumeResponse.Server.Volumes) == 2, "Server should have two volumes after attaching second volume") testhelpers.Equals(t, volumeID2, attachVolumeResponse.Server.Volumes["1"].ID) }) t.Run("teardown: delete server and volume", func(t *testing.T) { // Delete Server err = instanceAPI.DeleteServer(&DeleteServerRequest{ Zone: zone, ServerID: serverID, }) testhelpers.AssertNoError(t, err) volumeStatusAvailable := block.VolumeStatusAvailable _, err = blockAPI.WaitForVolumeAndReferences(&block.WaitForVolumeAndReferencesRequest{ VolumeID: volumeID, Zone: zone, VolumeTerminalStatus: &volumeStatusAvailable, }) testhelpers.AssertNoError(t, err) // Delete Volume err = blockAPI.DeleteVolume(&block.DeleteVolumeRequest{ Zone: zone, VolumeID: volumeID, }) testhelpers.AssertNoError(t, err) _, err = blockAPI.WaitForVolumeAndReferences(&block.WaitForVolumeAndReferencesRequest{ VolumeID: volumeID2, Zone: zone, VolumeTerminalStatus: &volumeStatusAvailable, }) testhelpers.AssertNoError(t, err) // Delete Volume err = blockAPI.DeleteVolume(&block.DeleteVolumeRequest{ Zone: zone, VolumeID: volumeID2, }) testhelpers.AssertNoError(t, err) }) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/security_group_utils_test.go000066400000000000000000000201451456366605600330540ustar00rootroot00000000000000package instance import ( "net" "testing" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers/httprecorder" "github.com/scaleway/scaleway-sdk-go/scw" ) func TestAPI_UpdateSecurityGroup(t *testing.T) { client, r, err := httprecorder.CreateRecordedScwClient("security-group-test") testhelpers.AssertNoError(t, err) defer func() { testhelpers.AssertNoError(t, r.Stop()) // Make sure recorder is stopped once done with it }() instanceAPI := NewAPI(client) createResponse, err := instanceAPI.CreateSecurityGroup(&CreateSecurityGroupRequest{ Name: "name", Description: "description", Stateful: true, InboundDefaultPolicy: SecurityGroupPolicyAccept, OutboundDefaultPolicy: SecurityGroupPolicyDrop, }) testhelpers.AssertNoError(t, err) accept := SecurityGroupPolicyAccept drop := SecurityGroupPolicyDrop updateResponse, err := instanceAPI.UpdateSecurityGroup(&UpdateSecurityGroupRequest{ SecurityGroupID: createResponse.SecurityGroup.ID, Name: scw.StringPtr("new_name"), Description: scw.StringPtr("new_description"), Stateful: scw.BoolPtr(false), InboundDefaultPolicy: drop, OutboundDefaultPolicy: accept, // Keep false here, switch it to true is too dangerous for the one who update the test cassette. ProjectDefault: scw.BoolPtr(false), Tags: scw.StringsPtr([]string{"foo", "bar"}), }) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, "new_name", updateResponse.SecurityGroup.Name) testhelpers.Equals(t, "new_description", updateResponse.SecurityGroup.Description) testhelpers.Equals(t, SecurityGroupPolicyDrop, updateResponse.SecurityGroup.InboundDefaultPolicy) testhelpers.Equals(t, SecurityGroupPolicyAccept, updateResponse.SecurityGroup.OutboundDefaultPolicy) testhelpers.Equals(t, false, updateResponse.SecurityGroup.Stateful) testhelpers.Equals(t, false, updateResponse.SecurityGroup.ProjectDefault) testhelpers.Equals(t, false, *updateResponse.SecurityGroup.OrganizationDefault) testhelpers.Equals(t, []string{"foo", "bar"}, updateResponse.SecurityGroup.Tags) err = instanceAPI.DeleteSecurityGroup(&DeleteSecurityGroupRequest{ SecurityGroupID: createResponse.SecurityGroup.ID, }) testhelpers.AssertNoError(t, err) } func TestAPI_UpdateSecurityGroupRule(t *testing.T) { client, r, err := httprecorder.CreateRecordedScwClient("security-group-rule-test") testhelpers.AssertNoError(t, err) defer func() { testhelpers.AssertNoError(t, r.Stop()) // Make sure recorder is stopped once done with it }() instanceAPI := NewAPI(client) bootstrap := func(t *testing.T) (*SecurityGroup, *SecurityGroupRule, func()) { createSecurityGroupResponse, err := instanceAPI.CreateSecurityGroup(&CreateSecurityGroupRequest{ Name: "name", Description: "description", Stateful: true, InboundDefaultPolicy: SecurityGroupPolicyAccept, OutboundDefaultPolicy: SecurityGroupPolicyDrop, }) testhelpers.AssertNoError(t, err) _, ipNet, _ := net.ParseCIDR("8.8.8.8/32") createRuleResponse, err := instanceAPI.CreateSecurityGroupRule(&CreateSecurityGroupRuleRequest{ SecurityGroupID: createSecurityGroupResponse.SecurityGroup.ID, Direction: SecurityGroupRuleDirectionInbound, Protocol: SecurityGroupRuleProtocolTCP, DestPortFrom: scw.Uint32Ptr(1), DestPortTo: scw.Uint32Ptr(1024), IPRange: scw.IPNet{IPNet: *ipNet}, Action: SecurityGroupRuleActionAccept, Position: 1, }) testhelpers.AssertNoError(t, err) return createSecurityGroupResponse.SecurityGroup, createRuleResponse.Rule, func() { err = instanceAPI.DeleteSecurityGroup(&DeleteSecurityGroupRequest{ SecurityGroupID: createSecurityGroupResponse.SecurityGroup.ID, }) testhelpers.AssertNoError(t, err) } } t.Run("Simple update", func(t *testing.T) { group, rule, cleanUp := bootstrap(t) defer cleanUp() _, ipNet, _ := net.ParseCIDR("1.1.1.1/32") updateResponse, err := instanceAPI.UpdateSecurityGroupRule(&UpdateSecurityGroupRuleRequest{ SecurityGroupID: group.ID, SecurityGroupRuleID: rule.ID, Action: SecurityGroupRuleActionDrop, IPRange: &scw.IPNet{IPNet: *ipNet}, DestPortFrom: scw.Uint32Ptr(1), DestPortTo: scw.Uint32Ptr(2048), Protocol: SecurityGroupRuleProtocolUDP, Direction: SecurityGroupRuleDirectionOutbound, }) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, SecurityGroupRuleActionDrop, updateResponse.Rule.Action) testhelpers.Equals(t, scw.IPNet{IPNet: net.IPNet{IP: net.IPv4(0x1, 0x1, 0x1, 0x1), Mask: net.IPMask{0xff, 0xff, 0xff, 0xff}}}, updateResponse.Rule.IPRange) testhelpers.Equals(t, scw.Uint32Ptr(1), updateResponse.Rule.DestPortFrom) testhelpers.Equals(t, scw.Uint32Ptr(2048), updateResponse.Rule.DestPortTo) testhelpers.Equals(t, SecurityGroupRuleProtocolUDP, updateResponse.Rule.Protocol) testhelpers.Equals(t, SecurityGroupRuleDirectionOutbound, updateResponse.Rule.Direction) }) t.Run("From a port range to a single port", func(t *testing.T) { group, rule, cleanUp := bootstrap(t) defer cleanUp() _, ipNet, _ := net.ParseCIDR("1.1.1.1/32") updateResponse, err := instanceAPI.UpdateSecurityGroupRule(&UpdateSecurityGroupRuleRequest{ SecurityGroupID: group.ID, SecurityGroupRuleID: rule.ID, Action: SecurityGroupRuleActionDrop, IPRange: &scw.IPNet{IPNet: *ipNet}, DestPortFrom: scw.Uint32Ptr(22), DestPortTo: scw.Uint32Ptr(22), Protocol: SecurityGroupRuleProtocolUDP, Direction: SecurityGroupRuleDirectionOutbound, }) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, SecurityGroupRuleActionDrop, updateResponse.Rule.Action) testhelpers.Equals(t, scw.IPNet{IPNet: net.IPNet{IP: net.IPv4(0x1, 0x1, 0x1, 0x1), Mask: net.IPMask{0xff, 0xff, 0xff, 0xff}}}, updateResponse.Rule.IPRange) testhelpers.Equals(t, uint32(22), *updateResponse.Rule.DestPortFrom) testhelpers.Equals(t, (*uint32)(nil), updateResponse.Rule.DestPortTo) testhelpers.Equals(t, SecurityGroupRuleProtocolUDP, updateResponse.Rule.Protocol) testhelpers.Equals(t, SecurityGroupRuleDirectionOutbound, updateResponse.Rule.Direction) }) t.Run("Switching to ICMP", func(t *testing.T) { group, rule, cleanUp := bootstrap(t) defer cleanUp() updateResponse, err := instanceAPI.UpdateSecurityGroupRule(&UpdateSecurityGroupRuleRequest{ SecurityGroupID: group.ID, SecurityGroupRuleID: rule.ID, Protocol: SecurityGroupRuleProtocolICMP, }) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, SecurityGroupRuleActionAccept, updateResponse.Rule.Action) testhelpers.Equals(t, scw.IPNet{IPNet: net.IPNet{IP: net.IPv4(0x8, 0x8, 0x8, 0x8), Mask: net.IPMask{0xff, 0xff, 0xff, 0xff}}}, updateResponse.Rule.IPRange) testhelpers.Equals(t, (*uint32)(nil), updateResponse.Rule.DestPortFrom) testhelpers.Equals(t, (*uint32)(nil), updateResponse.Rule.DestPortTo) testhelpers.Equals(t, SecurityGroupRuleProtocolICMP, updateResponse.Rule.Protocol) testhelpers.Equals(t, SecurityGroupRuleDirectionInbound, updateResponse.Rule.Direction) }) t.Run("Remove ports", func(t *testing.T) { group, rule, cleanUp := bootstrap(t) defer cleanUp() updateResponse, err := instanceAPI.UpdateSecurityGroupRule(&UpdateSecurityGroupRuleRequest{ SecurityGroupID: group.ID, SecurityGroupRuleID: rule.ID, DestPortFrom: scw.Uint32Ptr(0), DestPortTo: scw.Uint32Ptr(0), }) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, SecurityGroupRuleActionAccept, updateResponse.Rule.Action) testhelpers.Equals(t, scw.IPNet{IPNet: net.IPNet{IP: net.IPv4(0x8, 0x8, 0x8, 0x8), Mask: net.IPMask{0xff, 0xff, 0xff, 0xff}}}, updateResponse.Rule.IPRange) testhelpers.Equals(t, (*uint32)(nil), updateResponse.Rule.DestPortFrom) testhelpers.Equals(t, (*uint32)(nil), updateResponse.Rule.DestPortTo) testhelpers.Equals(t, SecurityGroupRuleProtocolTCP, updateResponse.Rule.Protocol) testhelpers.Equals(t, SecurityGroupRuleDirectionInbound, updateResponse.Rule.Direction) }) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/server_utils.go000066400000000000000000000250161456366605600302420ustar00rootroot00000000000000package instance import ( "bytes" "fmt" "io" "net/http" "time" "github.com/scaleway/scaleway-sdk-go/api/marketplace/v1" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" "github.com/scaleway/scaleway-sdk-go/validation" ) const ( defaultTimeout = 5 * time.Minute defaultRetryInterval = 5 * time.Second ) // CreateServer creates a server. func (s *API) CreateServer(req *CreateServerRequest, opts ...scw.RequestOption) (*CreateServerResponse, error) { // If image is not a UUID we try to fetch it from marketplace. if req.Image != "" && !validation.IsUUID(req.Image) { apiMarketplace := marketplace.NewAPI(s.client) imageID, err := apiMarketplace.GetLocalImageIDByLabel(&marketplace.GetLocalImageIDByLabelRequest{ ImageLabel: req.Image, Zone: req.Zone, CommercialType: req.CommercialType, }) if err != nil { return nil, err } req.Image = imageID } return s.createServer(req, opts...) } // UpdateServer updates a server. // // Note: Implementation is thread-safe. func (s *API) UpdateServer(req *UpdateServerRequest, opts ...scw.RequestOption) (*UpdateServerResponse, error) { defer lockServer(req.Zone, req.ServerID).Unlock() return s.updateServer(req, opts...) } // WaitForServerRequest is used by WaitForServer method. type WaitForServerRequest struct { ServerID string Zone scw.Zone Timeout *time.Duration RetryInterval *time.Duration } // WaitForServer wait for the server to be in a "terminal state" before returning. // This function can be used to wait for a server to be started for example. func (s *API) WaitForServer(req *WaitForServerRequest, opts ...scw.RequestOption) (*Server, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[ServerState]struct{}{ ServerStateStopped: {}, ServerStateStoppedInPlace: {}, ServerStateLocked: {}, ServerStateRunning: {}, } server, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetServer(&GetServerRequest{ ServerID: req.ServerID, Zone: req.Zone, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.Server.State] return res.Server, isTerminal, err }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for server failed") } return server.(*Server), nil } // ServerActionAndWaitRequest is used by ServerActionAndWait method. type ServerActionAndWaitRequest struct { ServerID string Zone scw.Zone Action ServerAction // Timeout: maximum time to wait before (default: 5 minutes) Timeout *time.Duration RetryInterval *time.Duration } // ServerActionAndWait start an action and wait for the server to be in the correct "terminal state" // expected by this action. func (s *API) ServerActionAndWait(req *ServerActionAndWaitRequest, opts ...scw.RequestOption) error { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } _, err := s.ServerAction(&ServerActionRequest{ Zone: req.Zone, ServerID: req.ServerID, Action: req.Action, }, opts...) if err != nil { return err } finalServer, err := s.WaitForServer(&WaitForServerRequest{ Zone: req.Zone, ServerID: req.ServerID, Timeout: &timeout, RetryInterval: &retryInterval, }, opts...) if err != nil { return err } // check the action was properly executed expectedState := ServerState("unknown") switch req.Action { case ServerActionPoweron, ServerActionReboot: expectedState = ServerStateRunning case ServerActionPoweroff: expectedState = ServerStateStopped case ServerActionStopInPlace: expectedState = ServerStateStoppedInPlace } // backup can be performed from any state if expectedState != ServerState("unknown") && finalServer.State != expectedState { return errors.New("expected state %s but found %s: %s", expectedState, finalServer.State, finalServer.StateDetail) } return nil } // GetServerTypeRequest is used by GetServerType. type GetServerTypeRequest struct { Zone scw.Zone Name string } // GetServerType get server type info by it's name. func (s *API) GetServerType(req *GetServerTypeRequest) (*ServerType, error) { res, err := s.ListServersTypes(&ListServersTypesRequest{ Zone: req.Zone, }, scw.WithAllPages()) if err != nil { return nil, err } if serverType, exist := res.Servers[req.Name]; exist { return serverType, nil } return nil, errors.New("could not find server type %q", req.Name) } // GetServerUserDataRequest is used by GetServerUserData method. type GetServerUserDataRequest struct { Zone scw.Zone `json:"-"` ServerID string `json:"-"` // Key defines the user data key to get. Key string `json:"-"` } // GetServerUserData gets the content of a user data on a server for the given key. func (s *API) GetServerUserData(req *GetServerUserDataRequest, opts ...scw.RequestOption) (io.Reader, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } if fmt.Sprint(req.Key) == "" { return nil, errors.New("field Key cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/user_data/" + fmt.Sprint(req.Key), Headers: http.Header{}, } res := &bytes.Buffer{} err = s.client.Do(scwReq, res, opts...) if err != nil { return nil, err } return res, nil } // SetServerUserDataRequest is used by SetServerUserData method. type SetServerUserDataRequest struct { Zone scw.Zone `json:"-"` ServerID string `json:"-"` // Key defines the user data key to set. Key string `json:"-"` // Content defines the data to set. Content io.Reader } // SetServerUserData sets the content of a user data on a server for the given key. func (s *API) SetServerUserData(req *SetServerUserDataRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return errors.New("field ServerID cannot be empty in request") } if fmt.Sprint(req.Key) == "" { return errors.New("field Key cannot be empty in request") } if req.Content == nil { return errors.New("field Content cannot be nil in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/instance/v1/zones/" + fmt.Sprint(req.Zone) + "/servers/" + fmt.Sprint(req.ServerID) + "/user_data/" + fmt.Sprint(req.Key), Headers: http.Header{}, } err = scwReq.SetBody(req.Content) if err != nil { return err } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // GetAllServerUserDataRequest is used by GetAllServerUserData method. type GetAllServerUserDataRequest struct { Zone scw.Zone `json:"-"` ServerID string `json:"-"` } // GetAllServerUserDataResponse is used by GetAllServerUserData method. type GetAllServerUserDataResponse struct { UserData map[string]io.Reader `json:"-"` } // GetAllServerUserData gets all user data on a server. func (s *API) GetAllServerUserData(req *GetAllServerUserDataRequest, opts ...scw.RequestOption) (*GetAllServerUserDataResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return nil, errors.New("field ServerID cannot be empty in request") } // get all user data keys allUserDataRes, err := s.ListServerUserData(&ListServerUserDataRequest{ Zone: req.Zone, ServerID: req.ServerID, }) if err != nil { return nil, err } res := &GetAllServerUserDataResponse{ UserData: make(map[string]io.Reader, len(allUserDataRes.UserData)), } // build a map with all user data for _, key := range allUserDataRes.UserData { value, err := s.GetServerUserData(&GetServerUserDataRequest{ Zone: req.Zone, ServerID: req.ServerID, Key: key, }) if err != nil { return nil, err } res.UserData[key] = value } return res, nil } // SetAllServerUserDataRequest is used by SetAllServerUserData method. type SetAllServerUserDataRequest struct { Zone scw.Zone `json:"-"` ServerID string `json:"-"` // UserData defines all user data that will be set to the server. // This map is idempotent, it means that all the current data will be overwritten and // all keys not present in this map will be deleted.. All data will be removed if this map is nil. UserData map[string]io.Reader `json:"-"` } // SetAllServerUserData sets all user data on a server, it deletes every keys previously set. func (s *API) SetAllServerUserData(req *SetAllServerUserDataRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ServerID) == "" { return errors.New("field ServerID cannot be empty in request") } // get all current user data keys allUserDataRes, err := s.ListServerUserData(&ListServerUserDataRequest{ Zone: req.Zone, ServerID: req.ServerID, }) if err != nil { return err } // delete all current user data for _, key := range allUserDataRes.UserData { _, exist := req.UserData[key] if exist { continue } err := s.DeleteServerUserData(&DeleteServerUserDataRequest{ Zone: req.Zone, ServerID: req.ServerID, Key: key, }) if err != nil { return err } } // set all new user data for key, value := range req.UserData { err := s.SetServerUserData(&SetServerUserDataRequest{ Zone: req.Zone, ServerID: req.ServerID, Key: key, Content: value, }) if err != nil { return err } } return nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/server_utils_test.go000066400000000000000000000115621456366605600313020ustar00rootroot00000000000000package instance import ( "bytes" "io" "io/ioutil" "strings" "testing" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers/httprecorder" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) func TestAPI_GetServerType(t *testing.T) { client, r, err := httprecorder.CreateRecordedScwClient("get-server-type") testhelpers.AssertNoError(t, err) defer func() { testhelpers.AssertNoError(t, r.Stop()) // Make sure recorder is stopped once done with it }() instanceAPI := NewAPI(client) serverType, err := instanceAPI.GetServerType(&GetServerTypeRequest{ Zone: scw.ZoneFrPar1, Name: "GP1-XS", }) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, 1*scw.GB, serverType.PerVolumeConstraint.LSSD.MinSize) testhelpers.Equals(t, 800*scw.GB, serverType.PerVolumeConstraint.LSSD.MaxSize) } func TestAPI_ServerUserData(t *testing.T) { client, r, err := httprecorder.CreateRecordedScwClient("server-user-data") testhelpers.AssertNoError(t, err) defer func() { testhelpers.AssertNoError(t, r.Stop()) // Make sure recorder is stopped once done with it }() instanceAPI := NewAPI(client) key := "hello" contentStr := "world" serverRes, err := instanceAPI.CreateServer(&CreateServerRequest{ Zone: scw.ZoneFrPar1, CommercialType: "DEV1-S", Name: namegenerator.GetRandomName("srv"), Image: "f974feac-abae-4365-b988-8ec7d1cec10d", Project: scw.StringPtr("14d2f7ae-9775-414c-9bed-6810e060d500"), }) testhelpers.AssertNoError(t, err) content := strings.NewReader(contentStr) err = instanceAPI.SetServerUserData(&SetServerUserDataRequest{ Zone: scw.ZoneFrPar1, ServerID: serverRes.Server.ID, Key: key, Content: content, }) testhelpers.AssertNoError(t, err) data, err := instanceAPI.GetServerUserData(&GetServerUserDataRequest{ Zone: scw.ZoneFrPar1, ServerID: serverRes.Server.ID, Key: key, }) testhelpers.AssertNoError(t, err) resUserData, err := ioutil.ReadAll(data) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, contentStr, string(resUserData)) } func TestAPI_AllServerUserData(t *testing.T) { client, r, err := httprecorder.CreateRecordedScwClient("all-server-user-data") testhelpers.AssertNoError(t, err) defer func() { testhelpers.AssertNoError(t, r.Stop()) // Make sure recorder is stopped once done with it }() instanceAPI := NewAPI(client) serverRes, err := instanceAPI.CreateServer(&CreateServerRequest{ Zone: scw.ZoneFrPar1, CommercialType: "DEV1-S", Name: namegenerator.GetRandomName("srv"), Image: "f974feac-abae-4365-b988-8ec7d1cec10d", Project: scw.StringPtr("14d2f7ae-9775-414c-9bed-6810e060d500"), }) testhelpers.AssertNoError(t, err) steps := []map[string]string{ { "hello": "world", "scale": "way", "xavier": "niel", "tic": "tac", "cloud-init": "on", }, { "xavier": "niel", "scale": "way", "steve": "wozniak", "cloud-init": "off", }, {}, } for _, data := range steps { // create user data userData := make(map[string]io.Reader, len(data)) for k, v := range data { userData[k] = bytes.NewBufferString(v) } // set all user data err := instanceAPI.SetAllServerUserData(&SetAllServerUserDataRequest{ Zone: scw.ZoneFrPar1, ServerID: serverRes.Server.ID, UserData: userData, }) testhelpers.AssertNoError(t, err) // get all user data allData, err := instanceAPI.GetAllServerUserData(&GetAllServerUserDataRequest{ Zone: scw.ZoneFrPar1, ServerID: serverRes.Server.ID, }) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, len(data), len(allData.UserData)) for expectedKey, expectedValue := range data { currentReader, exists := allData.UserData[expectedKey] testhelpers.Assert(t, exists, "%s key not found in result", expectedKey) currentValue, err := ioutil.ReadAll(currentReader) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, expectedValue, string(currentValue)) } } } func TestAPI_CreateServer(t *testing.T) { client, r, err := httprecorder.CreateRecordedScwClient("create-server") testhelpers.AssertNoError(t, err) defer func() { testhelpers.AssertNoError(t, r.Stop()) // Make sure recorder is stopped once done with it }() instanceAPI := NewAPI(client) res, err := instanceAPI.CreateServer(&CreateServerRequest{ Zone: scw.ZoneFrPar1, CommercialType: "GP1-XS", Image: "ubuntu_focal", }) testhelpers.AssertNoError(t, err) // this UUID might change when running the cassette later when the image "ubuntu_focal" got a new version testhelpers.Equals(t, "365a8b9c-0c6e-4875-a887-dc3213db9e20", res.Server.Image.ID) err = instanceAPI.DeleteServer(&DeleteServerRequest{ Zone: scw.ZoneFrPar1, ServerID: res.Server.ID, }) testhelpers.AssertNoError(t, err) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/snapshot_utils.go000066400000000000000000000027071456366605600305750ustar00rootroot00000000000000package instance import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) // WaitForImageRequest is used by WaitForImage method. type WaitForSnapshotRequest struct { SnapshotID string Zone scw.Zone Timeout *time.Duration RetryInterval *time.Duration } // WaitForSnapshot wait for the snapshot to be in a "terminal state" before returning. func (s *API) WaitForSnapshot(req *WaitForSnapshotRequest, opts ...scw.RequestOption) (*Snapshot, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[SnapshotState]struct{}{ SnapshotStateAvailable: {}, SnapshotStateError: {}, } snapshot, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetSnapshot(&GetSnapshotRequest{ SnapshotID: req.SnapshotID, Zone: req.Zone, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.Snapshot.State] return res.Snapshot, isTerminal, err }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for snapshot failed") } return snapshot.(*Snapshot), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/snapshot_utils_test.go000066400000000000000000000065631456366605600316400ustar00rootroot00000000000000package instance import ( "testing" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers/httprecorder" "github.com/scaleway/scaleway-sdk-go/scw" ) func TestWaitForSnapshot(t *testing.T) { client, r, err := httprecorder.CreateRecordedScwClient("snapshot-wait-test") testhelpers.AssertNoError(t, err) defer func() { testhelpers.AssertNoError(t, r.Stop()) // Make sure recorder is stopped once done with it }() instanceAPI := NewAPI(client) snapshotName := "backup" snapshot, cleanup := createSnapshot(t, instanceAPI, snapshotName) defer cleanup() res, err := instanceAPI.WaitForSnapshot(&WaitForSnapshotRequest{ SnapshotID: snapshot.ID, }) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, snapshot.ID, res.ID) testhelpers.Equals(t, SnapshotStateAvailable, res.State) testhelpers.Equals(t, snapshotName, res.Name) } // createSnapshot is a helper that create an snapshot. // It returns the newly created snapshot and a cleanup function func createSnapshot(t *testing.T, instanceAPI *API, snapshotName string) (*Snapshot, func()) { serverRes, err := instanceAPI.CreateServer(&CreateServerRequest{ CommercialType: "DEV1-M", Image: "ubuntu_focal", }) testhelpers.AssertNoError(t, err) // Backup will create a snapshot for each volume + an image base on all snapshots. snapshot, err := instanceAPI.CreateSnapshot(&CreateSnapshotRequest{ Name: snapshotName, VolumeID: &serverRes.Server.Volumes["0"].ID, }) testhelpers.AssertNoError(t, err) snapshotRes, err := instanceAPI.GetSnapshot(&GetSnapshotRequest{ SnapshotID: snapshot.Snapshot.ID, }) testhelpers.AssertNoError(t, err) return snapshotRes.Snapshot, func() { // Delete all created resources err := instanceAPI.DeleteServer(&DeleteServerRequest{ ServerID: serverRes.Server.ID, }) testhelpers.AssertNoError(t, err) err = instanceAPI.DeleteSnapshot(&DeleteSnapshotRequest{ SnapshotID: snapshotRes.Snapshot.ID, }) testhelpers.AssertNoError(t, err) } } func TestAPI_UpdateSnapshot(t *testing.T) { client, r, err := httprecorder.CreateRecordedScwClient("snapshot-test") testhelpers.AssertNoError(t, err) defer func() { testhelpers.AssertNoError(t, r.Stop()) // Make sure recorder is stopped once done with it }() instanceAPI := NewAPI(client) var ( volumeSize = 1 * scw.GB ) createVolume, err := instanceAPI.CreateVolume(&CreateVolumeRequest{ Name: "volume_name", VolumeType: VolumeVolumeTypeBSSD, Size: &volumeSize, }) testhelpers.AssertNoError(t, err) createResponse, err := instanceAPI.CreateSnapshot(&CreateSnapshotRequest{ Name: "name", VolumeID: &createVolume.Volume.ID, }) testhelpers.AssertNoError(t, err) updateResponse, err := instanceAPI.UpdateSnapshot(&UpdateSnapshotRequest{ SnapshotID: createResponse.Snapshot.ID, Name: scw.StringPtr("new_name"), Tags: scw.StringsPtr([]string{"foo", "bar"}), }) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, "new_name", updateResponse.Snapshot.Name) testhelpers.Equals(t, []string{"foo", "bar"}, updateResponse.Snapshot.Tags) _, err = instanceAPI.WaitForSnapshot(&WaitForSnapshotRequest{ SnapshotID: createResponse.Snapshot.ID, }) testhelpers.AssertNoError(t, err) err = instanceAPI.DeleteSnapshot(&DeleteSnapshotRequest{ SnapshotID: createResponse.Snapshot.ID, }) testhelpers.AssertNoError(t, err) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/testdata/000077500000000000000000000000001456366605600267725ustar00rootroot00000000000000all-server-user-data.yaml000066400000000000000000000716671456366605600335570ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/testdata--- version: 1 interactions: - request: body: '{"name":"srv-hardcore-raman","commercial_type":"DEV1-S","image":"f974feac-abae-4365-b988-8ec7d1cec10d","organization":"14d2f7ae-9775-414c-9bed-6810e060d500"}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers method: POST response: body: '{"server": {"allowed_actions": ["poweron", "backup"], "maintenances": [], "state_detail": "", "image": {"creation_date": "2019-03-05T10:13:15.974944+00:00", "default_bootscript": {"kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "default": false, "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "architecture": "x86_64", "title": "x86_64 mainline 4.9.93 rev1", "dtb": "", "organization": "11111111-1111-4111-8111-111111111111", "id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", "public": false}, "from_server": null, "arch": "x86_64", "id": "f974feac-abae-4365-b988-8ec7d1cec10d", "root_volume": {"size": 10000000000, "id": "dd5f5c10-23b1-4c9c-8445-eb6740957c84", "volume_type": "l_ssd", "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13"}, "name": "Ubuntu Bionic Beaver", "modification_date": "2019-03-05T13:32:29.274319+00:00", "state": "available", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "extra_volumes": {}, "public": true}, "creation_date": "2019-06-24T17:26:47.674533+00:00", "public_ip": null, "private_ip": null, "id": "b2266f9f-d089-41be-84b7-0bd9690fc505", "dynamic_ip_required": true, "modification_date": "2019-06-24T17:26:47.987175+00:00", "enable_ipv6": false, "hostname": "srv-hardcore-raman", "state": "stopped", "bootscript": {"kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "default": false, "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "architecture": "x86_64", "title": "x86_64 mainline 4.9.93 rev1", "dtb": "", "organization": "11111111-1111-4111-8111-111111111111", "id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", "public": false}, "location": null, "boot_type": "local", "ipv6": null, "commercial_type": "DEV1-S", "tags": [], "arch": "x86_64", "extra_networks": [], "compute_cluster": null, "name": "srv-hardcore-raman", "protected": false, "volumes": {"0": {"size": 20000000000, "state": "available", "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", "modification_date": "2019-06-24T17:26:47.901572+00:00", "organization": "14d2f7ae-9775-414c-9bed-6810e060d500", "export_uri": null, "creation_date": "2019-06-24T17:26:47.674533+00:00", "id": "29d7d72b-f566-4282-bb60-ab604028e3f6", "volume_type": "l_ssd", "server": {"id": "b2266f9f-d089-41be-84b7-0bd9690fc505", "name": "srv-hardcore-raman"}}}, "security_group": {"id": "e5bf4522-94b4-4933-bebb-9b21f786b4af", "name": "Default security group"}, "organization": "14d2f7ae-9775-414c-9bed-6810e060d500"}}' headers: Cache-Control: - no-cache Content-Length: - "2706" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 24 Jun 2019 17:26:47 GMT Location: - https://cp-par1.scaleway.com/servers/b2266f9f-d089-41be-84b7-0bd9690fc505 Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 201 Created code: 201 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data method: GET response: body: '{"user_data": []}' headers: Cache-Control: - no-cache Content-Length: - "17" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 24 Jun 2019 17:26:47 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 200 OK code: 200 duration: "" - request: body: way form: {} headers: Content-Type: - text/plain User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/scale method: PATCH response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - text/plain Date: - Mon, 24 Jun 2019 17:26:48 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 204 No Content code: 204 duration: "" - request: body: niel form: {} headers: Content-Type: - text/plain User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/xavier method: PATCH response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - text/plain Date: - Mon, 24 Jun 2019 17:26:48 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 204 No Content code: 204 duration: "" - request: body: tac form: {} headers: Content-Type: - text/plain User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/tic method: PATCH response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - text/plain Date: - Mon, 24 Jun 2019 17:26:48 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 204 No Content code: 204 duration: "" - request: body: "on" form: {} headers: Content-Type: - text/plain User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/cloud-init method: PATCH response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - text/plain Date: - Mon, 24 Jun 2019 17:26:48 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 204 No Content code: 204 duration: "" - request: body: world form: {} headers: Content-Type: - text/plain User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/hello method: PATCH response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - text/plain Date: - Mon, 24 Jun 2019 17:26:48 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 204 No Content code: 204 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data method: GET response: body: '{"user_data": ["cloud-init", "hello", "scale", "tic", "xavier"]}' headers: Cache-Control: - no-cache Content-Length: - "64" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 24 Jun 2019 17:26:48 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/cloud-init method: GET response: body: "on" headers: Cache-Control: - no-cache Content-Length: - "2" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - text/plain Date: - Mon, 24 Jun 2019 17:26:48 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/hello method: GET response: body: world headers: Cache-Control: - no-cache Content-Length: - "5" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - text/plain Date: - Mon, 24 Jun 2019 17:26:48 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/scale method: GET response: body: way headers: Cache-Control: - no-cache Content-Length: - "3" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - text/plain Date: - Mon, 24 Jun 2019 17:26:48 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/tic method: GET response: body: tac headers: Cache-Control: - no-cache Content-Length: - "3" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - text/plain Date: - Mon, 24 Jun 2019 17:26:48 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/xavier method: GET response: body: niel headers: Cache-Control: - no-cache Content-Length: - "4" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - text/plain Date: - Mon, 24 Jun 2019 17:26:48 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data method: GET response: body: '{"user_data": ["cloud-init", "hello", "scale", "tic", "xavier"]}' headers: Cache-Control: - no-cache Content-Length: - "64" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 24 Jun 2019 17:26:48 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/cloud-init method: DELETE response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 24 Jun 2019 17:26:48 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 204 No Content code: 204 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/hello method: DELETE response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 24 Jun 2019 17:26:48 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 204 No Content code: 204 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/scale method: DELETE response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 24 Jun 2019 17:26:49 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 204 No Content code: 204 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/tic method: DELETE response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 24 Jun 2019 17:26:49 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 204 No Content code: 204 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/xavier method: DELETE response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 24 Jun 2019 17:26:49 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 204 No Content code: 204 duration: "" - request: body: wozniak form: {} headers: Content-Type: - text/plain User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/steve method: PATCH response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - text/plain Date: - Mon, 24 Jun 2019 17:26:49 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 204 No Content code: 204 duration: "" - request: body: "off" form: {} headers: Content-Type: - text/plain User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/cloud-init method: PATCH response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - text/plain Date: - Mon, 24 Jun 2019 17:26:49 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 204 No Content code: 204 duration: "" - request: body: niel form: {} headers: Content-Type: - text/plain User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/xavier method: PATCH response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - text/plain Date: - Mon, 24 Jun 2019 17:26:49 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 204 No Content code: 204 duration: "" - request: body: way form: {} headers: Content-Type: - text/plain User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/scale method: PATCH response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - text/plain Date: - Mon, 24 Jun 2019 17:26:49 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 204 No Content code: 204 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data method: GET response: body: '{"user_data": ["cloud-init", "scale", "steve", "xavier"]}' headers: Cache-Control: - no-cache Content-Length: - "57" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 24 Jun 2019 17:26:49 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/cloud-init method: GET response: body: "off" headers: Cache-Control: - no-cache Content-Length: - "3" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - text/plain Date: - Mon, 24 Jun 2019 17:26:49 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/scale method: GET response: body: way headers: Cache-Control: - no-cache Content-Length: - "3" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - text/plain Date: - Mon, 24 Jun 2019 17:26:49 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/steve method: GET response: body: wozniak headers: Cache-Control: - no-cache Content-Length: - "7" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - text/plain Date: - Mon, 24 Jun 2019 17:26:49 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/xavier method: GET response: body: niel headers: Cache-Control: - no-cache Content-Length: - "4" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - text/plain Date: - Mon, 24 Jun 2019 17:26:49 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data method: GET response: body: '{"user_data": ["cloud-init", "scale", "steve", "xavier"]}' headers: Cache-Control: - no-cache Content-Length: - "57" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 24 Jun 2019 17:26:49 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/cloud-init method: DELETE response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 24 Jun 2019 17:26:50 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 204 No Content code: 204 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/scale method: DELETE response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 24 Jun 2019 17:26:50 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 204 No Content code: 204 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/steve method: DELETE response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 24 Jun 2019 17:26:50 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 204 No Content code: 204 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data/xavier method: DELETE response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 24 Jun 2019 17:26:50 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 204 No Content code: 204 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/b2266f9f-d089-41be-84b7-0bd9690fc505/user_data method: GET response: body: '{"user_data": []}' headers: Cache-Control: - no-cache Content-Length: - "17" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 24 Jun 2019 17:26:50 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 200 OK code: 200 duration: "" golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/testdata/create-server.yaml000066400000000000000000001732171456366605600324400ustar00rootroot00000000000000--- version: 1 interactions: - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.3; darwin; amd64) url: https://api.scaleway.com/marketplace/v1/images?page=1 method: GET response: body: '{"images": [{"valid_until": null, "description": "Ubuntu is the ideal distribution for scale-out computing, Ubuntu Server helps you make the most of your infrastructure.", "creation_date": "2018-04-27T14:07:25.221998+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "b381b2bf-804a-4b12-91f6-9f4ff273462f", "categories": ["distribution"], "name": "Ubuntu Bionic", "modification_date": "2019-03-26T14:00:51.745705+00:00", "versions": [{"creation_date": "2019-03-05T16:39:34.893732+00:00", "modification_date": "2019-03-05T16:39:34.893732+00:00", "id": "e640c621-305b-45f5-975f-a3f80c1cec66", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f974feac-abae-4365-b988-8ec7d1cec10d", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "f63fe42a-900f-4a5e-ba99-ab0e59469b7e", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "b4bdbee1-e1f1-4436-8de4-bdb1b6ba4803", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "9444d178-2285-4842-ac35-5e86eda8da91", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "a5076337-734f-4b99-95ed-9a5bc73b9b09", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "7663c62b-40e3-4e6b-a835-70723ec2050b", "zone": "ams1"}], "name": "2019-03-05T16:39:34.377275"}], "current_public_version": "e640c621-305b-45f5-975f-a3f80c1cec66", "label": "ubuntu_bionic", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Ubuntu is the ideal distribution for scale-out computing, Ubuntu Server helps you make the most of your infrastructure.", "creation_date": "2016-04-22T13:27:33.769932+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "acf93867-88d9-40ee-99ea-6b2bb1ee8f0c", "categories": ["distribution"], "name": "Ubuntu Xenial", "modification_date": "2020-01-20T09:04:40.661026+00:00", "versions": [{"creation_date": "2020-01-17T14:31:06.041118+00:00", "modification_date": "2020-01-17T14:31:06.041118+00:00", "id": "24cd2ef0-bbc5-4b1a-8b08-99f617eab446", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "3d6804e0-086e-4a06-8124-7240a657668d", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "245e5cea-a9b4-4a36-9055-27185afe8690", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "c40fbabc-efc8-4e04-91ea-5e1e22daece1", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "bd859e89-fb2d-466a-a546-383630a1ead1", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "6c34a3f3-5e8a-455b-9bc2-f07c4c35bf89", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a5f6bb77-3d64-4f7f-abe0-72492b1bc020", "zone": "par1"}], "name": "2020-01-17T14:31:06.031136"}], "current_public_version": "24cd2ef0-bbc5-4b1a-8b08-99f617eab446", "label": "ubuntu_xenial", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Debian is a free, powerful and stable operating system.", "creation_date": "2017-06-26T15:37:13.460764+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/debian.png", "id": "c94b5df7-e698-4ac9-b273-565d18f5f8d2", "categories": ["distribution"], "name": "Debian Stretch", "modification_date": "2020-01-20T09:04:42.765883+00:00", "versions": [{"creation_date": "2020-01-15T11:38:06.396694+00:00", "modification_date": "2020-01-15T11:38:06.396694+00:00", "id": "8342f5d0-46aa-46e7-8a6f-f41188c97fba", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "5f7ab0cd-d10e-49a0-91c8-315ed8a6a1a4", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "d954dc33-c52e-4960-93e1-b69c85d169be", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "22a1bd8d-4498-4800-a8e5-4bc85001176c", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "37938de8-e3be-479a-895d-095158f76212", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "86740237-62fc-4538-9b70-4373942f53d3", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "bd6ba96e-d4c4-41f9-88e2-8dad3e6f085b", "zone": "par1"}], "name": "2020-01-15T11:38:06.390074"}], "current_public_version": "8342f5d0-46aa-46e7-8a6f-f41188c97fba", "label": "debian_stretch", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Debian is a free, powerful and stable operating system.", "creation_date": "2016-03-05T14:52:36.322319+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/debian.png", "id": "fb619bdf-834e-4c71-b7b8-15b5546d18bd", "categories": ["distribution"], "name": "Debian Jessie", "modification_date": "2019-03-26T14:00:50.449502+00:00", "versions": [{"creation_date": "2018-04-10T22:31:04.322822+00:00", "modification_date": "2018-04-10T22:31:04.322822+00:00", "id": "d3846a7b-8219-4938-ad96-cc2173e22481", "local_images": [{"compatible_commercial_types": ["C1"], "arch": "arm", "id": "2dfad6d2-e527-4e93-8eb1-8dc57803b310", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "610f68d5-cbad-4923-98ae-782af8f3b527", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "dc22e553-2d2e-4689-94f8-8817db824202", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "2e570f53-199e-47cc-95dd-f7bc392496e3", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "abf9e3a2-7171-4764-91ef-57f30b21193d", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "69cbdd54-88a1-4458-b75e-662a0848a7ce", "zone": "ams1"}], "name": "2018-04-10T22:31:04.321157"}], "current_public_version": "d3846a7b-8219-4938-ad96-cc2173e22481", "label": "debian_jessie", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "The CentOS Project is a community-driven free software effort focused on delivering a robust open source ecosystem.", "creation_date": "2019-03-06T11:27:48.406290+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/centos.png", "id": "1d47b370-ac63-43b1-9f34-7328675e5e18", "categories": ["distribution"], "name": "CentOS 7.6", "modification_date": "2019-03-26T14:00:50.839069+00:00", "versions": [{"creation_date": "2019-03-18T09:29:00.247544+00:00", "modification_date": "2019-03-18T09:29:00.247544+00:00", "id": "53138072-3099-4566-8b18-de7b2739696a", "local_images": [{"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "05794ee5-c6d2-4d69-86dd-f1fc9032921d", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "0f44b130-2bc7-4f82-993e-de9d1042c56e", "zone": "par1"}], "name": "2019-03-18T09:29:00.168590"}], "current_public_version": "53138072-3099-4566-8b18-de7b2739696a", "label": "centos_7.6", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "The CentOS Project is a community-driven free software effort focused on delivering a robust open source ecosystem.", "creation_date": "2018-04-19T10:12:28.968536+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/centos.png", "id": "98fc244a-ed4c-4523-bd17-b9c4070b8e7e", "categories": ["distribution"], "name": "CentOS 7.4", "modification_date": "2019-03-26T14:00:53.445597+00:00", "versions": [{"creation_date": "2018-04-20T13:55:06.824033+00:00", "modification_date": "2018-04-20T13:55:06.824033+00:00", "id": "31be34e5-074d-4c63-8c77-454459f77c3f", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "ec8b431e-ad39-4523-8b94-f3fa7f3cbd06", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "7220ac63-bac8-484b-9d44-93e3bd01f5a6", "zone": "ams1"}], "name": "2018-04-20T13:55:06.817954"}], "current_public_version": "31be34e5-074d-4c63-8c77-454459f77c3f", "label": "centos_7.4", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Fedora is a powerful, flexible operating system that includes the best and latest datacenter technologies. It puts you in control of all your infrastructure and services.", "creation_date": "2019-03-06T09:07:51.652433+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/fedora.png", "id": "69adec15-f1a7-469a-9ba5-868577832521", "categories": ["distribution"], "name": "Fedora 29", "modification_date": "2019-03-26T14:00:51.848785+00:00", "versions": [{"creation_date": "2019-03-06T09:08:01.112958+00:00", "modification_date": "2019-03-06T09:08:01.112958+00:00", "id": "a0f02365-f1af-48cb-b82d-75853a4e05e1", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "541f4562-5417-4b59-85d6-caaf64c1f127", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "3c0f706e-0947-47a3-88a3-595c29f7567a", "zone": "ams1"}], "name": "2019-03-06T09:08:01.016040"}], "current_public_version": "a0f02365-f1af-48cb-b82d-75853a4e05e1", "label": "fedora_29", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "Fedora is a powerful, flexible operating system that includes the best and latest datacenter technologies. It puts you in control of all your infrastructure and services.", "creation_date": "2018-05-03T09:51:57.274011+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/fedora.png", "id": "30d0f04f-6422-4b74-9ce9-1c2267419978", "categories": ["distribution"], "name": "Fedora 28", "modification_date": "2019-03-26T14:00:50.156015+00:00", "versions": [{"creation_date": "2018-05-03T12:01:10.147973+00:00", "modification_date": "2018-05-03T12:01:10.147973+00:00", "id": "49e33199-28cc-44d6-bb2e-a6147944ad5c", "local_images": [{"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "830aad94-24e5-4363-b2c3-e62921bd9294", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "c9cd1782-2159-44b8-83b1-9c48ed6c8a63", "zone": "par1"}], "name": "2018-05-03T12:01:10.135200"}], "current_public_version": "49e33199-28cc-44d6-bb2e-a6147944ad5c", "label": "fedora_28", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Fedora is a powerful, flexible operating system that includes the best and latest datacenter technologies. It puts you in control of all your infrastructure and services.", "creation_date": "2018-04-19T10:14:08.648100+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/fedora.png", "id": "4bff4f37-3ef9-457e-9e8d-4a786cb2a5f2", "categories": ["distribution"], "name": "Fedora 27", "modification_date": "2019-03-26T14:00:53.140907+00:00", "versions": [{"creation_date": "2018-09-06T10:51:13.009967+00:00", "modification_date": "2018-09-06T10:51:13.009967+00:00", "id": "45b5823f-8ddf-4ea8-b106-33d2df127cdf", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "097a100e-fd2f-4918-8a5b-d86de5a489be", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "73f0bcd8-a152-4665-ac09-1b105905a475", "zone": "ams1"}], "name": "2018-09-06T10:51:13.011044"}], "current_public_version": "45b5823f-8ddf-4ea8-b106-33d2df127cdf", "label": "fedora_27", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Arch Linux is an independently developed Linux distribution versatile enough to suit any role.", "creation_date": "2016-03-07T20:55:32.213089+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/archlinux.png", "id": "8f60c5dd-e659-48da-97e3-fb7de42195f5", "categories": ["distribution"], "name": "Arch Linux", "modification_date": "2019-03-26T14:00:49.327070+00:00", "versions": [{"creation_date": "2018-04-20T15:59:04.594929+00:00", "modification_date": "2018-04-20T15:59:04.594929+00:00", "id": "f7696517-bc49-448b-9869-f2c84e7c2a96", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f21defd0-9fd9-4fb2-a29a-22844a6be3cd", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "3c904f73-080e-4c6f-8b28-8426cfdcb3c7", "zone": "ams1"}], "name": "2018-04-20T15:59:04.593811"}], "current_public_version": "f7696517-bc49-448b-9869-f2c84e7c2a96", "label": "arch_linux", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Alpine Linux is security-oriented, lightweight Linux distribution based on musl libc and busybox.", "creation_date": "2016-03-05T14:49:50.255568+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/alpinelinux.png", "id": "c0649a2a-e6bf-4712-9303-8d967153209c", "categories": ["distribution"], "name": "Alpine Linux", "modification_date": "2019-03-26T14:00:54.425917+00:00", "versions": [{"creation_date": "2018-04-26T10:18:10.201002+00:00", "modification_date": "2018-04-26T10:18:10.201002+00:00", "id": "be2293b6-9eba-4497-9659-2cfb927483b5", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "24141068-1043-4885-bf2b-8290f617e273", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "241b0bb3-9eed-4a7b-b0fd-71c45452ac95", "zone": "ams1"}], "name": "2018-04-26T10:18:10.196011"}], "current_public_version": "be2293b6-9eba-4497-9659-2cfb927483b5", "label": "alpine_linux", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Debian is a free operating system, developed by thousands of volunteers from all over the world who collaborate via the Internet.", "creation_date": "2019-07-16T13:55:36.377559+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/debian.png", "id": "7bdc1afb-231f-486a-9b85-1b0478bc0e4a", "categories": ["distribution"], "name": "Debian Buster", "modification_date": "2020-01-20T09:04:41.730609+00:00", "versions": [{"creation_date": "2020-01-15T11:52:04.860098+00:00", "modification_date": "2020-01-15T11:52:04.860098+00:00", "id": "763b45ed-2e31-4ba0-9beb-efb195503a2d", "local_images": [{"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "61010e34-7f1e-402b-a253-028a714a6678", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "4720c10f-59e3-4e20-915b-dcee1fc34c11", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "9d6e8a2c-31a9-439c-a4c5-9fba1c5b96ed", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "cc9188b3-3938-47d7-b091-c9ecad1fe507", "zone": "par1"}], "name": "2020-01-15T11:52:04.849401"}], "current_public_version": "763b45ed-2e31-4ba0-9beb-efb195503a2d", "label": "debian_buster", "organization": {"id": "51b656e3-4865-41e8-adbc-0c45bdd780db", "name": "Instances User Resources Build System"}}, {"valid_until": null, "description": "Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications.", "creation_date": "2016-03-05T15:11:26.847640+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/docker.png", "id": "c1b530d8-0ca0-45c4-80db-ba06608287b2", "categories": ["instantapp"], "name": "Docker", "modification_date": "2019-03-26T14:00:49.524465+00:00", "versions": [{"creation_date": "2019-03-07T17:07:39.090644+00:00", "modification_date": "2019-03-07T17:07:39.090644+00:00", "id": "bf30c937-6e89-4019-ad2a-92156a62cf3e", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "89c80d27-ddf4-4ffa-8215-b335cce3fd05", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "99e2a9c6-f0b9-42b6-8823-8b0d86ffe9bf", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "45a7e942-1fb0-48c0-bbf6-0acb9af24604", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "c669011a-ee16-42b6-b0c3-ecd19e419539", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "dcf35840-c007-4c8b-a48b-227cfd8a347b", "zone": "ams1"}], "name": "2019-03-07T17:07:39.004809"}], "current_public_version": "bf30c937-6e89-4019-ad2a-92156a62cf3e", "label": "docker", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "GitLab is a web-based Git repository manager with wiki and issue tracking features.", "creation_date": "2016-03-07T21:06:22.770864+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/gitlab.png", "id": "233074b9-e2ba-4e78-818e-dd4930ce6bee", "categories": ["instantapp"], "name": "GitLab", "modification_date": "2019-04-09T13:31:04.022755+00:00", "versions": [{"creation_date": "2019-04-09T13:31:03.648676+00:00", "modification_date": "2019-04-09T13:31:03.648676+00:00", "id": "a389c94b-8b19-4528-a4f6-0b7cac3425e9", "local_images": [{"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "06a2a6e9-922d-4353-9472-bbb1f79fda63", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "4527e41c-0e90-43a8-857e-d9584bf8467f", "zone": "par1"}], "name": "2019-04-09T13:31:03.352588"}], "current_public_version": "a389c94b-8b19-4528-a4f6-0b7cac3425e9", "label": "gitlab", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "A painless self-hosted Git service.", "creation_date": "2016-03-07T21:00:44.946716+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/gogs.png", "id": "90d512b8-e4b7-4821-98e9-78241d73a7e6", "categories": ["instantapp"], "name": "Gogs", "modification_date": "2019-03-26T14:00:54.513196+00:00", "versions": [{"creation_date": "2018-05-16T15:11:25.881343+00:00", "modification_date": "2018-05-16T15:11:25.881343+00:00", "id": "1b9e22e3-6a29-4f42-acfd-281ad086ee1d", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "776705c4-be8e-4a27-b740-2e8bbba518c5", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a513a250-e6e9-4687-892e-9d10b29e3972", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "d1341ece-ffda-4386-ad3a-27d60b650401", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "69b8bc0e-7771-42af-a4ad-ca756c31a18a", "zone": "ams1"}], "name": "2018-05-16T15:11:25.303762"}], "current_public_version": "1b9e22e3-6a29-4f42-acfd-281ad086ee1d", "label": "gogs", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.A dynamic, open source programming language with a focus on simplicity and productivity.", "creation_date": "2016-03-08T07:01:11.482482+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/golang.png", "id": "6c8d25c0-cb6f-4220-98aa-830b7e479ba5", "categories": ["instantapp"], "name": "Golang", "modification_date": "2019-03-26T14:00:52.861225+00:00", "versions": [{"creation_date": "2018-04-18T08:00:48.175340+00:00", "modification_date": "2018-04-18T08:00:48.175340+00:00", "id": "880194c8-53ce-4b6b-a274-4f79307e2f8e", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "43213956-c7a3-44b8-9d96-d51fa7457969", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "5ffb52aa-ea55-4596-9d0f-e403701b6624", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "bef7a6af-1bab-490a-a6cb-6a07c1b9ac7b", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "f0b7d9b8-aa31-45b4-9f7e-a68aa164ce6f", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "76ca1eb7-f68f-4770-a7a1-ab7665ae3297", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "0d954c34-341c-483a-be1c-71cf197343ed", "zone": "ams1"}], "name": "2018-04-18T08:00:48.129246"}], "current_public_version": "880194c8-53ce-4b6b-a274-4f79307e2f8e", "label": "golang", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Java is a computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible.", "creation_date": "2016-03-07T21:07:46.908969+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/java.png", "id": "d72d1b73-7460-446b-91fb-b451d079aa4d", "categories": ["instantapp"], "name": "Java", "modification_date": "2019-03-26T14:00:49.430836+00:00", "versions": [{"creation_date": "2018-04-18T10:11:18.535736+00:00", "modification_date": "2018-04-18T10:11:18.535736+00:00", "id": "f3f69cca-aadb-4e5e-94b0-254ce05a6639", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "c50cb4b2-bf7b-47e2-ab5f-3a9d3d4c1aef", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "98c93894-26a8-463b-a72b-c9d2b531b95d", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "43c43b5e-1e4f-4905-baef-71df3c565b4d", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "0c3f9f03-f490-444b-a05e-f342e917fed0", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "5e07622b-ad8b-4f65-b55f-cca18c3c0bbf", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "c0330755-e5d0-4c2c-ad0e-70687e1dccbb", "zone": "par1"}], "name": "2018-04-18T10:11:18.477156"}], "current_public_version": "f3f69cca-aadb-4e5e-94b0-254ce05a6639", "label": "java", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "LEMP stack is a version where Apache has been replaced with the more lightweight web server Nginx.", "creation_date": "2016-03-07T21:06:53.552980+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/lemp.png", "id": "986ba672-b489-4f66-9e3b-90194ac336d4", "categories": ["instantapp"], "name": "LEMP stack", "modification_date": "2019-04-09T13:31:12.129567+00:00", "versions": [{"creation_date": "2019-04-09T13:31:11.315416+00:00", "modification_date": "2019-04-09T13:31:11.315416+00:00", "id": "a2e5ed1a-6f01-4f20-aabd-4115c67df590", "local_images": [{"compatible_commercial_types": ["C1"], "arch": "arm", "id": "32332006-1420-4260-97c7-c1da586f68cd", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "d16622f6-32c1-4d16-a3ca-38b23d3a25fb", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "1bd37d60-4494-485f-9a82-0a211005489c", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "415d3727-0013-419a-abc6-1a688b096730", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "26c3727a-5b77-4b26-89c9-445ea2006f07", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "155ab61a-e069-4acb-bae3-e8217c5c0376", "zone": "ams1"}], "name": "2019-04-09T13:31:10.613803"}], "current_public_version": "a2e5ed1a-6f01-4f20-aabd-4115c67df590", "label": "lemp_stack", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "self-hosted Slack-alternative", "creation_date": "2016-07-11T14:52:57.803007+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/mattermost.png", "id": "98ad7ccb-cc7f-4828-9da3-113e9c1bd2db", "categories": ["instantapp"], "name": "Mattermost", "modification_date": "2019-03-26T14:00:51.938920+00:00", "versions": [{"creation_date": "2018-05-03T10:27:55.610920+00:00", "modification_date": "2018-05-03T10:27:55.610920+00:00", "id": "42371bf7-c1ca-4889-a6d4-43febda865ca", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "486e128c-fde7-42d7-9200-5d91b8dc2761", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "eb2ed407-177c-4195-a4ca-f3baa85e62ed", "zone": "ams1"}], "name": "2018-05-03T10:27:55.021511"}], "current_public_version": "42371bf7-c1ca-4889-a6d4-43febda865ca", "label": "mattermost", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Nextcloud is an open source, self-hosted file share and communication platform.", "creation_date": "2019-04-16T12:22:56.930842+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/nextcloud.png", "id": "7d4a7cb1-1fd5-4a64-920b-c79f47367254", "categories": ["instantapp"], "name": "NextCloud", "modification_date": "2019-04-16T12:25:38.758921+00:00", "versions": [{"creation_date": "2019-04-16T12:25:38.052537+00:00", "modification_date": "2019-04-16T12:25:38.052537+00:00", "id": "2fe66cc6-8985-4b5f-8325-83acc0589436", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "e9af0a24-4312-4305-9386-b3a79e02f92d", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "c38073cf-ee40-4dc2-8059-ec2845f38f46", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "b9e319f5-ac4c-400d-8ff6-a6a769755190", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "0390c3e0-186d-4b24-8d0d-0e08b74fb59a", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "900971a4-3a3e-4ef9-b92f-b33c366c9f5c", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "7b7d4dde-6fe1-4586-a5a5-ae1af2ca2605", "zone": "par1"}], "name": "2019-04-16T12:25:37.374676"}], "current_public_version": "2fe66cc6-8985-4b5f-8325-83acc0589436", "label": "nextcloud", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "Node.js is an open source, cross-platform runtime environment for server-side and networking applications.", "creation_date": "2016-03-07T21:06:07.014951+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/nodejs.png", "id": "d11d7cc2-6ec8-4f95-a286-24fb5bac9e39", "categories": ["instantapp"], "name": "Node.js", "modification_date": "2019-03-26T14:00:51.148549+00:00", "versions": [{"creation_date": "2018-04-18T10:07:15.744660+00:00", "modification_date": "2018-04-18T10:07:15.744660+00:00", "id": "af308511-bcb3-4583-b0e0-79dbb1eea63e", "local_images": [{"compatible_commercial_types": [], "arch": "arm", "id": "a8020f20-8a66-43f3-8253-35941db3d237", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "3cc79cc6-4649-46d9-a2b6-698f1236e1d0", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "c9fb2bed-a9b8-4e1a-bf15-db8e763fe7a7", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f01db1d0-092a-47de-a32e-09bd6bda7715", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "6f2e99e8-da99-4990-b689-7294e8a604fa", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "03980aee-14cd-44f1-be3c-508c8b8a19e6", "zone": "par1"}], "name": "2018-04-18T10:07:15.691016"}], "current_public_version": "af308511-bcb3-4583-b0e0-79dbb1eea63e", "label": "node.js", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Surf the web in a secure and anonymous way with OpenVPN InstantApp.", "creation_date": "2016-03-07T21:04:57.667667+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/openvpn.png", "id": "b6f4edc8-21e6-4aa2-8f52-1030cf6d4dd8", "categories": ["instantapp"], "name": "OpenVPN", "modification_date": "2019-03-26T14:00:52.955853+00:00", "versions": [{"creation_date": "2019-03-25T13:06:02.622633+00:00", "modification_date": "2019-03-25T13:06:02.622633+00:00", "id": "d812e374-1169-4c91-aa90-c72acceeecb2", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "b15ddb1a-0611-412e-881a-3aed1b36392b", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "02906ae8-bf44-4dd0-bd05-6312dd9fa234", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "3aa3622c-45d4-4388-9618-cce6974c71a0", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a5430536-2a51-425d-8613-ef84dae91e27", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "51573d2d-301f-4d24-b0d6-f151728c82f5", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "cac79531-98d5-48fa-aba1-8250214b88a3", "zone": "par1"}], "name": "2019-03-25T13:06:01.961936"}], "current_public_version": "d812e374-1169-4c91-aa90-c72acceeecb2", "label": "openvpn", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "ownCloud lets you sync & share your files, calendar, contacts and more. Access your data from all your devices, on an open platform you can extend and modify.", "creation_date": "2016-03-07T21:05:14.365925+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/owncloud.png", "id": "e22a5d54-ecb5-4fdd-a130-a473737ff7ab", "categories": ["instantapp"], "name": "ownCloud", "modification_date": "2019-03-26T14:00:52.457272+00:00", "versions": [{"creation_date": "2018-04-18T10:09:39.010195+00:00", "modification_date": "2018-04-18T10:09:39.010195+00:00", "id": "c9c02a9c-e072-48af-aefd-bf6be9028022", "local_images": [{"compatible_commercial_types": [], "arch": "arm", "id": "a5fb716a-1c60-4740-a179-98ce315ca3d7", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "2fdbbbb4-3b63-403b-9604-27713971efd6", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "4208a611-a789-40ea-ac0e-fb3001ee39a9", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "93de8eae-535f-47bd-88fa-84af7b5eaf76", "zone": "par1"}], "name": "2018-04-18T10:09:38.952503"}], "current_public_version": "c9c02a9c-e072-48af-aefd-bf6be9028022", "label": "owncloud", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "PrestaShop is a free, open source e-commerce solution.", "creation_date": "2016-03-07T21:01:47.997930+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/prestashop.png", "id": "58a551e0-1b8b-4c83-82e7-1b4602ad43d1", "categories": ["instantapp"], "name": "PrestaShop", "modification_date": "2019-03-26T14:00:50.067950+00:00", "versions": [{"creation_date": "2018-05-16T14:57:16.059809+00:00", "modification_date": "2018-05-16T14:57:16.059809+00:00", "id": "6c459ab1-4f1a-4f87-b92e-c00849c93fde", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "4d07fcfa-ccda-4945-81aa-8de2206b39c0", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "73db574d-d5a0-49d5-b6ca-dd662895fac3", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "c97dc20f-8066-4d56-aabf-2b75162c0f9f", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "c78c3206-eb2b-4217-ad7c-0aca98dec145", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "7f91941c-f06a-4103-91a4-793f03b11fda", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "271a9c1f-73ef-4943-bac7-799130228040", "zone": "ams1"}], "name": "2018-05-16T14:57:15.505378"}], "current_public_version": "6c459ab1-4f1a-4f87-b92e-c00849c93fde", "label": "prestashop", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "The intended audience of this InstantApp is Python developers who want to bootstrap or test a Python application easily, in seconds.", "creation_date": "2016-03-07T21:05:46.642023+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/python.png", "id": "5c0f7971-c308-442e-82ab-2eb147439bd7", "categories": ["instantapp"], "name": "Python", "modification_date": "2019-03-26T14:00:49.970905+00:00", "versions": [{"creation_date": "2018-04-17T16:43:36.089412+00:00", "modification_date": "2018-04-17T16:43:36.089412+00:00", "id": "2642a982-e61d-4a58-8105-8838a69a85e3", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "70b9c9cf-c2d9-4a80-b450-a7aef8226d96", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "5218fa4e-8239-4831-ac2a-c96e23f387a2", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "f205e2a6-621a-4534-a5d1-36f6cf1f8376", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "613a5226-3d97-4f0e-abe2-99385a050784", "zone": "ams1"}], "name": "2018-04-17T16:43:36.031203"}], "current_public_version": "2642a982-e61d-4a58-8105-8838a69a85e3", "label": "python", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "A dynamic, open source programming language with a focus on simplicity and productivity.", "creation_date": "2016-03-07T22:15:25.347873+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ruby.png", "id": "42866fbe-9168-4f77-8271-09beb6049a07", "categories": ["instantapp"], "name": "Ruby", "modification_date": "2019-03-26T14:00:54.119256+00:00", "versions": [{"creation_date": "2018-04-18T10:21:49.119857+00:00", "modification_date": "2018-04-18T10:21:49.119857+00:00", "id": "5b8c935b-5047-43fd-a423-045dae3e0d78", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "09c71ada-00c6-43de-ad44-c77c5b857a05", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "24f2e8ee-80f1-4a8d-83c4-74ed8cd80ed0", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "e2479a13-414b-4a0c-ba50-d01e67ee8600", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "f83a03fa-58eb-4b35-bda9-1a42b6d6d90d", "zone": "ams1"}], "name": "2018-04-18T10:21:49.057120"}], "current_public_version": "5b8c935b-5047-43fd-a423-045dae3e0d78", "label": "ruby", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "The torrents InstantApp spawns a private server to upload and download your digital files.", "creation_date": "2016-03-07T21:08:02.980958+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/seedbox.png", "id": "4e18f1fc-0b66-4692-a38d-bfa4c94f29de", "categories": ["instantapp"], "name": "Torrents", "modification_date": "2019-03-26T14:00:51.427329+00:00", "versions": [{"creation_date": "2019-03-25T13:04:02.099902+00:00", "modification_date": "2019-03-25T13:04:02.099902+00:00", "id": "53d2e4fb-20df-4ba9-8d65-29256f2be480", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "41d0db97-4822-4642-96ec-6f3fbcfc167c", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "3fbe5f72-81da-4a0a-91ef-36ab68fc801e", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "1aed7396-79dc-431d-af03-d3dde35d195f", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "398875b6-de43-4946-976f-ba5189954912", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a3160162-3d72-4632-8e42-4849a1280743", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f5d116e3-2b58-44cf-a83a-cd0682135473", "zone": "par1"}], "name": "2019-03-25T13:04:01.408435"}], "current_public_version": "53d2e4fb-20df-4ba9-8d65-29256f2be480", "label": "torrents", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Ubuntu is the ideal distribution for scale-out computing, Ubuntu Server helps you make the most of your infrastructure.", "creation_date": "2020-02-17T15:50:48.980694+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "3f1b9623-71ba-4fe3-b994-27fcdaa850ba", "categories": ["distribution"], "name": "Ubuntu 20.04 Focal Fossa", "modification_date": "2020-05-12T14:59:11.764621+00:00", "versions": [{"creation_date": "2020-05-12T14:08:49.605637+00:00", "modification_date": "2020-05-12T14:08:49.605637+00:00", "id": "8a23f8ac-240c-4c9c-b20e-c611361e0148", "local_images": [{"compatible_commercial_types": ["VC1S", "VC1M", "VC1L", "START1-XS", "START1-S", "START1-M", "START1-L", "X64-15GB", "X64-30GB", "X64-60GB", "X64-120GB", "GP1-XS", "GP1-S", "GP1-M", "GP1-L", "GP1-XL", "DEV1-S", "DEV1-M", "DEV1-L", "DEV1-XL"], "arch": "x86_64", "id": "365a8b9c-0c6e-4875-a887-dc3213db9e20", "zone": "par1"}, {"compatible_commercial_types": ["VC1S", "VC1M", "VC1L", "START1-XS", "START1-S", "START1-M", "START1-L", "X64-15GB", "X64-30GB", "X64-60GB", "X64-120GB", "GP1-XS", "GP1-S", "GP1-M", "GP1-L", "GP1-XL", "DEV1-S", "DEV1-M", "DEV1-L", "DEV1-XL"], "arch": "x86_64", "id": "80d81811-1bd2-44dc-bd1c-ec070c80c40b", "zone": "ams1"}], "name": "2020-05-12T14:08:49.566279+00:00"}], "current_public_version": "8a23f8ac-240c-4c9c-b20e-c611361e0148", "label": "ubuntu_focal", "organization": {"id": "51b656e3-4865-41e8-adbc-0c45bdd780db", "name": "Instances User Resources Build System"}}, {"valid_until": null, "description": "Ubuntu Bionic for Machine Learning 10.1", "creation_date": "2019-03-06T17:24:56.871317+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "e0808ca5-1e0a-4070-8aff-d2e49e9600c1", "categories": ["Machine Learning"], "name": "Ubuntu Bionic ML 10.1", "modification_date": "2020-02-17T12:56:29.417410+00:00", "versions": [{"creation_date": "2020-02-17T12:50:10.150196+00:00", "modification_date": "2020-02-17T12:50:10.150196+00:00", "id": "50a39102-80cf-4c9b-aed8-919e745df9d5", "local_images": [{"compatible_commercial_types": ["RENDER-S"], "arch": "x86_64", "id": "8fa4f46b-2cb2-40df-813a-727df120b9e4", "zone": "par1"}], "name": "2020-02-17T12:50:10.040529"}], "current_public_version": "50a39102-80cf-4c9b-aed8-919e745df9d5", "label": "ubuntu_bionic_ml_10.1", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "Ubuntu Bionic for Machine Learning 9.2", "creation_date": "2019-03-06T17:24:29.909001+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "7e48e55a-7b46-4e4f-b2d2-6b7316cdca8c", "categories": ["Machine Learning"], "name": "Ubuntu Bionic ML 9.2", "modification_date": "2020-02-17T12:55:53.623681+00:00", "versions": [{"creation_date": "2020-02-17T12:39:31.681271+00:00", "modification_date": "2020-02-17T12:39:31.681271+00:00", "id": "d0602033-62f8-455a-be55-0930291bb43f", "local_images": [{"compatible_commercial_types": ["RENDER-S"], "arch": "x86_64", "id": "1dad4207-f91a-48c3-9fac-6620e90b9434", "zone": "par1"}], "name": "2020-02-17T12:39:31.572184"}], "current_public_version": "d0602033-62f8-455a-be55-0930291bb43f", "label": "ubuntu_bionic_ml_9.2", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "WordPress is the most popular web software you can use to create a beautiful website or blog.", "creation_date": "2016-03-07T21:03:59.783534+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/wordpress.png", "id": "215a50f9-0ba8-4e9c-a4e7-10caf50e3586", "categories": ["instantapp"], "name": "WordPress", "modification_date": "2019-03-26T14:00:50.250657+00:00", "versions": [{"creation_date": "2019-03-08T08:58:28.971149+00:00", "modification_date": "2019-03-08T08:58:28.971149+00:00", "id": "3fb22e1f-de7f-4787-9bf8-32770151a45e", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "8523fb41-500a-4f21-998b-890908da6119", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "5645133b-67a3-4644-9941-16f7e2b428ea", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "757fac76-5265-46f8-8a1f-00c0fb270010", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "7a892c1a-bbdc-491f-9974-4008e3708664", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "726334eb-0733-4b6a-becd-769ff9bfe16d", "zone": "ams1"}], "name": "2019-03-08T08:58:28.893091"}], "current_public_version": "3fb22e1f-de7f-4787-9bf8-32770151a45e", "label": "wordpress", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}]}' headers: Cache-Control: - no-cache Content-Length: - "53981" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 04 Jun 2020 12:12:19 GMT Link: - ; rel="last" Server: - agw_listener_public_anycast Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - f98d6c90-613c-4839-a569-198fd9bbb942 X-Total-Count: - "31" status: 200 OK code: 200 duration: "" - request: body: '{"name":"srv-elegant-ritchie","commercial_type":"GP1-XS","image":"365a8b9c-0c6e-4875-a887-dc3213db9e20","organization":"951df375-e094-4d26-97c1-ba548eeb9c42"}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.3; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers method: POST response: body: '{"server": {"id": "d18f8660-b831-4314-8314-c534ef21fb79", "name": "srv-elegant-ritchie", "arch": "x86_64", "commercial_type": "GP1-XS", "boot_type": "local", "organization": "951df375-e094-4d26-97c1-ba548eeb9c42", "hostname": "srv-elegant-ritchie", "image": {"id": "365a8b9c-0c6e-4875-a887-dc3213db9e20", "name": "Ubuntu 20.04 Focal Fossa", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "903d339c-6144-4ca9-b2a0-9d280d6e3576", "name": "ubuntu_20.04_focal_fossa:volume-0", "volume_type": "l_ssd", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": "x86_64", "creation_date": "2020-05-12T14:08:16.646636+00:00", "modification_date": "2020-05-12T14:08:16.646636+00:00", "default_bootscript": null, "from_server": null, "state": "available", "zone": "fr-par-1"}, "volumes": {"0": {"id": "79801997-0369-4c13-8ca0-d95cdada05dc", "name": "ubuntu_20.04_focal_fossa:volume-0", "volume_type": "l_ssd", "export_uri": null, "organization": "951df375-e094-4d26-97c1-ba548eeb9c42", "server": {"id": "d18f8660-b831-4314-8314-c534ef21fb79", "name": "srv-elegant-ritchie"}, "size": 150000000000, "state": "available", "creation_date": "2020-06-04T12:12:19.737126+00:00", "modification_date": "2020-06-04T12:12:20.100008+00:00", "zone": "fr-par-1"}}, "tags": [], "state": "stopped", "protected": false, "state_detail": "", "public_ip": null, "ipv6": null, "extra_networks": [], "dynamic_ip_required": true, "enable_ipv6": false, "private_ip": null, "creation_date": "2020-06-04T12:12:19.737126+00:00", "modification_date": "2020-06-04T12:12:19.737126+00:00", "bootscript": {"id": "34017869-d088-475c-b5ec-2cede3bb84e3", "public": true, "title": "x86_64 mainline 4.4.182 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.4-4.4.182-rev1/vmlinuz-4.4.182", "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": true, "zone": "fr-par-1"}, "security_group": {"id": "54e2d5f6-d79c-44cc-b19f-613699b9cc7e", "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": ["poweron", "backup"], "placement_group": null, "private_nics": [], "zone": "fr-par-1"}}' headers: Cache-Control: - no-cache Content-Length: - "2316" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 04 Jun 2020 12:12:19 GMT Location: - https://cp-par1.scaleway.com/servers/d18f8660-b831-4314-8314-c534ef21fb79 Server: - agw_listener_public_anycast Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 5c9d9f22-aeab-40eb-a0e4-6c52a7e1845e status: 201 Created code: 201 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.3; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/d18f8660-b831-4314-8314-c534ef21fb79 method: DELETE response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 04 Jun 2020 12:12:19 GMT Server: - agw_listener_public_anycast Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 8f3f0eb9-939c-4537-9c59-655ea1cef71f status: 204 No Content code: 204 duration: "" golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/testdata/get-server-type.yaml000066400000000000000000000601621456366605600327250ustar00rootroot00000000000000--- version: 1 interactions: - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.6; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/products/servers?page=1 method: GET response: body: '{"servers": {"VC1S": {"monthly_price": 2.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 200000000000}}, "ncpus": 2, "ram": 2147483648, "arch": "x86_64", "volumes_constraint": {"min_size": 50000000000, "max_size": 50000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 209715200}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 209715200, "ipv6_support": true}, "hourly_price": 0.006, "alt_names": ["X64-2GB"], "capabilities": {"block_storage": false, "default_boot_type": "bootscript", "boot_types": ["bootscript", "rescue", "local"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "GP1-XS": {"monthly_price": 39.0, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 800000000000}}, "ncpus": 4, "ram": 17179869184, "arch": "x86_64", "volumes_constraint": {"min_size": 150000000000, "max_size": 150000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 419430400}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 419430400, "ipv6_support": true}, "hourly_price": 0.078, "alt_names": [], "capabilities": {"block_storage": true, "default_boot_type": "local", "boot_types": ["bootscript", "rescue", "local"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "DEV1-M": {"monthly_price": 7.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 800000000000}}, "ncpus": 3, "ram": 4294967296, "arch": "x86_64", "volumes_constraint": {"min_size": 40000000000, "max_size": 40000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 209715200}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 209715200, "ipv6_support": true}, "hourly_price": 0.016, "alt_names": [], "capabilities": {"block_storage": true, "default_boot_type": "local", "boot_types": ["bootscript", "rescue", "local"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "DEV1-L": {"monthly_price": 15.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 800000000000}}, "ncpus": 4, "ram": 8589934592, "arch": "x86_64", "volumes_constraint": {"min_size": 80000000000, "max_size": 80000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 314572800}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 314572800, "ipv6_support": true}, "hourly_price": 0.032, "alt_names": [], "capabilities": {"block_storage": true, "default_boot_type": "local", "boot_types": ["bootscript", "rescue", "local"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "START1-XS": {"monthly_price": 1.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 200000000000}}, "ncpus": 1, "ram": 1073741824, "arch": "x86_64", "volumes_constraint": {"min_size": 25000000000, "max_size": 25000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 104857600}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 104857600, "ipv6_support": true}, "hourly_price": 0.004, "alt_names": [], "capabilities": {"block_storage": false, "default_boot_type": "bootscript", "boot_types": ["bootscript", "rescue", "local"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "ARM64-8GB": {"monthly_price": 11.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 200000000000}}, "ncpus": 8, "ram": 8589934592, "arch": "arm64", "volumes_constraint": {"min_size": 200000000000, "max_size": 200000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 209715200}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 209715200, "ipv6_support": true}, "hourly_price": 0.024, "alt_names": [], "capabilities": {"block_storage": false, "default_boot_type": "bootscript", "boot_types": ["bootscript", "rescue"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "DEV1-S": {"monthly_price": 2.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 800000000000}}, "ncpus": 2, "ram": 2147483648, "arch": "x86_64", "volumes_constraint": {"min_size": 20000000000, "max_size": 20000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 104857600}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 104857600, "ipv6_support": true}, "hourly_price": 0.006, "alt_names": [], "capabilities": {"block_storage": true, "default_boot_type": "local", "boot_types": ["bootscript", "rescue", "local"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "RENDER-S": {"monthly_price": 499.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 800000000000}}, "ncpus": 10, "ram": 48318382080, "arch": "x86_64", "volumes_constraint": {"min_size": 400000000000, "max_size": 400000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 1048576000}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 1048576000, "ipv6_support": true}, "hourly_price": 1.0, "alt_names": [], "capabilities": {"block_storage": true, "default_boot_type": "local", "boot_types": ["local", "rescue"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": 1}, "GP1-XL": {"monthly_price": 569.0, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 800000000000}}, "ncpus": 48, "ram": 274877906944, "arch": "x86_64", "volumes_constraint": {"min_size": 600000000000, "max_size": 600000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 2147483648}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 2147483648, "ipv6_support": true}, "hourly_price": 1.138, "alt_names": [], "capabilities": {"block_storage": true, "default_boot_type": "local", "boot_types": ["bootscript", "rescue", "local"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "C2S": {"monthly_price": 11.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 200000000000}}, "ncpus": 4, "ram": 8589934592, "arch": "x86_64", "volumes_constraint": {"min_size": 50000000000, "max_size": 1000000000000}, "network": {"interfaces": [{"internal_bandwidth": 2684354560, "internet_bandwidth": 314572800}], "sum_internal_bandwidth": 2684354560, "sum_internet_bandwidth": 314572800, "ipv6_support": true}, "hourly_price": 0.024, "alt_names": [], "capabilities": {"block_storage": false, "default_boot_type": "bootscript", "boot_types": ["bootscript", "rescue"], "hot_snapshots_local_volume": false, "compute_clusters": false}, "baremetal": true, "gpu": null}, "X64-15GB": {"monthly_price": 24.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 200000000000}}, "ncpus": 6, "ram": 16106127360, "arch": "x86_64", "volumes_constraint": {"min_size": 200000000000, "max_size": 200000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 262144000}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 262144000, "ipv6_support": true}, "hourly_price": 0.05, "alt_names": [], "capabilities": {"block_storage": false, "default_boot_type": "bootscript", "boot_types": ["bootscript", "rescue", "local"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "ARM64-2GB": {"monthly_price": 2.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 200000000000}}, "ncpus": 4, "ram": 2147483648, "arch": "arm64", "volumes_constraint": {"min_size": 50000000000, "max_size": 50000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 209715200}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 209715200, "ipv6_support": true}, "hourly_price": 0.006, "alt_names": [], "capabilities": {"block_storage": false, "default_boot_type": "bootscript", "boot_types": ["bootscript", "rescue"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "DEV1-XL": {"monthly_price": 23.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 800000000000}}, "ncpus": 4, "ram": 12884901888, "arch": "x86_64", "volumes_constraint": {"min_size": 120000000000, "max_size": 120000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 419430400}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 419430400, "ipv6_support": true}, "hourly_price": 0.048, "alt_names": [], "capabilities": {"block_storage": true, "default_boot_type": "local", "boot_types": ["bootscript", "rescue", "local"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "C1": {"monthly_price": 2.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 200000000000}}, "ncpus": 4, "ram": 2147483648, "arch": "arm", "volumes_constraint": {"min_size": 50000000000, "max_size": 1000000000000}, "network": {"interfaces": [{"internal_bandwidth": 1073741824, "internet_bandwidth": 209715200}], "sum_internal_bandwidth": 1073741824, "sum_internet_bandwidth": 209715200, "ipv6_support": false}, "hourly_price": 0.006, "alt_names": [], "capabilities": {"block_storage": false, "default_boot_type": "bootscript", "boot_types": ["bootscript", "rescue"], "hot_snapshots_local_volume": false, "compute_clusters": false}, "baremetal": true, "gpu": null}, "VC1M": {"monthly_price": 5.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 200000000000}}, "ncpus": 4, "ram": 4294967296, "arch": "x86_64", "volumes_constraint": {"min_size": 100000000000, "max_size": 100000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 209715200}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 209715200, "ipv6_support": true}, "hourly_price": 0.012, "alt_names": ["X64-4GB"], "capabilities": {"block_storage": false, "default_boot_type": "bootscript", "boot_types": ["bootscript", "rescue", "local"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "C2L": {"monthly_price": 23.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 200000000000}}, "ncpus": 8, "ram": 34359738368, "arch": "x86_64", "volumes_constraint": {"min_size": 50000000000, "max_size": 1000000000000}, "network": {"interfaces": [{"internal_bandwidth": 2684354560, "internet_bandwidth": 629145600}, {"internal_bandwidth": 2684354560, "internet_bandwidth": null}], "sum_internal_bandwidth": 5368709120, "sum_internet_bandwidth": 629145600, "ipv6_support": true}, "hourly_price": 0.048, "alt_names": [], "capabilities": {"block_storage": false, "default_boot_type": "bootscript", "boot_types": ["bootscript", "rescue"], "hot_snapshots_local_volume": false, "compute_clusters": false}, "baremetal": true, "gpu": null}, "C2M": {"monthly_price": 17.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 200000000000}}, "ncpus": 8, "ram": 17179869184, "arch": "x86_64", "volumes_constraint": {"min_size": 50000000000, "max_size": 1000000000000}, "network": {"interfaces": [{"internal_bandwidth": 2684354560, "internet_bandwidth": 524288000}, {"internal_bandwidth": 2684354560, "internet_bandwidth": null}], "sum_internal_bandwidth": 5368709120, "sum_internet_bandwidth": 524288000, "ipv6_support": true}, "hourly_price": 0.036, "alt_names": [], "capabilities": {"block_storage": false, "default_boot_type": "bootscript", "boot_types": ["bootscript", "rescue"], "hot_snapshots_local_volume": false, "compute_clusters": false}, "baremetal": true, "gpu": null}, "ARM64-4GB": {"monthly_price": 5.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 200000000000}}, "ncpus": 6, "ram": 4294967296, "arch": "arm64", "volumes_constraint": {"min_size": 100000000000, "max_size": 100000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 209715200}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 209715200, "ipv6_support": true}, "hourly_price": 0.012, "alt_names": [], "capabilities": {"block_storage": false, "default_boot_type": "bootscript", "boot_types": ["bootscript", "rescue"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "ARM64-128GB": {"monthly_price": 279.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 200000000000}}, "ncpus": 64, "ram": 137438953472, "arch": "arm64", "volumes_constraint": {"min_size": 500000000000, "max_size": 1000000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 1073741824}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 1073741824, "ipv6_support": true}, "hourly_price": 0.56, "alt_names": [], "capabilities": {"block_storage": false, "default_boot_type": "bootscript", "boot_types": ["bootscript", "rescue"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "START1-S": {"monthly_price": 3.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 200000000000}}, "ncpus": 2, "ram": 2147483648, "arch": "x86_64", "volumes_constraint": {"min_size": 50000000000, "max_size": 50000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 209715200}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 209715200, "ipv6_support": true}, "hourly_price": 0.008, "alt_names": [], "capabilities": {"block_storage": false, "default_boot_type": "bootscript", "boot_types": ["bootscript", "rescue", "local"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "X64-30GB": {"monthly_price": 49.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 200000000000}}, "ncpus": 8, "ram": 32212254720, "arch": "x86_64", "volumes_constraint": {"min_size": 300000000000, "max_size": 400000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 524288000}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 524288000, "ipv6_support": true}, "hourly_price": 0.1, "alt_names": [], "capabilities": {"block_storage": false, "default_boot_type": "bootscript", "boot_types": ["bootscript", "rescue", "local"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "GP1-L": {"monthly_price": 299.0, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 800000000000}}, "ncpus": 32, "ram": 137438953472, "arch": "x86_64", "volumes_constraint": {"min_size": 600000000000, "max_size": 600000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 1073741824}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 1073741824, "ipv6_support": true}, "hourly_price": 0.598, "alt_names": [], "capabilities": {"block_storage": true, "default_boot_type": "local", "boot_types": ["bootscript", "rescue", "local"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "GP1-M": {"monthly_price": 159.0, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 800000000000}}, "ncpus": 16, "ram": 68719476736, "arch": "x86_64", "volumes_constraint": {"min_size": 600000000000, "max_size": 600000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 629145600}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 629145600, "ipv6_support": true}, "hourly_price": 0.318, "alt_names": [], "capabilities": {"block_storage": true, "default_boot_type": "local", "boot_types": ["bootscript", "rescue", "local"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "ARM64-64GB": {"monthly_price": 139.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 200000000000}}, "ncpus": 48, "ram": 68719476736, "arch": "arm64", "volumes_constraint": {"min_size": 400000000000, "max_size": 800000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 1073741824}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 1073741824, "ipv6_support": true}, "hourly_price": 0.28, "alt_names": [], "capabilities": {"block_storage": false, "default_boot_type": "bootscript", "boot_types": ["bootscript", "rescue"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "GP1-S": {"monthly_price": 79.0, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 800000000000}}, "ncpus": 8, "ram": 34359738368, "arch": "x86_64", "volumes_constraint": {"min_size": 300000000000, "max_size": 300000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 524288000}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 524288000, "ipv6_support": true}, "hourly_price": 0.158, "alt_names": [], "capabilities": {"block_storage": true, "default_boot_type": "local", "boot_types": ["bootscript", "rescue", "local"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "START1-L": {"monthly_price": 15.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 200000000000}}, "ncpus": 8, "ram": 8589934592, "arch": "x86_64", "volumes_constraint": {"min_size": 200000000000, "max_size": 200000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 419430400}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 419430400, "ipv6_support": true}, "hourly_price": 0.032, "alt_names": [], "capabilities": {"block_storage": false, "default_boot_type": "bootscript", "boot_types": ["bootscript", "rescue", "local"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "START1-M": {"monthly_price": 7.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 200000000000}}, "ncpus": 4, "ram": 4294967296, "arch": "x86_64", "volumes_constraint": {"min_size": 100000000000, "max_size": 100000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 314572800}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 314572800, "ipv6_support": true}, "hourly_price": 0.016, "alt_names": [], "capabilities": {"block_storage": false, "default_boot_type": "bootscript", "boot_types": ["bootscript", "rescue", "local"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "VC1L": {"monthly_price": 9.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 200000000000}}, "ncpus": 6, "ram": 8589934592, "arch": "x86_64", "volumes_constraint": {"min_size": 200000000000, "max_size": 200000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 209715200}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 209715200, "ipv6_support": true}, "hourly_price": 0.02, "alt_names": ["X64-8GB"], "capabilities": {"block_storage": false, "default_boot_type": "bootscript", "boot_types": ["bootscript", "rescue", "local"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "ARM64-32GB": {"monthly_price": 69.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 200000000000}}, "ncpus": 32, "ram": 34359738368, "arch": "arm64", "volumes_constraint": {"min_size": 300000000000, "max_size": 600000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 524288000}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 524288000, "ipv6_support": true}, "hourly_price": 0.14, "alt_names": [], "capabilities": {"block_storage": false, "default_boot_type": "bootscript", "boot_types": ["bootscript", "rescue"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "X64-120GB": {"monthly_price": 179.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 200000000000}}, "ncpus": 12, "ram": 128849018880, "arch": "x86_64", "volumes_constraint": {"min_size": 500000000000, "max_size": 1000000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 1073741824}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 1073741824, "ipv6_support": true}, "hourly_price": 0.36, "alt_names": [], "capabilities": {"block_storage": false, "default_boot_type": "bootscript", "boot_types": ["bootscript", "rescue", "local"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "ARM64-16GB": {"monthly_price": 34.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 200000000000}}, "ncpus": 16, "ram": 17179869184, "arch": "arm64", "volumes_constraint": {"min_size": 200000000000, "max_size": 400000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 524288000}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 524288000, "ipv6_support": true}, "hourly_price": 0.07, "alt_names": [], "capabilities": {"block_storage": false, "default_boot_type": "bootscript", "boot_types": ["bootscript", "rescue"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}, "X64-60GB": {"monthly_price": 89.99, "per_volume_constraint": {"l_ssd": {"min_size": 1000000000, "max_size": 200000000000}}, "ncpus": 10, "ram": 64424509440, "arch": "x86_64", "volumes_constraint": {"min_size": 400000000000, "max_size": 700000000000}, "network": {"interfaces": [{"internal_bandwidth": null, "internet_bandwidth": 1073741824}], "sum_internal_bandwidth": null, "sum_internet_bandwidth": 1073741824, "ipv6_support": true}, "hourly_price": 0.18, "alt_names": [], "capabilities": {"block_storage": false, "default_boot_type": "bootscript", "boot_types": ["bootscript", "rescue", "local"], "hot_snapshots_local_volume": true, "compute_clusters": true}, "baremetal": false, "gpu": null}}}' headers: Cache-Control: - no-cache Content-Length: - "22248" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 18 Jun 2019 13:56:00 GMT Link: - ; rel="last" Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Total-Count: - "32" status: 200 OK code: 200 duration: "" golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/testdata/image-wait-test.yaml000066400000000000000000002122261456366605600326640ustar00rootroot00000000000000--- version: 1 interactions: - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.3; darwin; amd64) url: https://api.scaleway.com/marketplace/v1/images?page=1 method: GET response: body: '{"images": [{"valid_until": null, "description": "Ubuntu is the ideal distribution for scale-out computing, Ubuntu Server helps you make the most of your infrastructure.", "creation_date": "2018-04-27T14:07:25.221998+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "b381b2bf-804a-4b12-91f6-9f4ff273462f", "categories": ["distribution"], "name": "Ubuntu Bionic", "modification_date": "2019-03-26T14:00:51.745705+00:00", "versions": [{"creation_date": "2019-03-05T16:39:34.893732+00:00", "modification_date": "2019-03-05T16:39:34.893732+00:00", "id": "e640c621-305b-45f5-975f-a3f80c1cec66", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f974feac-abae-4365-b988-8ec7d1cec10d", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "f63fe42a-900f-4a5e-ba99-ab0e59469b7e", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "b4bdbee1-e1f1-4436-8de4-bdb1b6ba4803", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "9444d178-2285-4842-ac35-5e86eda8da91", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "a5076337-734f-4b99-95ed-9a5bc73b9b09", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "7663c62b-40e3-4e6b-a835-70723ec2050b", "zone": "ams1"}], "name": "2019-03-05T16:39:34.377275"}], "current_public_version": "e640c621-305b-45f5-975f-a3f80c1cec66", "label": "ubuntu_bionic", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Ubuntu is the ideal distribution for scale-out computing, Ubuntu Server helps you make the most of your infrastructure.", "creation_date": "2016-04-22T13:27:33.769932+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "acf93867-88d9-40ee-99ea-6b2bb1ee8f0c", "categories": ["distribution"], "name": "Ubuntu Xenial", "modification_date": "2020-01-20T09:04:40.661026+00:00", "versions": [{"creation_date": "2020-01-17T14:31:06.041118+00:00", "modification_date": "2020-01-17T14:31:06.041118+00:00", "id": "24cd2ef0-bbc5-4b1a-8b08-99f617eab446", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "3d6804e0-086e-4a06-8124-7240a657668d", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "245e5cea-a9b4-4a36-9055-27185afe8690", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "c40fbabc-efc8-4e04-91ea-5e1e22daece1", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "bd859e89-fb2d-466a-a546-383630a1ead1", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "6c34a3f3-5e8a-455b-9bc2-f07c4c35bf89", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a5f6bb77-3d64-4f7f-abe0-72492b1bc020", "zone": "par1"}], "name": "2020-01-17T14:31:06.031136"}], "current_public_version": "24cd2ef0-bbc5-4b1a-8b08-99f617eab446", "label": "ubuntu_xenial", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Debian is a free, powerful and stable operating system.", "creation_date": "2017-06-26T15:37:13.460764+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/debian.png", "id": "c94b5df7-e698-4ac9-b273-565d18f5f8d2", "categories": ["distribution"], "name": "Debian Stretch", "modification_date": "2020-01-20T09:04:42.765883+00:00", "versions": [{"creation_date": "2020-01-15T11:38:06.396694+00:00", "modification_date": "2020-01-15T11:38:06.396694+00:00", "id": "8342f5d0-46aa-46e7-8a6f-f41188c97fba", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "5f7ab0cd-d10e-49a0-91c8-315ed8a6a1a4", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "d954dc33-c52e-4960-93e1-b69c85d169be", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "22a1bd8d-4498-4800-a8e5-4bc85001176c", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "37938de8-e3be-479a-895d-095158f76212", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "86740237-62fc-4538-9b70-4373942f53d3", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "bd6ba96e-d4c4-41f9-88e2-8dad3e6f085b", "zone": "par1"}], "name": "2020-01-15T11:38:06.390074"}], "current_public_version": "8342f5d0-46aa-46e7-8a6f-f41188c97fba", "label": "debian_stretch", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Debian is a free, powerful and stable operating system.", "creation_date": "2016-03-05T14:52:36.322319+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/debian.png", "id": "fb619bdf-834e-4c71-b7b8-15b5546d18bd", "categories": ["distribution"], "name": "Debian Jessie", "modification_date": "2019-03-26T14:00:50.449502+00:00", "versions": [{"creation_date": "2018-04-10T22:31:04.322822+00:00", "modification_date": "2018-04-10T22:31:04.322822+00:00", "id": "d3846a7b-8219-4938-ad96-cc2173e22481", "local_images": [{"compatible_commercial_types": ["C1"], "arch": "arm", "id": "2dfad6d2-e527-4e93-8eb1-8dc57803b310", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "610f68d5-cbad-4923-98ae-782af8f3b527", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "dc22e553-2d2e-4689-94f8-8817db824202", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "2e570f53-199e-47cc-95dd-f7bc392496e3", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "abf9e3a2-7171-4764-91ef-57f30b21193d", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "69cbdd54-88a1-4458-b75e-662a0848a7ce", "zone": "ams1"}], "name": "2018-04-10T22:31:04.321157"}], "current_public_version": "d3846a7b-8219-4938-ad96-cc2173e22481", "label": "debian_jessie", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "The CentOS Project is a community-driven free software effort focused on delivering a robust open source ecosystem.", "creation_date": "2019-03-06T11:27:48.406290+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/centos.png", "id": "1d47b370-ac63-43b1-9f34-7328675e5e18", "categories": ["distribution"], "name": "CentOS 7.6", "modification_date": "2019-03-26T14:00:50.839069+00:00", "versions": [{"creation_date": "2019-03-18T09:29:00.247544+00:00", "modification_date": "2019-03-18T09:29:00.247544+00:00", "id": "53138072-3099-4566-8b18-de7b2739696a", "local_images": [{"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "05794ee5-c6d2-4d69-86dd-f1fc9032921d", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "0f44b130-2bc7-4f82-993e-de9d1042c56e", "zone": "par1"}], "name": "2019-03-18T09:29:00.168590"}], "current_public_version": "53138072-3099-4566-8b18-de7b2739696a", "label": "centos_7.6", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "The CentOS Project is a community-driven free software effort focused on delivering a robust open source ecosystem.", "creation_date": "2018-04-19T10:12:28.968536+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/centos.png", "id": "98fc244a-ed4c-4523-bd17-b9c4070b8e7e", "categories": ["distribution"], "name": "CentOS 7.4", "modification_date": "2019-03-26T14:00:53.445597+00:00", "versions": [{"creation_date": "2018-04-20T13:55:06.824033+00:00", "modification_date": "2018-04-20T13:55:06.824033+00:00", "id": "31be34e5-074d-4c63-8c77-454459f77c3f", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "ec8b431e-ad39-4523-8b94-f3fa7f3cbd06", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "7220ac63-bac8-484b-9d44-93e3bd01f5a6", "zone": "ams1"}], "name": "2018-04-20T13:55:06.817954"}], "current_public_version": "31be34e5-074d-4c63-8c77-454459f77c3f", "label": "centos_7.4", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Fedora is a powerful, flexible operating system that includes the best and latest datacenter technologies. It puts you in control of all your infrastructure and services.", "creation_date": "2019-03-06T09:07:51.652433+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/fedora.png", "id": "69adec15-f1a7-469a-9ba5-868577832521", "categories": ["distribution"], "name": "Fedora 29", "modification_date": "2019-03-26T14:00:51.848785+00:00", "versions": [{"creation_date": "2019-03-06T09:08:01.112958+00:00", "modification_date": "2019-03-06T09:08:01.112958+00:00", "id": "a0f02365-f1af-48cb-b82d-75853a4e05e1", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "541f4562-5417-4b59-85d6-caaf64c1f127", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "3c0f706e-0947-47a3-88a3-595c29f7567a", "zone": "ams1"}], "name": "2019-03-06T09:08:01.016040"}], "current_public_version": "a0f02365-f1af-48cb-b82d-75853a4e05e1", "label": "fedora_29", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "Fedora is a powerful, flexible operating system that includes the best and latest datacenter technologies. It puts you in control of all your infrastructure and services.", "creation_date": "2018-05-03T09:51:57.274011+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/fedora.png", "id": "30d0f04f-6422-4b74-9ce9-1c2267419978", "categories": ["distribution"], "name": "Fedora 28", "modification_date": "2019-03-26T14:00:50.156015+00:00", "versions": [{"creation_date": "2018-05-03T12:01:10.147973+00:00", "modification_date": "2018-05-03T12:01:10.147973+00:00", "id": "49e33199-28cc-44d6-bb2e-a6147944ad5c", "local_images": [{"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "830aad94-24e5-4363-b2c3-e62921bd9294", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "c9cd1782-2159-44b8-83b1-9c48ed6c8a63", "zone": "par1"}], "name": "2018-05-03T12:01:10.135200"}], "current_public_version": "49e33199-28cc-44d6-bb2e-a6147944ad5c", "label": "fedora_28", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Fedora is a powerful, flexible operating system that includes the best and latest datacenter technologies. It puts you in control of all your infrastructure and services.", "creation_date": "2018-04-19T10:14:08.648100+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/fedora.png", "id": "4bff4f37-3ef9-457e-9e8d-4a786cb2a5f2", "categories": ["distribution"], "name": "Fedora 27", "modification_date": "2019-03-26T14:00:53.140907+00:00", "versions": [{"creation_date": "2018-09-06T10:51:13.009967+00:00", "modification_date": "2018-09-06T10:51:13.009967+00:00", "id": "45b5823f-8ddf-4ea8-b106-33d2df127cdf", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "097a100e-fd2f-4918-8a5b-d86de5a489be", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "73f0bcd8-a152-4665-ac09-1b105905a475", "zone": "ams1"}], "name": "2018-09-06T10:51:13.011044"}], "current_public_version": "45b5823f-8ddf-4ea8-b106-33d2df127cdf", "label": "fedora_27", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Arch Linux is an independently developed Linux distribution versatile enough to suit any role.", "creation_date": "2016-03-07T20:55:32.213089+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/archlinux.png", "id": "8f60c5dd-e659-48da-97e3-fb7de42195f5", "categories": ["distribution"], "name": "Arch Linux", "modification_date": "2019-03-26T14:00:49.327070+00:00", "versions": [{"creation_date": "2018-04-20T15:59:04.594929+00:00", "modification_date": "2018-04-20T15:59:04.594929+00:00", "id": "f7696517-bc49-448b-9869-f2c84e7c2a96", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f21defd0-9fd9-4fb2-a29a-22844a6be3cd", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "3c904f73-080e-4c6f-8b28-8426cfdcb3c7", "zone": "ams1"}], "name": "2018-04-20T15:59:04.593811"}], "current_public_version": "f7696517-bc49-448b-9869-f2c84e7c2a96", "label": "arch_linux", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Alpine Linux is security-oriented, lightweight Linux distribution based on musl libc and busybox.", "creation_date": "2016-03-05T14:49:50.255568+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/alpinelinux.png", "id": "c0649a2a-e6bf-4712-9303-8d967153209c", "categories": ["distribution"], "name": "Alpine Linux", "modification_date": "2019-03-26T14:00:54.425917+00:00", "versions": [{"creation_date": "2018-04-26T10:18:10.201002+00:00", "modification_date": "2018-04-26T10:18:10.201002+00:00", "id": "be2293b6-9eba-4497-9659-2cfb927483b5", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "24141068-1043-4885-bf2b-8290f617e273", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "241b0bb3-9eed-4a7b-b0fd-71c45452ac95", "zone": "ams1"}], "name": "2018-04-26T10:18:10.196011"}], "current_public_version": "be2293b6-9eba-4497-9659-2cfb927483b5", "label": "alpine_linux", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Debian is a free operating system, developed by thousands of volunteers from all over the world who collaborate via the Internet.", "creation_date": "2019-07-16T13:55:36.377559+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/debian.png", "id": "7bdc1afb-231f-486a-9b85-1b0478bc0e4a", "categories": ["distribution"], "name": "Debian Buster", "modification_date": "2020-01-20T09:04:41.730609+00:00", "versions": [{"creation_date": "2020-01-15T11:52:04.860098+00:00", "modification_date": "2020-01-15T11:52:04.860098+00:00", "id": "763b45ed-2e31-4ba0-9beb-efb195503a2d", "local_images": [{"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "61010e34-7f1e-402b-a253-028a714a6678", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "4720c10f-59e3-4e20-915b-dcee1fc34c11", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "9d6e8a2c-31a9-439c-a4c5-9fba1c5b96ed", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "cc9188b3-3938-47d7-b091-c9ecad1fe507", "zone": "par1"}], "name": "2020-01-15T11:52:04.849401"}], "current_public_version": "763b45ed-2e31-4ba0-9beb-efb195503a2d", "label": "debian_buster", "organization": {"id": "51b656e3-4865-41e8-adbc-0c45bdd780db", "name": "Instances User Resources Build System"}}, {"valid_until": null, "description": "Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications.", "creation_date": "2016-03-05T15:11:26.847640+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/docker.png", "id": "c1b530d8-0ca0-45c4-80db-ba06608287b2", "categories": ["instantapp"], "name": "Docker", "modification_date": "2019-03-26T14:00:49.524465+00:00", "versions": [{"creation_date": "2019-03-07T17:07:39.090644+00:00", "modification_date": "2019-03-07T17:07:39.090644+00:00", "id": "bf30c937-6e89-4019-ad2a-92156a62cf3e", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "89c80d27-ddf4-4ffa-8215-b335cce3fd05", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "99e2a9c6-f0b9-42b6-8823-8b0d86ffe9bf", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "45a7e942-1fb0-48c0-bbf6-0acb9af24604", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "c669011a-ee16-42b6-b0c3-ecd19e419539", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "dcf35840-c007-4c8b-a48b-227cfd8a347b", "zone": "ams1"}], "name": "2019-03-07T17:07:39.004809"}], "current_public_version": "bf30c937-6e89-4019-ad2a-92156a62cf3e", "label": "docker", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "GitLab is a web-based Git repository manager with wiki and issue tracking features.", "creation_date": "2016-03-07T21:06:22.770864+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/gitlab.png", "id": "233074b9-e2ba-4e78-818e-dd4930ce6bee", "categories": ["instantapp"], "name": "GitLab", "modification_date": "2019-04-09T13:31:04.022755+00:00", "versions": [{"creation_date": "2019-04-09T13:31:03.648676+00:00", "modification_date": "2019-04-09T13:31:03.648676+00:00", "id": "a389c94b-8b19-4528-a4f6-0b7cac3425e9", "local_images": [{"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "06a2a6e9-922d-4353-9472-bbb1f79fda63", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "4527e41c-0e90-43a8-857e-d9584bf8467f", "zone": "par1"}], "name": "2019-04-09T13:31:03.352588"}], "current_public_version": "a389c94b-8b19-4528-a4f6-0b7cac3425e9", "label": "gitlab", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "A painless self-hosted Git service.", "creation_date": "2016-03-07T21:00:44.946716+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/gogs.png", "id": "90d512b8-e4b7-4821-98e9-78241d73a7e6", "categories": ["instantapp"], "name": "Gogs", "modification_date": "2019-03-26T14:00:54.513196+00:00", "versions": [{"creation_date": "2018-05-16T15:11:25.881343+00:00", "modification_date": "2018-05-16T15:11:25.881343+00:00", "id": "1b9e22e3-6a29-4f42-acfd-281ad086ee1d", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "776705c4-be8e-4a27-b740-2e8bbba518c5", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a513a250-e6e9-4687-892e-9d10b29e3972", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "d1341ece-ffda-4386-ad3a-27d60b650401", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "69b8bc0e-7771-42af-a4ad-ca756c31a18a", "zone": "ams1"}], "name": "2018-05-16T15:11:25.303762"}], "current_public_version": "1b9e22e3-6a29-4f42-acfd-281ad086ee1d", "label": "gogs", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.A dynamic, open source programming language with a focus on simplicity and productivity.", "creation_date": "2016-03-08T07:01:11.482482+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/golang.png", "id": "6c8d25c0-cb6f-4220-98aa-830b7e479ba5", "categories": ["instantapp"], "name": "Golang", "modification_date": "2019-03-26T14:00:52.861225+00:00", "versions": [{"creation_date": "2018-04-18T08:00:48.175340+00:00", "modification_date": "2018-04-18T08:00:48.175340+00:00", "id": "880194c8-53ce-4b6b-a274-4f79307e2f8e", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "43213956-c7a3-44b8-9d96-d51fa7457969", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "5ffb52aa-ea55-4596-9d0f-e403701b6624", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "bef7a6af-1bab-490a-a6cb-6a07c1b9ac7b", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "f0b7d9b8-aa31-45b4-9f7e-a68aa164ce6f", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "76ca1eb7-f68f-4770-a7a1-ab7665ae3297", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "0d954c34-341c-483a-be1c-71cf197343ed", "zone": "ams1"}], "name": "2018-04-18T08:00:48.129246"}], "current_public_version": "880194c8-53ce-4b6b-a274-4f79307e2f8e", "label": "golang", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Java is a computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible.", "creation_date": "2016-03-07T21:07:46.908969+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/java.png", "id": "d72d1b73-7460-446b-91fb-b451d079aa4d", "categories": ["instantapp"], "name": "Java", "modification_date": "2019-03-26T14:00:49.430836+00:00", "versions": [{"creation_date": "2018-04-18T10:11:18.535736+00:00", "modification_date": "2018-04-18T10:11:18.535736+00:00", "id": "f3f69cca-aadb-4e5e-94b0-254ce05a6639", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "c50cb4b2-bf7b-47e2-ab5f-3a9d3d4c1aef", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "98c93894-26a8-463b-a72b-c9d2b531b95d", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "43c43b5e-1e4f-4905-baef-71df3c565b4d", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "0c3f9f03-f490-444b-a05e-f342e917fed0", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "5e07622b-ad8b-4f65-b55f-cca18c3c0bbf", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "c0330755-e5d0-4c2c-ad0e-70687e1dccbb", "zone": "par1"}], "name": "2018-04-18T10:11:18.477156"}], "current_public_version": "f3f69cca-aadb-4e5e-94b0-254ce05a6639", "label": "java", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "LEMP stack is a version where Apache has been replaced with the more lightweight web server Nginx.", "creation_date": "2016-03-07T21:06:53.552980+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/lemp.png", "id": "986ba672-b489-4f66-9e3b-90194ac336d4", "categories": ["instantapp"], "name": "LEMP stack", "modification_date": "2019-04-09T13:31:12.129567+00:00", "versions": [{"creation_date": "2019-04-09T13:31:11.315416+00:00", "modification_date": "2019-04-09T13:31:11.315416+00:00", "id": "a2e5ed1a-6f01-4f20-aabd-4115c67df590", "local_images": [{"compatible_commercial_types": ["C1"], "arch": "arm", "id": "32332006-1420-4260-97c7-c1da586f68cd", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "d16622f6-32c1-4d16-a3ca-38b23d3a25fb", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "1bd37d60-4494-485f-9a82-0a211005489c", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "415d3727-0013-419a-abc6-1a688b096730", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "26c3727a-5b77-4b26-89c9-445ea2006f07", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "155ab61a-e069-4acb-bae3-e8217c5c0376", "zone": "ams1"}], "name": "2019-04-09T13:31:10.613803"}], "current_public_version": "a2e5ed1a-6f01-4f20-aabd-4115c67df590", "label": "lemp_stack", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "self-hosted Slack-alternative", "creation_date": "2016-07-11T14:52:57.803007+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/mattermost.png", "id": "98ad7ccb-cc7f-4828-9da3-113e9c1bd2db", "categories": ["instantapp"], "name": "Mattermost", "modification_date": "2019-03-26T14:00:51.938920+00:00", "versions": [{"creation_date": "2018-05-03T10:27:55.610920+00:00", "modification_date": "2018-05-03T10:27:55.610920+00:00", "id": "42371bf7-c1ca-4889-a6d4-43febda865ca", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "486e128c-fde7-42d7-9200-5d91b8dc2761", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "eb2ed407-177c-4195-a4ca-f3baa85e62ed", "zone": "ams1"}], "name": "2018-05-03T10:27:55.021511"}], "current_public_version": "42371bf7-c1ca-4889-a6d4-43febda865ca", "label": "mattermost", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Nextcloud is an open source, self-hosted file share and communication platform.", "creation_date": "2019-04-16T12:22:56.930842+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/nextcloud.png", "id": "7d4a7cb1-1fd5-4a64-920b-c79f47367254", "categories": ["instantapp"], "name": "NextCloud", "modification_date": "2019-04-16T12:25:38.758921+00:00", "versions": [{"creation_date": "2019-04-16T12:25:38.052537+00:00", "modification_date": "2019-04-16T12:25:38.052537+00:00", "id": "2fe66cc6-8985-4b5f-8325-83acc0589436", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "e9af0a24-4312-4305-9386-b3a79e02f92d", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "c38073cf-ee40-4dc2-8059-ec2845f38f46", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "b9e319f5-ac4c-400d-8ff6-a6a769755190", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "0390c3e0-186d-4b24-8d0d-0e08b74fb59a", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "900971a4-3a3e-4ef9-b92f-b33c366c9f5c", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "7b7d4dde-6fe1-4586-a5a5-ae1af2ca2605", "zone": "par1"}], "name": "2019-04-16T12:25:37.374676"}], "current_public_version": "2fe66cc6-8985-4b5f-8325-83acc0589436", "label": "nextcloud", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "Node.js is an open source, cross-platform runtime environment for server-side and networking applications.", "creation_date": "2016-03-07T21:06:07.014951+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/nodejs.png", "id": "d11d7cc2-6ec8-4f95-a286-24fb5bac9e39", "categories": ["instantapp"], "name": "Node.js", "modification_date": "2019-03-26T14:00:51.148549+00:00", "versions": [{"creation_date": "2018-04-18T10:07:15.744660+00:00", "modification_date": "2018-04-18T10:07:15.744660+00:00", "id": "af308511-bcb3-4583-b0e0-79dbb1eea63e", "local_images": [{"compatible_commercial_types": [], "arch": "arm", "id": "a8020f20-8a66-43f3-8253-35941db3d237", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "3cc79cc6-4649-46d9-a2b6-698f1236e1d0", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "c9fb2bed-a9b8-4e1a-bf15-db8e763fe7a7", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f01db1d0-092a-47de-a32e-09bd6bda7715", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "6f2e99e8-da99-4990-b689-7294e8a604fa", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "03980aee-14cd-44f1-be3c-508c8b8a19e6", "zone": "par1"}], "name": "2018-04-18T10:07:15.691016"}], "current_public_version": "af308511-bcb3-4583-b0e0-79dbb1eea63e", "label": "node.js", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Surf the web in a secure and anonymous way with OpenVPN InstantApp.", "creation_date": "2016-03-07T21:04:57.667667+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/openvpn.png", "id": "b6f4edc8-21e6-4aa2-8f52-1030cf6d4dd8", "categories": ["instantapp"], "name": "OpenVPN", "modification_date": "2019-03-26T14:00:52.955853+00:00", "versions": [{"creation_date": "2019-03-25T13:06:02.622633+00:00", "modification_date": "2019-03-25T13:06:02.622633+00:00", "id": "d812e374-1169-4c91-aa90-c72acceeecb2", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "b15ddb1a-0611-412e-881a-3aed1b36392b", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "02906ae8-bf44-4dd0-bd05-6312dd9fa234", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "3aa3622c-45d4-4388-9618-cce6974c71a0", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a5430536-2a51-425d-8613-ef84dae91e27", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "51573d2d-301f-4d24-b0d6-f151728c82f5", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "cac79531-98d5-48fa-aba1-8250214b88a3", "zone": "par1"}], "name": "2019-03-25T13:06:01.961936"}], "current_public_version": "d812e374-1169-4c91-aa90-c72acceeecb2", "label": "openvpn", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "ownCloud lets you sync & share your files, calendar, contacts and more. Access your data from all your devices, on an open platform you can extend and modify.", "creation_date": "2016-03-07T21:05:14.365925+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/owncloud.png", "id": "e22a5d54-ecb5-4fdd-a130-a473737ff7ab", "categories": ["instantapp"], "name": "ownCloud", "modification_date": "2019-03-26T14:00:52.457272+00:00", "versions": [{"creation_date": "2018-04-18T10:09:39.010195+00:00", "modification_date": "2018-04-18T10:09:39.010195+00:00", "id": "c9c02a9c-e072-48af-aefd-bf6be9028022", "local_images": [{"compatible_commercial_types": [], "arch": "arm", "id": "a5fb716a-1c60-4740-a179-98ce315ca3d7", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "2fdbbbb4-3b63-403b-9604-27713971efd6", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "4208a611-a789-40ea-ac0e-fb3001ee39a9", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "93de8eae-535f-47bd-88fa-84af7b5eaf76", "zone": "par1"}], "name": "2018-04-18T10:09:38.952503"}], "current_public_version": "c9c02a9c-e072-48af-aefd-bf6be9028022", "label": "owncloud", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "PrestaShop is a free, open source e-commerce solution.", "creation_date": "2016-03-07T21:01:47.997930+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/prestashop.png", "id": "58a551e0-1b8b-4c83-82e7-1b4602ad43d1", "categories": ["instantapp"], "name": "PrestaShop", "modification_date": "2019-03-26T14:00:50.067950+00:00", "versions": [{"creation_date": "2018-05-16T14:57:16.059809+00:00", "modification_date": "2018-05-16T14:57:16.059809+00:00", "id": "6c459ab1-4f1a-4f87-b92e-c00849c93fde", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "4d07fcfa-ccda-4945-81aa-8de2206b39c0", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "73db574d-d5a0-49d5-b6ca-dd662895fac3", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "c97dc20f-8066-4d56-aabf-2b75162c0f9f", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "c78c3206-eb2b-4217-ad7c-0aca98dec145", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "7f91941c-f06a-4103-91a4-793f03b11fda", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "271a9c1f-73ef-4943-bac7-799130228040", "zone": "ams1"}], "name": "2018-05-16T14:57:15.505378"}], "current_public_version": "6c459ab1-4f1a-4f87-b92e-c00849c93fde", "label": "prestashop", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "The intended audience of this InstantApp is Python developers who want to bootstrap or test a Python application easily, in seconds.", "creation_date": "2016-03-07T21:05:46.642023+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/python.png", "id": "5c0f7971-c308-442e-82ab-2eb147439bd7", "categories": ["instantapp"], "name": "Python", "modification_date": "2019-03-26T14:00:49.970905+00:00", "versions": [{"creation_date": "2018-04-17T16:43:36.089412+00:00", "modification_date": "2018-04-17T16:43:36.089412+00:00", "id": "2642a982-e61d-4a58-8105-8838a69a85e3", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "70b9c9cf-c2d9-4a80-b450-a7aef8226d96", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "5218fa4e-8239-4831-ac2a-c96e23f387a2", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "f205e2a6-621a-4534-a5d1-36f6cf1f8376", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "613a5226-3d97-4f0e-abe2-99385a050784", "zone": "ams1"}], "name": "2018-04-17T16:43:36.031203"}], "current_public_version": "2642a982-e61d-4a58-8105-8838a69a85e3", "label": "python", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "A dynamic, open source programming language with a focus on simplicity and productivity.", "creation_date": "2016-03-07T22:15:25.347873+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ruby.png", "id": "42866fbe-9168-4f77-8271-09beb6049a07", "categories": ["instantapp"], "name": "Ruby", "modification_date": "2019-03-26T14:00:54.119256+00:00", "versions": [{"creation_date": "2018-04-18T10:21:49.119857+00:00", "modification_date": "2018-04-18T10:21:49.119857+00:00", "id": "5b8c935b-5047-43fd-a423-045dae3e0d78", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "09c71ada-00c6-43de-ad44-c77c5b857a05", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "24f2e8ee-80f1-4a8d-83c4-74ed8cd80ed0", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "e2479a13-414b-4a0c-ba50-d01e67ee8600", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "f83a03fa-58eb-4b35-bda9-1a42b6d6d90d", "zone": "ams1"}], "name": "2018-04-18T10:21:49.057120"}], "current_public_version": "5b8c935b-5047-43fd-a423-045dae3e0d78", "label": "ruby", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "The torrents InstantApp spawns a private server to upload and download your digital files.", "creation_date": "2016-03-07T21:08:02.980958+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/seedbox.png", "id": "4e18f1fc-0b66-4692-a38d-bfa4c94f29de", "categories": ["instantapp"], "name": "Torrents", "modification_date": "2019-03-26T14:00:51.427329+00:00", "versions": [{"creation_date": "2019-03-25T13:04:02.099902+00:00", "modification_date": "2019-03-25T13:04:02.099902+00:00", "id": "53d2e4fb-20df-4ba9-8d65-29256f2be480", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "41d0db97-4822-4642-96ec-6f3fbcfc167c", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "3fbe5f72-81da-4a0a-91ef-36ab68fc801e", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "1aed7396-79dc-431d-af03-d3dde35d195f", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "398875b6-de43-4946-976f-ba5189954912", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a3160162-3d72-4632-8e42-4849a1280743", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f5d116e3-2b58-44cf-a83a-cd0682135473", "zone": "par1"}], "name": "2019-03-25T13:04:01.408435"}], "current_public_version": "53d2e4fb-20df-4ba9-8d65-29256f2be480", "label": "torrents", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Ubuntu is the ideal distribution for scale-out computing, Ubuntu Server helps you make the most of your infrastructure.", "creation_date": "2020-02-17T15:50:48.980694+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "3f1b9623-71ba-4fe3-b994-27fcdaa850ba", "categories": ["distribution"], "name": "Ubuntu 20.04 Focal Fossa", "modification_date": "2020-05-12T14:59:11.764621+00:00", "versions": [{"creation_date": "2020-05-12T14:08:49.605637+00:00", "modification_date": "2020-05-12T14:08:49.605637+00:00", "id": "8a23f8ac-240c-4c9c-b20e-c611361e0148", "local_images": [{"compatible_commercial_types": ["VC1S", "VC1M", "VC1L", "START1-XS", "START1-S", "START1-M", "START1-L", "X64-15GB", "X64-30GB", "X64-60GB", "X64-120GB", "GP1-XS", "GP1-S", "GP1-M", "GP1-L", "GP1-XL", "DEV1-S", "DEV1-M", "DEV1-L", "DEV1-XL"], "arch": "x86_64", "id": "365a8b9c-0c6e-4875-a887-dc3213db9e20", "zone": "par1"}, {"compatible_commercial_types": ["VC1S", "VC1M", "VC1L", "START1-XS", "START1-S", "START1-M", "START1-L", "X64-15GB", "X64-30GB", "X64-60GB", "X64-120GB", "GP1-XS", "GP1-S", "GP1-M", "GP1-L", "GP1-XL", "DEV1-S", "DEV1-M", "DEV1-L", "DEV1-XL"], "arch": "x86_64", "id": "80d81811-1bd2-44dc-bd1c-ec070c80c40b", "zone": "ams1"}], "name": "2020-05-12T14:08:49.566279+00:00"}], "current_public_version": "8a23f8ac-240c-4c9c-b20e-c611361e0148", "label": "ubuntu_focal", "organization": {"id": "51b656e3-4865-41e8-adbc-0c45bdd780db", "name": "Instances User Resources Build System"}}, {"valid_until": null, "description": "Ubuntu Bionic for Machine Learning 10.1", "creation_date": "2019-03-06T17:24:56.871317+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "e0808ca5-1e0a-4070-8aff-d2e49e9600c1", "categories": ["Machine Learning"], "name": "Ubuntu Bionic ML 10.1", "modification_date": "2020-02-17T12:56:29.417410+00:00", "versions": [{"creation_date": "2020-02-17T12:50:10.150196+00:00", "modification_date": "2020-02-17T12:50:10.150196+00:00", "id": "50a39102-80cf-4c9b-aed8-919e745df9d5", "local_images": [{"compatible_commercial_types": ["RENDER-S"], "arch": "x86_64", "id": "8fa4f46b-2cb2-40df-813a-727df120b9e4", "zone": "par1"}], "name": "2020-02-17T12:50:10.040529"}], "current_public_version": "50a39102-80cf-4c9b-aed8-919e745df9d5", "label": "ubuntu_bionic_ml_10.1", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "Ubuntu Bionic for Machine Learning 9.2", "creation_date": "2019-03-06T17:24:29.909001+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "7e48e55a-7b46-4e4f-b2d2-6b7316cdca8c", "categories": ["Machine Learning"], "name": "Ubuntu Bionic ML 9.2", "modification_date": "2020-02-17T12:55:53.623681+00:00", "versions": [{"creation_date": "2020-02-17T12:39:31.681271+00:00", "modification_date": "2020-02-17T12:39:31.681271+00:00", "id": "d0602033-62f8-455a-be55-0930291bb43f", "local_images": [{"compatible_commercial_types": ["RENDER-S"], "arch": "x86_64", "id": "1dad4207-f91a-48c3-9fac-6620e90b9434", "zone": "par1"}], "name": "2020-02-17T12:39:31.572184"}], "current_public_version": "d0602033-62f8-455a-be55-0930291bb43f", "label": "ubuntu_bionic_ml_9.2", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "WordPress is the most popular web software you can use to create a beautiful website or blog.", "creation_date": "2016-03-07T21:03:59.783534+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/wordpress.png", "id": "215a50f9-0ba8-4e9c-a4e7-10caf50e3586", "categories": ["instantapp"], "name": "WordPress", "modification_date": "2019-03-26T14:00:50.250657+00:00", "versions": [{"creation_date": "2019-03-08T08:58:28.971149+00:00", "modification_date": "2019-03-08T08:58:28.971149+00:00", "id": "3fb22e1f-de7f-4787-9bf8-32770151a45e", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "8523fb41-500a-4f21-998b-890908da6119", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "5645133b-67a3-4644-9941-16f7e2b428ea", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "757fac76-5265-46f8-8a1f-00c0fb270010", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "7a892c1a-bbdc-491f-9974-4008e3708664", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "726334eb-0733-4b6a-becd-769ff9bfe16d", "zone": "ams1"}], "name": "2019-03-08T08:58:28.893091"}], "current_public_version": "3fb22e1f-de7f-4787-9bf8-32770151a45e", "label": "wordpress", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}]}' headers: Cache-Control: - no-cache Content-Length: - "53981" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 04 Jun 2020 12:09:46 GMT Link: - ; rel="last" Server: - agw_listener_public_anycast Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - b7883ad1-9619-413d-8df0-920a49624e88 X-Total-Count: - "31" status: 200 OK code: 200 duration: "" - request: body: '{"name":"srv-hopeful-babbage","commercial_type":"DEV1-M","image":"365a8b9c-0c6e-4875-a887-dc3213db9e20","organization":"951df375-e094-4d26-97c1-ba548eeb9c42"}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.3; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers method: POST response: body: '{"server": {"id": "58268fb6-0feb-45a7-89fd-c3a162e94045", "name": "srv-hopeful-babbage", "arch": "x86_64", "commercial_type": "DEV1-M", "boot_type": "local", "organization": "951df375-e094-4d26-97c1-ba548eeb9c42", "hostname": "srv-hopeful-babbage", "image": {"id": "365a8b9c-0c6e-4875-a887-dc3213db9e20", "name": "Ubuntu 20.04 Focal Fossa", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "903d339c-6144-4ca9-b2a0-9d280d6e3576", "name": "ubuntu_20.04_focal_fossa:volume-0", "volume_type": "l_ssd", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": "x86_64", "creation_date": "2020-05-12T14:08:16.646636+00:00", "modification_date": "2020-05-12T14:08:16.646636+00:00", "default_bootscript": null, "from_server": null, "state": "available", "zone": "fr-par-1"}, "volumes": {"0": {"id": "47b30be2-c56a-4d62-ab55-3a3a64ce45e1", "name": "ubuntu_20.04_focal_fossa:volume-0", "volume_type": "l_ssd", "export_uri": null, "organization": "951df375-e094-4d26-97c1-ba548eeb9c42", "server": {"id": "58268fb6-0feb-45a7-89fd-c3a162e94045", "name": "srv-hopeful-babbage"}, "size": 40000000000, "state": "available", "creation_date": "2020-06-04T12:09:46.628399+00:00", "modification_date": "2020-06-04T12:09:47.013929+00:00", "zone": "fr-par-1"}}, "tags": [], "state": "stopped", "protected": false, "state_detail": "", "public_ip": null, "ipv6": null, "extra_networks": [], "dynamic_ip_required": true, "enable_ipv6": false, "private_ip": null, "creation_date": "2020-06-04T12:09:46.628399+00:00", "modification_date": "2020-06-04T12:09:46.628399+00:00", "bootscript": {"id": "34017869-d088-475c-b5ec-2cede3bb84e3", "public": true, "title": "x86_64 mainline 4.4.182 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.4-4.4.182-rev1/vmlinuz-4.4.182", "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": true, "zone": "fr-par-1"}, "security_group": {"id": "54e2d5f6-d79c-44cc-b19f-613699b9cc7e", "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": ["poweron", "backup"], "placement_group": null, "private_nics": [], "zone": "fr-par-1"}}' headers: Cache-Control: - no-cache Content-Length: - "2315" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 04 Jun 2020 12:09:46 GMT Location: - https://cp-par1.scaleway.com/servers/58268fb6-0feb-45a7-89fd-c3a162e94045 Server: - agw_listener_public_anycast Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 3eed903e-b1d3-4629-a711-7fd6e24e4753 status: 201 Created code: 201 duration: "" - request: body: '{"action":"backup","name":"backup"}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.3; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/58268fb6-0feb-45a7-89fd-c3a162e94045/action method: POST response: body: '{"task": {"status": "pending", "description": "server_backup", "href_result": "/images/5330ac21-9a20-4eca-9770-b04cc2108fa6", "terminated_at": null, "href_from": "/servers/58268fb6-0feb-45a7-89fd-c3a162e94045/action", "started_at": "2020-06-04T12:09:47.576880+00:00", "id": "9aa43be9-2335-4c59-920b-bdb53f056608"}}' headers: Content-Length: - "314" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 04 Jun 2020 12:09:47 GMT Location: - https://cp-par1.scaleway.com/tasks/9aa43be9-2335-4c59-920b-bdb53f056608 Server: - agw_listener_public_anycast Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - c2bf8d5c-5769-4e0d-a12f-54ae882239f5 status: 202 Accepted code: 202 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.3; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/images/5330ac21-9a20-4eca-9770-b04cc2108fa6 method: GET response: body: '{"image": {"id": "5330ac21-9a20-4eca-9770-b04cc2108fa6", "name": "backup", "organization": "951df375-e094-4d26-97c1-ba548eeb9c42", "root_volume": {"id": "63ac0902-5f9f-4d6e-8de4-b75f02e000c1", "name": "backup_snap_0", "volume_type": "l_ssd", "size": 40000000000}, "extra_volumes": {}, "public": false, "arch": "x86_64", "creation_date": "2020-06-04T12:09:47.078981+00:00", "modification_date": "2020-06-04T12:09:47.078981+00:00", "default_bootscript": {"id": "34017869-d088-475c-b5ec-2cede3bb84e3", "public": true, "title": "x86_64 mainline 4.4.182 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.4-4.4.182-rev1/vmlinuz-4.4.182", "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": true, "zone": "fr-par-1"}, "from_server": "58268fb6-0feb-45a7-89fd-c3a162e94045", "state": "available", "zone": "fr-par-1"}}' headers: Cache-Control: - no-cache Content-Length: - "1017" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 04 Jun 2020 12:09:47 GMT Server: - agw_listener_public_anycast Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 474f7f3e-f55c-4302-9a25-35ee9064c2fa status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.3; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/images/5330ac21-9a20-4eca-9770-b04cc2108fa6 method: GET response: body: '{"image": {"id": "5330ac21-9a20-4eca-9770-b04cc2108fa6", "name": "backup", "organization": "951df375-e094-4d26-97c1-ba548eeb9c42", "root_volume": {"id": "63ac0902-5f9f-4d6e-8de4-b75f02e000c1", "name": "backup_snap_0", "volume_type": "l_ssd", "size": 40000000000}, "extra_volumes": {}, "public": false, "arch": "x86_64", "creation_date": "2020-06-04T12:09:47.078981+00:00", "modification_date": "2020-06-04T12:09:47.078981+00:00", "default_bootscript": {"id": "34017869-d088-475c-b5ec-2cede3bb84e3", "public": true, "title": "x86_64 mainline 4.4.182 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.4-4.4.182-rev1/vmlinuz-4.4.182", "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": true, "zone": "fr-par-1"}, "from_server": "58268fb6-0feb-45a7-89fd-c3a162e94045", "state": "available", "zone": "fr-par-1"}}' headers: Cache-Control: - no-cache Content-Length: - "1017" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 04 Jun 2020 12:09:47 GMT Server: - agw_listener_public_anycast Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - f2790c1b-a83f-43fa-8998-cdcc30fadef9 status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.3; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/58268fb6-0feb-45a7-89fd-c3a162e94045 method: DELETE response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 04 Jun 2020 12:09:47 GMT Server: - agw_listener_public_anycast Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - d9254def-61fc-4a2a-a670-480767b8bc97 status: 204 No Content code: 204 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.3; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/47b30be2-c56a-4d62-ab55-3a3a64ce45e1 method: DELETE response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 04 Jun 2020 12:09:47 GMT Server: - agw_listener_public_anycast Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 3a71398b-3b17-4743-97a0-9a7f3ded2753 status: 204 No Content code: 204 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.3; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/images/5330ac21-9a20-4eca-9770-b04cc2108fa6 method: DELETE response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 04 Jun 2020 12:09:49 GMT Server: - agw_listener_public_anycast Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 5c6b3b4b-11b0-4a1a-b712-e9904b8fe510 status: 204 No Content code: 204 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.3; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/snapshots/63ac0902-5f9f-4d6e-8de4-b75f02e000c1 method: DELETE response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 04 Jun 2020 12:09:49 GMT Server: - agw_listener_public_anycast Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - eae93dc8-624d-47e6-8cd7-349df155e80a status: 204 No Content code: 204 duration: "" security-group-rule-test.yaml000066400000000000000000000505421456366605600345300ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/testdata--- version: 1 interactions: - request: body: '{"name":"name","description":"description","project":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","stateful":true,"inbound_default_policy":"accept","outbound_default_policy":"drop"}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups method: POST response: body: '{"security_group": {"id": "4c3665d1-686b-4e00-8227-01008a3e311f", "creation_date": "2023-12-04T09:54:26.090979+00:00", "modification_date": "2023-12-04T09:54:26.090979+00:00", "name": "name", "description": "description", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "servers": [], "stateful": true, "inbound_default_policy": "accept", "outbound_default_policy": "drop", "organization_default": false, "project_default": false, "enable_default_security": true, "state": "syncing", "tags": [], "zone": "fr-par-1"}}' headers: Content-Length: - "575" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 04 Dec 2023 09:54:26 GMT Location: - https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/4c3665d1-686b-4e00-8227-01008a3e311f Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 424222bc-813c-4a07-9922-55e91c94738a status: 201 Created code: 201 duration: "" - request: body: '{"protocol":"TCP","direction":"inbound","action":"accept","ip_range":"8.8.8.8/32","dest_port_from":1,"dest_port_to":1024,"position":1}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/4c3665d1-686b-4e00-8227-01008a3e311f/rules method: POST response: body: '{"rule": {"id": "978fa298-455e-420c-9f6f-7adf41e50b22", "protocol": "TCP", "direction": "inbound", "ip_range": "8.8.8.8", "dest_ip_range": null, "dest_port_from": 1, "dest_port_to": 1024, "position": 1, "editable": true, "action": "accept", "zone": "fr-par-1"}}' headers: Content-Length: - "261" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 04 Dec 2023 09:54:26 GMT Location: - https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/4c3665d1-686b-4e00-8227-01008a3e311f/rules/978fa298-455e-420c-9f6f-7adf41e50b22 Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - a19442e9-1d1b-4c1e-848c-56585e787d21 status: 201 Created code: 201 duration: "" - request: body: '{"protocol":"UDP","direction":"outbound","action":"drop","ip_range":"1.1.1.1/32","dest_port_from":1,"dest_port_to":2048}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/4c3665d1-686b-4e00-8227-01008a3e311f/rules/978fa298-455e-420c-9f6f-7adf41e50b22 method: PATCH response: body: '{"rule": {"id": "978fa298-455e-420c-9f6f-7adf41e50b22", "protocol": "UDP", "direction": "outbound", "ip_range": "1.1.1.1", "dest_ip_range": null, "dest_port_from": 1, "dest_port_to": 2048, "position": 1, "editable": true, "action": "drop", "zone": "fr-par-1"}}' headers: Content-Length: - "260" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 04 Dec 2023 09:54:26 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 3604c2f3-68be-4bc4-ad42-bb6fa63ca9fa status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/4c3665d1-686b-4e00-8227-01008a3e311f method: DELETE response: body: "" headers: Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Date: - Mon, 04 Dec 2023 09:54:26 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - f5ba5034-24a2-48d8-bafd-6a19ed86b7bb status: 204 No Content code: 204 duration: "" - request: body: '{"name":"name","description":"description","project":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","stateful":true,"inbound_default_policy":"accept","outbound_default_policy":"drop"}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups method: POST response: body: '{"security_group": {"id": "107d6e04-9382-49eb-998c-73d965393940", "creation_date": "2023-12-04T09:54:26.920293+00:00", "modification_date": "2023-12-04T09:54:26.920293+00:00", "name": "name", "description": "description", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "servers": [], "stateful": true, "inbound_default_policy": "accept", "outbound_default_policy": "drop", "organization_default": false, "project_default": false, "enable_default_security": true, "state": "syncing", "tags": [], "zone": "fr-par-1"}}' headers: Content-Length: - "575" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 04 Dec 2023 09:54:26 GMT Location: - https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/107d6e04-9382-49eb-998c-73d965393940 Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 9dca7f70-e36c-4738-843e-e2e04bbf41e8 status: 201 Created code: 201 duration: "" - request: body: '{"protocol":"TCP","direction":"inbound","action":"accept","ip_range":"8.8.8.8/32","dest_port_from":1,"dest_port_to":1024,"position":1}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/107d6e04-9382-49eb-998c-73d965393940/rules method: POST response: body: '{"rule": {"id": "a8a7dbc6-ed53-41e0-97ef-69b552c445d0", "protocol": "TCP", "direction": "inbound", "ip_range": "8.8.8.8", "dest_ip_range": null, "dest_port_from": 1, "dest_port_to": 1024, "position": 1, "editable": true, "action": "accept", "zone": "fr-par-1"}}' headers: Content-Length: - "261" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 04 Dec 2023 09:54:27 GMT Location: - https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/107d6e04-9382-49eb-998c-73d965393940/rules/a8a7dbc6-ed53-41e0-97ef-69b552c445d0 Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 7c144588-2ffb-49d5-af8f-f03b5403f066 status: 201 Created code: 201 duration: "" - request: body: '{"protocol":"UDP","direction":"outbound","action":"drop","ip_range":"1.1.1.1/32","dest_port_from":22,"dest_port_to":22}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/107d6e04-9382-49eb-998c-73d965393940/rules/a8a7dbc6-ed53-41e0-97ef-69b552c445d0 method: PATCH response: body: '{"rule": {"id": "a8a7dbc6-ed53-41e0-97ef-69b552c445d0", "protocol": "UDP", "direction": "outbound", "ip_range": "1.1.1.1", "dest_ip_range": null, "dest_port_from": 22, "dest_port_to": null, "position": 1, "editable": true, "action": "drop", "zone": "fr-par-1"}}' headers: Content-Length: - "261" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 04 Dec 2023 09:54:27 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 77e019e5-af04-4203-b7a9-e9836acf0838 status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/107d6e04-9382-49eb-998c-73d965393940 method: DELETE response: body: "" headers: Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Date: - Mon, 04 Dec 2023 09:54:27 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 998c1bda-c845-424b-970e-134e8ce859b0 status: 204 No Content code: 204 duration: "" - request: body: '{"name":"name","description":"description","project":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","stateful":true,"inbound_default_policy":"accept","outbound_default_policy":"drop"}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups method: POST response: body: '{"security_group": {"id": "b7790067-7efe-414e-b936-b6ea53ef42c0", "creation_date": "2023-12-04T09:54:27.804840+00:00", "modification_date": "2023-12-04T09:54:27.804840+00:00", "name": "name", "description": "description", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "servers": [], "stateful": true, "inbound_default_policy": "accept", "outbound_default_policy": "drop", "organization_default": false, "project_default": false, "enable_default_security": true, "state": "syncing", "tags": [], "zone": "fr-par-1"}}' headers: Content-Length: - "575" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 04 Dec 2023 09:54:27 GMT Location: - https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/b7790067-7efe-414e-b936-b6ea53ef42c0 Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 024df3a3-d7d3-45b8-b503-87d59edb5237 status: 201 Created code: 201 duration: "" - request: body: '{"protocol":"TCP","direction":"inbound","action":"accept","ip_range":"8.8.8.8/32","dest_port_from":1,"dest_port_to":1024,"position":1}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/b7790067-7efe-414e-b936-b6ea53ef42c0/rules method: POST response: body: '{"rule": {"id": "78137458-81c6-4cd0-855b-85ac5b5d0ac6", "protocol": "TCP", "direction": "inbound", "ip_range": "8.8.8.8", "dest_ip_range": null, "dest_port_from": 1, "dest_port_to": 1024, "position": 1, "editable": true, "action": "accept", "zone": "fr-par-1"}}' headers: Content-Length: - "261" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 04 Dec 2023 09:54:28 GMT Location: - https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/b7790067-7efe-414e-b936-b6ea53ef42c0/rules/78137458-81c6-4cd0-855b-85ac5b5d0ac6 Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 0ea907af-640f-470e-ac51-4dcb6f84ffe6 status: 201 Created code: 201 duration: "" - request: body: '{"protocol":"ICMP"}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/b7790067-7efe-414e-b936-b6ea53ef42c0/rules/78137458-81c6-4cd0-855b-85ac5b5d0ac6 method: PATCH response: body: '{"rule": {"id": "78137458-81c6-4cd0-855b-85ac5b5d0ac6", "protocol": "ICMP", "direction": "inbound", "ip_range": "8.8.8.8", "dest_ip_range": null, "dest_port_from": null, "dest_port_to": null, "position": 1, "editable": true, "action": "accept", "zone": "fr-par-1"}}' headers: Content-Length: - "265" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 04 Dec 2023 09:54:28 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - bc059bec-471a-48f2-abb3-269f2a8f1826 status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/b7790067-7efe-414e-b936-b6ea53ef42c0 method: DELETE response: body: "" headers: Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Date: - Mon, 04 Dec 2023 09:54:28 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 8e1cfd8d-063d-4b5c-80c7-be8e142ca46b status: 204 No Content code: 204 duration: "" - request: body: '{"name":"name","description":"description","project":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","stateful":true,"inbound_default_policy":"accept","outbound_default_policy":"drop"}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups method: POST response: body: '{"security_group": {"id": "1ef8d388-748d-4662-a18d-d99827fe9f9d", "creation_date": "2023-12-04T09:54:28.598656+00:00", "modification_date": "2023-12-04T09:54:28.598656+00:00", "name": "name", "description": "description", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "servers": [], "stateful": true, "inbound_default_policy": "accept", "outbound_default_policy": "drop", "organization_default": false, "project_default": false, "enable_default_security": true, "state": "syncing", "tags": [], "zone": "fr-par-1"}}' headers: Content-Length: - "575" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 04 Dec 2023 09:54:28 GMT Location: - https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/1ef8d388-748d-4662-a18d-d99827fe9f9d Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - b19d7176-7d1d-401c-91ae-9f10a3c64092 status: 201 Created code: 201 duration: "" - request: body: '{"protocol":"TCP","direction":"inbound","action":"accept","ip_range":"8.8.8.8/32","dest_port_from":1,"dest_port_to":1024,"position":1}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/1ef8d388-748d-4662-a18d-d99827fe9f9d/rules method: POST response: body: '{"rule": {"id": "fc99eefd-00c8-445f-881f-2dc097825271", "protocol": "TCP", "direction": "inbound", "ip_range": "8.8.8.8", "dest_ip_range": null, "dest_port_from": 1, "dest_port_to": 1024, "position": 1, "editable": true, "action": "accept", "zone": "fr-par-1"}}' headers: Content-Length: - "261" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 04 Dec 2023 09:54:28 GMT Location: - https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/1ef8d388-748d-4662-a18d-d99827fe9f9d/rules/fc99eefd-00c8-445f-881f-2dc097825271 Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 76673ac9-433b-4d4f-900e-fce8af518127 status: 201 Created code: 201 duration: "" - request: body: '{"dest_port_from":0,"dest_port_to":0}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/1ef8d388-748d-4662-a18d-d99827fe9f9d/rules/fc99eefd-00c8-445f-881f-2dc097825271 method: PATCH response: body: '{"rule": {"id": "fc99eefd-00c8-445f-881f-2dc097825271", "protocol": "TCP", "direction": "inbound", "ip_range": "8.8.8.8", "dest_ip_range": null, "dest_port_from": null, "dest_port_to": null, "position": 1, "editable": true, "action": "accept", "zone": "fr-par-1"}}' headers: Content-Length: - "264" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 04 Dec 2023 09:54:29 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 464cbddf-1055-4894-ac1b-8ec6afd0e448 status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/1ef8d388-748d-4662-a18d-d99827fe9f9d method: DELETE response: body: "" headers: Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Date: - Mon, 04 Dec 2023 09:54:29 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - e1498644-a6ac-4aab-8cc3-c27a26b404f2 status: 204 No Content code: 204 duration: "" security-group-test.yaml000066400000000000000000000101351456366605600335550ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/testdata--- version: 1 interactions: - request: body: '{"name":"name","description":"description","project":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","stateful":true,"inbound_default_policy":"accept","outbound_default_policy":"drop"}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups method: POST response: body: '{"security_group": {"id": "47b2363e-f0a1-4f75-a45a-0c0375ed4eef", "creation_date": "2023-11-20T13:06:00.758750+00:00", "modification_date": "2023-11-20T13:06:00.758750+00:00", "name": "name", "description": "description", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "servers": [], "stateful": true, "inbound_default_policy": "accept", "outbound_default_policy": "drop", "organization_default": false, "project_default": false, "enable_default_security": true, "state": "syncing", "tags": [], "zone": "fr-par-1"}}' headers: Content-Length: - "575" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 20 Nov 2023 13:06:00 GMT Location: - https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/47b2363e-f0a1-4f75-a45a-0c0375ed4eef Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - e40b56b4-b73e-4d46-8db7-deaed04cba16 status: 201 Created code: 201 duration: "" - request: body: '{"name":"new_name","description":"new_description","inbound_default_policy":"drop","tags":["foo","bar"],"project_default":false,"outbound_default_policy":"accept","stateful":false}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/47b2363e-f0a1-4f75-a45a-0c0375ed4eef method: PATCH response: body: '{"security_group": {"id": "47b2363e-f0a1-4f75-a45a-0c0375ed4eef", "creation_date": "2023-11-20T13:06:00.758750+00:00", "modification_date": "2023-11-20T13:06:00.811016+00:00", "name": "new_name", "description": "new_description", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "servers": [], "stateful": false, "inbound_default_policy": "drop", "outbound_default_policy": "accept", "organization_default": false, "project_default": false, "enable_default_security": true, "state": "syncing", "tags": ["foo", "bar"], "zone": "fr-par-1"}}' headers: Content-Length: - "596" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 20 Nov 2023 13:06:00 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 65cf0b31-1f47-4ddc-9957-923b45a809ec status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/security_groups/47b2363e-f0a1-4f75-a45a-0c0375ed4eef method: DELETE response: body: "" headers: Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Date: - Mon, 20 Nov 2023 13:06:01 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 7812b2f7-bb6c-4bf2-b489-2ed2868fc981 status: 204 No Content code: 204 duration: "" server-incorrect-body.yaml000066400000000000000000000017511456366605600340320ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/testdata--- version: 1 interactions: - request: body: '{}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/0.0.0 url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers method: POST response: body: '{"fields": {"organization": ["required key not provided"], "image": ["required key not provided"], "name": ["required key not provided"], "volumes": ["required key not provided"]}, "message": "Validation Error", "type": "invalid_request_error"}' headers: Content-Length: - "244" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 23 May 2019 15:49:33 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 400 Bad Request code: 400 duration: "" golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/testdata/server-list-zones.yaml000066400000000000000000000436501456366605600333010ustar00rootroot00000000000000--- version: 1 interactions: - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.20.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-2/servers?order=creation_date_desc method: GET response: body: '{"servers": []}' headers: Content-Length: - "15" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 03 Aug 2023 12:13:24 GMT Link: - ; rel="last" Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - c7d9ed67-007c-4502-a69f-977594053229 X-Total-Count: - "0" status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.20.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/nl-ams-1/servers?order=creation_date_desc method: GET response: body: '{"servers": []}' headers: Content-Length: - "15" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 03 Aug 2023 12:13:24 GMT Link: - ; rel="last" Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 8ef1c9e8-5ac6-41c8-a256-52b6d7750490 X-Total-Count: - "0" status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.20.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/pl-waw-1/servers?order=creation_date_desc method: GET response: body: '{"servers": []}' headers: Content-Length: - "15" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 03 Aug 2023 12:13:24 GMT Link: - ; rel="last" Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 80326066-8b59-4a88-914f-1a872608ee26 X-Total-Count: - "0" status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.20.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/nl-ams-3/servers?order=creation_date_desc method: GET response: body: '{"servers": []}' headers: Content-Length: - "15" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 03 Aug 2023 12:13:24 GMT Link: - ; rel="last" Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - b9a9b487-fc34-4390-bc20-75493ea0ea27 X-Total-Count: - "0" status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.20.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/nl-ams-2/servers?order=creation_date_desc method: GET response: body: '{"servers": []}' headers: Content-Length: - "15" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 03 Aug 2023 12:13:24 GMT Link: - ; rel="last" Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 4f9412cb-247f-43d7-9154-4d0a5ba859cd X-Total-Count: - "0" status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.20.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/pl-waw-3/servers?order=creation_date_desc method: GET response: body: '{"servers": []}' headers: Content-Length: - "15" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 03 Aug 2023 12:13:24 GMT Link: - ; rel="last" Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 586a7119-be00-49c9-af4b-ec9d1efa61f8 X-Total-Count: - "0" status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.20.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/pl-waw-2/servers?order=creation_date_desc method: GET response: body: '{"servers": []}' headers: Content-Length: - "15" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 03 Aug 2023 12:13:24 GMT Link: - ; rel="last" Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - e4f2410c-cef3-432b-b5d0-4148f4b6e616 X-Total-Count: - "0" status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.20.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers?order=creation_date_desc method: GET response: body: '{"servers": [{"id": "c66fe648-06c8-4cab-83d4-d963bf0ef8df", "name": "kubetest-runner", "arch": "x86_64", "commercial_type": "PRO2-S", "boot_type": "local", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "hostname": "kubetest-runner", "image": {"id": "ce453858-557c-4f1c-a7a9-70026e67d054", "name": "Ubuntu 22.04 Jammy Jellyfish", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "30e9c843-1cdb-4bd4-96f7-cac26051eeaf", "name": "Ubuntu 22.04 Jammy Jellyfish", "volume_type": "unified", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": "x86_64", "creation_date": "2023-04-13T12:13:29.892843+00:00", "modification_date": "2023-04-13T12:13:29.892843+00:00", "default_bootscript": null, "from_server": null, "state": "available", "tags": [], "zone": "fr-par-1"}, "volumes": {"0": {"boot": false, "id": "df0026ac-7c59-4ecd-80b0-265281e2477e", "name": "Ubuntu 22.04 Jammy Jellyfish", "volume_type": "b_ssd", "export_uri": null, "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "server": {"id": "c66fe648-06c8-4cab-83d4-d963bf0ef8df", "name": "kubetest-runner"}, "size": 100000000000, "state": "available", "creation_date": "2023-05-03T12:12:04.671813+00:00", "modification_date": "2023-05-03T12:12:04.671813+00:00", "tags": [], "zone": "fr-par-1"}}, "tags": ["kube", "cli"], "state": "stopped", "protected": false, "state_detail": "", "public_ip": {"id": "58542407-77e1-444b-9fa3-30c4a0d9d7fb", "address": "163.172.170.102", "dynamic": false, "gateway": null, "netmask": "32", "family": "inet", "provisioning_mode": "dhcp"}, "public_ips": [{"id": "58542407-77e1-444b-9fa3-30c4a0d9d7fb", "address": "163.172.170.102", "dynamic": false, "gateway": null, "netmask": "32", "family": "inet", "provisioning_mode": "dhcp"}], "mac_address": "de:00:00:13:02:db", "routed_ip_enabled": false, "ipv6": null, "extra_networks": [], "dynamic_ip_required": true, "enable_ipv6": false, "private_ip": null, "creation_date": "2023-05-03T12:12:04.671813+00:00", "modification_date": "2023-06-22T08:44:57.189402+00:00", "bootscript": {"id": "fdfe150f-a870-4ce4-b432-9f56b5b995c1", "public": true, "title": "x86_64 mainline 4.4.230 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://10.194.3.9/kernel/x86_64-mainline-lts-4.4-4.4.230-rev1/vmlinuz-4.4.230", "dtb": "", "initrd": "http://10.194.3.9/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": true, "zone": "fr-par-1"}, "security_group": {"id": "0fe819c3-274d-472a-b3f5-ddb258d2d8bb", "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": ["poweron", "backup"], "placement_group": null, "private_nics": [], "zone": "fr-par-1"}]}' headers: Content-Length: - "2981" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 03 Aug 2023 12:13:24 GMT Link: - ; rel="last" Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 04bca493-3731-46bd-af59-529a9ae3d216 X-Total-Count: - "1" status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.20.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-3/servers?order=creation_date_desc method: GET response: body: '{"servers": [{"id": "38486156-25dc-4d55-aa7d-b234b05d9071", "name": "cli-srv-elated-edison", "arch": "x86_64", "commercial_type": "PRO2-XXS", "boot_type": "local", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "hostname": "cli-srv-elated-edison", "image": {"id": "670ac22a-8f62-4c60-99b7-f59ad838a34a", "name": "Ubuntu 22.04 Jammy Jellyfish", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "9a95c3a7-5f40-4dd8-963a-ddf48598da1b", "name": "Ubuntu 22.04 Jammy Jellyfish", "volume_type": "unified", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": "x86_64", "creation_date": "2023-07-24T07:51:14.827507+00:00", "modification_date": "2023-07-24T07:51:14.827507+00:00", "default_bootscript": null, "from_server": null, "state": "available", "tags": [], "zone": "fr-par-3"}, "volumes": {"0": {"boot": false, "id": "9ed0a26d-f208-47d9-b3b9-d7383f77360d", "name": "Ubuntu 22.04 Jammy Jellyfish", "volume_type": "b_ssd", "export_uri": null, "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "server": {"id": "38486156-25dc-4d55-aa7d-b234b05d9071", "name": "cli-srv-elated-edison"}, "size": 10000000000, "state": "available", "creation_date": "2023-08-02T11:30:08.321084+00:00", "modification_date": "2023-08-02T11:30:08.321084+00:00", "tags": [], "zone": "fr-par-3"}}, "tags": [], "state": "running", "protected": false, "state_detail": "booted", "public_ip": {"id": "73d1232c-d785-4206-97e2-a5763c059fdf", "address": "2001:bc8:a10:10:dc00:ff:fe04:ebad", "dynamic": false, "gateway": "fe80::dc00:ff:fe04:ebae", "netmask": "64", "family": "inet6", "provisioning_mode": "slaac"}, "public_ips": [{"id": "73d1232c-d785-4206-97e2-a5763c059fdf", "address": "2001:bc8:a10:10:dc00:ff:fe04:ebad", "dynamic": false, "gateway": "fe80::dc00:ff:fe04:ebae", "netmask": "64", "family": "inet6", "provisioning_mode": "slaac"}], "mac_address": "de:00:00:04:eb:ad", "routed_ip_enabled": true, "ipv6": null, "extra_networks": [], "dynamic_ip_required": false, "enable_ipv6": false, "private_ip": null, "creation_date": "2023-08-02T11:30:08.321084+00:00", "modification_date": "2023-08-02T11:40:36.316437+00:00", "bootscript": {"id": "346edd9d-a17a-45f5-b2ac-bbf282c3ce3c", "public": true, "title": "x86_64 mainline 4.4.230 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.4-4.4.230-rev1/vmlinuz-4.4.230", "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": true, "zone": "fr-par-3"}, "security_group": {"id": "2da7f6cb-2774-4873-aff8-bc03dae3a32e", "name": "Default security group"}, "location": {"zone_id": "fr-par-3", "platform_id": "60", "cluster_id": "6", "hypervisor_id": "201", "node_id": "4"}, "maintenances": [], "allowed_actions": ["poweroff", "terminate", "reboot", "stop_in_place", "backup"], "placement_group": null, "private_nics": [], "zone": "fr-par-3"}, {"id": "eb4460c2-b7cc-4c7a-acb7-69ea3fb57e77", "name": "cli-srv-awesome-greider", "arch": "x86_64", "commercial_type": "PRO2-XXS", "boot_type": "local", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "hostname": "cli-srv-awesome-greider", "image": {"id": "670ac22a-8f62-4c60-99b7-f59ad838a34a", "name": "Ubuntu 22.04 Jammy Jellyfish", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "9a95c3a7-5f40-4dd8-963a-ddf48598da1b", "name": "Ubuntu 22.04 Jammy Jellyfish", "volume_type": "unified", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": "x86_64", "creation_date": "2023-07-24T07:51:14.827507+00:00", "modification_date": "2023-07-24T07:51:14.827507+00:00", "default_bootscript": null, "from_server": null, "state": "available", "tags": [], "zone": "fr-par-3"}, "volumes": {"0": {"boot": false, "id": "ec18850b-b6e2-4890-bd23-2a09f38279c7", "name": "Ubuntu 22.04 Jammy Jellyfish", "volume_type": "b_ssd", "export_uri": null, "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "server": {"id": "eb4460c2-b7cc-4c7a-acb7-69ea3fb57e77", "name": "cli-srv-awesome-greider"}, "size": 10000000000, "state": "available", "creation_date": "2023-08-02T09:10:04.365308+00:00", "modification_date": "2023-08-02T09:10:04.365308+00:00", "tags": [], "zone": "fr-par-3"}}, "tags": [], "state": "running", "protected": false, "state_detail": "booted", "public_ip": {"id": "e0e2f5fb-9f6a-4875-8a20-0d97e61ccee8", "address": "51.159.82.173", "dynamic": false, "gateway": null, "netmask": "32", "family": "inet", "provisioning_mode": "dhcp"}, "public_ips": [{"id": "e0e2f5fb-9f6a-4875-8a20-0d97e61ccee8", "address": "51.159.82.173", "dynamic": false, "gateway": null, "netmask": "32", "family": "inet", "provisioning_mode": "dhcp"}], "mac_address": "de:00:00:04:eb:2f", "routed_ip_enabled": false, "ipv6": null, "extra_networks": [], "dynamic_ip_required": true, "enable_ipv6": false, "private_ip": "10.199.99.5", "creation_date": "2023-08-02T09:10:04.365308+00:00", "modification_date": "2023-08-02T09:10:08.260056+00:00", "bootscript": {"id": "346edd9d-a17a-45f5-b2ac-bbf282c3ce3c", "public": true, "title": "x86_64 mainline 4.4.230 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.4-4.4.230-rev1/vmlinuz-4.4.230", "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": true, "zone": "fr-par-3"}, "security_group": {"id": "2da7f6cb-2774-4873-aff8-bc03dae3a32e", "name": "Default security group"}, "location": {"zone_id": "fr-par-3", "platform_id": "60", "cluster_id": "6", "hypervisor_id": "501", "node_id": "3"}, "maintenances": [], "allowed_actions": ["poweroff", "terminate", "reboot", "stop_in_place", "backup", "enable_routed_ip"], "placement_group": null, "private_nics": [], "zone": "fr-par-3"}]}' headers: Content-Length: - "6378" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 03 Aug 2023 12:13:24 GMT Link: - ; rel="last" Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 89d5785c-cb40-42fa-b1e6-45ba9c03dca7 X-Total-Count: - "2" status: 200 OK code: 200 duration: "" golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/testdata/server-test.yaml000066400000000000000000000455631456366605600321560ustar00rootroot00000000000000--- version: 1 interactions: - request: body: '{"name":"instance_sdk_server_test","dynamic_ip_required":true,"commercial_type":"START1-S","image":"f974feac-abae-4365-b988-8ec7d1cec10d","enable_ipv6":true,"boot_type":"local","project":"14d2f7ae-9775-414c-9bed-6810e060d500","tags":["foo","bar"]}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.13.6; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers method: POST response: body: '{"server": {"id": "6a3d62f7-8852-4dd2-b16a-905b695cd199", "name": "instance_sdk_server_test", "arch": "x86_64", "commercial_type": "START1-S", "boot_type": "local", "organization": "14d2f7ae-9775-414c-9bed-6810e060d500", "project": "14d2f7ae-9775-414c-9bed-6810e060d500", "hostname": "instance-sdk-server-test", "image": {"id": "f974feac-abae-4365-b988-8ec7d1cec10d", "name": "Ubuntu Bionic Beaver", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "dd5f5c10-23b1-4c9c-8445-eb6740957c84", "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", "volume_type": "l_ssd", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": "x86_64", "creation_date": "2019-03-05T10:13:15.974944+00:00", "modification_date": "2019-03-05T13:32:29.274319+00:00", "default_bootscript": {"id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", "public": false, "title": "x86_64 mainline 4.9.93 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": false, "zone": "fr-par-1"}, "from_server": null, "state": "available", "zone": "fr-par-1"}, "volumes": {"0": {"id": "c6b29ca6-8895-42fb-a498-a89011c29ff7", "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", "volume_type": "l_ssd", "export_uri": null, "organization": "14d2f7ae-9775-414c-9bed-6810e060d500", "project": "14d2f7ae-9775-414c-9bed-6810e060d500", "server": {"id": "6a3d62f7-8852-4dd2-b16a-905b695cd199", "name": "instance_sdk_server_test"}, "size": 50000000000, "state": "available", "creation_date": "2020-08-14T13:02:02.652219+00:00", "modification_date": "2020-08-14T13:02:02.990859+00:00", "zone": "fr-par-1"}}, "tags": ["foo", "bar"], "state": "stopped", "protected": false, "state_detail": "", "public_ip": null, "ipv6": null, "extra_networks": [], "dynamic_ip_required": true, "enable_ipv6": true, "private_ip": null, "creation_date": "2020-08-14T13:02:02.652219+00:00", "modification_date": "2020-08-14T13:02:03.095139+00:00", "bootscript": {"id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", "public": false, "title": "x86_64 mainline 4.9.93 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": false, "zone": "fr-par-1"}, "security_group": {"id": "e5bf4522-94b4-4933-bebb-9b21f786b4af", "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": ["poweron", "backup"], "placement_group": null, "private_nics": [], "zone": "fr-par-1"}}' headers: Cache-Control: - no-cache Content-Length: - "3112" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Fri, 14 Aug 2020 13:02:02 GMT Location: - https://cp-par1.scaleway.com/servers/6a3d62f7-8852-4dd2-b16a-905b695cd199 Server: - agw_listener_public_vip Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - ec8ac5f5-cbda-4d28-92b7-76365f6dcc97 status: 201 Created code: 201 duration: "" - request: body: '{"name":"instance_sdk_server_test","image":"f974feac-abae-4365-b988-8ec7d1cec10d","organization":"14d2f7ae-9775-414c-9bed-6810e060d500"}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.13.6; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers method: POST response: body: '{"server": {"id": "12be8295-263f-4f71-9c7d-a33ef31f3887", "name": "instance_sdk_server_test", "arch": "x86_64", "commercial_type": "START1-S", "boot_type": "bootscript", "organization": "14d2f7ae-9775-414c-9bed-6810e060d500", "project": "14d2f7ae-9775-414c-9bed-6810e060d500", "hostname": "instance-sdk-server-test", "image": {"id": "f974feac-abae-4365-b988-8ec7d1cec10d", "name": "Ubuntu Bionic Beaver", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "dd5f5c10-23b1-4c9c-8445-eb6740957c84", "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", "volume_type": "l_ssd", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": "x86_64", "creation_date": "2019-03-05T10:13:15.974944+00:00", "modification_date": "2019-03-05T13:32:29.274319+00:00", "default_bootscript": {"id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", "public": false, "title": "x86_64 mainline 4.9.93 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": false, "zone": "fr-par-1"}, "from_server": null, "state": "available", "zone": "fr-par-1"}, "volumes": {"0": {"id": "a7f56913-ba01-42b7-9d88-f12d42ea309b", "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", "volume_type": "l_ssd", "export_uri": null, "organization": "14d2f7ae-9775-414c-9bed-6810e060d500", "project": "14d2f7ae-9775-414c-9bed-6810e060d500", "server": {"id": "12be8295-263f-4f71-9c7d-a33ef31f3887", "name": "instance_sdk_server_test"}, "size": 50000000000, "state": "available", "creation_date": "2020-08-14T13:02:03.527628+00:00", "modification_date": "2020-08-14T13:02:03.845180+00:00", "zone": "fr-par-1"}}, "tags": [], "state": "stopped", "protected": false, "state_detail": "", "public_ip": null, "ipv6": null, "extra_networks": [], "dynamic_ip_required": true, "enable_ipv6": false, "private_ip": null, "creation_date": "2020-08-14T13:02:03.527628+00:00", "modification_date": "2020-08-14T13:02:03.928001+00:00", "bootscript": {"id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", "public": false, "title": "x86_64 mainline 4.9.93 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": false, "zone": "fr-par-1"}, "security_group": {"id": "e5bf4522-94b4-4933-bebb-9b21f786b4af", "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": ["poweron", "backup"], "placement_group": null, "private_nics": [], "zone": "fr-par-1"}}' headers: Cache-Control: - no-cache Content-Length: - "3106" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Fri, 14 Aug 2020 13:02:03 GMT Location: - https://cp-par1.scaleway.com/servers/12be8295-263f-4f71-9c7d-a33ef31f3887 Server: - agw_listener_public_vip Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - f12de65b-8e0e-402d-bdfe-8c76b7837d8d status: 201 Created code: 201 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.13.6; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/12be8295-263f-4f71-9c7d-a33ef31f3887 method: DELETE response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Fri, 14 Aug 2020 13:02:04 GMT Server: - agw_listener_public_vip Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - f0a5c1f4-25a5-4273-8df5-2bf73062bea1 status: 204 No Content code: 204 duration: "" - request: body: '{"name":"some_new_name_for_server","tags":[]}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.13.6; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/6a3d62f7-8852-4dd2-b16a-905b695cd199 method: PATCH response: body: '{"server": {"id": "6a3d62f7-8852-4dd2-b16a-905b695cd199", "name": "some_new_name_for_server", "arch": "x86_64", "commercial_type": "START1-S", "boot_type": "local", "organization": "14d2f7ae-9775-414c-9bed-6810e060d500", "project": "14d2f7ae-9775-414c-9bed-6810e060d500", "hostname": "some-new-name-for-server", "image": {"id": "f974feac-abae-4365-b988-8ec7d1cec10d", "name": "Ubuntu Bionic Beaver", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "dd5f5c10-23b1-4c9c-8445-eb6740957c84", "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", "volume_type": "l_ssd", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": "x86_64", "creation_date": "2019-03-05T10:13:15.974944+00:00", "modification_date": "2019-03-05T13:32:29.274319+00:00", "default_bootscript": {"id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", "public": false, "title": "x86_64 mainline 4.9.93 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": false, "zone": "fr-par-1"}, "from_server": null, "state": "available", "zone": "fr-par-1"}, "volumes": {"0": {"id": "c6b29ca6-8895-42fb-a498-a89011c29ff7", "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", "volume_type": "l_ssd", "export_uri": null, "organization": "14d2f7ae-9775-414c-9bed-6810e060d500", "project": "14d2f7ae-9775-414c-9bed-6810e060d500", "server": {"id": "6a3d62f7-8852-4dd2-b16a-905b695cd199", "name": "some_new_name_for_server"}, "size": 50000000000, "state": "available", "creation_date": "2020-08-14T13:02:02.652219+00:00", "modification_date": "2020-08-14T13:02:02.990859+00:00", "zone": "fr-par-1"}}, "tags": [], "state": "stopped", "protected": false, "state_detail": "", "public_ip": null, "ipv6": null, "extra_networks": [], "dynamic_ip_required": true, "enable_ipv6": true, "private_ip": null, "creation_date": "2020-08-14T13:02:02.652219+00:00", "modification_date": "2020-08-14T13:02:04.847138+00:00", "bootscript": {"id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", "public": false, "title": "x86_64 mainline 4.9.93 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": false, "zone": "fr-par-1"}, "security_group": {"id": "e5bf4522-94b4-4933-bebb-9b21f786b4af", "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": ["poweron", "backup"], "placement_group": null, "private_nics": [], "zone": "fr-par-1"}}' headers: Cache-Control: - no-cache Content-Length: - "3100" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Fri, 14 Aug 2020 13:02:04 GMT Server: - agw_listener_public_vip Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 10bdaf49-c624-42a6-8523-2fa6ecdf9409 status: 200 OK code: 200 duration: "" - request: body: '{"volumes":{}}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.13.6; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/6a3d62f7-8852-4dd2-b16a-905b695cd199 method: PATCH response: body: '{"server": {"id": "6a3d62f7-8852-4dd2-b16a-905b695cd199", "name": "some_new_name_for_server", "arch": "x86_64", "commercial_type": "START1-S", "boot_type": "local", "organization": "14d2f7ae-9775-414c-9bed-6810e060d500", "project": "14d2f7ae-9775-414c-9bed-6810e060d500", "hostname": "some-new-name-for-server", "image": {"id": "f974feac-abae-4365-b988-8ec7d1cec10d", "name": "Ubuntu Bionic Beaver", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "dd5f5c10-23b1-4c9c-8445-eb6740957c84", "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", "volume_type": "l_ssd", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": "x86_64", "creation_date": "2019-03-05T10:13:15.974944+00:00", "modification_date": "2019-03-05T13:32:29.274319+00:00", "default_bootscript": {"id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", "public": false, "title": "x86_64 mainline 4.9.93 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": false, "zone": "fr-par-1"}, "from_server": null, "state": "available", "zone": "fr-par-1"}, "volumes": {}, "tags": [], "state": "stopped", "protected": false, "state_detail": "", "public_ip": null, "ipv6": null, "extra_networks": [], "dynamic_ip_required": true, "enable_ipv6": true, "private_ip": null, "creation_date": "2020-08-14T13:02:02.652219+00:00", "modification_date": "2020-08-14T13:02:04.847138+00:00", "bootscript": {"id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", "public": false, "title": "x86_64 mainline 4.9.93 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": false, "zone": "fr-par-1"}, "security_group": {"id": "e5bf4522-94b4-4933-bebb-9b21f786b4af", "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": ["poweron", "backup"], "placement_group": null, "private_nics": [], "zone": "fr-par-1"}}' headers: Cache-Control: - no-cache Content-Length: - "2557" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Fri, 14 Aug 2020 13:02:04 GMT Server: - agw_listener_public_vip Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - b5c48b57-5bd7-419a-ace2-a5f4348a6691 status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.13.6; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/6a3d62f7-8852-4dd2-b16a-905b695cd199 method: DELETE response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Fri, 14 Aug 2020 13:02:05 GMT Server: - agw_listener_public_vip Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 45a4d549-f633-4d1c-a08c-d7a0039fdfe5 status: 204 No Content code: 204 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.13.6; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/c6b29ca6-8895-42fb-a498-a89011c29ff7 method: DELETE response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Fri, 14 Aug 2020 13:02:05 GMT Server: - agw_listener_public_vip Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - caf7c95e-21e8-4e6e-8679-e632096c6cac status: 204 No Content code: 204 duration: "" golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/testdata/server-user-data.yaml000066400000000000000000000126161456366605600330550ustar00rootroot00000000000000--- version: 1 interactions: - request: body: '{"name":"srv-wonderful-goldberg","commercial_type":"DEV1-S","image":"f974feac-abae-4365-b988-8ec7d1cec10d","organization":"14d2f7ae-9775-414c-9bed-6810e060d500"}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers method: POST response: body: '{"server": {"allowed_actions": ["poweron", "backup"], "maintenances": [], "state_detail": "", "image": {"creation_date": "2019-03-05T10:13:15.974944+00:00", "default_bootscript": {"kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "default": false, "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "architecture": "x86_64", "title": "x86_64 mainline 4.9.93 rev1", "dtb": "", "organization": "11111111-1111-4111-8111-111111111111", "id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", "public": false}, "from_server": null, "arch": "x86_64", "id": "f974feac-abae-4365-b988-8ec7d1cec10d", "root_volume": {"size": 10000000000, "id": "dd5f5c10-23b1-4c9c-8445-eb6740957c84", "volume_type": "l_ssd", "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13"}, "name": "Ubuntu Bionic Beaver", "modification_date": "2019-03-05T13:32:29.274319+00:00", "state": "available", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "extra_volumes": {}, "public": true}, "creation_date": "2019-06-20T17:59:31.822202+00:00", "public_ip": null, "private_ip": null, "id": "d7b6fd2a-32f9-446f-ba49-6a67be590a07", "dynamic_ip_required": true, "modification_date": "2019-06-20T17:59:32.192591+00:00", "enable_ipv6": false, "hostname": "srv-wonderful-goldberg", "state": "stopped", "bootscript": {"kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "default": false, "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "architecture": "x86_64", "title": "x86_64 mainline 4.9.93 rev1", "dtb": "", "organization": "11111111-1111-4111-8111-111111111111", "id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", "public": false}, "location": null, "boot_type": "local", "ipv6": null, "commercial_type": "DEV1-S", "tags": [], "arch": "x86_64", "extra_networks": [], "compute_cluster": null, "name": "srv-wonderful-goldberg", "protected": false, "volumes": {"0": {"size": 20000000000, "state": "available", "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", "modification_date": "2019-06-20T17:59:32.094121+00:00", "organization": "14d2f7ae-9775-414c-9bed-6810e060d500", "export_uri": null, "creation_date": "2019-06-20T17:59:31.822202+00:00", "id": "fe034b14-2c3f-4f30-96f8-d695f24aa6de", "volume_type": "l_ssd", "server": {"id": "d7b6fd2a-32f9-446f-ba49-6a67be590a07", "name": "srv-wonderful-goldberg"}}}, "security_group": {"id": "e5bf4522-94b4-4933-bebb-9b21f786b4af", "name": "Default security group"}, "organization": "14d2f7ae-9775-414c-9bed-6810e060d500"}}' headers: Cache-Control: - no-cache Content-Length: - "2718" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 20 Jun 2019 17:59:32 GMT Location: - https://cp-par1.scaleway.com/servers/d7b6fd2a-32f9-446f-ba49-6a67be590a07 Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 201 Created code: 201 duration: "" - request: body: world form: {} headers: Content-Type: - text/plain User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/d7b6fd2a-32f9-446f-ba49-6a67be590a07/user_data/hello method: PATCH response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - text/plain Date: - Thu, 20 Jun 2019 17:59:32 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 204 No Content code: 204 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/0.0.0 (go1.12.5; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/d7b6fd2a-32f9-446f-ba49-6a67be590a07/user_data/hello method: GET response: body: world headers: Cache-Control: - no-cache Content-Length: - "5" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - text/plain Date: - Thu, 20 Jun 2019 17:59:32 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY status: 200 OK code: 200 duration: "" golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/testdata/snapshot-test.yaml000066400000000000000000000200621456366605600324720ustar00rootroot00000000000000--- version: 1 interactions: - request: body: '{"name":"volume_name","project":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","volume_type":"b_ssd","size":1000000000}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes method: POST response: body: '{"volume": {"id": "6c73aee5-1c22-4207-a6f8-3fdc16c88183", "name": "volume_name", "volume_type": "b_ssd", "export_uri": null, "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "server": null, "size": 1000000000, "state": "available", "creation_date": "2023-12-04T10:02:02.557422+00:00", "modification_date": "2023-12-04T10:02:02.557422+00:00", "tags": [], "zone": "fr-par-1"}}' headers: Content-Length: - "432" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 04 Dec 2023 10:02:02 GMT Location: - https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/6c73aee5-1c22-4207-a6f8-3fdc16c88183 Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - c118842c-92e2-4d20-b986-d22fcffb403b status: 201 Created code: 201 duration: "" - request: body: '{"name":"name","volume_id":"6c73aee5-1c22-4207-a6f8-3fdc16c88183","project":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b"}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/snapshots method: POST response: body: '{"snapshot": {"id": "7015526e-cd90-4f2a-bb37-fa9106cf313f", "name": "name", "volume_type": "b_ssd", "creation_date": "2023-12-04T10:02:02.713296+00:00", "modification_date": "2023-12-04T10:02:02.713296+00:00", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "size": 1000000000, "state": "snapshotting", "base_volume": {"id": "6c73aee5-1c22-4207-a6f8-3fdc16c88183", "name": "volume_name"}, "tags": [], "zone": "fr-par-1", "error_details": null}, "task": {"id": "1a6f272b-3d1a-4181-9f7f-e104a8fedf44", "description": "snapshot_7015526e-cd90-4f2a-bb37-fa9106cf313f", "status": "pending", "href_from": "/snapshots", "href_result": "snapshots/7015526e-cd90-4f2a-bb37-fa9106cf313f", "started_at": "2023-12-04T10:02:03.121513+00:00", "terminated_at": null}}' headers: Content-Length: - "809" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 04 Dec 2023 10:02:03 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 9c8a8504-af61-45a7-a4d3-f24bfbddc1ca status: 201 Created code: 201 duration: "" - request: body: '{"name":"new_name","tags":["foo","bar"]}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/snapshots/7015526e-cd90-4f2a-bb37-fa9106cf313f method: PATCH response: body: '{"snapshot": {"id": "7015526e-cd90-4f2a-bb37-fa9106cf313f", "name": "new_name", "volume_type": "b_ssd", "creation_date": "2023-12-04T10:02:02.713296+00:00", "modification_date": "2023-12-04T10:02:03.482505+00:00", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "size": 1000000000, "state": "snapshotting", "base_volume": {"id": "6c73aee5-1c22-4207-a6f8-3fdc16c88183", "name": "volume_name"}, "tags": ["foo", "bar"], "zone": "fr-par-1", "error_details": null}}' headers: Content-Length: - "519" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 04 Dec 2023 10:02:03 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - fcd34fb2-ab59-4b04-b35b-fc190a58878c status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/snapshots/7015526e-cd90-4f2a-bb37-fa9106cf313f method: GET response: body: '{"snapshot": {"id": "7015526e-cd90-4f2a-bb37-fa9106cf313f", "name": "new_name", "volume_type": "b_ssd", "creation_date": "2023-12-04T10:02:02.713296+00:00", "modification_date": "2023-12-04T10:02:03.482505+00:00", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "size": 1000000000, "state": "snapshotting", "base_volume": {"id": "6c73aee5-1c22-4207-a6f8-3fdc16c88183", "name": "volume_name"}, "tags": ["foo", "bar"], "zone": "fr-par-1", "error_details": null}}' headers: Content-Length: - "519" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 04 Dec 2023 10:02:03 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - cd1194dc-b398-43f4-987e-fd9918ad61a7 status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/snapshots/7015526e-cd90-4f2a-bb37-fa9106cf313f method: GET response: body: '{"snapshot": {"id": "7015526e-cd90-4f2a-bb37-fa9106cf313f", "name": "new_name", "volume_type": "b_ssd", "creation_date": "2023-12-04T10:02:02.713296+00:00", "modification_date": "2023-12-04T10:02:08.092862+00:00", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "size": 1000000000, "state": "available", "base_volume": {"id": "6c73aee5-1c22-4207-a6f8-3fdc16c88183", "name": "volume_name"}, "tags": ["foo", "bar"], "zone": "fr-par-1", "error_details": null}}' headers: Content-Length: - "516" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Mon, 04 Dec 2023 10:02:08 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 33f3bd9e-43cc-4236-813c-7ca7a228bb81 status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/snapshots/7015526e-cd90-4f2a-bb37-fa9106cf313f method: DELETE response: body: "" headers: Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Date: - Mon, 04 Dec 2023 10:02:09 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 5ade24b0-f382-4dcb-82c5-09ef41540b22 status: 204 No Content code: 204 duration: "" golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/testdata/snapshot-wait-test.yaml000066400000000000000000002057771456366605600334560ustar00rootroot00000000000000--- version: 1 interactions: - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.2; darwin; amd64) url: https://api.scaleway.com/marketplace/v1/images?page=1 method: GET response: body: '{"images": [{"valid_until": null, "description": "Ubuntu is the ideal distribution for scale-out computing, Ubuntu Server helps you make the most of your infrastructure.", "creation_date": "2018-04-27T14:07:25.221998+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "b381b2bf-804a-4b12-91f6-9f4ff273462f", "categories": ["distribution"], "name": "Ubuntu Bionic", "modification_date": "2019-03-26T14:00:51.745705+00:00", "versions": [{"creation_date": "2019-03-05T16:39:34.893732+00:00", "modification_date": "2019-03-05T16:39:34.893732+00:00", "id": "e640c621-305b-45f5-975f-a3f80c1cec66", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f974feac-abae-4365-b988-8ec7d1cec10d", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "f63fe42a-900f-4a5e-ba99-ab0e59469b7e", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "b4bdbee1-e1f1-4436-8de4-bdb1b6ba4803", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "9444d178-2285-4842-ac35-5e86eda8da91", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "a5076337-734f-4b99-95ed-9a5bc73b9b09", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "7663c62b-40e3-4e6b-a835-70723ec2050b", "zone": "ams1"}], "name": "2019-03-05T16:39:34.377275"}], "current_public_version": "e640c621-305b-45f5-975f-a3f80c1cec66", "label": "ubuntu_bionic", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Ubuntu is the ideal distribution for scale-out computing, Ubuntu Server helps you make the most of your infrastructure.", "creation_date": "2016-04-22T13:27:33.769932+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "acf93867-88d9-40ee-99ea-6b2bb1ee8f0c", "categories": ["distribution"], "name": "Ubuntu Xenial", "modification_date": "2020-01-20T09:04:40.661026+00:00", "versions": [{"creation_date": "2020-01-17T14:31:06.041118+00:00", "modification_date": "2020-01-17T14:31:06.041118+00:00", "id": "24cd2ef0-bbc5-4b1a-8b08-99f617eab446", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "3d6804e0-086e-4a06-8124-7240a657668d", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "245e5cea-a9b4-4a36-9055-27185afe8690", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "c40fbabc-efc8-4e04-91ea-5e1e22daece1", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "bd859e89-fb2d-466a-a546-383630a1ead1", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "6c34a3f3-5e8a-455b-9bc2-f07c4c35bf89", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a5f6bb77-3d64-4f7f-abe0-72492b1bc020", "zone": "par1"}], "name": "2020-01-17T14:31:06.031136"}], "current_public_version": "24cd2ef0-bbc5-4b1a-8b08-99f617eab446", "label": "ubuntu_xenial", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Debian is a free, powerful and stable operating system.", "creation_date": "2017-06-26T15:37:13.460764+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/debian.png", "id": "c94b5df7-e698-4ac9-b273-565d18f5f8d2", "categories": ["distribution"], "name": "Debian Stretch", "modification_date": "2020-01-20T09:04:42.765883+00:00", "versions": [{"creation_date": "2020-01-15T11:38:06.396694+00:00", "modification_date": "2020-01-15T11:38:06.396694+00:00", "id": "8342f5d0-46aa-46e7-8a6f-f41188c97fba", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "5f7ab0cd-d10e-49a0-91c8-315ed8a6a1a4", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "d954dc33-c52e-4960-93e1-b69c85d169be", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "22a1bd8d-4498-4800-a8e5-4bc85001176c", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "37938de8-e3be-479a-895d-095158f76212", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "86740237-62fc-4538-9b70-4373942f53d3", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "bd6ba96e-d4c4-41f9-88e2-8dad3e6f085b", "zone": "par1"}], "name": "2020-01-15T11:38:06.390074"}], "current_public_version": "8342f5d0-46aa-46e7-8a6f-f41188c97fba", "label": "debian_stretch", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Debian is a free, powerful and stable operating system.", "creation_date": "2016-03-05T14:52:36.322319+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/debian.png", "id": "fb619bdf-834e-4c71-b7b8-15b5546d18bd", "categories": ["distribution"], "name": "Debian Jessie", "modification_date": "2019-03-26T14:00:50.449502+00:00", "versions": [{"creation_date": "2018-04-10T22:31:04.322822+00:00", "modification_date": "2018-04-10T22:31:04.322822+00:00", "id": "d3846a7b-8219-4938-ad96-cc2173e22481", "local_images": [{"compatible_commercial_types": ["C1"], "arch": "arm", "id": "2dfad6d2-e527-4e93-8eb1-8dc57803b310", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "610f68d5-cbad-4923-98ae-782af8f3b527", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "dc22e553-2d2e-4689-94f8-8817db824202", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "2e570f53-199e-47cc-95dd-f7bc392496e3", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "abf9e3a2-7171-4764-91ef-57f30b21193d", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "69cbdd54-88a1-4458-b75e-662a0848a7ce", "zone": "ams1"}], "name": "2018-04-10T22:31:04.321157"}], "current_public_version": "d3846a7b-8219-4938-ad96-cc2173e22481", "label": "debian_jessie", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "The CentOS Project is a community-driven free software effort focused on delivering a robust open source ecosystem.", "creation_date": "2019-03-06T11:27:48.406290+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/centos.png", "id": "1d47b370-ac63-43b1-9f34-7328675e5e18", "categories": ["distribution"], "name": "CentOS 7.6", "modification_date": "2019-03-26T14:00:50.839069+00:00", "versions": [{"creation_date": "2019-03-18T09:29:00.247544+00:00", "modification_date": "2019-03-18T09:29:00.247544+00:00", "id": "53138072-3099-4566-8b18-de7b2739696a", "local_images": [{"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "05794ee5-c6d2-4d69-86dd-f1fc9032921d", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "0f44b130-2bc7-4f82-993e-de9d1042c56e", "zone": "par1"}], "name": "2019-03-18T09:29:00.168590"}], "current_public_version": "53138072-3099-4566-8b18-de7b2739696a", "label": "centos_7.6", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "The CentOS Project is a community-driven free software effort focused on delivering a robust open source ecosystem.", "creation_date": "2018-04-19T10:12:28.968536+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/centos.png", "id": "98fc244a-ed4c-4523-bd17-b9c4070b8e7e", "categories": ["distribution"], "name": "CentOS 7.4", "modification_date": "2019-03-26T14:00:53.445597+00:00", "versions": [{"creation_date": "2018-04-20T13:55:06.824033+00:00", "modification_date": "2018-04-20T13:55:06.824033+00:00", "id": "31be34e5-074d-4c63-8c77-454459f77c3f", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "ec8b431e-ad39-4523-8b94-f3fa7f3cbd06", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "7220ac63-bac8-484b-9d44-93e3bd01f5a6", "zone": "ams1"}], "name": "2018-04-20T13:55:06.817954"}], "current_public_version": "31be34e5-074d-4c63-8c77-454459f77c3f", "label": "centos_7.4", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Fedora is a powerful, flexible operating system that includes the best and latest datacenter technologies. It puts you in control of all your infrastructure and services.", "creation_date": "2019-03-06T09:07:51.652433+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/fedora.png", "id": "69adec15-f1a7-469a-9ba5-868577832521", "categories": ["distribution"], "name": "Fedora 29", "modification_date": "2019-03-26T14:00:51.848785+00:00", "versions": [{"creation_date": "2019-03-06T09:08:01.112958+00:00", "modification_date": "2019-03-06T09:08:01.112958+00:00", "id": "a0f02365-f1af-48cb-b82d-75853a4e05e1", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "541f4562-5417-4b59-85d6-caaf64c1f127", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "3c0f706e-0947-47a3-88a3-595c29f7567a", "zone": "ams1"}], "name": "2019-03-06T09:08:01.016040"}], "current_public_version": "a0f02365-f1af-48cb-b82d-75853a4e05e1", "label": "fedora_29", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "Fedora is a powerful, flexible operating system that includes the best and latest datacenter technologies. It puts you in control of all your infrastructure and services.", "creation_date": "2018-05-03T09:51:57.274011+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/fedora.png", "id": "30d0f04f-6422-4b74-9ce9-1c2267419978", "categories": ["distribution"], "name": "Fedora 28", "modification_date": "2019-03-26T14:00:50.156015+00:00", "versions": [{"creation_date": "2018-05-03T12:01:10.147973+00:00", "modification_date": "2018-05-03T12:01:10.147973+00:00", "id": "49e33199-28cc-44d6-bb2e-a6147944ad5c", "local_images": [{"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "830aad94-24e5-4363-b2c3-e62921bd9294", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "c9cd1782-2159-44b8-83b1-9c48ed6c8a63", "zone": "par1"}], "name": "2018-05-03T12:01:10.135200"}], "current_public_version": "49e33199-28cc-44d6-bb2e-a6147944ad5c", "label": "fedora_28", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Fedora is a powerful, flexible operating system that includes the best and latest datacenter technologies. It puts you in control of all your infrastructure and services.", "creation_date": "2018-04-19T10:14:08.648100+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/fedora.png", "id": "4bff4f37-3ef9-457e-9e8d-4a786cb2a5f2", "categories": ["distribution"], "name": "Fedora 27", "modification_date": "2019-03-26T14:00:53.140907+00:00", "versions": [{"creation_date": "2018-09-06T10:51:13.009967+00:00", "modification_date": "2018-09-06T10:51:13.009967+00:00", "id": "45b5823f-8ddf-4ea8-b106-33d2df127cdf", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "097a100e-fd2f-4918-8a5b-d86de5a489be", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "73f0bcd8-a152-4665-ac09-1b105905a475", "zone": "ams1"}], "name": "2018-09-06T10:51:13.011044"}], "current_public_version": "45b5823f-8ddf-4ea8-b106-33d2df127cdf", "label": "fedora_27", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Arch Linux is an independently developed Linux distribution versatile enough to suit any role.", "creation_date": "2016-03-07T20:55:32.213089+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/archlinux.png", "id": "8f60c5dd-e659-48da-97e3-fb7de42195f5", "categories": ["distribution"], "name": "Arch Linux", "modification_date": "2019-03-26T14:00:49.327070+00:00", "versions": [{"creation_date": "2018-04-20T15:59:04.594929+00:00", "modification_date": "2018-04-20T15:59:04.594929+00:00", "id": "f7696517-bc49-448b-9869-f2c84e7c2a96", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f21defd0-9fd9-4fb2-a29a-22844a6be3cd", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "3c904f73-080e-4c6f-8b28-8426cfdcb3c7", "zone": "ams1"}], "name": "2018-04-20T15:59:04.593811"}], "current_public_version": "f7696517-bc49-448b-9869-f2c84e7c2a96", "label": "arch_linux", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Alpine Linux is security-oriented, lightweight Linux distribution based on musl libc and busybox.", "creation_date": "2016-03-05T14:49:50.255568+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/alpinelinux.png", "id": "c0649a2a-e6bf-4712-9303-8d967153209c", "categories": ["distribution"], "name": "Alpine Linux", "modification_date": "2019-03-26T14:00:54.425917+00:00", "versions": [{"creation_date": "2018-04-26T10:18:10.201002+00:00", "modification_date": "2018-04-26T10:18:10.201002+00:00", "id": "be2293b6-9eba-4497-9659-2cfb927483b5", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "24141068-1043-4885-bf2b-8290f617e273", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "241b0bb3-9eed-4a7b-b0fd-71c45452ac95", "zone": "ams1"}], "name": "2018-04-26T10:18:10.196011"}], "current_public_version": "be2293b6-9eba-4497-9659-2cfb927483b5", "label": "alpine_linux", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Debian is a free operating system, developed by thousands of volunteers from all over the world who collaborate via the Internet.", "creation_date": "2019-07-16T13:55:36.377559+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/debian.png", "id": "7bdc1afb-231f-486a-9b85-1b0478bc0e4a", "categories": ["distribution"], "name": "Debian Buster", "modification_date": "2020-01-20T09:04:41.730609+00:00", "versions": [{"creation_date": "2020-01-15T11:52:04.860098+00:00", "modification_date": "2020-01-15T11:52:04.860098+00:00", "id": "763b45ed-2e31-4ba0-9beb-efb195503a2d", "local_images": [{"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "61010e34-7f1e-402b-a253-028a714a6678", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "4720c10f-59e3-4e20-915b-dcee1fc34c11", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "9d6e8a2c-31a9-439c-a4c5-9fba1c5b96ed", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "cc9188b3-3938-47d7-b091-c9ecad1fe507", "zone": "par1"}], "name": "2020-01-15T11:52:04.849401"}], "current_public_version": "763b45ed-2e31-4ba0-9beb-efb195503a2d", "label": "debian_buster", "organization": {"id": "51b656e3-4865-41e8-adbc-0c45bdd780db", "name": "Instances User Resources Build System"}}, {"valid_until": null, "description": "Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications.", "creation_date": "2016-03-05T15:11:26.847640+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/docker.png", "id": "c1b530d8-0ca0-45c4-80db-ba06608287b2", "categories": ["instantapp"], "name": "Docker", "modification_date": "2019-03-26T14:00:49.524465+00:00", "versions": [{"creation_date": "2019-03-07T17:07:39.090644+00:00", "modification_date": "2019-03-07T17:07:39.090644+00:00", "id": "bf30c937-6e89-4019-ad2a-92156a62cf3e", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "89c80d27-ddf4-4ffa-8215-b335cce3fd05", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "99e2a9c6-f0b9-42b6-8823-8b0d86ffe9bf", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "45a7e942-1fb0-48c0-bbf6-0acb9af24604", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "c669011a-ee16-42b6-b0c3-ecd19e419539", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "dcf35840-c007-4c8b-a48b-227cfd8a347b", "zone": "ams1"}], "name": "2019-03-07T17:07:39.004809"}], "current_public_version": "bf30c937-6e89-4019-ad2a-92156a62cf3e", "label": "docker", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "GitLab is a web-based Git repository manager with wiki and issue tracking features.", "creation_date": "2016-03-07T21:06:22.770864+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/gitlab.png", "id": "233074b9-e2ba-4e78-818e-dd4930ce6bee", "categories": ["instantapp"], "name": "GitLab", "modification_date": "2019-04-09T13:31:04.022755+00:00", "versions": [{"creation_date": "2019-04-09T13:31:03.648676+00:00", "modification_date": "2019-04-09T13:31:03.648676+00:00", "id": "a389c94b-8b19-4528-a4f6-0b7cac3425e9", "local_images": [{"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "06a2a6e9-922d-4353-9472-bbb1f79fda63", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "4527e41c-0e90-43a8-857e-d9584bf8467f", "zone": "par1"}], "name": "2019-04-09T13:31:03.352588"}], "current_public_version": "a389c94b-8b19-4528-a4f6-0b7cac3425e9", "label": "gitlab", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "A painless self-hosted Git service.", "creation_date": "2016-03-07T21:00:44.946716+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/gogs.png", "id": "90d512b8-e4b7-4821-98e9-78241d73a7e6", "categories": ["instantapp"], "name": "Gogs", "modification_date": "2019-03-26T14:00:54.513196+00:00", "versions": [{"creation_date": "2018-05-16T15:11:25.881343+00:00", "modification_date": "2018-05-16T15:11:25.881343+00:00", "id": "1b9e22e3-6a29-4f42-acfd-281ad086ee1d", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "776705c4-be8e-4a27-b740-2e8bbba518c5", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a513a250-e6e9-4687-892e-9d10b29e3972", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "d1341ece-ffda-4386-ad3a-27d60b650401", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "69b8bc0e-7771-42af-a4ad-ca756c31a18a", "zone": "ams1"}], "name": "2018-05-16T15:11:25.303762"}], "current_public_version": "1b9e22e3-6a29-4f42-acfd-281ad086ee1d", "label": "gogs", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.A dynamic, open source programming language with a focus on simplicity and productivity.", "creation_date": "2016-03-08T07:01:11.482482+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/golang.png", "id": "6c8d25c0-cb6f-4220-98aa-830b7e479ba5", "categories": ["instantapp"], "name": "Golang", "modification_date": "2019-03-26T14:00:52.861225+00:00", "versions": [{"creation_date": "2018-04-18T08:00:48.175340+00:00", "modification_date": "2018-04-18T08:00:48.175340+00:00", "id": "880194c8-53ce-4b6b-a274-4f79307e2f8e", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "43213956-c7a3-44b8-9d96-d51fa7457969", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "5ffb52aa-ea55-4596-9d0f-e403701b6624", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "bef7a6af-1bab-490a-a6cb-6a07c1b9ac7b", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "f0b7d9b8-aa31-45b4-9f7e-a68aa164ce6f", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "76ca1eb7-f68f-4770-a7a1-ab7665ae3297", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "0d954c34-341c-483a-be1c-71cf197343ed", "zone": "ams1"}], "name": "2018-04-18T08:00:48.129246"}], "current_public_version": "880194c8-53ce-4b6b-a274-4f79307e2f8e", "label": "golang", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Java is a computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible.", "creation_date": "2016-03-07T21:07:46.908969+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/java.png", "id": "d72d1b73-7460-446b-91fb-b451d079aa4d", "categories": ["instantapp"], "name": "Java", "modification_date": "2019-03-26T14:00:49.430836+00:00", "versions": [{"creation_date": "2018-04-18T10:11:18.535736+00:00", "modification_date": "2018-04-18T10:11:18.535736+00:00", "id": "f3f69cca-aadb-4e5e-94b0-254ce05a6639", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "c50cb4b2-bf7b-47e2-ab5f-3a9d3d4c1aef", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "98c93894-26a8-463b-a72b-c9d2b531b95d", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "43c43b5e-1e4f-4905-baef-71df3c565b4d", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "0c3f9f03-f490-444b-a05e-f342e917fed0", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "5e07622b-ad8b-4f65-b55f-cca18c3c0bbf", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "c0330755-e5d0-4c2c-ad0e-70687e1dccbb", "zone": "par1"}], "name": "2018-04-18T10:11:18.477156"}], "current_public_version": "f3f69cca-aadb-4e5e-94b0-254ce05a6639", "label": "java", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "LEMP stack is a version where Apache has been replaced with the more lightweight web server Nginx.", "creation_date": "2016-03-07T21:06:53.552980+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/lemp.png", "id": "986ba672-b489-4f66-9e3b-90194ac336d4", "categories": ["instantapp"], "name": "LEMP stack", "modification_date": "2019-04-09T13:31:12.129567+00:00", "versions": [{"creation_date": "2019-04-09T13:31:11.315416+00:00", "modification_date": "2019-04-09T13:31:11.315416+00:00", "id": "a2e5ed1a-6f01-4f20-aabd-4115c67df590", "local_images": [{"compatible_commercial_types": ["C1"], "arch": "arm", "id": "32332006-1420-4260-97c7-c1da586f68cd", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "d16622f6-32c1-4d16-a3ca-38b23d3a25fb", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "1bd37d60-4494-485f-9a82-0a211005489c", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "415d3727-0013-419a-abc6-1a688b096730", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "26c3727a-5b77-4b26-89c9-445ea2006f07", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "155ab61a-e069-4acb-bae3-e8217c5c0376", "zone": "ams1"}], "name": "2019-04-09T13:31:10.613803"}], "current_public_version": "a2e5ed1a-6f01-4f20-aabd-4115c67df590", "label": "lemp_stack", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "self-hosted Slack-alternative", "creation_date": "2016-07-11T14:52:57.803007+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/mattermost.png", "id": "98ad7ccb-cc7f-4828-9da3-113e9c1bd2db", "categories": ["instantapp"], "name": "Mattermost", "modification_date": "2019-03-26T14:00:51.938920+00:00", "versions": [{"creation_date": "2018-05-03T10:27:55.610920+00:00", "modification_date": "2018-05-03T10:27:55.610920+00:00", "id": "42371bf7-c1ca-4889-a6d4-43febda865ca", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "486e128c-fde7-42d7-9200-5d91b8dc2761", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "eb2ed407-177c-4195-a4ca-f3baa85e62ed", "zone": "ams1"}], "name": "2018-05-03T10:27:55.021511"}], "current_public_version": "42371bf7-c1ca-4889-a6d4-43febda865ca", "label": "mattermost", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Nextcloud is an open source, self-hosted file share and communication platform.", "creation_date": "2019-04-16T12:22:56.930842+00:00", "logo": "http://marketplace-logos.s3.nl-ams.scw.cloud/nextcloud.png", "id": "7d4a7cb1-1fd5-4a64-920b-c79f47367254", "categories": ["instantapp"], "name": "NextCloud", "modification_date": "2019-04-16T12:25:38.758921+00:00", "versions": [{"creation_date": "2019-04-16T12:25:38.052537+00:00", "modification_date": "2019-04-16T12:25:38.052537+00:00", "id": "2fe66cc6-8985-4b5f-8325-83acc0589436", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "e9af0a24-4312-4305-9386-b3a79e02f92d", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "c38073cf-ee40-4dc2-8059-ec2845f38f46", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "b9e319f5-ac4c-400d-8ff6-a6a769755190", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "0390c3e0-186d-4b24-8d0d-0e08b74fb59a", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "900971a4-3a3e-4ef9-b92f-b33c366c9f5c", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "7b7d4dde-6fe1-4586-a5a5-ae1af2ca2605", "zone": "par1"}], "name": "2019-04-16T12:25:37.374676"}], "current_public_version": "2fe66cc6-8985-4b5f-8325-83acc0589436", "label": "nextcloud", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "Node.js is an open source, cross-platform runtime environment for server-side and networking applications.", "creation_date": "2016-03-07T21:06:07.014951+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/nodejs.png", "id": "d11d7cc2-6ec8-4f95-a286-24fb5bac9e39", "categories": ["instantapp"], "name": "Node.js", "modification_date": "2019-03-26T14:00:51.148549+00:00", "versions": [{"creation_date": "2018-04-18T10:07:15.744660+00:00", "modification_date": "2018-04-18T10:07:15.744660+00:00", "id": "af308511-bcb3-4583-b0e0-79dbb1eea63e", "local_images": [{"compatible_commercial_types": [], "arch": "arm", "id": "a8020f20-8a66-43f3-8253-35941db3d237", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "3cc79cc6-4649-46d9-a2b6-698f1236e1d0", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "c9fb2bed-a9b8-4e1a-bf15-db8e763fe7a7", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f01db1d0-092a-47de-a32e-09bd6bda7715", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "6f2e99e8-da99-4990-b689-7294e8a604fa", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "03980aee-14cd-44f1-be3c-508c8b8a19e6", "zone": "par1"}], "name": "2018-04-18T10:07:15.691016"}], "current_public_version": "af308511-bcb3-4583-b0e0-79dbb1eea63e", "label": "node.js", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Surf the web in a secure and anonymous way with OpenVPN InstantApp.", "creation_date": "2016-03-07T21:04:57.667667+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/openvpn.png", "id": "b6f4edc8-21e6-4aa2-8f52-1030cf6d4dd8", "categories": ["instantapp"], "name": "OpenVPN", "modification_date": "2019-03-26T14:00:52.955853+00:00", "versions": [{"creation_date": "2019-03-25T13:06:02.622633+00:00", "modification_date": "2019-03-25T13:06:02.622633+00:00", "id": "d812e374-1169-4c91-aa90-c72acceeecb2", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "b15ddb1a-0611-412e-881a-3aed1b36392b", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "02906ae8-bf44-4dd0-bd05-6312dd9fa234", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "3aa3622c-45d4-4388-9618-cce6974c71a0", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a5430536-2a51-425d-8613-ef84dae91e27", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "51573d2d-301f-4d24-b0d6-f151728c82f5", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "cac79531-98d5-48fa-aba1-8250214b88a3", "zone": "par1"}], "name": "2019-03-25T13:06:01.961936"}], "current_public_version": "d812e374-1169-4c91-aa90-c72acceeecb2", "label": "openvpn", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "ownCloud lets you sync & share your files, calendar, contacts and more. Access your data from all your devices, on an open platform you can extend and modify.", "creation_date": "2016-03-07T21:05:14.365925+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/owncloud.png", "id": "e22a5d54-ecb5-4fdd-a130-a473737ff7ab", "categories": ["instantapp"], "name": "ownCloud", "modification_date": "2019-03-26T14:00:52.457272+00:00", "versions": [{"creation_date": "2018-04-18T10:09:39.010195+00:00", "modification_date": "2018-04-18T10:09:39.010195+00:00", "id": "c9c02a9c-e072-48af-aefd-bf6be9028022", "local_images": [{"compatible_commercial_types": [], "arch": "arm", "id": "a5fb716a-1c60-4740-a179-98ce315ca3d7", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "2fdbbbb4-3b63-403b-9604-27713971efd6", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "4208a611-a789-40ea-ac0e-fb3001ee39a9", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "93de8eae-535f-47bd-88fa-84af7b5eaf76", "zone": "par1"}], "name": "2018-04-18T10:09:38.952503"}], "current_public_version": "c9c02a9c-e072-48af-aefd-bf6be9028022", "label": "owncloud", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "PrestaShop is a free, open source e-commerce solution.", "creation_date": "2016-03-07T21:01:47.997930+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/prestashop.png", "id": "58a551e0-1b8b-4c83-82e7-1b4602ad43d1", "categories": ["instantapp"], "name": "PrestaShop", "modification_date": "2019-03-26T14:00:50.067950+00:00", "versions": [{"creation_date": "2018-05-16T14:57:16.059809+00:00", "modification_date": "2018-05-16T14:57:16.059809+00:00", "id": "6c459ab1-4f1a-4f87-b92e-c00849c93fde", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "4d07fcfa-ccda-4945-81aa-8de2206b39c0", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "73db574d-d5a0-49d5-b6ca-dd662895fac3", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "c97dc20f-8066-4d56-aabf-2b75162c0f9f", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "c78c3206-eb2b-4217-ad7c-0aca98dec145", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "7f91941c-f06a-4103-91a4-793f03b11fda", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "271a9c1f-73ef-4943-bac7-799130228040", "zone": "ams1"}], "name": "2018-05-16T14:57:15.505378"}], "current_public_version": "6c459ab1-4f1a-4f87-b92e-c00849c93fde", "label": "prestashop", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "The intended audience of this InstantApp is Python developers who want to bootstrap or test a Python application easily, in seconds.", "creation_date": "2016-03-07T21:05:46.642023+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/python.png", "id": "5c0f7971-c308-442e-82ab-2eb147439bd7", "categories": ["instantapp"], "name": "Python", "modification_date": "2019-03-26T14:00:49.970905+00:00", "versions": [{"creation_date": "2018-04-17T16:43:36.089412+00:00", "modification_date": "2018-04-17T16:43:36.089412+00:00", "id": "2642a982-e61d-4a58-8105-8838a69a85e3", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "70b9c9cf-c2d9-4a80-b450-a7aef8226d96", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "5218fa4e-8239-4831-ac2a-c96e23f387a2", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "f205e2a6-621a-4534-a5d1-36f6cf1f8376", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "613a5226-3d97-4f0e-abe2-99385a050784", "zone": "ams1"}], "name": "2018-04-17T16:43:36.031203"}], "current_public_version": "2642a982-e61d-4a58-8105-8838a69a85e3", "label": "python", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "A dynamic, open source programming language with a focus on simplicity and productivity.", "creation_date": "2016-03-07T22:15:25.347873+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ruby.png", "id": "42866fbe-9168-4f77-8271-09beb6049a07", "categories": ["instantapp"], "name": "Ruby", "modification_date": "2019-03-26T14:00:54.119256+00:00", "versions": [{"creation_date": "2018-04-18T10:21:49.119857+00:00", "modification_date": "2018-04-18T10:21:49.119857+00:00", "id": "5b8c935b-5047-43fd-a423-045dae3e0d78", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "09c71ada-00c6-43de-ad44-c77c5b857a05", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "24f2e8ee-80f1-4a8d-83c4-74ed8cd80ed0", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "e2479a13-414b-4a0c-ba50-d01e67ee8600", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "f83a03fa-58eb-4b35-bda9-1a42b6d6d90d", "zone": "ams1"}], "name": "2018-04-18T10:21:49.057120"}], "current_public_version": "5b8c935b-5047-43fd-a423-045dae3e0d78", "label": "ruby", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "The torrents InstantApp spawns a private server to upload and download your digital files.", "creation_date": "2016-03-07T21:08:02.980958+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/seedbox.png", "id": "4e18f1fc-0b66-4692-a38d-bfa4c94f29de", "categories": ["instantapp"], "name": "Torrents", "modification_date": "2019-03-26T14:00:51.427329+00:00", "versions": [{"creation_date": "2019-03-25T13:04:02.099902+00:00", "modification_date": "2019-03-25T13:04:02.099902+00:00", "id": "53d2e4fb-20df-4ba9-8d65-29256f2be480", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "41d0db97-4822-4642-96ec-6f3fbcfc167c", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "3fbe5f72-81da-4a0a-91ef-36ab68fc801e", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "1aed7396-79dc-431d-af03-d3dde35d195f", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "398875b6-de43-4946-976f-ba5189954912", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a3160162-3d72-4632-8e42-4849a1280743", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f5d116e3-2b58-44cf-a83a-cd0682135473", "zone": "par1"}], "name": "2019-03-25T13:04:01.408435"}], "current_public_version": "53d2e4fb-20df-4ba9-8d65-29256f2be480", "label": "torrents", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Ubuntu is the ideal distribution for scale-out computing, Ubuntu Server helps you make the most of your infrastructure.", "creation_date": "2020-02-17T15:50:48.980694+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "3f1b9623-71ba-4fe3-b994-27fcdaa850ba", "categories": ["distribution"], "name": "Ubuntu 20.04 Focal Fossa", "modification_date": "2020-04-28T15:23:46.153257+00:00", "versions": [{"creation_date": "2020-04-28T15:08:03.947699+00:00", "modification_date": "2020-04-28T15:08:03.947699+00:00", "id": "61cf23b2-447a-48d4-9cfe-02b965fa651b", "local_images": [{"compatible_commercial_types": ["VC1S", "VC1M", "VC1L", "START1-XS", "START1-S", "START1-M", "START1-L", "X64-15GB", "X64-30GB", "X64-60GB", "X64-120GB", "RENDER-S", "GP1-XS", "GP1-S", "GP1-M", "GP1-L", "GP1-XL", "DEV1-S", "DEV1-M", "DEV1-L", "DEV1-XL"], "arch": "x86_64", "id": "03e798ba-0c65-485b-82f1-828588f8da58", "zone": "ams1"}, {"compatible_commercial_types": ["VC1S", "VC1M", "VC1L", "START1-XS", "START1-S", "START1-M", "START1-L", "X64-15GB", "X64-30GB", "X64-60GB", "X64-120GB", "RENDER-S", "GP1-XS", "GP1-S", "GP1-M", "GP1-L", "GP1-XL", "DEV1-S", "DEV1-M", "DEV1-L", "DEV1-XL"], "arch": "x86_64", "id": "365a8b9c-0c6e-4875-a887-dc3213db9e20", "zone": "par1"}], "name": "2020-04-28T15:08:03.913957+00:00"}], "current_public_version": "61cf23b2-447a-48d4-9cfe-02b965fa651b", "label": "ubuntu_focal", "organization": {"id": "51b656e3-4865-41e8-adbc-0c45bdd780db", "name": "Instances User Resources Build System"}}, {"valid_until": null, "description": "Ubuntu Bionic for Machine Learning 10.1", "creation_date": "2019-03-06T17:24:56.871317+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "e0808ca5-1e0a-4070-8aff-d2e49e9600c1", "categories": ["Machine Learning"], "name": "Ubuntu Bionic ML 10.1", "modification_date": "2020-02-17T12:56:29.417410+00:00", "versions": [{"creation_date": "2020-02-17T12:50:10.150196+00:00", "modification_date": "2020-02-17T12:50:10.150196+00:00", "id": "50a39102-80cf-4c9b-aed8-919e745df9d5", "local_images": [{"compatible_commercial_types": ["RENDER-S"], "arch": "x86_64", "id": "8fa4f46b-2cb2-40df-813a-727df120b9e4", "zone": "par1"}], "name": "2020-02-17T12:50:10.040529"}], "current_public_version": "50a39102-80cf-4c9b-aed8-919e745df9d5", "label": "ubuntu_bionic_ml_10.1", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "Ubuntu Bionic for Machine Learning 9.2", "creation_date": "2019-03-06T17:24:29.909001+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "7e48e55a-7b46-4e4f-b2d2-6b7316cdca8c", "categories": ["Machine Learning"], "name": "Ubuntu Bionic ML 9.2", "modification_date": "2020-02-17T12:55:53.623681+00:00", "versions": [{"creation_date": "2020-02-17T12:39:31.681271+00:00", "modification_date": "2020-02-17T12:39:31.681271+00:00", "id": "d0602033-62f8-455a-be55-0930291bb43f", "local_images": [{"compatible_commercial_types": ["RENDER-S"], "arch": "x86_64", "id": "1dad4207-f91a-48c3-9fac-6620e90b9434", "zone": "par1"}], "name": "2020-02-17T12:39:31.572184"}], "current_public_version": "d0602033-62f8-455a-be55-0930291bb43f", "label": "ubuntu_bionic_ml_9.2", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "WordPress is the most popular web software you can use to create a beautiful website or blog.", "creation_date": "2016-03-07T21:03:59.783534+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/wordpress.png", "id": "215a50f9-0ba8-4e9c-a4e7-10caf50e3586", "categories": ["instantapp"], "name": "WordPress", "modification_date": "2019-03-26T14:00:50.250657+00:00", "versions": [{"creation_date": "2019-03-08T08:58:28.971149+00:00", "modification_date": "2019-03-08T08:58:28.971149+00:00", "id": "3fb22e1f-de7f-4787-9bf8-32770151a45e", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "8523fb41-500a-4f21-998b-890908da6119", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "5645133b-67a3-4644-9941-16f7e2b428ea", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "757fac76-5265-46f8-8a1f-00c0fb270010", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "7a892c1a-bbdc-491f-9974-4008e3708664", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "726334eb-0733-4b6a-becd-769ff9bfe16d", "zone": "ams1"}], "name": "2019-03-08T08:58:28.893091"}], "current_public_version": "3fb22e1f-de7f-4787-9bf8-32770151a45e", "label": "wordpress", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}]}' headers: Cache-Control: - no-cache Content-Length: - "54004" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Wed, 29 Apr 2020 14:13:27 GMT Link: - ; rel="last" Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 6d29413a-9566-4260-8452-750a22dce3ba X-Total-Count: - "31" status: 200 OK code: 200 duration: "" - request: body: '{"name":"srv-flamboyant-borg","commercial_type":"DEV1-M","image":"f974feac-abae-4365-b988-8ec7d1cec10d","organization":"951df375-e094-4d26-97c1-ba548eeb9c42"}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.2; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers method: POST response: body: '{"server": {"id": "4f494afb-238f-475f-bf12-dd90d0c9e5fe", "name": "srv-flamboyant-borg", "arch": "x86_64", "commercial_type": "DEV1-M", "boot_type": "local", "organization": "951df375-e094-4d26-97c1-ba548eeb9c42", "hostname": "srv-flamboyant-borg", "image": {"id": "f974feac-abae-4365-b988-8ec7d1cec10d", "name": "Ubuntu Bionic Beaver", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "dd5f5c10-23b1-4c9c-8445-eb6740957c84", "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", "volume_type": "l_ssd", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": "x86_64", "creation_date": "2019-03-05T10:13:15.974944+00:00", "modification_date": "2019-03-05T13:32:29.274319+00:00", "default_bootscript": {"id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", "public": false, "title": "x86_64 mainline 4.9.93 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": false, "zone": "fr-par-1"}, "from_server": null, "state": "available", "zone": "fr-par-1"}, "volumes": {"0": {"id": "ae4c4e69-fc02-4761-bcf8-5f7158c01add", "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13", "volume_type": "l_ssd", "export_uri": null, "organization": "951df375-e094-4d26-97c1-ba548eeb9c42", "server": {"id": "4f494afb-238f-475f-bf12-dd90d0c9e5fe", "name": "srv-flamboyant-borg"}, "size": 40000000000, "state": "available", "creation_date": "2020-04-29T14:13:28.317050+00:00", "modification_date": "2020-04-29T14:13:28.664963+00:00", "zone": "fr-par-1"}}, "tags": [], "state": "stopped", "protected": false, "state_detail": "", "public_ip": null, "ipv6": null, "extra_networks": [], "dynamic_ip_required": true, "enable_ipv6": false, "private_ip": null, "creation_date": "2020-04-29T14:13:28.317050+00:00", "modification_date": "2020-04-29T14:13:28.691563+00:00", "bootscript": {"id": "15fbd2f7-a0f9-412b-8502-6a44da8d98b8", "public": false, "title": "x86_64 mainline 4.9.93 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "kernel": "http://169.254.42.24/kernel/x86_64-mainline-lts-4.9-4.9.93-rev1/vmlinuz-4.9.93", "dtb": "", "initrd": "http://169.254.42.24/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": false, "zone": "fr-par-1"}, "security_group": {"id": "54e2d5f6-d79c-44cc-b19f-613699b9cc7e", "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": ["poweron", "backup"], "placement_group": null, "private_nics": [], "zone": "fr-par-1"}}' headers: Cache-Control: - no-cache Content-Length: - "2829" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Wed, 29 Apr 2020 14:13:28 GMT Location: - https://cp-par1.scaleway.com/servers/4f494afb-238f-475f-bf12-dd90d0c9e5fe Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 43d1a548-6b67-4e31-85c5-e3d89da38636 status: 201 Created code: 201 duration: "" - request: body: '{"name":"backup","volume_id":"ae4c4e69-fc02-4761-bcf8-5f7158c01add","organization":"951df375-e094-4d26-97c1-ba548eeb9c42"}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.2; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/snapshots method: POST response: body: '{"snapshot": {"id": "825c5c7e-0cf8-4df7-97cc-6b7134fa45b2", "name": "backup", "volume_type": "l_ssd", "creation_date": "2020-04-29T14:13:28.838144+00:00", "modification_date": "2020-04-29T14:13:28.838144+00:00", "organization": "951df375-e094-4d26-97c1-ba548eeb9c42", "size": 40000000000, "state": "available", "base_volume": {"id": "ae4c4e69-fc02-4761-bcf8-5f7158c01add", "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13"}, "zone": "fr-par-1"}}' headers: Cache-Control: - no-cache Content-Length: - "468" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Wed, 29 Apr 2020 14:13:28 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 0445c95d-37c8-452f-9ebf-64900935e535 status: 201 Created code: 201 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.2; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/snapshots/825c5c7e-0cf8-4df7-97cc-6b7134fa45b2 method: GET response: body: '{"snapshot": {"id": "825c5c7e-0cf8-4df7-97cc-6b7134fa45b2", "name": "backup", "volume_type": "l_ssd", "creation_date": "2020-04-29T14:13:28.838144+00:00", "modification_date": "2020-04-29T14:13:28.838144+00:00", "organization": "951df375-e094-4d26-97c1-ba548eeb9c42", "size": 40000000000, "state": "available", "base_volume": {"id": "ae4c4e69-fc02-4761-bcf8-5f7158c01add", "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13"}, "zone": "fr-par-1"}}' headers: Cache-Control: - no-cache Content-Length: - "468" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Wed, 29 Apr 2020 14:13:28 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - dc71538f-abcc-4648-a40a-a2ec27ce7b11 status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.2; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/snapshots/825c5c7e-0cf8-4df7-97cc-6b7134fa45b2 method: GET response: body: '{"snapshot": {"id": "825c5c7e-0cf8-4df7-97cc-6b7134fa45b2", "name": "backup", "volume_type": "l_ssd", "creation_date": "2020-04-29T14:13:28.838144+00:00", "modification_date": "2020-04-29T14:13:28.838144+00:00", "organization": "951df375-e094-4d26-97c1-ba548eeb9c42", "size": 40000000000, "state": "available", "base_volume": {"id": "ae4c4e69-fc02-4761-bcf8-5f7158c01add", "name": "snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13"}, "zone": "fr-par-1"}}' headers: Cache-Control: - no-cache Content-Length: - "468" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Wed, 29 Apr 2020 14:13:28 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - b0a2747a-cb95-41ff-a191-49e45eaa9ce7 status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.2; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/4f494afb-238f-475f-bf12-dd90d0c9e5fe method: DELETE response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Wed, 29 Apr 2020 14:13:29 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 6d9dc5c6-411a-47d2-815f-67a1d7930b42 status: 204 No Content code: 204 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.2; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/snapshots/825c5c7e-0cf8-4df7-97cc-6b7134fa45b2 method: DELETE response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Wed, 29 Apr 2020 14:13:29 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - c221f3fd-6658-4522-ba0e-2404a1e11f53 status: 204 No Content code: 204 duration: "" golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/testdata/utils-test-block.yaml000066400000000000000000001106451456366605600330720ustar00rootroot00000000000000--- version: 1 interactions: - request: body: '{"name":"instance_utils_test","project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","from_empty":{"size":20000000000},"tags":null}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes method: POST response: body: '{"id":"916cf57b-cc1b-4acc-b860-a19c3b06647e", "name":"instance_utils_test", "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "created_at":"2023-10-10T16:44:39.680346Z", "updated_at":"2023-10-10T16:44:39.680346Z", "references":[], "parent_snapshot_id":null, "status":"creating", "tags":[], "specs":{"perf_iops":5000, "class":"sbs"}, "zone":"fr-par-1"}' headers: Content-Length: - "391" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 16:44:39 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 455985ca-4384-4a35-9048-14df169d143b status: 200 OK code: 200 duration: "" - request: body: '{"name":"instance_utils_test2","project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","from_empty":{"size":20000000000},"tags":null}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes method: POST response: body: '{"id":"40263419-3952-463c-a87c-48f210b5d227", "name":"instance_utils_test2", "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "created_at":"2023-10-10T16:44:39.807643Z", "updated_at":"2023-10-10T16:44:39.807643Z", "references":[], "parent_snapshot_id":null, "status":"creating", "tags":[], "specs":{"perf_iops":5000, "class":"sbs"}, "zone":"fr-par-1"}' headers: Content-Length: - "392" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 16:44:39 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - b0869f2d-59e1-418c-b64c-219179f74b0b status: 200 OK code: 200 duration: "" - request: body: '{"name":"instance_utils_test","commercial_type":"PRO2-XXS","image":"81b9475d-e1b5-43c2-ac48-4c1a3b640686","volumes":{"0":{"id":"916cf57b-cc1b-4acc-b860-a19c3b06647e","volume_type":"sbs_volume"}},"project":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b"}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers method: POST response: body: '{"server": {"id": "0bbd8da7-0dbd-4099-9454-90f6f6fb297a", "name": "instance_utils_test", "arch": "x86_64", "commercial_type": "PRO2-XXS", "boot_type": "local", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "hostname": "instance-utils-test", "image": {"id": "81b9475d-e1b5-43c2-ac48-4c1a3b640686", "name": "Ubuntu 22.04 Jammy Jellyfish", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "235f1b04-c3f6-4245-9530-43fb642ff96d", "name": "Ubuntu 22.04 Jammy Jellyfish", "volume_type": "unified", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": "x86_64", "creation_date": "2023-08-08T13:35:09.293489+00:00", "modification_date": "2023-08-08T13:35:09.293489+00:00", "default_bootscript": null, "from_server": null, "state": "available", "tags": [], "zone": "fr-par-1"}, "volumes": {"0": {"boot": false, "volume_type": "sbs_volume", "id": "916cf57b-cc1b-4acc-b860-a19c3b06647e"}}, "tags": [], "state": "stopped", "protected": false, "state_detail": "", "public_ip": null, "public_ips": [], "mac_address": "de:00:00:28:34:a7", "routed_ip_enabled": false, "ipv6": null, "extra_networks": [], "dynamic_ip_required": true, "enable_ipv6": false, "private_ip": null, "creation_date": "2023-10-10T16:44:40.300039+00:00", "modification_date": "2023-10-10T16:44:40.300039+00:00", "bootscript": {"id": "fdfe150f-a870-4ce4-b432-9f56b5b995c1", "public": true, "title": "x86_64 mainline 4.4.230 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://10.194.3.9/kernel/x86_64-mainline-lts-4.4-4.4.230-rev1/vmlinuz-4.4.230", "dtb": "", "initrd": "http://10.194.3.9/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": true, "zone": "fr-par-1"}, "security_group": {"id": "0fe819c3-274d-472a-b3f5-ddb258d2d8bb", "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": ["poweron", "backup", "enable_routed_ip"], "placement_group": null, "private_nics": [], "zone": "fr-par-1"}}' headers: Content-Length: - "2216" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 16:44:40 GMT Location: - https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/0bbd8da7-0dbd-4099-9454-90f6f6fb297a Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 25faf7e1-9e1f-48f1-8d2b-0007e0cc5c92 status: 201 Created code: 201 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/916cf57b-cc1b-4acc-b860-a19c3b06647e method: GET response: body: '{"type": "not_found", "message": "resource is not found", "resource": "instance_volume", "resource_id": "916cf57b-cc1b-4acc-b860-a19c3b06647e"}' headers: Content-Length: - "143" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 16:44:41 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 4026fb3d-3e0a-4970-bd7a-31241ed88a91 status: 404 Not Found code: 404 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes/916cf57b-cc1b-4acc-b860-a19c3b06647e method: GET response: body: '{"id":"916cf57b-cc1b-4acc-b860-a19c3b06647e", "name":"instance_utils_test", "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "created_at":"2023-10-10T16:44:39.680346Z", "updated_at":"2023-10-10T16:44:40.385412Z", "references":[{"id":"a400f5c5-1ed2-4e68-9b9e-5422efe3d560", "product_resource_type":"instance_server", "product_resource_id":"0bbd8da7-0dbd-4099-9454-90f6f6fb297a", "created_at":"2023-10-10T16:44:40.385412Z", "type":"exclusive", "status":"attached"}], "parent_snapshot_id":null, "status":"in_use", "tags":[], "specs":{"perf_iops":5000, "class":"sbs"}, "zone":"fr-par-1"}' headers: Content-Length: - "624" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 16:44:41 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - e4954a0a-0518-4e44-a415-427f51819ba3 status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/0bbd8da7-0dbd-4099-9454-90f6f6fb297a method: GET response: body: '{"server": {"id": "0bbd8da7-0dbd-4099-9454-90f6f6fb297a", "name": "instance_utils_test", "arch": "x86_64", "commercial_type": "PRO2-XXS", "boot_type": "local", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "hostname": "instance-utils-test", "image": {"id": "81b9475d-e1b5-43c2-ac48-4c1a3b640686", "name": "Ubuntu 22.04 Jammy Jellyfish", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "235f1b04-c3f6-4245-9530-43fb642ff96d", "name": "Ubuntu 22.04 Jammy Jellyfish", "volume_type": "unified", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": "x86_64", "creation_date": "2023-08-08T13:35:09.293489+00:00", "modification_date": "2023-08-08T13:35:09.293489+00:00", "default_bootscript": null, "from_server": null, "state": "available", "tags": [], "zone": "fr-par-1"}, "volumes": {"0": {"boot": false, "volume_type": "sbs_volume", "id": "916cf57b-cc1b-4acc-b860-a19c3b06647e"}}, "tags": [], "state": "stopped", "protected": false, "state_detail": "", "public_ip": null, "public_ips": [], "mac_address": "de:00:00:28:34:a7", "routed_ip_enabled": false, "ipv6": null, "extra_networks": [], "dynamic_ip_required": true, "enable_ipv6": false, "private_ip": null, "creation_date": "2023-10-10T16:44:40.300039+00:00", "modification_date": "2023-10-10T16:44:40.300039+00:00", "bootscript": {"id": "fdfe150f-a870-4ce4-b432-9f56b5b995c1", "public": true, "title": "x86_64 mainline 4.4.230 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://10.194.3.9/kernel/x86_64-mainline-lts-4.4-4.4.230-rev1/vmlinuz-4.4.230", "dtb": "", "initrd": "http://10.194.3.9/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": true, "zone": "fr-par-1"}, "security_group": {"id": "0fe819c3-274d-472a-b3f5-ddb258d2d8bb", "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": ["poweron", "backup", "enable_routed_ip"], "placement_group": null, "private_nics": [], "zone": "fr-par-1"}}' headers: Content-Length: - "2216" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 16:44:42 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 9a0e6ddd-4dfc-4854-9bbb-adee1e5dde0a status: 200 OK code: 200 duration: "" - request: body: '{"volumes":{}}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/0bbd8da7-0dbd-4099-9454-90f6f6fb297a method: PATCH response: body: '{"server": {"id": "0bbd8da7-0dbd-4099-9454-90f6f6fb297a", "name": "instance_utils_test", "arch": "x86_64", "commercial_type": "PRO2-XXS", "boot_type": "local", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "hostname": "instance-utils-test", "image": {"id": "81b9475d-e1b5-43c2-ac48-4c1a3b640686", "name": "Ubuntu 22.04 Jammy Jellyfish", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "235f1b04-c3f6-4245-9530-43fb642ff96d", "name": "Ubuntu 22.04 Jammy Jellyfish", "volume_type": "unified", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": "x86_64", "creation_date": "2023-08-08T13:35:09.293489+00:00", "modification_date": "2023-08-08T13:35:09.293489+00:00", "default_bootscript": null, "from_server": null, "state": "available", "tags": [], "zone": "fr-par-1"}, "volumes": {}, "tags": [], "state": "stopped", "protected": false, "state_detail": "", "public_ip": null, "public_ips": [], "mac_address": "de:00:00:28:34:a7", "routed_ip_enabled": false, "ipv6": null, "extra_networks": [], "dynamic_ip_required": true, "enable_ipv6": false, "private_ip": null, "creation_date": "2023-10-10T16:44:40.300039+00:00", "modification_date": "2023-10-10T16:44:40.300039+00:00", "bootscript": {"id": "fdfe150f-a870-4ce4-b432-9f56b5b995c1", "public": true, "title": "x86_64 mainline 4.4.230 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://10.194.3.9/kernel/x86_64-mainline-lts-4.4-4.4.230-rev1/vmlinuz-4.4.230", "dtb": "", "initrd": "http://10.194.3.9/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": true, "zone": "fr-par-1"}, "security_group": {"id": "0fe819c3-274d-472a-b3f5-ddb258d2d8bb", "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": ["poweron", "backup", "enable_routed_ip"], "placement_group": null, "private_nics": [], "zone": "fr-par-1"}}' headers: Content-Length: - "2121" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 16:44:42 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 41c46561-a9f5-476a-aa5e-e2db7b7da0fd status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/916cf57b-cc1b-4acc-b860-a19c3b06647e method: GET response: body: '{"type": "not_found", "message": "resource is not found", "resource": "instance_volume", "resource_id": "916cf57b-cc1b-4acc-b860-a19c3b06647e"}' headers: Content-Length: - "143" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 16:44:42 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 7cd65619-632c-43c6-aa2e-6bf8b7181199 status: 404 Not Found code: 404 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes/916cf57b-cc1b-4acc-b860-a19c3b06647e method: GET response: body: '{"id":"916cf57b-cc1b-4acc-b860-a19c3b06647e", "name":"instance_utils_test", "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "created_at":"2023-10-10T16:44:39.680346Z", "updated_at":"2023-10-10T16:44:40.385412Z", "references":[{"id":"a400f5c5-1ed2-4e68-9b9e-5422efe3d560", "product_resource_type":"instance_server", "product_resource_id":"0bbd8da7-0dbd-4099-9454-90f6f6fb297a", "created_at":"2023-10-10T16:44:40.385412Z", "type":"exclusive", "status":"detaching"}], "parent_snapshot_id":null, "status":"in_use", "tags":[], "specs":{"perf_iops":5000, "class":"sbs"}, "zone":"fr-par-1"}' headers: Content-Length: - "625" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 16:44:42 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 0205f242-c9e2-4c35-9c2b-647868781d60 status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/0bbd8da7-0dbd-4099-9454-90f6f6fb297a method: GET response: body: '{"server": {"id": "0bbd8da7-0dbd-4099-9454-90f6f6fb297a", "name": "instance_utils_test", "arch": "x86_64", "commercial_type": "PRO2-XXS", "boot_type": "local", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "hostname": "instance-utils-test", "image": {"id": "81b9475d-e1b5-43c2-ac48-4c1a3b640686", "name": "Ubuntu 22.04 Jammy Jellyfish", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "235f1b04-c3f6-4245-9530-43fb642ff96d", "name": "Ubuntu 22.04 Jammy Jellyfish", "volume_type": "unified", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": "x86_64", "creation_date": "2023-08-08T13:35:09.293489+00:00", "modification_date": "2023-08-08T13:35:09.293489+00:00", "default_bootscript": null, "from_server": null, "state": "available", "tags": [], "zone": "fr-par-1"}, "volumes": {}, "tags": [], "state": "stopped", "protected": false, "state_detail": "", "public_ip": null, "public_ips": [], "mac_address": "de:00:00:28:34:a7", "routed_ip_enabled": false, "ipv6": null, "extra_networks": [], "dynamic_ip_required": true, "enable_ipv6": false, "private_ip": null, "creation_date": "2023-10-10T16:44:40.300039+00:00", "modification_date": "2023-10-10T16:44:40.300039+00:00", "bootscript": {"id": "fdfe150f-a870-4ce4-b432-9f56b5b995c1", "public": true, "title": "x86_64 mainline 4.4.230 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://10.194.3.9/kernel/x86_64-mainline-lts-4.4-4.4.230-rev1/vmlinuz-4.4.230", "dtb": "", "initrd": "http://10.194.3.9/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": true, "zone": "fr-par-1"}, "security_group": {"id": "0fe819c3-274d-472a-b3f5-ddb258d2d8bb", "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": ["poweron", "backup", "enable_routed_ip"], "placement_group": null, "private_nics": [], "zone": "fr-par-1"}}' headers: Content-Length: - "2121" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 16:44:43 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 43ae674b-2213-450f-a05f-4164021a45b9 status: 200 OK code: 200 duration: "" - request: body: '{"volumes":{"0":{"id":"916cf57b-cc1b-4acc-b860-a19c3b06647e","volume_type":"sbs_volume"}}}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/0bbd8da7-0dbd-4099-9454-90f6f6fb297a method: PATCH response: body: '{"server": {"id": "0bbd8da7-0dbd-4099-9454-90f6f6fb297a", "name": "instance_utils_test", "arch": "x86_64", "commercial_type": "PRO2-XXS", "boot_type": "local", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "hostname": "instance-utils-test", "image": {"id": "81b9475d-e1b5-43c2-ac48-4c1a3b640686", "name": "Ubuntu 22.04 Jammy Jellyfish", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "235f1b04-c3f6-4245-9530-43fb642ff96d", "name": "Ubuntu 22.04 Jammy Jellyfish", "volume_type": "unified", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": "x86_64", "creation_date": "2023-08-08T13:35:09.293489+00:00", "modification_date": "2023-08-08T13:35:09.293489+00:00", "default_bootscript": null, "from_server": null, "state": "available", "tags": [], "zone": "fr-par-1"}, "volumes": {"0": {"boot": false, "volume_type": "sbs_volume", "id": "916cf57b-cc1b-4acc-b860-a19c3b06647e"}}, "tags": [], "state": "stopped", "protected": false, "state_detail": "", "public_ip": null, "public_ips": [], "mac_address": "de:00:00:28:34:a7", "routed_ip_enabled": false, "ipv6": null, "extra_networks": [], "dynamic_ip_required": true, "enable_ipv6": false, "private_ip": null, "creation_date": "2023-10-10T16:44:40.300039+00:00", "modification_date": "2023-10-10T16:44:40.300039+00:00", "bootscript": {"id": "fdfe150f-a870-4ce4-b432-9f56b5b995c1", "public": true, "title": "x86_64 mainline 4.4.230 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://10.194.3.9/kernel/x86_64-mainline-lts-4.4-4.4.230-rev1/vmlinuz-4.4.230", "dtb": "", "initrd": "http://10.194.3.9/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": true, "zone": "fr-par-1"}, "security_group": {"id": "0fe819c3-274d-472a-b3f5-ddb258d2d8bb", "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": [], "placement_group": null, "private_nics": [], "zone": "fr-par-1"}}' headers: Content-Length: - "2177" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 16:44:43 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - b217b9d0-1c6a-4ae7-84db-a18dae993f93 status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/40263419-3952-463c-a87c-48f210b5d227 method: GET response: body: '{"type": "not_found", "message": "resource is not found", "resource": "instance_volume", "resource_id": "40263419-3952-463c-a87c-48f210b5d227"}' headers: Content-Length: - "143" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 16:44:43 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 3b7011d2-f1ed-45f3-a11b-72ea685fc883 status: 404 Not Found code: 404 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes/40263419-3952-463c-a87c-48f210b5d227 method: GET response: body: '{"id":"40263419-3952-463c-a87c-48f210b5d227", "name":"instance_utils_test2", "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "created_at":"2023-10-10T16:44:39.807643Z", "updated_at":"2023-10-10T16:44:39.874536Z", "references":[], "parent_snapshot_id":null, "status":"available", "tags":[], "specs":{"perf_iops":5000, "class":"sbs"}, "zone":"fr-par-1"}' headers: Content-Length: - "393" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 16:44:43 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - f67de56f-166b-490a-a65c-094b0410cb3b status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/0bbd8da7-0dbd-4099-9454-90f6f6fb297a method: GET response: body: '{"server": {"id": "0bbd8da7-0dbd-4099-9454-90f6f6fb297a", "name": "instance_utils_test", "arch": "x86_64", "commercial_type": "PRO2-XXS", "boot_type": "local", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "hostname": "instance-utils-test", "image": {"id": "81b9475d-e1b5-43c2-ac48-4c1a3b640686", "name": "Ubuntu 22.04 Jammy Jellyfish", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "235f1b04-c3f6-4245-9530-43fb642ff96d", "name": "Ubuntu 22.04 Jammy Jellyfish", "volume_type": "unified", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": "x86_64", "creation_date": "2023-08-08T13:35:09.293489+00:00", "modification_date": "2023-08-08T13:35:09.293489+00:00", "default_bootscript": null, "from_server": null, "state": "available", "tags": [], "zone": "fr-par-1"}, "volumes": {"0": {"boot": false, "volume_type": "sbs_volume", "id": "916cf57b-cc1b-4acc-b860-a19c3b06647e"}}, "tags": [], "state": "stopped", "protected": false, "state_detail": "", "public_ip": null, "public_ips": [], "mac_address": "de:00:00:28:34:a7", "routed_ip_enabled": false, "ipv6": null, "extra_networks": [], "dynamic_ip_required": true, "enable_ipv6": false, "private_ip": null, "creation_date": "2023-10-10T16:44:40.300039+00:00", "modification_date": "2023-10-10T16:44:40.300039+00:00", "bootscript": {"id": "fdfe150f-a870-4ce4-b432-9f56b5b995c1", "public": true, "title": "x86_64 mainline 4.4.230 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://10.194.3.9/kernel/x86_64-mainline-lts-4.4-4.4.230-rev1/vmlinuz-4.4.230", "dtb": "", "initrd": "http://10.194.3.9/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": true, "zone": "fr-par-1"}, "security_group": {"id": "0fe819c3-274d-472a-b3f5-ddb258d2d8bb", "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": [], "placement_group": null, "private_nics": [], "zone": "fr-par-1"}}' headers: Content-Length: - "2177" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 16:44:44 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 037b5c2f-86fe-4c9d-bfcb-db4620468d90 status: 200 OK code: 200 duration: "" - request: body: '{"volumes":{"0":{"id":"916cf57b-cc1b-4acc-b860-a19c3b06647e","volume_type":"sbs_volume"},"1":{"id":"40263419-3952-463c-a87c-48f210b5d227","volume_type":"sbs_volume"}}}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/0bbd8da7-0dbd-4099-9454-90f6f6fb297a method: PATCH response: body: '{"server": {"id": "0bbd8da7-0dbd-4099-9454-90f6f6fb297a", "name": "instance_utils_test", "arch": "x86_64", "commercial_type": "PRO2-XXS", "boot_type": "local", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "hostname": "instance-utils-test", "image": {"id": "81b9475d-e1b5-43c2-ac48-4c1a3b640686", "name": "Ubuntu 22.04 Jammy Jellyfish", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "235f1b04-c3f6-4245-9530-43fb642ff96d", "name": "Ubuntu 22.04 Jammy Jellyfish", "volume_type": "unified", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": "x86_64", "creation_date": "2023-08-08T13:35:09.293489+00:00", "modification_date": "2023-08-08T13:35:09.293489+00:00", "default_bootscript": null, "from_server": null, "state": "available", "tags": [], "zone": "fr-par-1"}, "volumes": {"0": {"boot": false, "volume_type": "sbs_volume", "id": "916cf57b-cc1b-4acc-b860-a19c3b06647e"}, "1": {"boot": false, "volume_type": "sbs_volume", "id": "40263419-3952-463c-a87c-48f210b5d227"}}, "tags": [], "state": "stopped", "protected": false, "state_detail": "", "public_ip": null, "public_ips": [], "mac_address": "de:00:00:28:34:a7", "routed_ip_enabled": false, "ipv6": null, "extra_networks": [], "dynamic_ip_required": true, "enable_ipv6": false, "private_ip": null, "creation_date": "2023-10-10T16:44:40.300039+00:00", "modification_date": "2023-10-10T16:44:40.300039+00:00", "bootscript": {"id": "fdfe150f-a870-4ce4-b432-9f56b5b995c1", "public": true, "title": "x86_64 mainline 4.4.230 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://10.194.3.9/kernel/x86_64-mainline-lts-4.4-4.4.230-rev1/vmlinuz-4.4.230", "dtb": "", "initrd": "http://10.194.3.9/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": true, "zone": "fr-par-1"}, "security_group": {"id": "0fe819c3-274d-472a-b3f5-ddb258d2d8bb", "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": [], "placement_group": null, "private_nics": [], "zone": "fr-par-1"}}' headers: Content-Length: - "2274" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 16:44:44 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 8986a20c-a6e2-4b60-ba24-95ca29709da9 status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/0bbd8da7-0dbd-4099-9454-90f6f6fb297a method: DELETE response: body: "" headers: Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Date: - Tue, 10 Oct 2023 16:44:45 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 5271125a-68dd-4465-ad88-efd0163d73aa status: 204 No Content code: 204 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes/916cf57b-cc1b-4acc-b860-a19c3b06647e method: GET response: body: '{"id":"916cf57b-cc1b-4acc-b860-a19c3b06647e", "name":"instance_utils_test", "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "created_at":"2023-10-10T16:44:39.680346Z", "updated_at":"2023-10-10T16:44:45.075855Z", "references":[], "parent_snapshot_id":null, "status":"available", "tags":[], "specs":{"perf_iops":5000, "class":"sbs"}, "zone":"fr-par-1"}' headers: Content-Length: - "392" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 16:44:45 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - b8dfacb2-08a3-4c26-a69c-114d8b8f6383 status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes/916cf57b-cc1b-4acc-b860-a19c3b06647e method: DELETE response: body: "" headers: Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 16:44:45 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 1303607c-fb64-48f2-aae3-791567dce562 status: 204 No Content code: 204 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes/40263419-3952-463c-a87c-48f210b5d227 method: GET response: body: '{"id":"40263419-3952-463c-a87c-48f210b5d227", "name":"instance_utils_test2", "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "created_at":"2023-10-10T16:44:39.807643Z", "updated_at":"2023-10-10T16:44:45.128611Z", "references":[], "parent_snapshot_id":null, "status":"available", "tags":[], "specs":{"perf_iops":5000, "class":"sbs"}, "zone":"fr-par-1"}' headers: Content-Length: - "393" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 16:44:45 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - d2bebc64-ef63-4e90-a5d2-a0d633042250 status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes/40263419-3952-463c-a87c-48f210b5d227 method: DELETE response: body: "" headers: Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 16:44:45 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 16f002c9-e5ec-473d-aa6a-e9cff8dec4a3 status: 204 No Content code: 204 duration: "" golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/testdata/utils-test.yaml000066400000000000000000000632621456366605600320040ustar00rootroot00000000000000--- version: 1 interactions: - request: body: '{"name":"instance_utils_test","commercial_type":"PRO2-XXS","image":"81b9475d-e1b5-43c2-ac48-4c1a3b640686","project":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b"}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers method: POST response: body: '{"server": {"id": "d98c50d4-04b9-405d-be55-40dc42c5b344", "name": "instance_utils_test", "arch": "x86_64", "commercial_type": "PRO2-XXS", "boot_type": "local", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "hostname": "instance-utils-test", "image": {"id": "81b9475d-e1b5-43c2-ac48-4c1a3b640686", "name": "Ubuntu 22.04 Jammy Jellyfish", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "235f1b04-c3f6-4245-9530-43fb642ff96d", "name": "Ubuntu 22.04 Jammy Jellyfish", "volume_type": "unified", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": "x86_64", "creation_date": "2023-08-08T13:35:09.293489+00:00", "modification_date": "2023-08-08T13:35:09.293489+00:00", "default_bootscript": null, "from_server": null, "state": "available", "tags": [], "zone": "fr-par-1"}, "volumes": {"0": {"boot": false, "id": "6ced1bf4-b4f1-4e86-bd2d-0374a9626fc2", "name": "Ubuntu 22.04 Jammy Jellyfish", "volume_type": "b_ssd", "export_uri": null, "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "server": {"id": "d98c50d4-04b9-405d-be55-40dc42c5b344", "name": "instance_utils_test"}, "size": 10000000000, "state": "available", "creation_date": "2023-10-10T09:15:38.261953+00:00", "modification_date": "2023-10-10T09:15:38.261953+00:00", "tags": [], "zone": "fr-par-1"}}, "tags": [], "state": "stopped", "protected": false, "state_detail": "", "public_ip": null, "public_ips": [], "mac_address": "de:00:00:28:23:37", "routed_ip_enabled": false, "ipv6": null, "extra_networks": [], "dynamic_ip_required": true, "enable_ipv6": false, "private_ip": null, "creation_date": "2023-10-10T09:15:38.261953+00:00", "modification_date": "2023-10-10T09:15:38.261953+00:00", "bootscript": {"id": "fdfe150f-a870-4ce4-b432-9f56b5b995c1", "public": true, "title": "x86_64 mainline 4.4.230 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://10.194.3.9/kernel/x86_64-mainline-lts-4.4-4.4.230-rev1/vmlinuz-4.4.230", "dtb": "", "initrd": "http://10.194.3.9/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": true, "zone": "fr-par-1"}, "security_group": {"id": "0fe819c3-274d-472a-b3f5-ddb258d2d8bb", "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": ["poweron", "backup", "enable_routed_ip"], "placement_group": null, "private_nics": [], "zone": "fr-par-1"}}' headers: Content-Length: - "2652" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 09:15:38 GMT Location: - https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/d98c50d4-04b9-405d-be55-40dc42c5b344 Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 9f05fb6a-ad06-4f27-9ea4-07860cd3a735 status: 201 Created code: 201 duration: "" - request: body: '{"project":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b","type":"unknown_iptype"}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/ips method: POST response: body: '{"ip": {"id": "785a05a2-5ca1-48c2-bea1-8ec4b358853b", "address": "51.15.243.218", "prefix": null, "reverse": null, "server": null, "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "zone": "fr-par-1", "type": "nat", "state": "attached", "tags": []}}' headers: Content-Length: - "306" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 09:15:39 GMT Location: - https://api.scaleway.com/instance/v1/zones/fr-par-1/ips/785a05a2-5ca1-48c2-bea1-8ec4b358853b Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 9263a54a-4df9-4c8d-ba7f-6e6676662636 status: 201 Created code: 201 duration: "" - request: body: '{"type":"unknown_iptype","server":"d98c50d4-04b9-405d-be55-40dc42c5b344"}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/ips/785a05a2-5ca1-48c2-bea1-8ec4b358853b method: PATCH response: body: '{"ip": {"id": "785a05a2-5ca1-48c2-bea1-8ec4b358853b", "address": "51.15.243.218", "prefix": null, "reverse": null, "server": {"id": "d98c50d4-04b9-405d-be55-40dc42c5b344", "name": "instance_utils_test"}, "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "zone": "fr-par-1", "type": "nat", "state": "attached", "tags": []}}' headers: Content-Length: - "379" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 09:15:39 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 5adf5fd2-64f8-4a03-a978-2085819552ed status: 200 OK code: 200 duration: "" - request: body: '{"type":"unknown_iptype","server":null}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/ips/785a05a2-5ca1-48c2-bea1-8ec4b358853b method: PATCH response: body: '{"ip": {"id": "785a05a2-5ca1-48c2-bea1-8ec4b358853b", "address": "51.15.243.218", "prefix": null, "reverse": null, "server": null, "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "zone": "fr-par-1", "type": "nat", "state": "detached", "tags": []}}' headers: Content-Length: - "306" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 09:15:39 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - abd05986-39e4-470f-a2fe-c810a8dd60e5 status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/ips/785a05a2-5ca1-48c2-bea1-8ec4b358853b method: DELETE response: body: "" headers: Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Date: - Tue, 10 Oct 2023 09:15:39 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - c18db02f-632e-46a1-a21c-4967e8a108da status: 204 No Content code: 204 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/6ced1bf4-b4f1-4e86-bd2d-0374a9626fc2 method: GET response: body: '{"volume": {"id": "6ced1bf4-b4f1-4e86-bd2d-0374a9626fc2", "name": "Ubuntu 22.04 Jammy Jellyfish", "volume_type": "b_ssd", "export_uri": null, "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "server": {"id": "d98c50d4-04b9-405d-be55-40dc42c5b344", "name": "instance_utils_test"}, "size": 10000000000, "state": "available", "creation_date": "2023-10-10T09:15:38.261953+00:00", "modification_date": "2023-10-10T09:15:38.261953+00:00", "tags": [], "zone": "fr-par-1"}}' headers: Content-Length: - "523" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 09:15:39 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 487e6ad2-2b73-4498-83fb-1425e9eccf15 status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/d98c50d4-04b9-405d-be55-40dc42c5b344 method: GET response: body: '{"server": {"id": "d98c50d4-04b9-405d-be55-40dc42c5b344", "name": "instance_utils_test", "arch": "x86_64", "commercial_type": "PRO2-XXS", "boot_type": "local", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "hostname": "instance-utils-test", "image": {"id": "81b9475d-e1b5-43c2-ac48-4c1a3b640686", "name": "Ubuntu 22.04 Jammy Jellyfish", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "235f1b04-c3f6-4245-9530-43fb642ff96d", "name": "Ubuntu 22.04 Jammy Jellyfish", "volume_type": "unified", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": "x86_64", "creation_date": "2023-08-08T13:35:09.293489+00:00", "modification_date": "2023-08-08T13:35:09.293489+00:00", "default_bootscript": null, "from_server": null, "state": "available", "tags": [], "zone": "fr-par-1"}, "volumes": {"0": {"boot": false, "id": "6ced1bf4-b4f1-4e86-bd2d-0374a9626fc2", "name": "Ubuntu 22.04 Jammy Jellyfish", "volume_type": "b_ssd", "export_uri": null, "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "server": {"id": "d98c50d4-04b9-405d-be55-40dc42c5b344", "name": "instance_utils_test"}, "size": 10000000000, "state": "available", "creation_date": "2023-10-10T09:15:38.261953+00:00", "modification_date": "2023-10-10T09:15:38.261953+00:00", "tags": [], "zone": "fr-par-1"}}, "tags": [], "state": "stopped", "protected": false, "state_detail": "", "public_ip": null, "public_ips": [], "mac_address": "de:00:00:28:23:37", "routed_ip_enabled": false, "ipv6": null, "extra_networks": [], "dynamic_ip_required": true, "enable_ipv6": false, "private_ip": null, "creation_date": "2023-10-10T09:15:38.261953+00:00", "modification_date": "2023-10-10T09:15:38.261953+00:00", "bootscript": {"id": "fdfe150f-a870-4ce4-b432-9f56b5b995c1", "public": true, "title": "x86_64 mainline 4.4.230 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://10.194.3.9/kernel/x86_64-mainline-lts-4.4-4.4.230-rev1/vmlinuz-4.4.230", "dtb": "", "initrd": "http://10.194.3.9/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": true, "zone": "fr-par-1"}, "security_group": {"id": "0fe819c3-274d-472a-b3f5-ddb258d2d8bb", "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": ["poweron", "backup", "enable_routed_ip"], "placement_group": null, "private_nics": [], "zone": "fr-par-1"}}' headers: Content-Length: - "2652" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 09:15:40 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 45254b89-4baf-42d4-ae6d-fd195b7dda23 status: 200 OK code: 200 duration: "" - request: body: '{"volumes":{}}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/d98c50d4-04b9-405d-be55-40dc42c5b344 method: PATCH response: body: '{"server": {"id": "d98c50d4-04b9-405d-be55-40dc42c5b344", "name": "instance_utils_test", "arch": "x86_64", "commercial_type": "PRO2-XXS", "boot_type": "local", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "hostname": "instance-utils-test", "image": {"id": "81b9475d-e1b5-43c2-ac48-4c1a3b640686", "name": "Ubuntu 22.04 Jammy Jellyfish", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "235f1b04-c3f6-4245-9530-43fb642ff96d", "name": "Ubuntu 22.04 Jammy Jellyfish", "volume_type": "unified", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": "x86_64", "creation_date": "2023-08-08T13:35:09.293489+00:00", "modification_date": "2023-08-08T13:35:09.293489+00:00", "default_bootscript": null, "from_server": null, "state": "available", "tags": [], "zone": "fr-par-1"}, "volumes": {}, "tags": [], "state": "stopped", "protected": false, "state_detail": "", "public_ip": null, "public_ips": [], "mac_address": "de:00:00:28:23:37", "routed_ip_enabled": false, "ipv6": null, "extra_networks": [], "dynamic_ip_required": true, "enable_ipv6": false, "private_ip": null, "creation_date": "2023-10-10T09:15:38.261953+00:00", "modification_date": "2023-10-10T09:15:38.261953+00:00", "bootscript": {"id": "fdfe150f-a870-4ce4-b432-9f56b5b995c1", "public": true, "title": "x86_64 mainline 4.4.230 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://10.194.3.9/kernel/x86_64-mainline-lts-4.4-4.4.230-rev1/vmlinuz-4.4.230", "dtb": "", "initrd": "http://10.194.3.9/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": true, "zone": "fr-par-1"}, "security_group": {"id": "0fe819c3-274d-472a-b3f5-ddb258d2d8bb", "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": ["poweron", "backup", "enable_routed_ip"], "placement_group": null, "private_nics": [], "zone": "fr-par-1"}}' headers: Content-Length: - "2121" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 09:15:40 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - d3ac5d9c-81af-4e4f-a8dd-957b411d134c status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/6ced1bf4-b4f1-4e86-bd2d-0374a9626fc2 method: GET response: body: '{"volume": {"id": "6ced1bf4-b4f1-4e86-bd2d-0374a9626fc2", "name": "Ubuntu 22.04 Jammy Jellyfish", "volume_type": "b_ssd", "export_uri": null, "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "server": null, "size": 10000000000, "state": "available", "creation_date": "2023-10-10T09:15:38.261953+00:00", "modification_date": "2023-10-10T09:15:40.350007+00:00", "tags": [], "zone": "fr-par-1"}}' headers: Content-Length: - "450" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 09:15:40 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - e12c4f7d-3176-4bdc-8c69-24e0054d1315 status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/d98c50d4-04b9-405d-be55-40dc42c5b344 method: GET response: body: '{"server": {"id": "d98c50d4-04b9-405d-be55-40dc42c5b344", "name": "instance_utils_test", "arch": "x86_64", "commercial_type": "PRO2-XXS", "boot_type": "local", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "hostname": "instance-utils-test", "image": {"id": "81b9475d-e1b5-43c2-ac48-4c1a3b640686", "name": "Ubuntu 22.04 Jammy Jellyfish", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "235f1b04-c3f6-4245-9530-43fb642ff96d", "name": "Ubuntu 22.04 Jammy Jellyfish", "volume_type": "unified", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": "x86_64", "creation_date": "2023-08-08T13:35:09.293489+00:00", "modification_date": "2023-08-08T13:35:09.293489+00:00", "default_bootscript": null, "from_server": null, "state": "available", "tags": [], "zone": "fr-par-1"}, "volumes": {}, "tags": [], "state": "stopped", "protected": false, "state_detail": "", "public_ip": null, "public_ips": [], "mac_address": "de:00:00:28:23:37", "routed_ip_enabled": false, "ipv6": null, "extra_networks": [], "dynamic_ip_required": true, "enable_ipv6": false, "private_ip": null, "creation_date": "2023-10-10T09:15:38.261953+00:00", "modification_date": "2023-10-10T09:15:38.261953+00:00", "bootscript": {"id": "fdfe150f-a870-4ce4-b432-9f56b5b995c1", "public": true, "title": "x86_64 mainline 4.4.230 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://10.194.3.9/kernel/x86_64-mainline-lts-4.4-4.4.230-rev1/vmlinuz-4.4.230", "dtb": "", "initrd": "http://10.194.3.9/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": true, "zone": "fr-par-1"}, "security_group": {"id": "0fe819c3-274d-472a-b3f5-ddb258d2d8bb", "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": ["poweron", "backup", "enable_routed_ip"], "placement_group": null, "private_nics": [], "zone": "fr-par-1"}}' headers: Content-Length: - "2121" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 09:15:40 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 23420bb5-e634-4f49-9318-7643e0f5cd21 status: 200 OK code: 200 duration: "" - request: body: '{"volumes":{"0":{"id":"6ced1bf4-b4f1-4e86-bd2d-0374a9626fc2","name":"6ced1bf4-b4f1-4e86-bd2d-0374a9626fc2"}}}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/d98c50d4-04b9-405d-be55-40dc42c5b344 method: PATCH response: body: '{"server": {"id": "d98c50d4-04b9-405d-be55-40dc42c5b344", "name": "instance_utils_test", "arch": "x86_64", "commercial_type": "PRO2-XXS", "boot_type": "local", "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "hostname": "instance-utils-test", "image": {"id": "81b9475d-e1b5-43c2-ac48-4c1a3b640686", "name": "Ubuntu 22.04 Jammy Jellyfish", "organization": "51b656e3-4865-41e8-adbc-0c45bdd780db", "project": "51b656e3-4865-41e8-adbc-0c45bdd780db", "root_volume": {"id": "235f1b04-c3f6-4245-9530-43fb642ff96d", "name": "Ubuntu 22.04 Jammy Jellyfish", "volume_type": "unified", "size": 10000000000}, "extra_volumes": {}, "public": true, "arch": "x86_64", "creation_date": "2023-08-08T13:35:09.293489+00:00", "modification_date": "2023-08-08T13:35:09.293489+00:00", "default_bootscript": null, "from_server": null, "state": "available", "tags": [], "zone": "fr-par-1"}, "volumes": {"0": {"boot": false, "id": "6ced1bf4-b4f1-4e86-bd2d-0374a9626fc2", "name": "Ubuntu 22.04 Jammy Jellyfish", "volume_type": "b_ssd", "export_uri": null, "organization": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "project": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", "server": {"id": "d98c50d4-04b9-405d-be55-40dc42c5b344", "name": "instance_utils_test"}, "size": 10000000000, "state": "available", "creation_date": "2023-10-10T09:15:38.261953+00:00", "modification_date": "2023-10-10T09:15:40.986653+00:00", "tags": [], "zone": "fr-par-1"}}, "tags": [], "state": "stopped", "protected": false, "state_detail": "", "public_ip": null, "public_ips": [], "mac_address": "de:00:00:28:23:37", "routed_ip_enabled": false, "ipv6": null, "extra_networks": [], "dynamic_ip_required": true, "enable_ipv6": false, "private_ip": null, "creation_date": "2023-10-10T09:15:38.261953+00:00", "modification_date": "2023-10-10T09:15:38.261953+00:00", "bootscript": {"id": "fdfe150f-a870-4ce4-b432-9f56b5b995c1", "public": true, "title": "x86_64 mainline 4.4.230 rev1", "architecture": "x86_64", "organization": "11111111-1111-4111-8111-111111111111", "project": "11111111-1111-4111-8111-111111111111", "kernel": "http://10.194.3.9/kernel/x86_64-mainline-lts-4.4-4.4.230-rev1/vmlinuz-4.4.230", "dtb": "", "initrd": "http://10.194.3.9/initrd/initrd-Linux-x86_64-v3.14.6.gz", "bootcmdargs": "LINUX_COMMON scaleway boot=local nbd.max_part=16", "default": true, "zone": "fr-par-1"}, "security_group": {"id": "0fe819c3-274d-472a-b3f5-ddb258d2d8bb", "name": "Default security group"}, "location": null, "maintenances": [], "allowed_actions": ["poweron", "backup", "enable_routed_ip"], "placement_group": null, "private_nics": [], "zone": "fr-par-1"}}' headers: Content-Length: - "2652" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 10 Oct 2023 09:15:41 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 1bdd821b-b03f-4a71-8d1a-cb203d27ca32 status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/servers/d98c50d4-04b9-405d-be55-40dc42c5b344 method: DELETE response: body: "" headers: Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Date: - Tue, 10 Oct 2023 09:15:41 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - a6634954-7a64-4b28-9786-7f7ca3da6b1a status: 204 No Content code: 204 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.21.1; linux; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/6ced1bf4-b4f1-4e86-bd2d-0374a9626fc2 method: DELETE response: body: "" headers: Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Date: - Tue, 10 Oct 2023 09:15:41 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 41993e5b-f681-4b71-9838-b81f3ffd7d12 status: 204 No Content code: 204 duration: "" golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/testdata/volume-utils-test.yaml000066400000000000000000000070431456366605600333040ustar00rootroot00000000000000--- version: 1 interactions: - request: body: '{"name":"test volume","organization":"951df375-e094-4d26-97c1-ba548eeb9c42","volume_type":"l_ssd","size":20000000000}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.3; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes method: POST response: body: '{"volume": {"id": "fd5ad3da-3123-4726-9a2b-c7647bc89b04", "name": "test volume", "volume_type": "l_ssd", "export_uri": null, "organization": "951df375-e094-4d26-97c1-ba548eeb9c42", "server": null, "size": 20000000000, "state": "available", "creation_date": "2020-05-20T12:39:42.548392+00:00", "modification_date": "2020-05-20T12:39:42.548392+00:00", "zone": "fr-par-1"}}' headers: Cache-Control: - no-cache Content-Length: - "370" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Wed, 20 May 2020 12:39:42 GMT Location: - https://cp-par1.scaleway.com/volumes/fd5ad3da-3123-4726-9a2b-c7647bc89b04 Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 6fb1b944-1ad1-417e-8568-ad7dbeb80dde status: 201 Created code: 201 duration: "" - request: body: '{"name":"some new volume name"}' form: {} headers: Content-Type: - application/json User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.3; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/fd5ad3da-3123-4726-9a2b-c7647bc89b04 method: PATCH response: body: '{"volume": {"id": "fd5ad3da-3123-4726-9a2b-c7647bc89b04", "name": "some new volume name", "volume_type": "l_ssd", "export_uri": null, "organization": "951df375-e094-4d26-97c1-ba548eeb9c42", "server": null, "size": 20000000000, "state": "available", "creation_date": "2020-05-20T12:39:42.548392+00:00", "modification_date": "2020-05-20T12:39:42.548392+00:00", "zone": "fr-par-1"}}' headers: Cache-Control: - no-cache Content-Length: - "379" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Wed, 20 May 2020 12:39:42 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - aa94c984-91fe-4d9e-a504-725b6c87ede0 status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.3; darwin; amd64) url: https://api.scaleway.com/instance/v1/zones/fr-par-1/volumes/fd5ad3da-3123-4726-9a2b-c7647bc89b04 method: DELETE response: body: "" headers: Cache-Control: - no-cache Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Wed, 20 May 2020 12:39:42 GMT Server: - scaleway_api Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - f031e794-2e6c-4ac9-ade2-01e3d13c3a36 status: 204 No Content code: 204 duration: "" golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/volume_utils.go000066400000000000000000000057541456366605600302520ustar00rootroot00000000000000package instance import ( goerrors "errors" "time" block "github.com/scaleway/scaleway-sdk-go/api/block/v1alpha1" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) // WaitForImageRequest is used by WaitForImage method. type WaitForVolumeRequest struct { VolumeID string Zone scw.Zone Timeout *time.Duration RetryInterval *time.Duration } // WaitForSnapshot wait for the snapshot to be in a "terminal state" before returning. func (s *API) WaitForVolume(req *WaitForVolumeRequest, opts ...scw.RequestOption) (*Volume, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[VolumeState]struct{}{ VolumeStateAvailable: {}, VolumeStateError: {}, } volume, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetVolume(&GetVolumeRequest{ VolumeID: req.VolumeID, Zone: req.Zone, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.Volume.State] return res.Volume, isTerminal, err }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for volume failed") } return volume.(*Volume), nil } type unknownVolume struct { ID string ServerID *string Type VolumeVolumeType } type getUnknownVolumeRequest struct { Zone scw.Zone VolumeID string IsBlockVolume *bool } // getUnknownVolume is used to get a volume that can be either from instance or block API func (s *API) getUnknownVolume(req *getUnknownVolumeRequest, opts ...scw.RequestOption) (*unknownVolume, error) { volume := &unknownVolume{ ID: req.VolumeID, } // Try instance API if req.IsBlockVolume == nil || *req.IsBlockVolume == false { getVolumeResponse, err := s.GetVolume(&GetVolumeRequest{ Zone: req.Zone, VolumeID: req.VolumeID, }) notFoundErr := &scw.ResourceNotFoundError{} if err != nil && !goerrors.As(err, ¬FoundErr) { return nil, err } if getVolumeResponse != nil { if getVolumeResponse.Volume != nil && getVolumeResponse.Volume.Server != nil { volume.ServerID = &getVolumeResponse.Volume.Server.ID } volume.Type = getVolumeResponse.Volume.VolumeType } } if volume.Type == "" && (req.IsBlockVolume == nil || *req.IsBlockVolume == true) { getVolumeResponse, err := block.NewAPI(s.client).GetVolume(&block.GetVolumeRequest{ Zone: req.Zone, VolumeID: req.VolumeID, }) if err != nil { return nil, err } for _, reference := range getVolumeResponse.References { if reference.ProductResourceType == "instance_server" { volume.ServerID = &reference.ProductResourceID } } volume.Type = VolumeVolumeTypeSbsVolume } return volume, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/instance/v1/volume_utils_test.go000066400000000000000000000033201456366605600312740ustar00rootroot00000000000000package instance import ( "testing" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers/httprecorder" "github.com/scaleway/scaleway-sdk-go/scw" ) func TestUpdateVolume(t *testing.T) { client, r, err := httprecorder.CreateRecordedScwClient("volume-utils-test") testhelpers.AssertNoError(t, err) defer func() { testhelpers.AssertNoError(t, r.Stop()) // Make sure recorder is stopped once done with it }() instanceAPI := NewAPI(client) var ( zone = scw.ZoneFrPar1 project = "951df375-e094-4d26-97c1-ba548eeb9c42" volumeName = "test volume" volumeSize = 20 * scw.GB volumeType = VolumeVolumeTypeLSSD newVolumeName = "some new volume name" volumeID string ) // Create volume createVolumeResponse, err := instanceAPI.CreateVolume(&CreateVolumeRequest{ Zone: zone, Name: volumeName, Project: &project, Size: &volumeSize, VolumeType: volumeType, }) testhelpers.AssertNoError(t, err) volumeID = createVolumeResponse.Volume.ID // Update volume and test whether successfully updated updateVolumeResponse, err := instanceAPI.UpdateVolume(&UpdateVolumeRequest{ Zone: zone, Name: &newVolumeName, VolumeID: volumeID, }) testhelpers.AssertNoError(t, err) testhelpers.Assert(t, updateVolumeResponse.Volume != nil, "Should have volume in response") testhelpers.Equals(t, newVolumeName, updateVolumeResponse.Volume.Name) testhelpers.Equals(t, volumeSize, updateVolumeResponse.Volume.Size) // check that server is not changed // Delete Volume err = instanceAPI.DeleteVolume(&DeleteVolumeRequest{ Zone: zone, VolumeID: volumeID, }) testhelpers.AssertNoError(t, err) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/iot/000077500000000000000000000000001456366605600236225ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/iot/v1/000077500000000000000000000000001456366605600241505ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/iot/v1/iot_helpers.go000066400000000000000000000027351456366605600270230ustar00rootroot00000000000000package iot import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) const ( waitForHubDefaultTimeout = 15 * time.Minute defaultRetryInterval = 5 * time.Second ) // WaitForHubRequest is used by WaitForHub method. type WaitForHubRequest struct { HubID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForHub waits for the hub to be in a ready state before returning. func (s *API) WaitForHub(req *WaitForHubRequest, opts ...scw.RequestOption) (*Hub, error) { timeout := waitForHubDefaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[HubStatus]struct{}{ HubStatusError: {}, HubStatusReady: {}, HubStatusDisabled: {}, } hub, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { hub, err := s.GetHub(&GetHubRequest{ HubID: req.HubID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[hub.Status] return hub, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for hub failed") } return hub.(*Hub), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/iot/v1/iot_sdk.go000066400000000000000000002403541456366605600261430ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package iot provides methods and message types of the iot v1 API. package iot import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type DeviceMessageFiltersRulePolicy string const ( DeviceMessageFiltersRulePolicyUnknown = DeviceMessageFiltersRulePolicy("unknown") DeviceMessageFiltersRulePolicyAccept = DeviceMessageFiltersRulePolicy("accept") DeviceMessageFiltersRulePolicyReject = DeviceMessageFiltersRulePolicy("reject") ) func (enum DeviceMessageFiltersRulePolicy) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum DeviceMessageFiltersRulePolicy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DeviceMessageFiltersRulePolicy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DeviceMessageFiltersRulePolicy(DeviceMessageFiltersRulePolicy(tmp).String()) return nil } type DeviceStatus string const ( DeviceStatusUnknown = DeviceStatus("unknown") DeviceStatusError = DeviceStatus("error") DeviceStatusEnabled = DeviceStatus("enabled") DeviceStatusDisabled = DeviceStatus("disabled") ) func (enum DeviceStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum DeviceStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DeviceStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DeviceStatus(DeviceStatus(tmp).String()) return nil } type HubProductPlan string const ( HubProductPlanPlanUnknown = HubProductPlan("plan_unknown") HubProductPlanPlanShared = HubProductPlan("plan_shared") HubProductPlanPlanDedicated = HubProductPlan("plan_dedicated") HubProductPlanPlanHa = HubProductPlan("plan_ha") ) func (enum HubProductPlan) String() string { if enum == "" { // return default value if empty return "plan_unknown" } return string(enum) } func (enum HubProductPlan) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *HubProductPlan) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = HubProductPlan(HubProductPlan(tmp).String()) return nil } type HubStatus string const ( HubStatusUnknown = HubStatus("unknown") HubStatusError = HubStatus("error") HubStatusEnabling = HubStatus("enabling") HubStatusReady = HubStatus("ready") HubStatusDisabling = HubStatus("disabling") HubStatusDisabled = HubStatus("disabled") ) func (enum HubStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum HubStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *HubStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = HubStatus(HubStatus(tmp).String()) return nil } type ListDevicesRequestOrderBy string const ( ListDevicesRequestOrderByNameAsc = ListDevicesRequestOrderBy("name_asc") ListDevicesRequestOrderByNameDesc = ListDevicesRequestOrderBy("name_desc") ListDevicesRequestOrderByStatusAsc = ListDevicesRequestOrderBy("status_asc") ListDevicesRequestOrderByStatusDesc = ListDevicesRequestOrderBy("status_desc") ListDevicesRequestOrderByHubIDAsc = ListDevicesRequestOrderBy("hub_id_asc") ListDevicesRequestOrderByHubIDDesc = ListDevicesRequestOrderBy("hub_id_desc") ListDevicesRequestOrderByCreatedAtAsc = ListDevicesRequestOrderBy("created_at_asc") ListDevicesRequestOrderByCreatedAtDesc = ListDevicesRequestOrderBy("created_at_desc") ListDevicesRequestOrderByUpdatedAtAsc = ListDevicesRequestOrderBy("updated_at_asc") ListDevicesRequestOrderByUpdatedAtDesc = ListDevicesRequestOrderBy("updated_at_desc") ListDevicesRequestOrderByAllowInsecureAsc = ListDevicesRequestOrderBy("allow_insecure_asc") ListDevicesRequestOrderByAllowInsecureDesc = ListDevicesRequestOrderBy("allow_insecure_desc") ) func (enum ListDevicesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "name_asc" } return string(enum) } func (enum ListDevicesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListDevicesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListDevicesRequestOrderBy(ListDevicesRequestOrderBy(tmp).String()) return nil } type ListHubsRequestOrderBy string const ( ListHubsRequestOrderByNameAsc = ListHubsRequestOrderBy("name_asc") ListHubsRequestOrderByNameDesc = ListHubsRequestOrderBy("name_desc") ListHubsRequestOrderByStatusAsc = ListHubsRequestOrderBy("status_asc") ListHubsRequestOrderByStatusDesc = ListHubsRequestOrderBy("status_desc") ListHubsRequestOrderByProductPlanAsc = ListHubsRequestOrderBy("product_plan_asc") ListHubsRequestOrderByProductPlanDesc = ListHubsRequestOrderBy("product_plan_desc") ListHubsRequestOrderByCreatedAtAsc = ListHubsRequestOrderBy("created_at_asc") ListHubsRequestOrderByCreatedAtDesc = ListHubsRequestOrderBy("created_at_desc") ListHubsRequestOrderByUpdatedAtAsc = ListHubsRequestOrderBy("updated_at_asc") ListHubsRequestOrderByUpdatedAtDesc = ListHubsRequestOrderBy("updated_at_desc") ) func (enum ListHubsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "name_asc" } return string(enum) } func (enum ListHubsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListHubsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListHubsRequestOrderBy(ListHubsRequestOrderBy(tmp).String()) return nil } type ListNetworksRequestOrderBy string const ( ListNetworksRequestOrderByNameAsc = ListNetworksRequestOrderBy("name_asc") ListNetworksRequestOrderByNameDesc = ListNetworksRequestOrderBy("name_desc") ListNetworksRequestOrderByTypeAsc = ListNetworksRequestOrderBy("type_asc") ListNetworksRequestOrderByTypeDesc = ListNetworksRequestOrderBy("type_desc") ListNetworksRequestOrderByCreatedAtAsc = ListNetworksRequestOrderBy("created_at_asc") ListNetworksRequestOrderByCreatedAtDesc = ListNetworksRequestOrderBy("created_at_desc") ) func (enum ListNetworksRequestOrderBy) String() string { if enum == "" { // return default value if empty return "name_asc" } return string(enum) } func (enum ListNetworksRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListNetworksRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListNetworksRequestOrderBy(ListNetworksRequestOrderBy(tmp).String()) return nil } type ListRoutesRequestOrderBy string const ( ListRoutesRequestOrderByNameAsc = ListRoutesRequestOrderBy("name_asc") ListRoutesRequestOrderByNameDesc = ListRoutesRequestOrderBy("name_desc") ListRoutesRequestOrderByHubIDAsc = ListRoutesRequestOrderBy("hub_id_asc") ListRoutesRequestOrderByHubIDDesc = ListRoutesRequestOrderBy("hub_id_desc") ListRoutesRequestOrderByTypeAsc = ListRoutesRequestOrderBy("type_asc") ListRoutesRequestOrderByTypeDesc = ListRoutesRequestOrderBy("type_desc") ListRoutesRequestOrderByCreatedAtAsc = ListRoutesRequestOrderBy("created_at_asc") ListRoutesRequestOrderByCreatedAtDesc = ListRoutesRequestOrderBy("created_at_desc") ) func (enum ListRoutesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "name_asc" } return string(enum) } func (enum ListRoutesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListRoutesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListRoutesRequestOrderBy(ListRoutesRequestOrderBy(tmp).String()) return nil } type NetworkNetworkType string const ( NetworkNetworkTypeUnknown = NetworkNetworkType("unknown") NetworkNetworkTypeSigfox = NetworkNetworkType("sigfox") NetworkNetworkTypeRest = NetworkNetworkType("rest") ) func (enum NetworkNetworkType) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum NetworkNetworkType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *NetworkNetworkType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = NetworkNetworkType(NetworkNetworkType(tmp).String()) return nil } type RouteDatabaseConfigEngine string const ( RouteDatabaseConfigEngineUnknown = RouteDatabaseConfigEngine("unknown") RouteDatabaseConfigEnginePostgresql = RouteDatabaseConfigEngine("postgresql") RouteDatabaseConfigEngineMysql = RouteDatabaseConfigEngine("mysql") ) func (enum RouteDatabaseConfigEngine) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum RouteDatabaseConfigEngine) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *RouteDatabaseConfigEngine) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = RouteDatabaseConfigEngine(RouteDatabaseConfigEngine(tmp).String()) return nil } type RouteRestConfigHTTPVerb string const ( RouteRestConfigHTTPVerbUnknown = RouteRestConfigHTTPVerb("unknown") RouteRestConfigHTTPVerbGet = RouteRestConfigHTTPVerb("get") RouteRestConfigHTTPVerbPost = RouteRestConfigHTTPVerb("post") RouteRestConfigHTTPVerbPut = RouteRestConfigHTTPVerb("put") RouteRestConfigHTTPVerbPatch = RouteRestConfigHTTPVerb("patch") RouteRestConfigHTTPVerbDelete = RouteRestConfigHTTPVerb("delete") ) func (enum RouteRestConfigHTTPVerb) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum RouteRestConfigHTTPVerb) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *RouteRestConfigHTTPVerb) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = RouteRestConfigHTTPVerb(RouteRestConfigHTTPVerb(tmp).String()) return nil } type RouteRouteType string const ( RouteRouteTypeUnknown = RouteRouteType("unknown") RouteRouteTypeS3 = RouteRouteType("s3") RouteRouteTypeDatabase = RouteRouteType("database") RouteRouteTypeRest = RouteRouteType("rest") ) func (enum RouteRouteType) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum RouteRouteType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *RouteRouteType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = RouteRouteType(RouteRouteType(tmp).String()) return nil } type RouteS3ConfigS3Strategy string const ( RouteS3ConfigS3StrategyUnknown = RouteS3ConfigS3Strategy("unknown") RouteS3ConfigS3StrategyPerTopic = RouteS3ConfigS3Strategy("per_topic") RouteS3ConfigS3StrategyPerMessage = RouteS3ConfigS3Strategy("per_message") ) func (enum RouteS3ConfigS3Strategy) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum RouteS3ConfigS3Strategy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *RouteS3ConfigS3Strategy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = RouteS3ConfigS3Strategy(RouteS3ConfigS3Strategy(tmp).String()) return nil } // DeviceMessageFiltersRule: device message filters rule. type DeviceMessageFiltersRule struct { // Policy: if set to `accept`, all topics in the topics list will be allowed, with all other topics being denied. // If set to `reject`, all topics in the topics list will be denied, with all other topics being allowed. // Default value: unknown Policy DeviceMessageFiltersRulePolicy `json:"policy"` // Topics: list of topics to accept or reject. It must be valid MQTT topics and up to 65535 characters. Topics *[]string `json:"topics"` } // DeviceMessageFilters: device message filters. type DeviceMessageFilters struct { // Publish: filtering rule to restrict topics the device can publish to. Publish *DeviceMessageFiltersRule `json:"publish"` // Subscribe: filtering rule to restrict topics the device can subscribe to. Subscribe *DeviceMessageFiltersRule `json:"subscribe"` } // HubTwinsGraphiteConfig: hub twins graphite config. type HubTwinsGraphiteConfig struct { PushURI string `json:"push_uri"` } // Certificate: certificate. type Certificate struct { Crt string `json:"crt"` Key string `json:"key"` } // Device: device. type Device struct { // ID: device ID, also used as MQTT Client ID or username. ID string `json:"id"` // Name: device name. Name string `json:"name"` // Description: device description. Description string `json:"description"` // Status: device status. // Default value: unknown Status DeviceStatus `json:"status"` // HubID: hub ID. HubID string `json:"hub_id"` // LastActivityAt: last connection/activity date of a device. LastActivityAt *time.Time `json:"last_activity_at"` // IsConnected: defines whether the device is connected to the Hub. IsConnected bool `json:"is_connected"` // AllowInsecure: defines whether to allow the device to connect to the Hub without TLS mutual authentication. AllowInsecure bool `json:"allow_insecure"` // AllowMultipleConnections: defines whether to allow multiple physical devices to connect to the Hub with this device's credentials. AllowMultipleConnections bool `json:"allow_multiple_connections"` // MessageFilters: filter-sets to restrict the topics the device can publish/subscribe to. MessageFilters *DeviceMessageFilters `json:"message_filters"` // HasCustomCertificate: assigning a custom certificate allows a device to authenticate using that specific certificate without checking the Hub's CA certificate. HasCustomCertificate bool `json:"has_custom_certificate"` // CreatedAt: date at which the device was added. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date at which the device was last modified. UpdatedAt *time.Time `json:"updated_at"` } // Network: network. type Network struct { // ID: network ID. ID string `json:"id"` // Name: network name. Name string `json:"name"` // Type: type of network to connect with. // Default value: unknown Type NetworkNetworkType `json:"type"` // Endpoint: endpoint to use for interacting with the network. Endpoint string `json:"endpoint"` // HubID: hub ID to connect the Network to. HubID string `json:"hub_id"` // CreatedAt: date at which the network was created. CreatedAt *time.Time `json:"created_at"` // TopicPrefix: this prefix will be prepended to all topics for this Network. TopicPrefix string `json:"topic_prefix"` } // CreateRouteRequestDatabaseConfig: create route request database config. type CreateRouteRequestDatabaseConfig struct { Host string `json:"host"` Port uint32 `json:"port"` Dbname string `json:"dbname"` Username string `json:"username"` Password string `json:"password"` Query string `json:"query"` // Engine: default value: unknown Engine RouteDatabaseConfigEngine `json:"engine"` } // CreateRouteRequestRestConfig: create route request rest config. type CreateRouteRequestRestConfig struct { // Verb: default value: unknown Verb RouteRestConfigHTTPVerb `json:"verb"` URI string `json:"uri"` Headers map[string]string `json:"headers"` } // CreateRouteRequestS3Config: create route request s3 config. type CreateRouteRequestS3Config struct { BucketRegion string `json:"bucket_region"` BucketName string `json:"bucket_name"` ObjectPrefix string `json:"object_prefix"` // Strategy: default value: unknown Strategy RouteS3ConfigS3Strategy `json:"strategy"` } // Hub: hub. type Hub struct { // ID: hub ID. ID string `json:"id"` // Name: hub name. Name string `json:"name"` // Status: current status of the Hub. // Default value: unknown Status HubStatus `json:"status"` // ProductPlan: hub feature set. // Default value: plan_unknown ProductPlan HubProductPlan `json:"product_plan"` // Enabled: defines whether the hub has been enabled. Enabled bool `json:"enabled"` // DeviceCount: number of registered devices. DeviceCount uint64 `json:"device_count"` // ConnectedDeviceCount: number of currently connected devices. ConnectedDeviceCount uint64 `json:"connected_device_count"` // Endpoint: devices should be connected to this host. Port may be 1883 (MQTT), 8883 (MQTT over TLS), 80 (MQTT over Websocket) or 443 (MQTT over Websocket over TLS). Endpoint string `json:"endpoint"` // DisableEvents: defines whether to disable Hub events. DisableEvents bool `json:"disable_events"` // EventsTopicPrefix: hub events topic prefix. EventsTopicPrefix string `json:"events_topic_prefix"` // Region: region of the Hub. Region scw.Region `json:"region"` // CreatedAt: hub creation date. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: hub last modification date. UpdatedAt *time.Time `json:"updated_at"` // ProjectID: project owning the resource. ProjectID string `json:"project_id"` // OrganizationID: organization owning the resource. OrganizationID string `json:"organization_id"` // EnableDeviceAutoProvisioning: when an unknown device connects to your hub using a valid certificate chain, it will be automatically provisioned inside your Hub. The Hub uses the common name of the device certifcate to find out if a device with the same name already exists. This setting can only be enabled on a hub with a custom certificate authority. EnableDeviceAutoProvisioning bool `json:"enable_device_auto_provisioning"` // HasCustomCa: flag is automatically set to `false` after Hub creation, as Hub certificates are managed by Scaleway. Once a custom certificate authority is set, the flag will be set to `true`. HasCustomCa bool `json:"has_custom_ca"` // TwinsGraphiteConfig: bETA - not implemented yet. // Precisely one of TwinsGraphiteConfig must be set. TwinsGraphiteConfig *HubTwinsGraphiteConfig `json:"twins_graphite_config,omitempty"` } // RouteSummary: route summary. type RouteSummary struct { // ID: route ID. ID string `json:"id"` // Name: route name. Name string `json:"name"` // HubID: hub ID of the route. HubID string `json:"hub_id"` // Topic: topic the route subscribes to. It must be a valid MQTT topic and up to 65535 characters. Topic string `json:"topic"` // Type: route type. // Default value: unknown Type RouteRouteType `json:"type"` // CreatedAt: date at which the route was created. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date at which the route was last updated. UpdatedAt *time.Time `json:"updated_at"` } // ListTwinDocumentsResponseDocumentSummary: list twin documents response document summary. type ListTwinDocumentsResponseDocumentSummary struct { // DocumentName: name of the document. DocumentName string `json:"document_name"` } // RouteDatabaseConfig: route database config. type RouteDatabaseConfig struct { // Engine: database engine the route will connect to. If not specified, the default database will be 'PostgreSQL'. // Default value: unknown Engine RouteDatabaseConfigEngine `json:"engine"` // Host: database host. Host string `json:"host"` // Port: database port. Port uint32 `json:"port"` // Dbname: database name. Dbname string `json:"dbname"` // Username: database username. Make sure this account can execute the provided query. Username string `json:"username"` // Password: database password. Password string `json:"password"` // Query: SQL query to be executed ($TOPIC and $PAYLOAD variables are available, see documentation). Query string `json:"query"` } // RouteRestConfig: route rest config. type RouteRestConfig struct { // Verb: HTTP verb used to call REST URI. // Default value: unknown Verb RouteRestConfigHTTPVerb `json:"verb"` // URI: URI of the REST endpoint. URI string `json:"uri"` // Headers: HTTP call extra headers. Headers map[string]string `json:"headers"` } // RouteS3Config: route s3 config. type RouteS3Config struct { // BucketRegion: region of the S3 route's destination bucket (e.g., 'fr-par'). BucketRegion string `json:"bucket_region"` // BucketName: destination bucket name of the S3 route. BucketName string `json:"bucket_name"` // ObjectPrefix: optional string to prefix object names with. ObjectPrefix string `json:"object_prefix"` // Strategy: how the S3 route's objects will be created: one per topic or one per message. // Default value: unknown Strategy RouteS3ConfigS3Strategy `json:"strategy"` } // UpdateRouteRequestDatabaseConfig: update route request database config. type UpdateRouteRequestDatabaseConfig struct { Host *string `json:"host"` Port *uint32 `json:"port"` Dbname *string `json:"dbname"` Username *string `json:"username"` Password *string `json:"password"` Query *string `json:"query"` // Engine: default value: unknown Engine RouteDatabaseConfigEngine `json:"engine"` } // UpdateRouteRequestRestConfig: update route request rest config. type UpdateRouteRequestRestConfig struct { // Verb: default value: unknown Verb RouteRestConfigHTTPVerb `json:"verb"` URI *string `json:"uri"` Headers *map[string]string `json:"headers"` } // UpdateRouteRequestS3Config: update route request s3 config. type UpdateRouteRequestS3Config struct { BucketRegion *string `json:"bucket_region"` BucketName *string `json:"bucket_name"` ObjectPrefix *string `json:"object_prefix"` // Strategy: default value: unknown Strategy RouteS3ConfigS3Strategy `json:"strategy"` } // CreateDeviceRequest: create device request. type CreateDeviceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Name: device name. Name string `json:"name"` // HubID: hub ID of the device. HubID string `json:"hub_id"` // AllowInsecure: defines whether to allow plain and server-authenticated SSL connections in addition to mutually-authenticated ones. AllowInsecure bool `json:"allow_insecure"` // AllowMultipleConnections: defines whether to allow multiple physical devices to connect with this device's credentials. AllowMultipleConnections bool `json:"allow_multiple_connections"` // MessageFilters: filter-sets to authorize or deny the device to publish/subscribe to specific topics. MessageFilters *DeviceMessageFilters `json:"message_filters,omitempty"` // Description: device description. Description *string `json:"description,omitempty"` } // CreateDeviceResponse: create device response. type CreateDeviceResponse struct { // Device: information related to the created device. Device *Device `json:"device"` // Certificate: device certificate. Certificate *Certificate `json:"certificate"` } // CreateHubRequest: create hub request. type CreateHubRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Name: hub name (up to 255 characters). Name string `json:"name"` // ProjectID: project/Organization ID to filter for, only Hubs from this Project/Organization will be returned. ProjectID string `json:"project_id"` // ProductPlan: hub product plan. // Default value: plan_unknown ProductPlan HubProductPlan `json:"product_plan"` // DisableEvents: disable Hub events. DisableEvents *bool `json:"disable_events,omitempty"` // EventsTopicPrefix: topic prefix (default '$SCW/events') of Hub events. EventsTopicPrefix *string `json:"events_topic_prefix,omitempty"` // TwinsGraphiteConfig: bETA - not implemented yet. // Precisely one of TwinsGraphiteConfig must be set. TwinsGraphiteConfig *HubTwinsGraphiteConfig `json:"twins_graphite_config,omitempty"` } // CreateNetworkRequest: create network request. type CreateNetworkRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Name: network name. Name string `json:"name"` // Type: type of network to connect with. // Default value: unknown Type NetworkNetworkType `json:"type"` // HubID: hub ID to connect the Network to. HubID string `json:"hub_id"` // TopicPrefix: topic prefix for the Network. TopicPrefix string `json:"topic_prefix"` } // CreateNetworkResponse: create network response. type CreateNetworkResponse struct { // Network: information related to the created network. Network *Network `json:"network"` // Secret: endpoint Key to keep secret. This cannot be retrieved later. Secret string `json:"secret"` } // CreateRouteRequest: create route request. type CreateRouteRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Name: route name. Name string `json:"name"` // HubID: hub ID of the route. HubID string `json:"hub_id"` // Topic: topic the route subscribes to. It must be a valid MQTT topic and up to 65535 characters. Topic string `json:"topic"` // S3Config: if creating S3 Route, S3-specific configuration fields. // Precisely one of S3Config, DbConfig, RestConfig must be set. S3Config *CreateRouteRequestS3Config `json:"s3_config,omitempty"` // DbConfig: if creating Database Route, DB-specific configuration fields. // Precisely one of S3Config, DbConfig, RestConfig must be set. DbConfig *CreateRouteRequestDatabaseConfig `json:"db_config,omitempty"` // RestConfig: if creating Rest Route, Rest-specific configuration fields. // Precisely one of S3Config, DbConfig, RestConfig must be set. RestConfig *CreateRouteRequestRestConfig `json:"rest_config,omitempty"` } // DeleteDeviceRequest: delete device request. type DeleteDeviceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DeviceID: device ID. DeviceID string `json:"-"` } // DeleteHubRequest: delete hub request. type DeleteHubRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // HubID: hub ID. HubID string `json:"-"` // DeleteDevices: defines whether to force the deletion of devices added to this Hub or reject the operation. DeleteDevices *bool `json:"delete_devices,omitempty"` } // DeleteNetworkRequest: delete network request. type DeleteNetworkRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NetworkID: network ID. NetworkID string `json:"-"` } // DeleteRouteRequest: delete route request. type DeleteRouteRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // RouteID: route ID. RouteID string `json:"-"` } // DeleteTwinDocumentRequest: delete twin document request. type DeleteTwinDocumentRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // TwinID: twin ID. TwinID string `json:"-"` // DocumentName: name of the document. DocumentName string `json:"-"` } // DeleteTwinDocumentsRequest: delete twin documents request. type DeleteTwinDocumentsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // TwinID: twin ID. TwinID string `json:"-"` } // DisableDeviceRequest: disable device request. type DisableDeviceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DeviceID: device ID. DeviceID string `json:"-"` } // DisableHubRequest: disable hub request. type DisableHubRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // HubID: hub ID. HubID string `json:"-"` } // EnableDeviceRequest: enable device request. type EnableDeviceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DeviceID: device ID. DeviceID string `json:"-"` } // EnableHubRequest: enable hub request. type EnableHubRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // HubID: hub ID. HubID string `json:"-"` } // GetDeviceCertificateRequest: get device certificate request. type GetDeviceCertificateRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DeviceID: device ID. DeviceID string `json:"-"` } // GetDeviceCertificateResponse: get device certificate response. type GetDeviceCertificateResponse struct { // Device: information related to the created device. Device *Device `json:"device"` // CertificatePem: device certificate. CertificatePem string `json:"certificate_pem"` } // GetDeviceMetricsRequest: get device metrics request. type GetDeviceMetricsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DeviceID: device ID. DeviceID string `json:"-"` // StartDate: start date used to compute the best scale for the returned metrics. StartDate *time.Time `json:"start_date,omitempty"` } // GetDeviceMetricsResponse: get device metrics response. type GetDeviceMetricsResponse struct { // Metrics: metrics for a device over the requested period. Metrics []*scw.TimeSeries `json:"metrics"` } // GetDeviceRequest: get device request. type GetDeviceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DeviceID: device ID. DeviceID string `json:"-"` } // GetHubCARequest: get hub ca request. type GetHubCARequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` HubID string `json:"-"` } // GetHubCAResponse: get hub ca response. type GetHubCAResponse struct { CaCertPem string `json:"ca_cert_pem"` } // GetHubMetricsRequest: get hub metrics request. type GetHubMetricsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // HubID: hub ID. HubID string `json:"-"` // StartDate: start date used to compute the best scale for returned metrics. StartDate *time.Time `json:"start_date,omitempty"` } // GetHubMetricsResponse: get hub metrics response. type GetHubMetricsResponse struct { // Metrics: metrics for a Hub over the requested period. Metrics []*scw.TimeSeries `json:"metrics"` } // GetHubRequest: get hub request. type GetHubRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // HubID: hub ID. HubID string `json:"-"` } // GetNetworkRequest: get network request. type GetNetworkRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NetworkID: network ID. NetworkID string `json:"-"` } // GetRouteRequest: get route request. type GetRouteRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // RouteID: route ID. RouteID string `json:"-"` } // GetTwinDocumentRequest: get twin document request. type GetTwinDocumentRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // TwinID: twin ID. TwinID string `json:"-"` // DocumentName: name of the document. DocumentName string `json:"-"` } // ListDevicesRequest: list devices request. type ListDevicesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: number of devices to return within a page. Maximum value is 100. PageSize *uint32 `json:"-"` // OrderBy: ordering of requested devices. // Default value: name_asc OrderBy ListDevicesRequestOrderBy `json:"-"` // Name: name to filter for, only devices with this name will be returned. Name *string `json:"-"` // HubID: hub ID to filter for, only devices attached to this Hub will be returned. HubID *string `json:"-"` // AllowInsecure: defines wheter to filter the allow_insecure flag. AllowInsecure *bool `json:"-"` // Status: device status (enabled, disabled, etc.). // Default value: unknown Status DeviceStatus `json:"-"` } // ListDevicesResponse: list devices response. type ListDevicesResponse struct { // TotalCount: total number of devices. TotalCount uint32 `json:"total_count"` // Devices: page of devices. Devices []*Device `json:"devices"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListDevicesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListDevicesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListDevicesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Devices = append(r.Devices, results.Devices...) r.TotalCount += uint32(len(results.Devices)) return uint32(len(results.Devices)), nil } // ListHubsRequest: list hubs request. type ListHubsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: number of Hubs to return within a page. Maximum value is 100. PageSize *uint32 `json:"-"` // OrderBy: sort order of Hubs in the response. // Default value: name_asc OrderBy ListHubsRequestOrderBy `json:"-"` // ProjectID: only list Hubs of this Project ID. ProjectID *string `json:"-"` // OrganizationID: only list Hubs of this Organization ID. OrganizationID *string `json:"-"` // Name: hub name. Name *string `json:"-"` } // ListHubsResponse: list hubs response. type ListHubsResponse struct { // TotalCount: total number of Hubs. TotalCount uint32 `json:"total_count"` // Hubs: a page of hubs. Hubs []*Hub `json:"hubs"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListHubsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListHubsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListHubsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Hubs = append(r.Hubs, results.Hubs...) r.TotalCount += uint32(len(results.Hubs)) return uint32(len(results.Hubs)), nil } // ListNetworksRequest: list networks request. type ListNetworksRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: number of networks to return. The maximum value is 100. PageSize *uint32 `json:"-"` // OrderBy: ordering of requested routes. // Default value: name_asc OrderBy ListNetworksRequestOrderBy `json:"-"` // Name: network name to filter for. Name *string `json:"-"` // HubID: hub ID to filter for. HubID *string `json:"-"` // TopicPrefix: topic prefix to filter for. TopicPrefix *string `json:"-"` } // ListNetworksResponse: list networks response. type ListNetworksResponse struct { // TotalCount: total number of Networks. TotalCount uint32 `json:"total_count"` // Networks: page of networks. Networks []*Network `json:"networks"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListNetworksResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListNetworksResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListNetworksResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Networks = append(r.Networks, results.Networks...) r.TotalCount += uint32(len(results.Networks)) return uint32(len(results.Networks)), nil } // ListRoutesRequest: list routes request. type ListRoutesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: number of routes to return within a page. Maximum value is 100. PageSize *uint32 `json:"-"` // OrderBy: ordering of requested routes. // Default value: name_asc OrderBy ListRoutesRequestOrderBy `json:"-"` // HubID: hub ID to filter for. HubID *string `json:"-"` // Name: route name to filter for. Name *string `json:"-"` } // ListRoutesResponse: list routes response. type ListRoutesResponse struct { // TotalCount: total number of routes. TotalCount uint32 `json:"total_count"` // Routes: page of routes. Routes []*RouteSummary `json:"routes"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListRoutesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListRoutesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListRoutesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Routes = append(r.Routes, results.Routes...) r.TotalCount += uint32(len(results.Routes)) return uint32(len(results.Routes)), nil } // ListTwinDocumentsRequest: list twin documents request. type ListTwinDocumentsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // TwinID: twin ID. TwinID string `json:"-"` } // ListTwinDocumentsResponse: list twin documents response. type ListTwinDocumentsResponse struct { // Documents: list of the twin document. Documents []*ListTwinDocumentsResponseDocumentSummary `json:"documents"` } // PatchTwinDocumentRequest: patch twin document request. type PatchTwinDocumentRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // TwinID: twin ID. TwinID string `json:"-"` // DocumentName: name of the document. DocumentName string `json:"-"` // Version: if set, ensures that the current version of the document matches before persisting the update. Version *uint32 `json:"version,omitempty"` // Data: a json data that will be applied on the document's current data. // Patching rules: // * The patch goes recursively through the patch objects. // * If the patch object property is null, it is removed from the final object. // * If the patch object property is a value (number, strings, bool, arrays), it is replaced. // * If the patch object property is an object, the previous rules will be applied recursively on it. Data *scw.JSONObject `json:"data,omitempty"` } // PutTwinDocumentRequest: put twin document request. type PutTwinDocumentRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // TwinID: twin ID. TwinID string `json:"-"` // DocumentName: name of the document. DocumentName string `json:"-"` // Version: if set, ensures that the current version of the document matches before persisting the update. Version *uint32 `json:"version,omitempty"` // Data: new data that will replace the contents of the document. Data *scw.JSONObject `json:"data,omitempty"` } // RenewDeviceCertificateRequest: renew device certificate request. type RenewDeviceCertificateRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DeviceID: device ID. DeviceID string `json:"-"` } // RenewDeviceCertificateResponse: renew device certificate response. type RenewDeviceCertificateResponse struct { // Device: information related to the created device. Device *Device `json:"device"` // Certificate: device certificate. Certificate *Certificate `json:"certificate"` } // Route: route. type Route struct { // ID: route ID. ID string `json:"id"` // Name: route name. Name string `json:"name"` // HubID: hub ID of the route. HubID string `json:"hub_id"` // Topic: topic the route subscribes to. It must be a valid MQTT topic and up to 65535 characters. Topic string `json:"topic"` // Type: route type. // Default value: unknown Type RouteRouteType `json:"type"` // CreatedAt: date at which the route was created. CreatedAt *time.Time `json:"created_at"` // S3Config: when using S3 Route, S3-specific configuration fields. // Precisely one of S3Config, DbConfig, RestConfig must be set. S3Config *RouteS3Config `json:"s3_config,omitempty"` // DbConfig: when using Database Route, DB-specific configuration fields. // Precisely one of S3Config, DbConfig, RestConfig must be set. DbConfig *RouteDatabaseConfig `json:"db_config,omitempty"` // RestConfig: when using Rest Route, Rest-specific configuration fields. // Precisely one of S3Config, DbConfig, RestConfig must be set. RestConfig *RouteRestConfig `json:"rest_config,omitempty"` // UpdatedAt: date at which the route was last updated. UpdatedAt *time.Time `json:"updated_at"` } // SetDeviceCertificateRequest: set device certificate request. type SetDeviceCertificateRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DeviceID: device ID. DeviceID string `json:"-"` // CertificatePem: pEM-encoded custom certificate. CertificatePem string `json:"certificate_pem"` } // SetDeviceCertificateResponse: set device certificate response. type SetDeviceCertificateResponse struct { Device *Device `json:"device"` CertificatePem string `json:"certificate_pem"` } // SetHubCARequest: set hub ca request. type SetHubCARequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // HubID: hub ID. HubID string `json:"-"` // CaCertPem: cA's PEM-encoded certificate. CaCertPem string `json:"ca_cert_pem"` // ChallengeCertPem: challenge is a PEM-encoded certificate that acts as proof of possession of the CA. It must be signed by the CA, and have a Common Name equal to the Hub ID. ChallengeCertPem string `json:"challenge_cert_pem"` } // TwinDocument: twin document. type TwinDocument struct { // TwinID: parent twin ID of the document. TwinID string `json:"twin_id"` // DocumentName: name of the document. DocumentName string `json:"document_name"` // Version: new version of the document. Version uint32 `json:"version"` // Data: new data related to the document. Data *scw.JSONObject `json:"data"` } // UpdateDeviceRequest: update device request. type UpdateDeviceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DeviceID: device ID. DeviceID string `json:"-"` // Description: description for the device. Description *string `json:"description,omitempty"` // AllowInsecure: defines whether to allow plain and server-authenticated SSL connections in addition to mutually-authenticated ones. AllowInsecure *bool `json:"allow_insecure,omitempty"` // AllowMultipleConnections: defines whether to allow multiple physical devices to connect with this device's credentials. AllowMultipleConnections *bool `json:"allow_multiple_connections,omitempty"` // MessageFilters: filter-sets to restrict the topics the device can publish/subscribe to. MessageFilters *DeviceMessageFilters `json:"message_filters,omitempty"` // HubID: change Hub for this device, additional fees may apply, see IoT Hub pricing. HubID *string `json:"hub_id,omitempty"` } // UpdateHubRequest: update hub request. type UpdateHubRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // HubID: ID of the Hub you want to update. HubID string `json:"-"` // Name: hub name (up to 255 characters). Name *string `json:"name,omitempty"` // ProductPlan: hub product plan. // Default value: plan_unknown ProductPlan HubProductPlan `json:"product_plan"` // DisableEvents: disable Hub events. DisableEvents *bool `json:"disable_events,omitempty"` // EventsTopicPrefix: topic prefix of Hub events. EventsTopicPrefix *string `json:"events_topic_prefix,omitempty"` // EnableDeviceAutoProvisioning: enable device auto provisioning. EnableDeviceAutoProvisioning *bool `json:"enable_device_auto_provisioning,omitempty"` // TwinsGraphiteConfig: bETA - not implemented yet. // Precisely one of TwinsGraphiteConfig must be set. TwinsGraphiteConfig *HubTwinsGraphiteConfig `json:"twins_graphite_config,omitempty"` } // UpdateRouteRequest: update route request. type UpdateRouteRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // RouteID: route id. RouteID string `json:"-"` // Name: route name. Name *string `json:"name,omitempty"` // Topic: topic the route subscribes to. It must be a valid MQTT topic and up to 65535 characters. Topic *string `json:"topic,omitempty"` // S3Config: when updating S3 Route, S3-specific configuration fields. // Precisely one of S3Config, DbConfig, RestConfig must be set. S3Config *UpdateRouteRequestS3Config `json:"s3_config,omitempty"` // DbConfig: when updating Database Route, DB-specific configuration fields. // Precisely one of S3Config, DbConfig, RestConfig must be set. DbConfig *UpdateRouteRequestDatabaseConfig `json:"db_config,omitempty"` // RestConfig: when updating Rest Route, Rest-specific configuration fields. // Precisely one of S3Config, DbConfig, RestConfig must be set. RestConfig *UpdateRouteRequestRestConfig `json:"rest_config,omitempty"` } // This API allows you to manage IoT hubs and devices. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Regions() []scw.Region { return []scw.Region{scw.RegionFrPar} } // ListHubs: List all Hubs in the specified zone. By default, returned Hubs are ordered by creation date in ascending order, though this can be modified via the `order_by` field. func (s *API) ListHubs(req *ListHubsRequest, opts ...scw.RequestOption) (*ListHubsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "name", req.Name) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/hubs", Query: query, } var resp ListHubsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateHub: Create a new Hub in the targeted region, specifying its configuration including name and product plan. func (s *API) CreateHub(req *CreateHubRequest, opts ...scw.RequestOption) (*Hub, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if req.Name == "" { req.Name = namegenerator.GetRandomName("hub") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/hubs", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Hub err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetHub: Retrieve information about an existing IoT Hub, specified by its Hub ID. Its full details, including name, status and endpoint, are returned in the response object. func (s *API) GetHub(req *GetHubRequest, opts ...scw.RequestOption) (*Hub, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.HubID) == "" { return nil, errors.New("field HubID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/hubs/" + fmt.Sprint(req.HubID) + "", } var resp Hub err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateHub: Update the parameters of an existing IoT Hub, specified by its Hub ID. func (s *API) UpdateHub(req *UpdateHubRequest, opts ...scw.RequestOption) (*Hub, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.HubID) == "" { return nil, errors.New("field HubID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/hubs/" + fmt.Sprint(req.HubID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Hub err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // EnableHub: Enable an existing IoT Hub, specified by its Hub ID. func (s *API) EnableHub(req *EnableHubRequest, opts ...scw.RequestOption) (*Hub, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.HubID) == "" { return nil, errors.New("field HubID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/hubs/" + fmt.Sprint(req.HubID) + "/enable", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Hub err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DisableHub: Disable an existing IoT Hub, specified by its Hub ID. func (s *API) DisableHub(req *DisableHubRequest, opts ...scw.RequestOption) (*Hub, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.HubID) == "" { return nil, errors.New("field HubID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/hubs/" + fmt.Sprint(req.HubID) + "/disable", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Hub err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteHub: Delete an existing IoT Hub, specified by its Hub ID. Deleting a Hub is permanent, and cannot be undone. func (s *API) DeleteHub(req *DeleteHubRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } query := url.Values{} parameter.AddToQuery(query, "delete_devices", req.DeleteDevices) if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.HubID) == "" { return errors.New("field HubID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/hubs/" + fmt.Sprint(req.HubID) + "", Query: query, } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // Deprecated: GetHubMetrics: Get the metrics of an existing IoT Hub, specified by its Hub ID. func (s *API) GetHubMetrics(req *GetHubMetricsRequest, opts ...scw.RequestOption) (*GetHubMetricsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } query := url.Values{} parameter.AddToQuery(query, "start_date", req.StartDate) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.HubID) == "" { return nil, errors.New("field HubID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/hubs/" + fmt.Sprint(req.HubID) + "/metrics", Query: query, } var resp GetHubMetricsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SetHubCA: Set a particular PEM-encoded certificate, specified by the Hub ID. func (s *API) SetHubCA(req *SetHubCARequest, opts ...scw.RequestOption) (*Hub, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.HubID) == "" { return nil, errors.New("field HubID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/hubs/" + fmt.Sprint(req.HubID) + "/ca", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Hub err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetHubCA: Get information for a particular PEM-encoded certificate, specified by the Hub ID. func (s *API) GetHubCA(req *GetHubCARequest, opts ...scw.RequestOption) (*GetHubCAResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.HubID) == "" { return nil, errors.New("field HubID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/hubs/" + fmt.Sprint(req.HubID) + "/ca", } var resp GetHubCAResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListDevices: List all devices in the specified region. By default, returned devices are ordered by creation date in ascending order, though this can be modified via the `order_by` field. func (s *API) ListDevices(req *ListDevicesRequest, opts ...scw.RequestOption) (*ListDevicesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "hub_id", req.HubID) parameter.AddToQuery(query, "allow_insecure", req.AllowInsecure) parameter.AddToQuery(query, "status", req.Status) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/devices", Query: query, } var resp ListDevicesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateDevice: Attach a device to a given Hub. func (s *API) CreateDevice(req *CreateDeviceRequest, opts ...scw.RequestOption) (*CreateDeviceResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.Name == "" { req.Name = namegenerator.GetRandomName("device") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/devices", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp CreateDeviceResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetDevice: Retrieve information about an existing device, specified by its device ID. Its full details, including name, status and ID, are returned in the response object. func (s *API) GetDevice(req *GetDeviceRequest, opts ...scw.RequestOption) (*Device, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DeviceID) == "" { return nil, errors.New("field DeviceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/devices/" + fmt.Sprint(req.DeviceID) + "", } var resp Device err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateDevice: Update the parameters of an existing device, specified by its device ID. func (s *API) UpdateDevice(req *UpdateDeviceRequest, opts ...scw.RequestOption) (*Device, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DeviceID) == "" { return nil, errors.New("field DeviceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/devices/" + fmt.Sprint(req.DeviceID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Device err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // EnableDevice: Enable a specific device, specified by its device ID. func (s *API) EnableDevice(req *EnableDeviceRequest, opts ...scw.RequestOption) (*Device, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DeviceID) == "" { return nil, errors.New("field DeviceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/devices/" + fmt.Sprint(req.DeviceID) + "/enable", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Device err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DisableDevice: Disable an existing device, specified by its device ID. func (s *API) DisableDevice(req *DisableDeviceRequest, opts ...scw.RequestOption) (*Device, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DeviceID) == "" { return nil, errors.New("field DeviceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/devices/" + fmt.Sprint(req.DeviceID) + "/disable", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Device err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // RenewDeviceCertificate: Renew the certificate of an existing device, specified by its device ID. func (s *API) RenewDeviceCertificate(req *RenewDeviceCertificateRequest, opts ...scw.RequestOption) (*RenewDeviceCertificateResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DeviceID) == "" { return nil, errors.New("field DeviceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/devices/" + fmt.Sprint(req.DeviceID) + "/renew-certificate", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp RenewDeviceCertificateResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SetDeviceCertificate: Switch the existing certificate of a given device with an EM-encoded custom certificate. func (s *API) SetDeviceCertificate(req *SetDeviceCertificateRequest, opts ...scw.RequestOption) (*SetDeviceCertificateResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DeviceID) == "" { return nil, errors.New("field DeviceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/devices/" + fmt.Sprint(req.DeviceID) + "/certificate", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SetDeviceCertificateResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetDeviceCertificate: Get information for a particular PEM-encoded certificate, specified by the device ID. The response returns full details of the device, including its type of certificate. func (s *API) GetDeviceCertificate(req *GetDeviceCertificateRequest, opts ...scw.RequestOption) (*GetDeviceCertificateResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DeviceID) == "" { return nil, errors.New("field DeviceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/devices/" + fmt.Sprint(req.DeviceID) + "/certificate", } var resp GetDeviceCertificateResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteDevice: Remove a specific device from the specific Hub it is attached to. func (s *API) DeleteDevice(req *DeleteDeviceRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DeviceID) == "" { return errors.New("field DeviceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/devices/" + fmt.Sprint(req.DeviceID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // Deprecated: GetDeviceMetrics: Get the metrics of an existing device, specified by its device ID. func (s *API) GetDeviceMetrics(req *GetDeviceMetricsRequest, opts ...scw.RequestOption) (*GetDeviceMetricsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } query := url.Values{} parameter.AddToQuery(query, "start_date", req.StartDate) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DeviceID) == "" { return nil, errors.New("field DeviceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/devices/" + fmt.Sprint(req.DeviceID) + "/metrics", Query: query, } var resp GetDeviceMetricsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListRoutes: List all routes in the specified region. By default, returned routes are ordered by creation date in ascending order, though this can be modified via the `order_by` field. func (s *API) ListRoutes(req *ListRoutesRequest, opts ...scw.RequestOption) (*ListRoutesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "hub_id", req.HubID) parameter.AddToQuery(query, "name", req.Name) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/routes", Query: query, } var resp ListRoutesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateRoute: Multiple kinds of routes can be created, such as: // - Database Route // Create a route that will record subscribed MQTT messages into your database. // You need to manage the database by yourself. // - REST Route. // Create a route that will call a REST API on received subscribed MQTT messages. // - S3 Routes. // Create a route that will put subscribed MQTT messages into an S3 bucket. // You need to create the bucket yourself and grant write access. // Granting can be done with s3cmd (`s3cmd setacl s3:// --acl-grant=write:555c69c3-87d0-4bf8-80f1-99a2f757d031:555c69c3-87d0-4bf8-80f1-99a2f757d031`). func (s *API) CreateRoute(req *CreateRouteRequest, opts ...scw.RequestOption) (*Route, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.Name == "" { req.Name = namegenerator.GetRandomName("route") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/routes", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Route err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateRoute: Update the parameters of an existing route, specified by its route ID. func (s *API) UpdateRoute(req *UpdateRouteRequest, opts ...scw.RequestOption) (*Route, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.RouteID) == "" { return nil, errors.New("field RouteID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/routes/" + fmt.Sprint(req.RouteID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Route err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetRoute: Get information for a particular route, specified by the route ID. The response returns full details of the route, including its type, the topic it subscribes to and its configuration. func (s *API) GetRoute(req *GetRouteRequest, opts ...scw.RequestOption) (*Route, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.RouteID) == "" { return nil, errors.New("field RouteID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/routes/" + fmt.Sprint(req.RouteID) + "", } var resp Route err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteRoute: Delete an existing route, specified by its route ID. Deleting a route is permanent, and cannot be undone. func (s *API) DeleteRoute(req *DeleteRouteRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.RouteID) == "" { return errors.New("field RouteID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/routes/" + fmt.Sprint(req.RouteID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListNetworks: List the networks. func (s *API) ListNetworks(req *ListNetworksRequest, opts ...scw.RequestOption) (*ListNetworksResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "hub_id", req.HubID) parameter.AddToQuery(query, "topic_prefix", req.TopicPrefix) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/networks", Query: query, } var resp ListNetworksResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateNetwork: Create a new network for an existing hub. Beside the default network, you can add networks for different data providers. Possible network types are Sigfox and REST. func (s *API) CreateNetwork(req *CreateNetworkRequest, opts ...scw.RequestOption) (*CreateNetworkResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.Name == "" { req.Name = namegenerator.GetRandomName("network") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/networks", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp CreateNetworkResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetNetwork: Retrieve an existing network, specified by its network ID. The response returns full details of the network, including its type, the topic prefix and its endpoint. func (s *API) GetNetwork(req *GetNetworkRequest, opts ...scw.RequestOption) (*Network, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NetworkID) == "" { return nil, errors.New("field NetworkID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/networks/" + fmt.Sprint(req.NetworkID) + "", } var resp Network err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteNetwork: Delete an existing network, specified by its network ID. Deleting a network is permanent, and cannot be undone. func (s *API) DeleteNetwork(req *DeleteNetworkRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NetworkID) == "" { return errors.New("field NetworkID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/networks/" + fmt.Sprint(req.NetworkID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // GetTwinDocument: BETA - Get a Cloud Twin Document. func (s *API) GetTwinDocument(req *GetTwinDocumentRequest, opts ...scw.RequestOption) (*TwinDocument, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.TwinID) == "" { return nil, errors.New("field TwinID cannot be empty in request") } if fmt.Sprint(req.DocumentName) == "" { return nil, errors.New("field DocumentName cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/twins/" + fmt.Sprint(req.TwinID) + "/documents/" + fmt.Sprint(req.DocumentName) + "", } var resp TwinDocument err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // PutTwinDocument: BETA - Update a Cloud Twin Document. func (s *API) PutTwinDocument(req *PutTwinDocumentRequest, opts ...scw.RequestOption) (*TwinDocument, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.TwinID) == "" { return nil, errors.New("field TwinID cannot be empty in request") } if fmt.Sprint(req.DocumentName) == "" { return nil, errors.New("field DocumentName cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/twins/" + fmt.Sprint(req.TwinID) + "/documents/" + fmt.Sprint(req.DocumentName) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp TwinDocument err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // PatchTwinDocument: BETA - Patch a Cloud Twin Document. func (s *API) PatchTwinDocument(req *PatchTwinDocumentRequest, opts ...scw.RequestOption) (*TwinDocument, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.TwinID) == "" { return nil, errors.New("field TwinID cannot be empty in request") } if fmt.Sprint(req.DocumentName) == "" { return nil, errors.New("field DocumentName cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/twins/" + fmt.Sprint(req.TwinID) + "/documents/" + fmt.Sprint(req.DocumentName) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp TwinDocument err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteTwinDocument: BETA - Delete a Cloud Twin Document. func (s *API) DeleteTwinDocument(req *DeleteTwinDocumentRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.TwinID) == "" { return errors.New("field TwinID cannot be empty in request") } if fmt.Sprint(req.DocumentName) == "" { return errors.New("field DocumentName cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/twins/" + fmt.Sprint(req.TwinID) + "/documents/" + fmt.Sprint(req.DocumentName) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListTwinDocuments: BETA - List the documents of a Cloud Twin. func (s *API) ListTwinDocuments(req *ListTwinDocumentsRequest, opts ...scw.RequestOption) (*ListTwinDocumentsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.TwinID) == "" { return nil, errors.New("field TwinID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/twins/" + fmt.Sprint(req.TwinID) + "", } var resp ListTwinDocumentsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteTwinDocuments: BETA - Delete all the documents of a Cloud Twin. func (s *API) DeleteTwinDocuments(req *DeleteTwinDocumentsRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.TwinID) == "" { return errors.New("field TwinID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/iot/v1/regions/" + fmt.Sprint(req.Region) + "/twins/" + fmt.Sprint(req.TwinID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/ipam/000077500000000000000000000000001456366605600237555ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/ipam/v1/000077500000000000000000000000001456366605600243035ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/ipam/v1/ipam_sdk.go000066400000000000000000000362351456366605600264320ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package ipam provides methods and message types of the ipam v1 API. package ipam import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type ListIPsRequestOrderBy string const ( ListIPsRequestOrderByCreatedAtDesc = ListIPsRequestOrderBy("created_at_desc") ListIPsRequestOrderByCreatedAtAsc = ListIPsRequestOrderBy("created_at_asc") ListIPsRequestOrderByUpdatedAtDesc = ListIPsRequestOrderBy("updated_at_desc") ListIPsRequestOrderByUpdatedAtAsc = ListIPsRequestOrderBy("updated_at_asc") ListIPsRequestOrderByAttachedAtDesc = ListIPsRequestOrderBy("attached_at_desc") ListIPsRequestOrderByAttachedAtAsc = ListIPsRequestOrderBy("attached_at_asc") ) func (enum ListIPsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_desc" } return string(enum) } func (enum ListIPsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListIPsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListIPsRequestOrderBy(ListIPsRequestOrderBy(tmp).String()) return nil } type ResourceType string const ( ResourceTypeUnknownType = ResourceType("unknown_type") ResourceTypeInstanceServer = ResourceType("instance_server") ResourceTypeInstanceIP = ResourceType("instance_ip") ResourceTypeInstancePrivateNic = ResourceType("instance_private_nic") ResourceTypeLBServer = ResourceType("lb_server") ResourceTypeFipIP = ResourceType("fip_ip") ResourceTypeVpcGateway = ResourceType("vpc_gateway") ResourceTypeVpcGatewayNetwork = ResourceType("vpc_gateway_network") ResourceTypeK8sNode = ResourceType("k8s_node") ResourceTypeK8sCluster = ResourceType("k8s_cluster") ResourceTypeRdbInstance = ResourceType("rdb_instance") ResourceTypeRedisCluster = ResourceType("redis_cluster") ResourceTypeBaremetalServer = ResourceType("baremetal_server") ResourceTypeBaremetalPrivateNic = ResourceType("baremetal_private_nic") ResourceTypeLlmDeployment = ResourceType("llm_deployment") ) func (enum ResourceType) String() string { if enum == "" { // return default value if empty return "unknown_type" } return string(enum) } func (enum ResourceType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ResourceType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ResourceType(ResourceType(tmp).String()) return nil } // Resource: resource. type Resource struct { // Type: type of resource the IP is attached to. // Default value: unknown_type Type ResourceType `json:"type"` // ID: ID of the resource the IP is attached to. ID string `json:"id"` // MacAddress: mAC of the resource the IP is attached to. MacAddress *string `json:"mac_address"` // Name: when the IP is in a Private Network, then a DNS record is available to resolve the resource name to this IP. Name *string `json:"name"` } // Reverse: reverse. type Reverse struct { // Hostname: reverse domain name. Hostname string `json:"hostname"` // Address: IP corresponding to the hostname. Address *net.IP `json:"address"` } // Source: source. type Source struct { // Zonal: this source is global. // Precisely one of Zonal, PrivateNetworkID, SubnetID must be set. Zonal *string `json:"zonal,omitempty"` // PrivateNetworkID: this source is specific. // Precisely one of Zonal, PrivateNetworkID, SubnetID must be set. PrivateNetworkID *string `json:"private_network_id,omitempty"` // SubnetID: this source is specific. // Precisely one of Zonal, PrivateNetworkID, SubnetID must be set. SubnetID *string `json:"subnet_id,omitempty"` } // IP: ip. type IP struct { // ID: IP ID. ID string `json:"id"` // Address: iPv4 or IPv6 address in CIDR notation. Address scw.IPNet `json:"address"` // ProjectID: scaleway Project the IP belongs to. ProjectID string `json:"project_id"` // IsIPv6: defines whether the IP is an IPv6 (false = IPv4). IsIPv6 bool `json:"is_ipv6"` // CreatedAt: date the IP was booked. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date the IP was last modified. UpdatedAt *time.Time `json:"updated_at"` // Source: source pool where the IP was booked in. Source *Source `json:"source"` // Resource: resource which the IP is attached to. Resource *Resource `json:"resource"` // Tags: tags for the IP. Tags []string `json:"tags"` // Reverses: array of reverses associated with the IP. Reverses []*Reverse `json:"reverses"` // Region: region of the IP. Region scw.Region `json:"region"` // Zone: zone of the IP, if zonal. Zone *scw.Zone `json:"zone"` } // BookIPRequest: book ip request. type BookIPRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: when creating an IP in a Private Network, the Project must match the Private Network's Project. ProjectID string `json:"project_id"` // Source: source in which to book the IP. Not all sources are available for booking. Source *Source `json:"source"` // IsIPv6: request an IPv6 instead of an IPv4. IsIPv6 bool `json:"is_ipv6"` // Address: note that only the Private Network source allows you to pick a specific IP. If the requested IP is already booked, then the call will fail. Address *net.IP `json:"address,omitempty"` // Tags: tags for the IP. Tags []string `json:"tags"` } // GetIPRequest: get ip request. type GetIPRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // IPID: IP ID. IPID string `json:"-"` } // ListIPsRequest: list i ps request. type ListIPsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // OrderBy: sort order of the returned IPs. // Default value: created_at_desc OrderBy ListIPsRequestOrderBy `json:"-"` // Page: page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: maximum number of IPs to return per page. PageSize *uint32 `json:"-"` // ProjectID: project ID to filter for. Only IPs belonging to this Project will be returned. ProjectID *string `json:"-"` // Zonal: zone to filter for. Only IPs that are zonal, and in this zone, will be returned. // Precisely one of Zonal, PrivateNetworkID must be set. Zonal *string `json:"zonal,omitempty"` // PrivateNetworkID: only IPs that are private, and in this Private Network, will be returned. // Precisely one of Zonal, PrivateNetworkID must be set. PrivateNetworkID *string `json:"private_network_id,omitempty"` // Attached: defines whether to filter only for IPs which are attached to a resource. Attached *bool `json:"-"` // ResourceID: resource ID to filter for. Only IPs attached to this resource will be returned. ResourceID *string `json:"-"` // ResourceType: resource type to filter for. Only IPs attached to this type of resource will be returned. // Default value: unknown_type ResourceType ResourceType `json:"-"` // MacAddress: mAC address to filter for. Only IPs attached to a resource with this MAC address will be returned. MacAddress *string `json:"-"` // Tags: tags to filter for, only IPs with one or more matching tags will be returned. Tags []string `json:"-"` // OrganizationID: organization ID to filter for. Only IPs belonging to this Organization will be returned. OrganizationID *string `json:"-"` // IsIPv6: defines whether to filter only for IPv4s or IPv6s. IsIPv6 *bool `json:"-"` // ResourceName: attached resource name to filter for, only IPs attached to a resource with this string within their name will be returned. ResourceName *string `json:"-"` } // ListIPsResponse: list i ps response. type ListIPsResponse struct { TotalCount uint64 `json:"total_count"` IPs []*IP `json:"ips"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListIPsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListIPsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListIPsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.IPs = append(r.IPs, results.IPs...) r.TotalCount += uint64(len(results.IPs)) return uint64(len(results.IPs)), nil } // ReleaseIPRequest: release ip request. type ReleaseIPRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // IPID: IP ID. IPID string `json:"-"` } // UpdateIPRequest: update ip request. type UpdateIPRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // IPID: IP ID. IPID string `json:"-"` // Tags: tags for the IP. Tags *[]string `json:"tags,omitempty"` // Reverses: array of reverse domain names associated with an IP in the subnet of the current IP. Reverses []*Reverse `json:"reverses"` } // This API allows you to manage IP addresses with Scaleway's IP Address Management tool. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Regions() []scw.Region { return []scw.Region{scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw} } // BookIP: Book a new IP from the specified source. Currently IPs can only be booked from a Private Network. func (s *API) BookIP(req *BookIPRequest, opts ...scw.RequestOption) (*IP, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/ipam/v1/regions/" + fmt.Sprint(req.Region) + "/ips", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp IP err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ReleaseIP: Release an IP not currently attached to a resource, and returns it to the available IP pool. func (s *API) ReleaseIP(req *ReleaseIPRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.IPID) == "" { return errors.New("field IPID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/ipam/v1/regions/" + fmt.Sprint(req.Region) + "/ips/" + fmt.Sprint(req.IPID) + "", } err = scwReq.SetBody(req) if err != nil { return err } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // GetIP: Retrieve details of an existing IP, specified by its IP ID. func (s *API) GetIP(req *GetIPRequest, opts ...scw.RequestOption) (*IP, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.IPID) == "" { return nil, errors.New("field IPID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/ipam/v1/regions/" + fmt.Sprint(req.Region) + "/ips/" + fmt.Sprint(req.IPID) + "", } var resp IP err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateIP: Update parameters including tags of the specified IP. func (s *API) UpdateIP(req *UpdateIPRequest, opts ...scw.RequestOption) (*IP, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.IPID) == "" { return nil, errors.New("field IPID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/ipam/v1/regions/" + fmt.Sprint(req.Region) + "/ips/" + fmt.Sprint(req.IPID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp IP err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListIPs: List existing IPs in the specified region using various filters. For example, you can filter for IPs within a specified Private Network, or for public IPs within a specified Project. By default, the IPs returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. func (s *API) ListIPs(req *ListIPsRequest, opts ...scw.RequestOption) (*ListIPsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "attached", req.Attached) parameter.AddToQuery(query, "resource_id", req.ResourceID) parameter.AddToQuery(query, "resource_type", req.ResourceType) parameter.AddToQuery(query, "mac_address", req.MacAddress) parameter.AddToQuery(query, "tags", req.Tags) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "is_ipv6", req.IsIPv6) parameter.AddToQuery(query, "resource_name", req.ResourceName) parameter.AddToQuery(query, "zonal", req.Zonal) parameter.AddToQuery(query, "private_network_id", req.PrivateNetworkID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/ipam/v1/regions/" + fmt.Sprint(req.Region) + "/ips", Query: query, } var resp ListIPsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/ipam/v1alpha1/000077500000000000000000000000001456366605600253725ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/ipam/v1alpha1/ipam_sdk.go000066400000000000000000000213571456366605600275200ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package ipam provides methods and message types of the ipam v1alpha1 API. package ipam import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type ListIPsRequestOrderBy string const ( ListIPsRequestOrderByCreatedAtDesc = ListIPsRequestOrderBy("created_at_desc") ListIPsRequestOrderByCreatedAtAsc = ListIPsRequestOrderBy("created_at_asc") ListIPsRequestOrderByUpdatedAtDesc = ListIPsRequestOrderBy("updated_at_desc") ListIPsRequestOrderByUpdatedAtAsc = ListIPsRequestOrderBy("updated_at_asc") ListIPsRequestOrderByAttachedAtDesc = ListIPsRequestOrderBy("attached_at_desc") ListIPsRequestOrderByAttachedAtAsc = ListIPsRequestOrderBy("attached_at_asc") ) func (enum ListIPsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_desc" } return string(enum) } func (enum ListIPsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListIPsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListIPsRequestOrderBy(ListIPsRequestOrderBy(tmp).String()) return nil } type ResourceType string const ( ResourceTypeUnknownType = ResourceType("unknown_type") ResourceTypeInstanceServer = ResourceType("instance_server") ResourceTypeInstanceIP = ResourceType("instance_ip") ResourceTypeInstancePrivateNic = ResourceType("instance_private_nic") ResourceTypeLBServer = ResourceType("lb_server") ResourceTypeFipIP = ResourceType("fip_ip") ResourceTypeVpcGateway = ResourceType("vpc_gateway") ResourceTypeVpcGatewayNetwork = ResourceType("vpc_gateway_network") ResourceTypeK8sNode = ResourceType("k8s_node") ResourceTypeK8sCluster = ResourceType("k8s_cluster") ResourceTypeRdbInstance = ResourceType("rdb_instance") ResourceTypeRedisCluster = ResourceType("redis_cluster") ResourceTypeBaremetalServer = ResourceType("baremetal_server") ResourceTypeBaremetalPrivateNic = ResourceType("baremetal_private_nic") ResourceTypeLlmDeployment = ResourceType("llm_deployment") ) func (enum ResourceType) String() string { if enum == "" { // return default value if empty return "unknown_type" } return string(enum) } func (enum ResourceType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ResourceType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ResourceType(ResourceType(tmp).String()) return nil } // Resource: resource. type Resource struct { // Type: default value: unknown_type Type ResourceType `json:"type"` ID string `json:"id"` MacAddress *string `json:"mac_address"` Name *string `json:"name"` } // Reverse: reverse. type Reverse struct { Hostname string `json:"hostname"` Address *net.IP `json:"address"` } // IP: ip. type IP struct { ID string `json:"id"` Address scw.IPNet `json:"address"` ProjectID string `json:"project_id"` IsIPv6 bool `json:"is_ipv6"` CreatedAt *time.Time `json:"created_at"` UpdatedAt *time.Time `json:"updated_at"` // Precisely one of Regional, Zonal, ZonalNat, SubnetID must be set. Regional *bool `json:"regional,omitempty"` // Precisely one of Regional, Zonal, ZonalNat, SubnetID must be set. Zonal *string `json:"zonal,omitempty"` // Precisely one of Regional, Zonal, ZonalNat, SubnetID must be set. ZonalNat *string `json:"zonal_nat,omitempty"` // Precisely one of Regional, Zonal, ZonalNat, SubnetID must be set. SubnetID *string `json:"subnet_id,omitempty"` Resource *Resource `json:"resource"` Tags []string `json:"tags"` Reverses []*Reverse `json:"reverses"` // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"region"` // Zone: zone to target. If none is passed will use default zone from the config. Zone *scw.Zone `json:"zone"` } // ListIPsRequest: list i ps request. type ListIPsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` // OrderBy: default value: created_at_desc OrderBy ListIPsRequestOrderBy `json:"-"` ProjectID *string `json:"-"` OrganizationID *string `json:"-"` // Precisely one of Zonal, ZonalNat, Regional, PrivateNetworkID, SubnetID must be set. Zonal *string `json:"zonal,omitempty"` // Precisely one of Zonal, ZonalNat, Regional, PrivateNetworkID, SubnetID must be set. ZonalNat *string `json:"zonal_nat,omitempty"` // Precisely one of Zonal, ZonalNat, Regional, PrivateNetworkID, SubnetID must be set. Regional *bool `json:"regional,omitempty"` // Precisely one of Zonal, ZonalNat, Regional, PrivateNetworkID, SubnetID must be set. PrivateNetworkID *string `json:"private_network_id,omitempty"` // Precisely one of Zonal, ZonalNat, Regional, PrivateNetworkID, SubnetID must be set. SubnetID *string `json:"subnet_id,omitempty"` Attached *bool `json:"-"` ResourceID *string `json:"-"` // ResourceType: default value: unknown_type ResourceType ResourceType `json:"-"` MacAddress *string `json:"-"` Tags *[]string `json:"-"` IsIPv6 *bool `json:"-"` ResourceName *string `json:"-"` ResourceIDs []string `json:"-"` } // ListIPsResponse: list i ps response. type ListIPsResponse struct { TotalCount uint64 `json:"total_count"` IPs []*IP `json:"ips"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListIPsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListIPsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListIPsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.IPs = append(r.IPs, results.IPs...) r.TotalCount += uint64(len(results.IPs)) return uint64(len(results.IPs)), nil } // IPAM API. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Regions() []scw.Region { return []scw.Region{scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw} } // ListIPs: Find IP addresses. func (s *API) ListIPs(req *ListIPsRequest, opts ...scw.RequestOption) (*ListIPsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "attached", req.Attached) parameter.AddToQuery(query, "resource_id", req.ResourceID) parameter.AddToQuery(query, "resource_type", req.ResourceType) parameter.AddToQuery(query, "mac_address", req.MacAddress) parameter.AddToQuery(query, "tags", req.Tags) parameter.AddToQuery(query, "is_ipv6", req.IsIPv6) parameter.AddToQuery(query, "resource_name", req.ResourceName) parameter.AddToQuery(query, "resource_ids", req.ResourceIDs) parameter.AddToQuery(query, "zonal", req.Zonal) parameter.AddToQuery(query, "zonal_nat", req.ZonalNat) parameter.AddToQuery(query, "regional", req.Regional) parameter.AddToQuery(query, "private_network_id", req.PrivateNetworkID) parameter.AddToQuery(query, "subnet_id", req.SubnetID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/ipam/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/ips", Query: query, } var resp ListIPsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/ipfs/000077500000000000000000000000001456366605600237705ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/ipfs/v1alpha1/000077500000000000000000000000001456366605600254055ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/ipfs/v1alpha1/ipfs_sdk.go000066400000000000000000001103471456366605600275440ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package ipfs provides methods and message types of the ipfs v1alpha1 API. package ipfs import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type ListNamesRequestOrderBy string const ( ListNamesRequestOrderByCreatedAtAsc = ListNamesRequestOrderBy("created_at_asc") ListNamesRequestOrderByCreatedAtDesc = ListNamesRequestOrderBy("created_at_desc") ) func (enum ListNamesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListNamesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListNamesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListNamesRequestOrderBy(ListNamesRequestOrderBy(tmp).String()) return nil } type ListPinsRequestOrderBy string const ( ListPinsRequestOrderByCreatedAtAsc = ListPinsRequestOrderBy("created_at_asc") ListPinsRequestOrderByCreatedAtDesc = ListPinsRequestOrderBy("created_at_desc") ) func (enum ListPinsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListPinsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListPinsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListPinsRequestOrderBy(ListPinsRequestOrderBy(tmp).String()) return nil } type ListVolumesRequestOrderBy string const ( ListVolumesRequestOrderByCreatedAtAsc = ListVolumesRequestOrderBy("created_at_asc") ListVolumesRequestOrderByCreatedAtDesc = ListVolumesRequestOrderBy("created_at_desc") ) func (enum ListVolumesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListVolumesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListVolumesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListVolumesRequestOrderBy(ListVolumesRequestOrderBy(tmp).String()) return nil } type NameStatus string const ( NameStatusUnknownStatus = NameStatus("unknown_status") NameStatusQueued = NameStatus("queued") NameStatusPublishing = NameStatus("publishing") NameStatusFailed = NameStatus("failed") NameStatusPublished = NameStatus("published") ) func (enum NameStatus) String() string { if enum == "" { // return default value if empty return "unknown_status" } return string(enum) } func (enum NameStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *NameStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = NameStatus(NameStatus(tmp).String()) return nil } type PinDetails string const ( PinDetailsUnknownDetails = PinDetails("unknown_details") PinDetailsPinningLookingForProvider = PinDetails("pinning_looking_for_provider") PinDetailsPinningInProgress = PinDetails("pinning_in_progress") PinDetailsPinningBlocksFetched = PinDetails("pinning_blocks_fetched") PinDetailsPinningFetchingURLData = PinDetails("pinning_fetching_url_data") PinDetailsPinnedOk = PinDetails("pinned_ok") PinDetailsUnpinnedOk = PinDetails("unpinned_ok") PinDetailsUnpinningInProgress = PinDetails("unpinning_in_progress") PinDetailsFailedContainsBannedCid = PinDetails("failed_contains_banned_cid") PinDetailsFailedPinning = PinDetails("failed_pinning") PinDetailsFailedPinningNoProvider = PinDetails("failed_pinning_no_provider") PinDetailsFailedPinningBadCidFormat = PinDetails("failed_pinning_bad_cid_format") PinDetailsFailedPinningTimeout = PinDetails("failed_pinning_timeout") PinDetailsFailedPinningTooBigContent = PinDetails("failed_pinning_too_big_content") PinDetailsFailedPinningUnreachableURL = PinDetails("failed_pinning_unreachable_url") PinDetailsFailedPinningBadURLFormat = PinDetails("failed_pinning_bad_url_format") PinDetailsFailedPinningNoURLContentLength = PinDetails("failed_pinning_no_url_content_length") PinDetailsFailedPinningBadURLStatusCode = PinDetails("failed_pinning_bad_url_status_code") PinDetailsFailedUnpinning = PinDetails("failed_unpinning") PinDetailsCheckingCoherence = PinDetails("checking_coherence") PinDetailsRescheduled = PinDetails("rescheduled") ) func (enum PinDetails) String() string { if enum == "" { // return default value if empty return "unknown_details" } return string(enum) } func (enum PinDetails) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *PinDetails) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = PinDetails(PinDetails(tmp).String()) return nil } type PinStatus string const ( PinStatusUnknownStatus = PinStatus("unknown_status") PinStatusQueued = PinStatus("queued") PinStatusPinning = PinStatus("pinning") PinStatusFailed = PinStatus("failed") PinStatusPinned = PinStatus("pinned") ) func (enum PinStatus) String() string { if enum == "" { // return default value if empty return "unknown_status" } return string(enum) } func (enum PinStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *PinStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = PinStatus(PinStatus(tmp).String()) return nil } // PinCIDMeta: pin cid meta. type PinCIDMeta struct { ID *string `json:"id"` } // PinCID: pin cid. type PinCID struct { Cid *string `json:"cid"` Name *string `json:"name"` Origins []string `json:"origins"` Meta *PinCIDMeta `json:"meta"` } // PinInfo: pin info. type PinInfo struct { ID *string `json:"id"` URL *string `json:"url"` Size *uint64 `json:"size"` Progress *uint32 `json:"progress"` // StatusDetails: default value: unknown_details StatusDetails PinDetails `json:"status_details"` } // Name: name. type Name struct { NameID string `json:"name_id"` ProjectID string `json:"project_id"` CreatedAt *time.Time `json:"created_at"` UpdatedAt *time.Time `json:"updated_at"` Tags []string `json:"tags"` Name string `json:"name"` Key string `json:"key"` // Status: default value: unknown_status Status NameStatus `json:"status"` Value string `json:"value"` // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"region"` } // Pin: pin. type Pin struct { PinID string `json:"pin_id"` // Status: default value: unknown_status Status PinStatus `json:"status"` CreatedAt *time.Time `json:"created_at"` Cid *PinCID `json:"cid"` Delegates []string `json:"delegates"` Info *PinInfo `json:"info"` } // Volume: volume. type Volume struct { ID string `json:"id"` ProjectID string `json:"project_id"` // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"region"` CountPin uint64 `json:"count_pin"` CreatedAt *time.Time `json:"created_at"` UpdatedAt *time.Time `json:"updated_at"` Tags []string `json:"tags"` Name string `json:"name"` Size *uint64 `json:"size"` } // CreatePinByCIDRequest: create pin by cid request. type CreatePinByCIDRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // VolumeID: volume ID on which you want to pin your content. VolumeID string `json:"volume_id"` // Cid: cID containing the content you want to pin. Cid string `json:"cid"` // Origins: node containing the content you want to pin. Origins []string `json:"origins"` // Name: pin name. Name *string `json:"name,omitempty"` } // CreatePinByURLRequest: create pin by url request. type CreatePinByURLRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // VolumeID: volume ID on which you want to pin your content. VolumeID string `json:"volume_id"` // URL: URL containing the content you want to pin. URL string `json:"url"` // Name: pin name. Name *string `json:"name,omitempty"` } // CreateVolumeRequest: create volume request. type CreateVolumeRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: project ID. ProjectID string `json:"project_id"` // Name: volume name. Name string `json:"name"` } // DeletePinRequest: delete pin request. type DeletePinRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // PinID: pin ID you want to remove from the volume. PinID string `json:"-"` // VolumeID: volume ID. VolumeID string `json:"volume_id"` } // DeleteVolumeRequest: delete volume request. type DeleteVolumeRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // VolumeID: volume ID. VolumeID string `json:"-"` } // ExportKeyNameResponse: export key name response. type ExportKeyNameResponse struct { NameID string `json:"name_id"` ProjectID string `json:"project_id"` CreatedAt *time.Time `json:"created_at"` UpdatedAt *time.Time `json:"updated_at"` PublicKey string `json:"public_key"` PrivateKey string `json:"private_key"` } // GetPinRequest: get pin request. type GetPinRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // PinID: pin ID of which you want to obtain information. PinID string `json:"-"` // VolumeID: volume ID. VolumeID string `json:"volume_id"` } // GetVolumeRequest: get volume request. type GetVolumeRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // VolumeID: volume ID. VolumeID string `json:"-"` } // IpnsAPICreateNameRequest: ipns api create name request. type IpnsAPICreateNameRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: project ID. ProjectID string `json:"project_id"` // Name: name for your records. Name string `json:"name"` // Value: value you want to associate with your records, CID or IPNS key. Value string `json:"value"` } // IpnsAPIDeleteNameRequest: ipns api delete name request. type IpnsAPIDeleteNameRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NameID: name ID you wish to delete. NameID string `json:"-"` } // IpnsAPIExportKeyNameRequest: ipns api export key name request. type IpnsAPIExportKeyNameRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NameID: name ID whose keys you want to export. NameID string `json:"-"` } // IpnsAPIGetNameRequest: ipns api get name request. type IpnsAPIGetNameRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NameID: name ID whose information you want to retrieve. NameID string `json:"-"` } // IpnsAPIImportKeyNameRequest: ipns api import key name request. type IpnsAPIImportKeyNameRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: project ID. ProjectID string `json:"project_id"` // Name: name for your records. Name string `json:"name"` // PrivateKey: base64 private key. PrivateKey string `json:"private_key"` // Value: value you want to associate with your records, CID or IPNS key. Value string `json:"value"` } // IpnsAPIListNamesRequest: ipns api list names request. type IpnsAPIListNamesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: project ID. ProjectID *string `json:"-"` // OrganizationID: organization ID. OrganizationID *string `json:"-"` // OrderBy: sort the order of the returned names. // Default value: created_at_asc OrderBy ListNamesRequestOrderBy `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: maximum number of names to return per page. PageSize *uint32 `json:"-"` } // IpnsAPIUpdateNameRequest: ipns api update name request. type IpnsAPIUpdateNameRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NameID: name ID you wish to update. NameID string `json:"-"` // Name: new name you want to associate with your record. Name *string `json:"name,omitempty"` // Tags: new tags you want to associate with your record. Tags *[]string `json:"tags,omitempty"` // Value: value you want to associate with your records, CID or IPNS key. Value *string `json:"value,omitempty"` } // ListNamesResponse: list names response. type ListNamesResponse struct { Names []*Name `json:"names"` TotalCount uint64 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListNamesResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListNamesResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListNamesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Names = append(r.Names, results.Names...) r.TotalCount += uint64(len(results.Names)) return uint64(len(results.Names)), nil } // ListPinsRequest: list pins request. type ListPinsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // VolumeID: volume ID of which you want to list the pins. VolumeID string `json:"-"` // ProjectID: project ID. ProjectID *string `json:"-"` // OrganizationID: organization ID. OrganizationID *string `json:"-"` // OrderBy: sort order of the returned Volume. // Default value: created_at_asc OrderBy ListPinsRequestOrderBy `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: maximum number of volumes to return per page. PageSize *uint32 `json:"-"` // Status: list pins by status. // Default value: unknown_status Status PinStatus `json:"-"` } // ListPinsResponse: list pins response. type ListPinsResponse struct { TotalCount uint64 `json:"total_count"` Pins []*Pin `json:"pins"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListPinsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListPinsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListPinsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Pins = append(r.Pins, results.Pins...) r.TotalCount += uint64(len(results.Pins)) return uint64(len(results.Pins)), nil } // ListVolumesRequest: list volumes request. type ListVolumesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: project ID, only volumes belonging to this project will be listed. ProjectID string `json:"-"` // OrderBy: sort the order of the returned volumes. // Default value: created_at_asc OrderBy ListVolumesRequestOrderBy `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: maximum number of volumes to return per page. PageSize *uint32 `json:"-"` } // ListVolumesResponse: list volumes response. type ListVolumesResponse struct { Volumes []*Volume `json:"volumes"` TotalCount uint64 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListVolumesResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListVolumesResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListVolumesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Volumes = append(r.Volumes, results.Volumes...) r.TotalCount += uint64(len(results.Volumes)) return uint64(len(results.Volumes)), nil } // ReplacePinRequest: replace pin request. type ReplacePinRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // PinID: pin ID whose information you wish to replace. PinID string `json:"-"` // VolumeID: volume ID. VolumeID string `json:"volume_id"` // Cid: new CID you want to pin in place of the old one. Cid string `json:"cid"` // Name: new name to replace. Name *string `json:"name,omitempty"` // Origins: node containing the content you want to pin. Origins []string `json:"origins"` } // ReplacePinResponse: replace pin response. type ReplacePinResponse struct { Pin *Pin `json:"pin"` } // UpdateVolumeRequest: update volume request. type UpdateVolumeRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // VolumeID: volume ID. VolumeID string `json:"-"` // Name: volume name. Name *string `json:"name,omitempty"` // Tags: tags of the volume. Tags *[]string `json:"tags,omitempty"` } // IPFS Pinning service API. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Regions() []scw.Region { return []scw.Region{scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw} } // CreateVolume: Create a new volume from a Project ID. Volume is identified by an ID and used to host pin references. // Volume is personal (at least to your organization) even if IPFS blocks and CID are available to anyone. // Should be the first command you made because every pin must be attached to a volume. func (s *API) CreateVolume(req *CreateVolumeRequest, opts ...scw.RequestOption) (*Volume, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/ipfs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/volumes", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Volume err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetVolume: Retrieve information about a specific volume. func (s *API) GetVolume(req *GetVolumeRequest, opts ...scw.RequestOption) (*Volume, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.VolumeID) == "" { return nil, errors.New("field VolumeID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/ipfs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/volumes/" + fmt.Sprint(req.VolumeID) + "", } var resp Volume err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListVolumes: Retrieve information about all volumes from a Project ID. func (s *API) ListVolumes(req *ListVolumesRequest, opts ...scw.RequestOption) (*ListVolumesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/ipfs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/volumes", Query: query, } var resp ListVolumesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateVolume: Update volume information (tag, name...). func (s *API) UpdateVolume(req *UpdateVolumeRequest, opts ...scw.RequestOption) (*Volume, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.VolumeID) == "" { return nil, errors.New("field VolumeID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/ipfs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/volumes/" + fmt.Sprint(req.VolumeID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Volume err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteVolume: Delete a volume by its ID and every pin attached to this volume. This process can take a while to conclude, depending on the size of your pinned content. func (s *API) DeleteVolume(req *DeleteVolumeRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.VolumeID) == "" { return errors.New("field VolumeID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/ipfs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/volumes/" + fmt.Sprint(req.VolumeID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // CreatePinByURL: Will fetch and store the content pointed by the provided URL. The content must be available on the public IPFS network. // The content (IPFS blocks) will be host by the pinning service until pin deletion. // From that point, any other IPFS peer can fetch and host your content: Make sure to pin public or encrypted content. // Many pin requests (from different users) can target the same CID. // A pin is defined by its ID (UUID), its status (queued, pinning, pinned or failed) and target CID. func (s *API) CreatePinByURL(req *CreatePinByURLRequest, opts ...scw.RequestOption) (*Pin, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/ipfs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/pins/create-by-url", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Pin err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreatePinByCID: Will fetch and store the content pointed by the provided CID. The content must be available on the public IPFS network. // The content (IPFS blocks) will be host by the pinning service until pin deletion. // From that point, any other IPFS peer can fetch and host your content: Make sure to pin public or encrypted content. // Many pin requests (from different users) can target the same CID. // A pin is defined by its ID (UUID), its status (queued, pinning, pinned or failed) and target CID. func (s *API) CreatePinByCID(req *CreatePinByCIDRequest, opts ...scw.RequestOption) (*Pin, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/ipfs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/pins/create-by-cid", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Pin err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ReplacePin: Deletes the given resource ID and pins the new CID in its place. // Will fetch and store the content pointed by the provided CID. The content must be available on the public IPFS network. // The content (IPFS blocks) is hosted by the pinning service until the pin is deleted. // While the content is available any other IPFS peer can fetch and host your content. For this reason, we recommend that you pin either public or encrypted content. // Several different pin requests can target the same CID. // A pin is defined by its ID (UUID), its status (queued, pinning, pinned or failed) and target CID. func (s *API) ReplacePin(req *ReplacePinRequest, opts ...scw.RequestOption) (*ReplacePinResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.PinID) == "" { return nil, errors.New("field PinID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/ipfs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/pins/" + fmt.Sprint(req.PinID) + "/replace", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp ReplacePinResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetPin: Retrieve information about the provided **pin ID**, such as status, last modification, and CID. func (s *API) GetPin(req *GetPinRequest, opts ...scw.RequestOption) (*Pin, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } query := url.Values{} parameter.AddToQuery(query, "volume_id", req.VolumeID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.PinID) == "" { return nil, errors.New("field PinID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/ipfs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/pins/" + fmt.Sprint(req.PinID) + "", Query: query, } var resp Pin err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListPins: Retrieve information about all pins within a volume. func (s *API) ListPins(req *ListPinsRequest, opts ...scw.RequestOption) (*ListPinsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "volume_id", req.VolumeID) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "status", req.Status) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/ipfs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/pins", Query: query, } var resp ListPinsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeletePin: An unpin request means that you no longer own the content. // This content can therefore be removed and no longer provided on the IPFS network. func (s *API) DeletePin(req *DeletePinRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } query := url.Values{} parameter.AddToQuery(query, "volume_id", req.VolumeID) if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.PinID) == "" { return errors.New("field PinID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/ipfs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/pins/" + fmt.Sprint(req.PinID) + "", Query: query, } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } type IpnsAPI struct { client *scw.Client } // NewIpnsAPI returns a IpnsAPI object from a Scaleway client. func NewIpnsAPI(client *scw.Client) *IpnsAPI { return &IpnsAPI{ client: client, } } func (s *IpnsAPI) Regions() []scw.Region { return []scw.Region{scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw} } // CreateName: You can use the `ipns key` command to list and generate more names and their respective keys. func (s *IpnsAPI) CreateName(req *IpnsAPICreateNameRequest, opts ...scw.RequestOption) (*Name, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/ipfs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/names", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Name err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetName: Retrieve information about a specific name. func (s *IpnsAPI) GetName(req *IpnsAPIGetNameRequest, opts ...scw.RequestOption) (*Name, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NameID) == "" { return nil, errors.New("field NameID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/ipfs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/names/" + fmt.Sprint(req.NameID) + "", } var resp Name err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteName: Delete a name by its ID. func (s *IpnsAPI) DeleteName(req *IpnsAPIDeleteNameRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NameID) == "" { return errors.New("field NameID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/ipfs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/names/" + fmt.Sprint(req.NameID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListNames: Retrieve information about all names from a Project ID. func (s *IpnsAPI) ListNames(req *IpnsAPIListNamesRequest, opts ...scw.RequestOption) (*ListNamesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/ipfs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/names", Query: query, } var resp ListNamesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateName: Update name information (CID, tag, name...). func (s *IpnsAPI) UpdateName(req *IpnsAPIUpdateNameRequest, opts ...scw.RequestOption) (*Name, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NameID) == "" { return nil, errors.New("field NameID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/ipfs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/names/" + fmt.Sprint(req.NameID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Name err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ExportKeyName: Export a private key by its ID. func (s *IpnsAPI) ExportKeyName(req *IpnsAPIExportKeyNameRequest, opts ...scw.RequestOption) (*ExportKeyNameResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NameID) == "" { return nil, errors.New("field NameID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/ipfs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/names/" + fmt.Sprint(req.NameID) + "/export-key", } var resp ExportKeyNameResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ImportKeyName: Import a private key. func (s *IpnsAPI) ImportKeyName(req *IpnsAPIImportKeyNameRequest, opts ...scw.RequestOption) (*Name, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/ipfs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/names/import-key", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Name err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/jobs/000077500000000000000000000000001456366605600237645ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/jobs/v1alpha1/000077500000000000000000000000001456366605600254015ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/jobs/v1alpha1/custom_job_run.go000066400000000000000000000030371456366605600307630ustar00rootroot00000000000000package jobs import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) const ( defaultRetryInterval = 15 * time.Second defaultTimeout = 15 * time.Minute ) type WaitForJobRunRequest struct { JobRunID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForJobRun waits for the job run to be in a "terminal state" before returning. // This function can be used to wait for a job run to fail for example. func (s *API) WaitForJobRun(req *WaitForJobRunRequest, opts ...scw.RequestOption) (*JobRun, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[JobRunState]struct{}{ JobRunStateSucceeded: {}, JobRunStateFailed: {}, JobRunStateCanceled: {}, } jobRun, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetJobRun(&GetJobRunRequest{ JobRunID: req.JobRunID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.State] return res, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for job run failed") } return jobRun.(*JobRun), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/jobs/v1alpha1/jobs_sdk.go000066400000000000000000000515011456366605600275300ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package jobs provides methods and message types of the jobs v1alpha1 API. package jobs import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type JobRunState string const ( JobRunStateUnknownState = JobRunState("unknown_state") JobRunStateQueued = JobRunState("queued") JobRunStateScheduled = JobRunState("scheduled") JobRunStateRunning = JobRunState("running") JobRunStateSucceeded = JobRunState("succeeded") JobRunStateFailed = JobRunState("failed") JobRunStateCanceled = JobRunState("canceled") JobRunStateInternalError = JobRunState("internal_error") ) func (enum JobRunState) String() string { if enum == "" { // return default value if empty return "unknown_state" } return string(enum) } func (enum JobRunState) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *JobRunState) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = JobRunState(JobRunState(tmp).String()) return nil } type ListJobDefinitionsRequestOrderBy string const ( ListJobDefinitionsRequestOrderByCreatedAtAsc = ListJobDefinitionsRequestOrderBy("created_at_asc") ListJobDefinitionsRequestOrderByCreatedAtDesc = ListJobDefinitionsRequestOrderBy("created_at_desc") ) func (enum ListJobDefinitionsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListJobDefinitionsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListJobDefinitionsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListJobDefinitionsRequestOrderBy(ListJobDefinitionsRequestOrderBy(tmp).String()) return nil } type ListJobRunsRequestOrderBy string const ( ListJobRunsRequestOrderByCreatedAtAsc = ListJobRunsRequestOrderBy("created_at_asc") ListJobRunsRequestOrderByCreatedAtDesc = ListJobRunsRequestOrderBy("created_at_desc") ) func (enum ListJobRunsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListJobRunsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListJobRunsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListJobRunsRequestOrderBy(ListJobRunsRequestOrderBy(tmp).String()) return nil } // CronSchedule: cron schedule. type CronSchedule struct { Schedule string `json:"schedule"` Timezone string `json:"timezone"` } // CreateJobDefinitionRequestCronScheduleConfig: create job definition request cron schedule config. type CreateJobDefinitionRequestCronScheduleConfig struct { Schedule string `json:"schedule"` Timezone string `json:"timezone"` } // JobDefinition: job definition. type JobDefinition struct { ID string `json:"id"` Name string `json:"name"` CreatedAt *time.Time `json:"created_at"` UpdatedAt *time.Time `json:"updated_at"` CPULimit uint32 `json:"cpu_limit"` MemoryLimit uint32 `json:"memory_limit"` ImageURI string `json:"image_uri"` Command string `json:"command"` ProjectID string `json:"project_id"` EnvironmentVariables map[string]string `json:"environment_variables"` Description string `json:"description"` JobTimeout *scw.Duration `json:"job_timeout"` CronSchedule *CronSchedule `json:"cron_schedule"` LocalStorageCapacity uint32 `json:"local_storage_capacity"` // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"region"` } // JobRun: job run. type JobRun struct { ID string `json:"id"` JobDefinitionID string `json:"job_definition_id"` // State: default value: unknown_state State JobRunState `json:"state"` CreatedAt *time.Time `json:"created_at"` UpdatedAt *time.Time `json:"updated_at"` TerminatedAt *time.Time `json:"terminated_at"` ExitCode *int32 `json:"exit_code"` RunDuration *scw.Duration `json:"run_duration"` ErrorMessage string `json:"error_message"` CPULimit uint32 `json:"cpu_limit"` MemoryLimit uint32 `json:"memory_limit"` Command string `json:"command"` EnvironmentVariables map[string]string `json:"environment_variables"` LocalStorageCapacity uint32 `json:"local_storage_capacity"` // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"region"` } // UpdateJobDefinitionRequestCronScheduleConfig: update job definition request cron schedule config. type UpdateJobDefinitionRequestCronScheduleConfig struct { Schedule *string `json:"schedule"` Timezone *string `json:"timezone"` } // CreateJobDefinitionRequest: create job definition request. type CreateJobDefinitionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Name: name of the job definition. Name string `json:"name"` // CPULimit: CPU limit of the job. CPULimit uint32 `json:"cpu_limit"` // MemoryLimit: memory limit of the job (in MiB). MemoryLimit uint32 `json:"memory_limit"` // LocalStorageCapacity: local storage capacity of the job (in MiB). LocalStorageCapacity *uint32 `json:"local_storage_capacity,omitempty"` // ImageURI: image to use for the job. ImageURI string `json:"image_uri"` // Command: startup command. Command string `json:"command"` // ProjectID: UUID of the Scaleway Project containing the job. ProjectID string `json:"project_id"` // EnvironmentVariables: environment variables of the job. EnvironmentVariables map[string]string `json:"environment_variables"` // Description: description of the job. Description string `json:"description"` // JobTimeout: timeout of the job in seconds. JobTimeout *scw.Duration `json:"job_timeout,omitempty"` CronSchedule *CreateJobDefinitionRequestCronScheduleConfig `json:"cron_schedule,omitempty"` } // DeleteJobDefinitionRequest: delete job definition request. type DeleteJobDefinitionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // JobDefinitionID: UUID of the job definition to delete. JobDefinitionID string `json:"-"` } // GetJobDefinitionRequest: get job definition request. type GetJobDefinitionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // JobDefinitionID: UUID of the job definition to get. JobDefinitionID string `json:"-"` } // GetJobRunRequest: get job run request. type GetJobRunRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // JobRunID: UUID of the job run to get. JobRunID string `json:"-"` } // ListJobDefinitionsRequest: list job definitions request. type ListJobDefinitionsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` // OrderBy: default value: created_at_asc OrderBy ListJobDefinitionsRequestOrderBy `json:"-"` ProjectID *string `json:"-"` } // ListJobDefinitionsResponse: list job definitions response. type ListJobDefinitionsResponse struct { JobDefinitions []*JobDefinition `json:"job_definitions"` TotalCount uint64 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListJobDefinitionsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListJobDefinitionsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListJobDefinitionsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.JobDefinitions = append(r.JobDefinitions, results.JobDefinitions...) r.TotalCount += uint64(len(results.JobDefinitions)) return uint64(len(results.JobDefinitions)), nil } // ListJobRunsRequest: list job runs request. type ListJobRunsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` // OrderBy: default value: created_at_asc OrderBy ListJobRunsRequestOrderBy `json:"-"` JobDefinitionID *string `json:"-"` ProjectID *string `json:"-"` } // ListJobRunsResponse: list job runs response. type ListJobRunsResponse struct { JobRuns []*JobRun `json:"job_runs"` TotalCount uint64 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListJobRunsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListJobRunsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListJobRunsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.JobRuns = append(r.JobRuns, results.JobRuns...) r.TotalCount += uint64(len(results.JobRuns)) return uint64(len(results.JobRuns)), nil } // StartJobDefinitionRequest: start job definition request. type StartJobDefinitionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // JobDefinitionID: UUID of the job definition to start. JobDefinitionID string `json:"-"` // Command: contextual startup command for this specific job run. Command *string `json:"command,omitempty"` // EnvironmentVariables: contextual environment variables for this specific job run. EnvironmentVariables *map[string]string `json:"environment_variables,omitempty"` // Replicas: number of jobs to run. Replicas *uint32 `json:"replicas,omitempty"` } // StartJobDefinitionResponse: start job definition response. type StartJobDefinitionResponse struct { JobRuns []*JobRun `json:"job_runs"` } // StopJobRunRequest: stop job run request. type StopJobRunRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // JobRunID: UUID of the job run to stop. JobRunID string `json:"-"` } // UpdateJobDefinitionRequest: update job definition request. type UpdateJobDefinitionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // JobDefinitionID: UUID of the job definition to update. JobDefinitionID string `json:"-"` // Name: name of the job definition. Name *string `json:"name,omitempty"` // CPULimit: CPU limit of the job. CPULimit *uint32 `json:"cpu_limit,omitempty"` // MemoryLimit: memory limit of the job (in MiB). MemoryLimit *uint32 `json:"memory_limit,omitempty"` // LocalStorageCapacity: local storage capacity of the job (in MiB). LocalStorageCapacity *uint32 `json:"local_storage_capacity,omitempty"` // ImageURI: image to use for the job. ImageURI *string `json:"image_uri,omitempty"` // Command: startup command. Command *string `json:"command,omitempty"` // EnvironmentVariables: environment variables of the job. EnvironmentVariables *map[string]string `json:"environment_variables,omitempty"` // Description: description of the job. Description *string `json:"description,omitempty"` // JobTimeout: timeout of the job in seconds. JobTimeout *scw.Duration `json:"job_timeout,omitempty"` CronSchedule *UpdateJobDefinitionRequestCronScheduleConfig `json:"cron_schedule,omitempty"` } // Serverless Jobs API. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Regions() []scw.Region { return []scw.Region{scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw} } // CreateJobDefinition: Create a new job definition in a specified Project. func (s *API) CreateJobDefinition(req *CreateJobDefinitionRequest, opts ...scw.RequestOption) (*JobDefinition, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if req.Name == "" { req.Name = namegenerator.GetRandomName("job") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/serverless-jobs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/job-definitions", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp JobDefinition err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetJobDefinition: Get a job definition by its unique identifier. func (s *API) GetJobDefinition(req *GetJobDefinitionRequest, opts ...scw.RequestOption) (*JobDefinition, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.JobDefinitionID) == "" { return nil, errors.New("field JobDefinitionID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/serverless-jobs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/job-definitions/" + fmt.Sprint(req.JobDefinitionID) + "", } var resp JobDefinition err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListJobDefinitions: List all your job definitions with filters. func (s *API) ListJobDefinitions(req *ListJobDefinitionsRequest, opts ...scw.RequestOption) (*ListJobDefinitionsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/serverless-jobs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/job-definitions", Query: query, } var resp ListJobDefinitionsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateJobDefinition: Update an existing job definition associated with the specified unique identifier. func (s *API) UpdateJobDefinition(req *UpdateJobDefinitionRequest, opts ...scw.RequestOption) (*JobDefinition, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.JobDefinitionID) == "" { return nil, errors.New("field JobDefinitionID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/serverless-jobs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/job-definitions/" + fmt.Sprint(req.JobDefinitionID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp JobDefinition err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteJobDefinition: Delete an exsisting job definition by its unique identifier. func (s *API) DeleteJobDefinition(req *DeleteJobDefinitionRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.JobDefinitionID) == "" { return errors.New("field JobDefinitionID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/serverless-jobs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/job-definitions/" + fmt.Sprint(req.JobDefinitionID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // StartJobDefinition: Run an existing job definition by its unique identifier. This will create a new job run. func (s *API) StartJobDefinition(req *StartJobDefinitionRequest, opts ...scw.RequestOption) (*StartJobDefinitionResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.JobDefinitionID) == "" { return nil, errors.New("field JobDefinitionID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/serverless-jobs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/job-definitions/" + fmt.Sprint(req.JobDefinitionID) + "/start", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp StartJobDefinitionResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetJobRun: Get a job run by its unique identifier. func (s *API) GetJobRun(req *GetJobRunRequest, opts ...scw.RequestOption) (*JobRun, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.JobRunID) == "" { return nil, errors.New("field JobRunID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/serverless-jobs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/job-runs/" + fmt.Sprint(req.JobRunID) + "", } var resp JobRun err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // StopJobRun: Stop a job run by its unique identifier. func (s *API) StopJobRun(req *StopJobRunRequest, opts ...scw.RequestOption) (*JobRun, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.JobRunID) == "" { return nil, errors.New("field JobRunID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/serverless-jobs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/job-runs/" + fmt.Sprint(req.JobRunID) + "/stop", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp JobRun err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListJobRuns: List all job runs with filters. func (s *API) ListJobRuns(req *ListJobRunsRequest, opts ...scw.RequestOption) (*ListJobRunsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "job_definition_id", req.JobDefinitionID) parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/serverless-jobs/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/job-runs", Query: query, } var resp ListJobRunsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/k8s/000077500000000000000000000000001456366605600235345ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/k8s/v1/000077500000000000000000000000001456366605600240625ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/k8s/v1/k8s_helpers.go000066400000000000000000000126221456366605600266430ustar00rootroot00000000000000package k8s import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) const ( waitForClusterDefaultTimeout = 15 * time.Minute waitForPoolDefaultTimeout = 15 * time.Minute waitForNodeDefaultTimeout = 15 * time.Minute defaultRetryInterval = 5 * time.Second ) // WaitForClusterRequest is used by WaitForCluster method. type WaitForClusterRequest struct { ClusterID string Region scw.Region Status ClusterStatus Timeout *time.Duration RetryInterval *time.Duration } // WaitForCluster waits for the cluster to be in a "terminal state" before returning. func (s *API) WaitForCluster(req *WaitForClusterRequest, opts ...scw.RequestOption) (*Cluster, error) { timeout := waitForClusterDefaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[ClusterStatus]struct{}{ ClusterStatusReady: {}, ClusterStatusLocked: {}, ClusterStatusDeleted: {}, ClusterStatusPoolRequired: {}, } cluster, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { cluster, err := s.GetCluster(&GetClusterRequest{ ClusterID: req.ClusterID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[cluster.Status] return cluster, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for cluster failed") } return cluster.(*Cluster), nil } // WaitForPoolRequest is used by WaitForPool method. type WaitForPoolRequest struct { PoolID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForPool waits for a pool to be ready func (s *API) WaitForPool(req *WaitForPoolRequest, opts ...scw.RequestOption) (*Pool, error) { timeout := waitForPoolDefaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[PoolStatus]struct{}{ PoolStatusReady: {}, PoolStatusWarning: {}, } pool, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetPool(&GetPoolRequest{ PoolID: req.PoolID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.Status] return res, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for pool failed") } return pool.(*Pool), err } // WaitForNodeRequest is used by WaitForNode method. type WaitForNodeRequest struct { NodeID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForNode waits for a Node to be ready func (s *API) WaitForNode(req *WaitForNodeRequest, opts ...scw.RequestOption) (*Node, error) { timeout := waitForNodeDefaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[NodeStatus]struct{}{ NodeStatusCreationError: {}, NodeStatusReady: {}, } node, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetNode(&GetNodeRequest{ NodeID: req.NodeID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.Status] return res, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for node failed") } return node.(*Node), err } // WaitForClusterPoolRequest is used by WaitForClusterPool method. type WaitForClusterPoolRequest struct { ClusterID string Region scw.Region Status ClusterStatus Timeout *time.Duration RetryInterval *time.Duration } // WaitForClusterPool waits for the pool associated with a cluster to be in a "terminal state" before returning. func (s *API) WaitForClusterPool(req *WaitForClusterRequest, opts ...scw.RequestOption) (*Cluster, error) { timeout := waitForClusterDefaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[ClusterStatus]struct{}{ ClusterStatusPoolRequired: {}, ClusterStatusReady: {}, } cluster, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { cluster, err := s.GetCluster(&GetClusterRequest{ ClusterID: req.ClusterID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[cluster.Status] return cluster, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for cluster failed") } return cluster.(*Cluster), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/k8s/v1/k8s_sdk.go000066400000000000000000002655441456366605600257770ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package k8s provides methods and message types of the k8s v1 API. package k8s import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type AutoscalerEstimator string const ( AutoscalerEstimatorUnknownEstimator = AutoscalerEstimator("unknown_estimator") AutoscalerEstimatorBinpacking = AutoscalerEstimator("binpacking") ) func (enum AutoscalerEstimator) String() string { if enum == "" { // return default value if empty return "unknown_estimator" } return string(enum) } func (enum AutoscalerEstimator) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *AutoscalerEstimator) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = AutoscalerEstimator(AutoscalerEstimator(tmp).String()) return nil } // Kubernetes autoscaler strategy to fit pods into cluster nodes (https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/FAQ.md#what-are-expanders). type AutoscalerExpander string const ( AutoscalerExpanderUnknownExpander = AutoscalerExpander("unknown_expander") AutoscalerExpanderRandom = AutoscalerExpander("random") AutoscalerExpanderMostPods = AutoscalerExpander("most_pods") AutoscalerExpanderLeastWaste = AutoscalerExpander("least_waste") AutoscalerExpanderPriority = AutoscalerExpander("priority") AutoscalerExpanderPrice = AutoscalerExpander("price") ) func (enum AutoscalerExpander) String() string { if enum == "" { // return default value if empty return "unknown_expander" } return string(enum) } func (enum AutoscalerExpander) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *AutoscalerExpander) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = AutoscalerExpander(AutoscalerExpander(tmp).String()) return nil } type CNI string const ( CNIUnknownCni = CNI("unknown_cni") // Cilium CNI will be configured (https://github.com/cilium/cilium). CNICilium = CNI("cilium") // Calico CNI will be configured (https://github.com/projectcalico/calico). CNICalico = CNI("calico") CNIWeave = CNI("weave") CNIFlannel = CNI("flannel") // Kilo CNI will be configured (https://github.com/squat/kilo/). Note that this CNI is only available for Kosmos clusters. CNIKilo = CNI("kilo") ) func (enum CNI) String() string { if enum == "" { // return default value if empty return "unknown_cni" } return string(enum) } func (enum CNI) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *CNI) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = CNI(CNI(tmp).String()) return nil } type ClusterStatus string const ( ClusterStatusUnknown = ClusterStatus("unknown") // Cluster is provisioning. ClusterStatusCreating = ClusterStatus("creating") // Cluster is ready to use. ClusterStatusReady = ClusterStatus("ready") // Cluster is waiting to be processed for deletion. ClusterStatusDeleting = ClusterStatus("deleting") ClusterStatusDeleted = ClusterStatus("deleted") // Cluster is updating its own configuration, it can be a version upgrade too. ClusterStatusUpdating = ClusterStatus("updating") // Cluster is locked because an abuse has been detected or reported. ClusterStatusLocked = ClusterStatus("locked") // Cluster has no associated pool. ClusterStatusPoolRequired = ClusterStatus("pool_required") ) func (enum ClusterStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum ClusterStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ClusterStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ClusterStatus(ClusterStatus(tmp).String()) return nil } type ClusterTypeAvailability string const ( // Type is available in quantity. ClusterTypeAvailabilityAvailable = ClusterTypeAvailability("available") // Limited availability. ClusterTypeAvailabilityScarce = ClusterTypeAvailability("scarce") // Out of stock. ClusterTypeAvailabilityShortage = ClusterTypeAvailability("shortage") ) func (enum ClusterTypeAvailability) String() string { if enum == "" { // return default value if empty return "available" } return string(enum) } func (enum ClusterTypeAvailability) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ClusterTypeAvailability) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ClusterTypeAvailability(ClusterTypeAvailability(tmp).String()) return nil } type ClusterTypeResiliency string const ( ClusterTypeResiliencyUnknownResiliency = ClusterTypeResiliency("unknown_resiliency") // The control plane is rescheduled on other machines in case of failure of a lower layer. ClusterTypeResiliencyStandard = ClusterTypeResiliency("standard") // The control plane has replicas to ensure service continuity in case of failure of a lower layer. ClusterTypeResiliencyHighAvailability = ClusterTypeResiliency("high_availability") ) func (enum ClusterTypeResiliency) String() string { if enum == "" { // return default value if empty return "unknown_resiliency" } return string(enum) } func (enum ClusterTypeResiliency) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ClusterTypeResiliency) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ClusterTypeResiliency(ClusterTypeResiliency(tmp).String()) return nil } type ListClustersRequestOrderBy string const ( ListClustersRequestOrderByCreatedAtAsc = ListClustersRequestOrderBy("created_at_asc") ListClustersRequestOrderByCreatedAtDesc = ListClustersRequestOrderBy("created_at_desc") ListClustersRequestOrderByUpdatedAtAsc = ListClustersRequestOrderBy("updated_at_asc") ListClustersRequestOrderByUpdatedAtDesc = ListClustersRequestOrderBy("updated_at_desc") ListClustersRequestOrderByNameAsc = ListClustersRequestOrderBy("name_asc") ListClustersRequestOrderByNameDesc = ListClustersRequestOrderBy("name_desc") ListClustersRequestOrderByStatusAsc = ListClustersRequestOrderBy("status_asc") ListClustersRequestOrderByStatusDesc = ListClustersRequestOrderBy("status_desc") ListClustersRequestOrderByVersionAsc = ListClustersRequestOrderBy("version_asc") ListClustersRequestOrderByVersionDesc = ListClustersRequestOrderBy("version_desc") ) func (enum ListClustersRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListClustersRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListClustersRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListClustersRequestOrderBy(ListClustersRequestOrderBy(tmp).String()) return nil } type ListNodesRequestOrderBy string const ( ListNodesRequestOrderByCreatedAtAsc = ListNodesRequestOrderBy("created_at_asc") ListNodesRequestOrderByCreatedAtDesc = ListNodesRequestOrderBy("created_at_desc") ) func (enum ListNodesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListNodesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListNodesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListNodesRequestOrderBy(ListNodesRequestOrderBy(tmp).String()) return nil } type ListPoolsRequestOrderBy string const ( ListPoolsRequestOrderByCreatedAtAsc = ListPoolsRequestOrderBy("created_at_asc") ListPoolsRequestOrderByCreatedAtDesc = ListPoolsRequestOrderBy("created_at_desc") ListPoolsRequestOrderByUpdatedAtAsc = ListPoolsRequestOrderBy("updated_at_asc") ListPoolsRequestOrderByUpdatedAtDesc = ListPoolsRequestOrderBy("updated_at_desc") ListPoolsRequestOrderByNameAsc = ListPoolsRequestOrderBy("name_asc") ListPoolsRequestOrderByNameDesc = ListPoolsRequestOrderBy("name_desc") ListPoolsRequestOrderByStatusAsc = ListPoolsRequestOrderBy("status_asc") ListPoolsRequestOrderByStatusDesc = ListPoolsRequestOrderBy("status_desc") ListPoolsRequestOrderByVersionAsc = ListPoolsRequestOrderBy("version_asc") ListPoolsRequestOrderByVersionDesc = ListPoolsRequestOrderBy("version_desc") ) func (enum ListPoolsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListPoolsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListPoolsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListPoolsRequestOrderBy(ListPoolsRequestOrderBy(tmp).String()) return nil } type MaintenanceWindowDayOfTheWeek string const ( MaintenanceWindowDayOfTheWeekAny = MaintenanceWindowDayOfTheWeek("any") MaintenanceWindowDayOfTheWeekMonday = MaintenanceWindowDayOfTheWeek("monday") MaintenanceWindowDayOfTheWeekTuesday = MaintenanceWindowDayOfTheWeek("tuesday") MaintenanceWindowDayOfTheWeekWednesday = MaintenanceWindowDayOfTheWeek("wednesday") MaintenanceWindowDayOfTheWeekThursday = MaintenanceWindowDayOfTheWeek("thursday") MaintenanceWindowDayOfTheWeekFriday = MaintenanceWindowDayOfTheWeek("friday") MaintenanceWindowDayOfTheWeekSaturday = MaintenanceWindowDayOfTheWeek("saturday") MaintenanceWindowDayOfTheWeekSunday = MaintenanceWindowDayOfTheWeek("sunday") ) func (enum MaintenanceWindowDayOfTheWeek) String() string { if enum == "" { // return default value if empty return "any" } return string(enum) } func (enum MaintenanceWindowDayOfTheWeek) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *MaintenanceWindowDayOfTheWeek) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = MaintenanceWindowDayOfTheWeek(MaintenanceWindowDayOfTheWeek(tmp).String()) return nil } type NodeStatus string const ( NodeStatusUnknown = NodeStatus("unknown") // Node is provisioning. NodeStatusCreating = NodeStatus("creating") // Node is unable to connect to apiserver. NodeStatusNotReady = NodeStatus("not_ready") // Node is ready to execute workload (marked schedulable by k8s scheduler). NodeStatusReady = NodeStatus("ready") // Node is waiting to be processed for deletion. NodeStatusDeleting = NodeStatus("deleting") NodeStatusDeleted = NodeStatus("deleted") // Node is locked because an abuse has been detected or reported. NodeStatusLocked = NodeStatus("locked") // Node is rebooting. NodeStatusRebooting = NodeStatus("rebooting") NodeStatusCreationError = NodeStatus("creation_error") NodeStatusUpgrading = NodeStatus("upgrading") NodeStatusStarting = NodeStatus("starting") NodeStatusRegistering = NodeStatus("registering") ) func (enum NodeStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum NodeStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *NodeStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = NodeStatus(NodeStatus(tmp).String()) return nil } type PoolStatus string const ( PoolStatusUnknown = PoolStatus("unknown") // Pool has the right amount of nodes and is ready to process the workload. PoolStatusReady = PoolStatus("ready") // Pool is waiting to be processed for deletion. PoolStatusDeleting = PoolStatus("deleting") PoolStatusDeleted = PoolStatus("deleted") // Pool is growing or shrinking. PoolStatusScaling = PoolStatus("scaling") PoolStatusWarning = PoolStatus("warning") // Pool is locked because an abuse has been detected or reported. PoolStatusLocked = PoolStatus("locked") // Pool is upgrading its Kubernetes version. PoolStatusUpgrading = PoolStatus("upgrading") ) func (enum PoolStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum PoolStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *PoolStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = PoolStatus(PoolStatus(tmp).String()) return nil } type PoolVolumeType string const ( PoolVolumeTypeDefaultVolumeType = PoolVolumeType("default_volume_type") // Local Block Storage: your system is stored locally on your node hypervisor. Lower latency, no persistence across node replacements. PoolVolumeTypeLSSD = PoolVolumeType("l_ssd") // Remote Block Storage: your system is stored on a centralized and resilient cluster. Higher latency, persistence across node replacements. PoolVolumeTypeBSSD = PoolVolumeType("b_ssd") ) func (enum PoolVolumeType) String() string { if enum == "" { // return default value if empty return "default_volume_type" } return string(enum) } func (enum PoolVolumeType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *PoolVolumeType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = PoolVolumeType(PoolVolumeType(tmp).String()) return nil } type Runtime string const ( RuntimeUnknownRuntime = Runtime("unknown_runtime") RuntimeDocker = Runtime("docker") // Containerd Runtime will be configured (https://github.com/containerd/containerd). RuntimeContainerd = Runtime("containerd") RuntimeCrio = Runtime("crio") ) func (enum Runtime) String() string { if enum == "" { // return default value if empty return "unknown_runtime" } return string(enum) } func (enum Runtime) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *Runtime) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = Runtime(Runtime(tmp).String()) return nil } // MaintenanceWindow: maintenance window. type MaintenanceWindow struct { // StartHour: start time of the two-hour maintenance window. StartHour uint32 `json:"start_hour"` // Day: day of the week for the maintenance window. // Default value: any Day MaintenanceWindowDayOfTheWeek `json:"day"` } // PoolUpgradePolicy: pool upgrade policy. type PoolUpgradePolicy struct { MaxUnavailable uint32 `json:"max_unavailable"` MaxSurge uint32 `json:"max_surge"` } // CreateClusterRequestPoolConfigUpgradePolicy: create cluster request pool config upgrade policy. type CreateClusterRequestPoolConfigUpgradePolicy struct { // MaxUnavailable: the maximum number of nodes that can be not ready at the same time. MaxUnavailable *uint32 `json:"max_unavailable"` // MaxSurge: the maximum number of nodes to be created during the upgrade. MaxSurge *uint32 `json:"max_surge"` } // ClusterAutoUpgrade: cluster auto upgrade. type ClusterAutoUpgrade struct { // Enabled: defines whether auto upgrade is enabled for the cluster. Enabled bool `json:"enabled"` // MaintenanceWindow: maintenance window of the cluster auto upgrades. MaintenanceWindow *MaintenanceWindow `json:"maintenance_window"` } // ClusterAutoscalerConfig: cluster autoscaler config. type ClusterAutoscalerConfig struct { // ScaleDownDisabled: disable the cluster autoscaler. ScaleDownDisabled bool `json:"scale_down_disabled"` // ScaleDownDelayAfterAdd: how long after scale up that scale down evaluation resumes. ScaleDownDelayAfterAdd string `json:"scale_down_delay_after_add"` // Estimator: type of resource estimator to be used in scale up. // Default value: unknown_estimator Estimator AutoscalerEstimator `json:"estimator"` // Expander: type of node group expander to be used in scale up. // Default value: unknown_expander Expander AutoscalerExpander `json:"expander"` // IgnoreDaemonsetsUtilization: ignore DaemonSet pods when calculating resource utilization for scaling down. IgnoreDaemonsetsUtilization bool `json:"ignore_daemonsets_utilization"` // BalanceSimilarNodeGroups: detect similar node groups and balance the number of nodes between them. BalanceSimilarNodeGroups bool `json:"balance_similar_node_groups"` // ExpendablePodsPriorityCutoff: pods with priority below cutoff will be expendable. They can be killed without any consideration during scale down and they won't cause scale up. Pods with null priority (PodPriority disabled) are non expendable. ExpendablePodsPriorityCutoff int32 `json:"expendable_pods_priority_cutoff"` // ScaleDownUnneededTime: how long a node should be unneeded before it is eligible to be scaled down. ScaleDownUnneededTime string `json:"scale_down_unneeded_time"` // ScaleDownUtilizationThreshold: node utilization level, defined as a sum of requested resources divided by capacity, below which a node can be considered for scale down. ScaleDownUtilizationThreshold float32 `json:"scale_down_utilization_threshold"` // MaxGracefulTerminationSec: maximum number of seconds the cluster autoscaler waits for pod termination when trying to scale down a node. MaxGracefulTerminationSec uint32 `json:"max_graceful_termination_sec"` } // ClusterOpenIDConnectConfig: cluster open id connect config. type ClusterOpenIDConnectConfig struct { // IssuerURL: URL of the provider which allows the API server to discover public signing keys. Only URLs using the `https://` scheme are accepted. This is typically the provider's discovery URL without a path, for example "https://accounts.google.com" or "https://login.salesforce.com". IssuerURL string `json:"issuer_url"` // ClientID: a client ID that all tokens must be issued for. ClientID string `json:"client_id"` // UsernameClaim: jWT claim to use as the user name. The default is `sub`, which is expected to be the end user's unique identifier. Admins can choose other claims, such as `email` or `name`, depending on their provider. However, claims other than `email` will be prefixed with the issuer URL to prevent name collision. UsernameClaim string `json:"username_claim"` // UsernamePrefix: prefix prepended to username claims to prevent name collision (such as `system:` users). For example, the value `oidc:` will create usernames like `oidc:jane.doe`. If this flag is not provided and `username_claim` is a value other than `email`, the prefix defaults to `( Issuer URL )#` where `( Issuer URL )` is the value of `issuer_url`. The value `-` can be used to disable all prefixing. UsernamePrefix string `json:"username_prefix"` // GroupsClaim: jWT claim to use as the user's group. GroupsClaim []string `json:"groups_claim"` // GroupsPrefix: prefix prepended to group claims to prevent name collision (such as `system:` groups). For example, the value `oidc:` will create group names like `oidc:engineering` and `oidc:infra`. GroupsPrefix string `json:"groups_prefix"` // RequiredClaim: multiple key=value pairs describing a required claim in the ID token. If set, the claims are verified to be present in the ID token with a matching value. RequiredClaim []string `json:"required_claim"` } // Pool: pool. type Pool struct { // ID: pool ID. ID string `json:"id"` // ClusterID: cluster ID of the pool. ClusterID string `json:"cluster_id"` // CreatedAt: date on which the pool was created. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date on which the pool was last updated. UpdatedAt *time.Time `json:"updated_at"` // Name: pool name. Name string `json:"name"` // Status: pool status. // Default value: unknown Status PoolStatus `json:"status"` // Version: pool version. Version string `json:"version"` // NodeType: node type is the type of Scaleway Instance wanted for the pool. Nodes with insufficient memory are not eligible (DEV1-S, PLAY2-PICO, STARDUST). 'external' is a special node type used to provision instances from other cloud providers in a Kosmos Cluster. NodeType string `json:"node_type"` // Autoscaling: defines whether the autoscaling feature is enabled for the pool. Autoscaling bool `json:"autoscaling"` // Size: size (number of nodes) of the pool. Size uint32 `json:"size"` // MinSize: defines the minimum size of the pool. Note that this field is only used when autoscaling is enabled on the pool. MinSize uint32 `json:"min_size"` // MaxSize: defines the maximum size of the pool. Note that this field is only used when autoscaling is enabled on the pool. MaxSize uint32 `json:"max_size"` // ContainerRuntime: customization of the container runtime is available for each pool. Note that `docker` has been deprecated since version 1.20 and will be removed by version 1.24. // Default value: unknown_runtime ContainerRuntime Runtime `json:"container_runtime"` // Autohealing: defines whether the autohealing feature is enabled for the pool. Autohealing bool `json:"autohealing"` // Tags: tags associated with the pool. Tags []string `json:"tags"` // PlacementGroupID: placement group ID in which all the nodes of the pool will be created. PlacementGroupID *string `json:"placement_group_id"` // KubeletArgs: kubelet arguments to be used by this pool. Note that this feature is experimental. KubeletArgs map[string]string `json:"kubelet_args"` // UpgradePolicy: pool upgrade policy. UpgradePolicy *PoolUpgradePolicy `json:"upgrade_policy"` // Zone: zone in which the pool's nodes will be spawned. Zone scw.Zone `json:"zone"` // RootVolumeType: defines the system volume disk type. Two different types of volume (`volume_type`) are provided: `l_ssd` is a local block storage which means your system is stored locally on your node's hypervisor. `b_ssd` is a remote block storage which means your system is stored on a centralized and resilient cluster. // Default value: default_volume_type RootVolumeType PoolVolumeType `json:"root_volume_type"` // RootVolumeSize: system volume disk size. RootVolumeSize *scw.Size `json:"root_volume_size"` // PublicIPDisabled: defines if the public IP should be removed from Nodes. To use this feature, your Cluster must have an attached Private Network set up with a Public Gateway. PublicIPDisabled bool `json:"public_ip_disabled"` // Region: cluster region of the pool. Region scw.Region `json:"region"` } // CreateClusterRequestAutoUpgrade: create cluster request auto upgrade. type CreateClusterRequestAutoUpgrade struct { // Enable: defines whether auto upgrade is enabled for the cluster. Enable bool `json:"enable"` // MaintenanceWindow: maintenance window of the cluster auto upgrades. MaintenanceWindow *MaintenanceWindow `json:"maintenance_window"` } // CreateClusterRequestAutoscalerConfig: create cluster request autoscaler config. type CreateClusterRequestAutoscalerConfig struct { // ScaleDownDisabled: disable the cluster autoscaler. ScaleDownDisabled *bool `json:"scale_down_disabled"` // ScaleDownDelayAfterAdd: how long after scale up that scale down evaluation resumes. ScaleDownDelayAfterAdd *string `json:"scale_down_delay_after_add"` // Estimator: type of resource estimator to be used in scale up. // Default value: unknown_estimator Estimator AutoscalerEstimator `json:"estimator"` // Expander: type of node group expander to be used in scale up. // Default value: unknown_expander Expander AutoscalerExpander `json:"expander"` // IgnoreDaemonsetsUtilization: ignore DaemonSet pods when calculating resource utilization for scaling down. IgnoreDaemonsetsUtilization *bool `json:"ignore_daemonsets_utilization"` // BalanceSimilarNodeGroups: detect similar node groups and balance the number of nodes between them. BalanceSimilarNodeGroups *bool `json:"balance_similar_node_groups"` // ExpendablePodsPriorityCutoff: pods with priority below cutoff will be expendable. They can be killed without any consideration during scale down and they won't cause scale up. Pods with null priority (PodPriority disabled) are non expendable. ExpendablePodsPriorityCutoff *int32 `json:"expendable_pods_priority_cutoff"` // ScaleDownUnneededTime: how long a node should be unneeded before it is eligible to be scaled down. ScaleDownUnneededTime *string `json:"scale_down_unneeded_time"` // ScaleDownUtilizationThreshold: node utilization level, defined as a sum of requested resources divided by capacity, below which a node can be considered for scale down. ScaleDownUtilizationThreshold *float32 `json:"scale_down_utilization_threshold"` // MaxGracefulTerminationSec: maximum number of seconds the cluster autoscaler waits for pod termination when trying to scale down a node. MaxGracefulTerminationSec *uint32 `json:"max_graceful_termination_sec"` } // CreateClusterRequestOpenIDConnectConfig: create cluster request open id connect config. type CreateClusterRequestOpenIDConnectConfig struct { // IssuerURL: URL of the provider which allows the API server to discover public signing keys. Only URLs using the `https://` scheme are accepted. This is typically the provider's discovery URL without a path, for example "https://accounts.google.com" or "https://login.salesforce.com". IssuerURL string `json:"issuer_url"` // ClientID: a client ID that all tokens must be issued for. ClientID string `json:"client_id"` // UsernameClaim: jWT claim to use as the user name. The default is `sub`, which is expected to be the end user's unique identifier. Admins can choose other claims, such as `email` or `name`, depending on their provider. However, claims other than `email` will be prefixed with the issuer URL to prevent name collision. UsernameClaim *string `json:"username_claim"` // UsernamePrefix: prefix prepended to username claims to prevent name collision (such as `system:` users). For example, the value `oidc:` will create usernames like `oidc:jane.doe`. If this flag is not provided and `username_claim` is a value other than `email`, the prefix defaults to `( Issuer URL )#` where `( Issuer URL )` is the value of `issuer_url`. The value `-` can be used to disable all prefixing. UsernamePrefix *string `json:"username_prefix"` // GroupsClaim: jWT claim to use as the user's group. GroupsClaim *[]string `json:"groups_claim"` // GroupsPrefix: prefix prepended to group claims to prevent name collision (such as `system:` groups). For example, the value `oidc:` will create group names like `oidc:engineering` and `oidc:infra`. GroupsPrefix *string `json:"groups_prefix"` // RequiredClaim: multiple key=value pairs describing a required claim in the ID token. If set, the claims are verified to be present in the ID token with a matching value. RequiredClaim *[]string `json:"required_claim"` } // CreateClusterRequestPoolConfig: create cluster request pool config. type CreateClusterRequestPoolConfig struct { // Name: name of the pool. Name string `json:"name"` // NodeType: node type is the type of Scaleway Instance wanted for the pool. Nodes with insufficient memory are not eligible (DEV1-S, PLAY2-PICO, STARDUST). 'external' is a special node type used to provision instances from other cloud providers in a Kosmos Cluster. NodeType string `json:"node_type"` // PlacementGroupID: placement group ID in which all the nodes of the pool will be created. PlacementGroupID *string `json:"placement_group_id"` // Autoscaling: defines whether the autoscaling feature is enabled for the pool. Autoscaling bool `json:"autoscaling"` // Size: size (number of nodes) of the pool. Size uint32 `json:"size"` // MinSize: defines the minimum size of the pool. Note that this field is only used when autoscaling is enabled on the pool. MinSize *uint32 `json:"min_size"` // MaxSize: defines the maximum size of the pool. Note that this field is only used when autoscaling is enabled on the pool. MaxSize *uint32 `json:"max_size"` // ContainerRuntime: customization of the container runtime is available for each pool. Note that `docker` has been deprecated since version 1.20 and will be removed by version 1.24. // Default value: unknown_runtime ContainerRuntime Runtime `json:"container_runtime"` // Autohealing: defines whether the autohealing feature is enabled for the pool. Autohealing bool `json:"autohealing"` // Tags: tags associated with the pool. Tags []string `json:"tags"` // KubeletArgs: kubelet arguments to be used by this pool. Note that this feature is experimental. KubeletArgs map[string]string `json:"kubelet_args"` // UpgradePolicy: pool upgrade policy. UpgradePolicy *CreateClusterRequestPoolConfigUpgradePolicy `json:"upgrade_policy"` // Zone: zone in which the pool's nodes will be spawned. Zone scw.Zone `json:"zone"` // RootVolumeType: defines the system volume disk type. Two different types of volume (`volume_type`) are provided: `l_ssd` is a local block storage which means your system is stored locally on your node's hypervisor. `b_ssd` is a remote block storage which means your system is stored on a centralized and resilient cluster. // Default value: default_volume_type RootVolumeType PoolVolumeType `json:"root_volume_type"` // RootVolumeSize: system volume disk size. RootVolumeSize *scw.Size `json:"root_volume_size"` // PublicIPDisabled: defines if the public IP should be removed from Nodes. To use this feature, your Cluster must have an attached Private Network set up with a Public Gateway. PublicIPDisabled bool `json:"public_ip_disabled"` } // CreatePoolRequestUpgradePolicy: create pool request upgrade policy. type CreatePoolRequestUpgradePolicy struct { MaxUnavailable *uint32 `json:"max_unavailable"` MaxSurge *uint32 `json:"max_surge"` } // ExternalNodeCoreV1Taint: external node core v1 taint. type ExternalNodeCoreV1Taint struct { Key string `json:"key"` Value string `json:"value"` Effect string `json:"effect"` } // ClusterType: cluster type. type ClusterType struct { // Name: cluster type name. Name string `json:"name"` // Availability: cluster type availability. // Default value: available Availability ClusterTypeAvailability `json:"availability"` // MaxNodes: maximum number of nodes supported by the offer. MaxNodes uint32 `json:"max_nodes"` // CommitmentDelay: time period during which you can no longer switch to a lower offer. CommitmentDelay *scw.Duration `json:"commitment_delay"` // SLA: value of the Service Level Agreement of the offer. SLA float32 `json:"sla"` // Resiliency: resiliency offered by the offer. // Default value: unknown_resiliency Resiliency ClusterTypeResiliency `json:"resiliency"` // Memory: max RAM allowed for the control plane. Memory scw.Size `json:"memory"` // Dedicated: returns information if this offer uses dedicated resources. Dedicated bool `json:"dedicated"` // AuditLogsSupported: true if the offer allows activation of the audit log functionality. Please note that audit logs are sent to Cockpit. AuditLogsSupported bool `json:"audit_logs_supported"` } // Version: version. type Version struct { // Name: name of the Kubernetes version. Name string `json:"name"` // Label: label of the Kubernetes version. Label string `json:"label"` // Region: region in which this version is available. Region scw.Region `json:"region"` // AvailableCnis: supported Container Network Interface (CNI) plugins for this version. AvailableCnis []CNI `json:"available_cnis"` // AvailableContainerRuntimes: supported container runtimes for this version. AvailableContainerRuntimes []Runtime `json:"available_container_runtimes"` // AvailableFeatureGates: supported feature gates for this version. AvailableFeatureGates []string `json:"available_feature_gates"` // AvailableAdmissionPlugins: supported admission plugins for this version. AvailableAdmissionPlugins []string `json:"available_admission_plugins"` // AvailableKubeletArgs: supported kubelet arguments for this version. AvailableKubeletArgs map[string]string `json:"available_kubelet_args"` } // Cluster: cluster. type Cluster struct { // ID: cluster ID. ID string `json:"id"` // Type: cluster type. Type string `json:"type"` // Name: cluster name. Name string `json:"name"` // Status: status of the cluster. // Default value: unknown Status ClusterStatus `json:"status"` // Version: kubernetes version of the cluster. Version string `json:"version"` // Region: region in which the cluster is deployed. Region scw.Region `json:"region"` // OrganizationID: ID of the Organization owning the cluster. OrganizationID string `json:"organization_id"` // ProjectID: ID of the Project owning the cluster. ProjectID string `json:"project_id"` // Tags: tags associated with the cluster. Tags []string `json:"tags"` // Cni: container Network Interface (CNI) plugin running in the cluster. // Default value: unknown_cni Cni CNI `json:"cni"` // Description: cluster description. Description string `json:"description"` // ClusterURL: kubernetes API server URL of the cluster. ClusterURL string `json:"cluster_url"` // DNSWildcard: wildcard DNS resolving all the ready cluster nodes. DNSWildcard string `json:"dns_wildcard"` // CreatedAt: date on which the cluster was created. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date on which the cluster was last updated. UpdatedAt *time.Time `json:"updated_at"` // AutoscalerConfig: autoscaler config for the cluster. AutoscalerConfig *ClusterAutoscalerConfig `json:"autoscaler_config"` // AutoUpgrade: auto upgrade configuration of the cluster. AutoUpgrade *ClusterAutoUpgrade `json:"auto_upgrade"` // UpgradeAvailable: defines whether a new Kubernetes version is available. UpgradeAvailable bool `json:"upgrade_available"` // FeatureGates: list of enabled feature gates. FeatureGates []string `json:"feature_gates"` // AdmissionPlugins: list of enabled admission plugins. AdmissionPlugins []string `json:"admission_plugins"` // OpenIDConnectConfig: this configuration enables to update the OpenID Connect configuration of the Kubernetes API server. OpenIDConnectConfig *ClusterOpenIDConnectConfig `json:"open_id_connect_config"` // ApiserverCertSans: additional Subject Alternative Names for the Kubernetes API server certificate. ApiserverCertSans []string `json:"apiserver_cert_sans"` // PrivateNetworkID: private network ID for internal cluster communication. PrivateNetworkID *string `json:"private_network_id"` // CommitmentEndsAt: date on which it will be possible to switch to a smaller offer. CommitmentEndsAt *time.Time `json:"commitment_ends_at"` } // Node: node. type Node struct { // ID: node ID. ID string `json:"id"` // PoolID: pool ID of the node. PoolID string `json:"pool_id"` // ClusterID: cluster ID of the node. ClusterID string `json:"cluster_id"` // ProviderID: underlying instance ID. It is prefixed by instance type and location information (see https://pkg.go.dev/k8s.io/api/core/v1#NodeSpec.ProviderID). ProviderID string `json:"provider_id"` // Region: cluster region of the node. Region scw.Region `json:"region"` // Name: name of the node. Name string `json:"name"` // Deprecated: PublicIPV4: public IPv4 address of the node. PublicIPV4 *net.IP `json:"public_ip_v4,omitempty"` // Deprecated: PublicIPV6: public IPv6 address of the node. PublicIPV6 *net.IP `json:"public_ip_v6,omitempty"` // Deprecated: Conditions: conditions of the node. These conditions contain the Node Problem Detector conditions, as well as some in house conditions. Conditions *map[string]string `json:"conditions,omitempty"` // Status: status of the node. // Default value: unknown Status NodeStatus `json:"status"` // ErrorMessage: details of the error, if any occurred when managing the node. ErrorMessage *string `json:"error_message"` // CreatedAt: date on which the node was created. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date on which the node was last updated. UpdatedAt *time.Time `json:"updated_at"` } // UpdateClusterRequestAutoUpgrade: update cluster request auto upgrade. type UpdateClusterRequestAutoUpgrade struct { // Enable: defines whether auto upgrade is enabled for the cluster. Enable *bool `json:"enable"` // MaintenanceWindow: maintenance window of the cluster auto upgrades. MaintenanceWindow *MaintenanceWindow `json:"maintenance_window"` } // UpdateClusterRequestAutoscalerConfig: update cluster request autoscaler config. type UpdateClusterRequestAutoscalerConfig struct { // ScaleDownDisabled: disable the cluster autoscaler. ScaleDownDisabled *bool `json:"scale_down_disabled"` // ScaleDownDelayAfterAdd: how long after scale up that scale down evaluation resumes. ScaleDownDelayAfterAdd *string `json:"scale_down_delay_after_add"` // Estimator: type of resource estimator to be used in scale up. // Default value: unknown_estimator Estimator AutoscalerEstimator `json:"estimator"` // Expander: type of node group expander to be used in scale up. // Default value: unknown_expander Expander AutoscalerExpander `json:"expander"` // IgnoreDaemonsetsUtilization: ignore DaemonSet pods when calculating resource utilization for scaling down. IgnoreDaemonsetsUtilization *bool `json:"ignore_daemonsets_utilization"` // BalanceSimilarNodeGroups: detect similar node groups and balance the number of nodes between them. BalanceSimilarNodeGroups *bool `json:"balance_similar_node_groups"` // ExpendablePodsPriorityCutoff: pods with priority below cutoff will be expendable. They can be killed without any consideration during scale down and they won't cause scale up. Pods with null priority (PodPriority disabled) are non expendable. ExpendablePodsPriorityCutoff *int32 `json:"expendable_pods_priority_cutoff"` // ScaleDownUnneededTime: how long a node should be unneeded before it is eligible to be scaled down. ScaleDownUnneededTime *string `json:"scale_down_unneeded_time"` // ScaleDownUtilizationThreshold: node utilization level, defined as a sum of requested resources divided by capacity, below which a node can be considered for scale down. ScaleDownUtilizationThreshold *float32 `json:"scale_down_utilization_threshold"` // MaxGracefulTerminationSec: maximum number of seconds the cluster autoscaler waits for pod termination when trying to scale down a node. MaxGracefulTerminationSec *uint32 `json:"max_graceful_termination_sec"` } // UpdateClusterRequestOpenIDConnectConfig: update cluster request open id connect config. type UpdateClusterRequestOpenIDConnectConfig struct { // IssuerURL: URL of the provider which allows the API server to discover public signing keys. Only URLs using the `https://` scheme are accepted. This is typically the provider's discovery URL without a path, for example "https://accounts.google.com" or "https://login.salesforce.com". IssuerURL *string `json:"issuer_url"` // ClientID: a client ID that all tokens must be issued for. ClientID *string `json:"client_id"` // UsernameClaim: jWT claim to use as the user name. The default is `sub`, which is expected to be the end user's unique identifier. Admins can choose other claims, such as `email` or `name`, depending on their provider. However, claims other than `email` will be prefixed with the issuer URL to prevent name collision. UsernameClaim *string `json:"username_claim"` // UsernamePrefix: prefix prepended to username claims to prevent name collision (such as `system:` users). For example, the value `oidc:` will create usernames like `oidc:jane.doe`. If this flag is not provided and `username_claim` is a value other than `email`, the prefix defaults to `( Issuer URL )#` where `( Issuer URL )` is the value of `issuer_url`. The value `-` can be used to disable all prefixing. UsernamePrefix *string `json:"username_prefix"` // GroupsClaim: jWT claim to use as the user's group. GroupsClaim *[]string `json:"groups_claim"` // GroupsPrefix: prefix prepended to group claims to prevent name collision (such as `system:` groups). For example, the value `oidc:` will create group names like `oidc:engineering` and `oidc:infra`. GroupsPrefix *string `json:"groups_prefix"` // RequiredClaim: multiple key=value pairs describing a required claim in the ID token. If set, the claims are verified to be present in the ID token with a matching value. RequiredClaim *[]string `json:"required_claim"` } // UpdatePoolRequestUpgradePolicy: update pool request upgrade policy. type UpdatePoolRequestUpgradePolicy struct { MaxUnavailable *uint32 `json:"max_unavailable"` MaxSurge *uint32 `json:"max_surge"` } // CreateClusterRequest: create cluster request. type CreateClusterRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Deprecated: OrganizationID: organization ID in which the cluster will be created. // Precisely one of ProjectID, OrganizationID must be set. OrganizationID *string `json:"organization_id,omitempty"` // ProjectID: project ID in which the cluster will be created. // Precisely one of ProjectID, OrganizationID must be set. ProjectID *string `json:"project_id,omitempty"` // Type: type of the cluster (possible values are kapsule, multicloud, kapsule-dedicated-8, kapsule-dedicated-16). Type string `json:"type"` // Name: cluster name. Name string `json:"name"` // Description: cluster description. Description string `json:"description"` // Tags: tags associated with the cluster. Tags []string `json:"tags"` // Version: kubernetes version of the cluster. Version string `json:"version"` // Cni: container Network Interface (CNI) plugin running in the cluster. // Default value: unknown_cni Cni CNI `json:"cni"` // Pools: pools created along with the cluster. Pools []*CreateClusterRequestPoolConfig `json:"pools"` // AutoscalerConfig: autoscaler configuration for the cluster. It allows you to set (to an extent) your preferred autoscaler configuration, which is an implementation of the cluster-autoscaler (https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler/). AutoscalerConfig *CreateClusterRequestAutoscalerConfig `json:"autoscaler_config,omitempty"` // AutoUpgrade: auto upgrade configuration of the cluster. This configuration enables to set a specific 2-hour time window in which the cluster can be automatically updated to the latest patch version. AutoUpgrade *CreateClusterRequestAutoUpgrade `json:"auto_upgrade,omitempty"` // FeatureGates: list of feature gates to enable. FeatureGates []string `json:"feature_gates"` // AdmissionPlugins: list of admission plugins to enable. AdmissionPlugins []string `json:"admission_plugins"` // OpenIDConnectConfig: openID Connect configuration of the cluster. This configuration enables to update the OpenID Connect configuration of the Kubernetes API server. OpenIDConnectConfig *CreateClusterRequestOpenIDConnectConfig `json:"open_id_connect_config,omitempty"` // ApiserverCertSans: additional Subject Alternative Names for the Kubernetes API server certificate. ApiserverCertSans []string `json:"apiserver_cert_sans"` // PrivateNetworkID: private network ID for internal cluster communication (cannot be changed later). PrivateNetworkID *string `json:"private_network_id,omitempty"` } // CreateExternalNodeRequest: create external node request. type CreateExternalNodeRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` PoolID string `json:"-"` } // CreatePoolRequest: create pool request. type CreatePoolRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ClusterID: cluster ID to which the pool will be attached. ClusterID string `json:"-"` // Name: pool name. Name string `json:"name"` // NodeType: node type is the type of Scaleway Instance wanted for the pool. Nodes with insufficient memory are not eligible (DEV1-S, PLAY2-PICO, STARDUST). 'external' is a special node type used to provision instances from other cloud providers in a Kosmos Cluster. NodeType string `json:"node_type"` // PlacementGroupID: placement group ID in which all the nodes of the pool will be created. PlacementGroupID *string `json:"placement_group_id,omitempty"` // Autoscaling: defines whether the autoscaling feature is enabled for the pool. Autoscaling bool `json:"autoscaling"` // Size: size (number of nodes) of the pool. Size uint32 `json:"size"` // MinSize: defines the minimum size of the pool. Note that this field is only used when autoscaling is enabled on the pool. MinSize *uint32 `json:"min_size,omitempty"` // MaxSize: defines the maximum size of the pool. Note that this field is only used when autoscaling is enabled on the pool. MaxSize *uint32 `json:"max_size,omitempty"` // ContainerRuntime: customization of the container runtime is available for each pool. Note that `docker` has been deprecated since version 1.20 and will be removed by version 1.24. // Default value: unknown_runtime ContainerRuntime Runtime `json:"container_runtime"` // Autohealing: defines whether the autohealing feature is enabled for the pool. Autohealing bool `json:"autohealing"` // Tags: tags associated with the pool. Tags []string `json:"tags"` // KubeletArgs: kubelet arguments to be used by this pool. Note that this feature is experimental. KubeletArgs map[string]string `json:"kubelet_args"` // UpgradePolicy: pool upgrade policy. UpgradePolicy *CreatePoolRequestUpgradePolicy `json:"upgrade_policy,omitempty"` // Zone: zone in which the pool's nodes will be spawned. Zone scw.Zone `json:"zone"` // RootVolumeType: defines the system volume disk type. Two different types of volume (`volume_type`) are provided: `l_ssd` is a local block storage which means your system is stored locally on your node's hypervisor. `b_ssd` is a remote block storage which means your system is stored on a centralized and resilient cluster. // Default value: default_volume_type RootVolumeType PoolVolumeType `json:"root_volume_type"` // RootVolumeSize: system volume disk size. RootVolumeSize *scw.Size `json:"root_volume_size,omitempty"` // PublicIPDisabled: defines if the public IP should be removed from Nodes. To use this feature, your Cluster must have an attached Private Network set up with a Public Gateway. PublicIPDisabled bool `json:"public_ip_disabled"` } // DeleteClusterRequest: delete cluster request. type DeleteClusterRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ClusterID: ID of the cluster to delete. ClusterID string `json:"-"` // WithAdditionalResources: defines whether all volumes (including retain volume type), empty Private Networks and Load Balancers with a name starting with the cluster ID will also be deleted. WithAdditionalResources bool `json:"with_additional_resources"` } // DeleteNodeRequest: delete node request. type DeleteNodeRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NodeID: ID of the node to replace. NodeID string `json:"-"` // SkipDrain: skip draining node from its workload (Note: this parameter is currently inactive). SkipDrain bool `json:"-"` // Replace: add a new node after the deletion of this node. Replace bool `json:"-"` } // DeletePoolRequest: delete pool request. type DeletePoolRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // PoolID: ID of the pool to delete. PoolID string `json:"-"` } // ExternalNode: external node. type ExternalNode struct { ID string `json:"id"` Name string `json:"name"` ClusterURL string `json:"cluster_url"` PoolVersion string `json:"pool_version"` ClusterCa string `json:"cluster_ca"` KubeToken string `json:"kube_token"` KubeletConfig string `json:"kubelet_config"` ExternalIP string `json:"external_ip"` ContainerdVersion string `json:"containerd_version"` RuncVersion string `json:"runc_version"` CniPluginsVersion string `json:"cni_plugins_version"` NodeLabels map[string]string `json:"node_labels"` NodeTaints []*ExternalNodeCoreV1Taint `json:"node_taints"` } // GetClusterKubeConfigRequest: get cluster kube config request. type GetClusterKubeConfigRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ClusterID: cluster ID for which to download the kubeconfig. ClusterID string `json:"-"` // Redacted: hide the legacy token from the kubeconfig. Redacted *bool `json:"redacted,omitempty"` } // GetClusterRequest: get cluster request. type GetClusterRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ClusterID: ID of the requested cluster. ClusterID string `json:"-"` } // GetNodeRequest: get node request. type GetNodeRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NodeID: ID of the requested node. NodeID string `json:"-"` } // GetPoolRequest: get pool request. type GetPoolRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // PoolID: ID of the requested pool. PoolID string `json:"-"` } // GetVersionRequest: get version request. type GetVersionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // VersionName: requested version name. VersionName string `json:"-"` } // ListClusterAvailableTypesRequest: list cluster available types request. type ListClusterAvailableTypesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ClusterID: cluster ID for which the available Kubernetes types will be listed. ClusterID string `json:"-"` } // ListClusterAvailableTypesResponse: list cluster available types response. type ListClusterAvailableTypesResponse struct { // ClusterTypes: available cluster types for the cluster. ClusterTypes []*ClusterType `json:"cluster_types"` // TotalCount: total number of types. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListClusterAvailableTypesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListClusterAvailableTypesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListClusterAvailableTypesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.ClusterTypes = append(r.ClusterTypes, results.ClusterTypes...) r.TotalCount += uint32(len(results.ClusterTypes)) return uint32(len(results.ClusterTypes)), nil } // ListClusterAvailableVersionsRequest: list cluster available versions request. type ListClusterAvailableVersionsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ClusterID: cluster ID for which the available Kubernetes versions will be listed. ClusterID string `json:"-"` } // ListClusterAvailableVersionsResponse: list cluster available versions response. type ListClusterAvailableVersionsResponse struct { // Versions: available Kubernetes versions for the cluster. Versions []*Version `json:"versions"` } // ListClusterTypesRequest: list cluster types request. type ListClusterTypesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: page number, from the paginated results, to return for cluster-types. Page *int32 `json:"-"` // PageSize: maximum number of clusters per page. PageSize *uint32 `json:"-"` } // ListClusterTypesResponse: list cluster types response. type ListClusterTypesResponse struct { // TotalCount: total number of cluster-types. TotalCount uint32 `json:"total_count"` // ClusterTypes: paginated returned cluster-types. ClusterTypes []*ClusterType `json:"cluster_types"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListClusterTypesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListClusterTypesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListClusterTypesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.ClusterTypes = append(r.ClusterTypes, results.ClusterTypes...) r.TotalCount += uint32(len(results.ClusterTypes)) return uint32(len(results.ClusterTypes)), nil } // ListClustersRequest: list clusters request. type ListClustersRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // OrganizationID: organization ID on which to filter the returned clusters. OrganizationID *string `json:"-"` // ProjectID: project ID on which to filter the returned clusters. ProjectID *string `json:"-"` // OrderBy: sort order of returned clusters. // Default value: created_at_asc OrderBy ListClustersRequestOrderBy `json:"-"` // Page: page number to return for clusters, from the paginated results. Page *int32 `json:"-"` // PageSize: maximum number of clusters per page. PageSize *uint32 `json:"-"` // Name: name to filter on, only clusters containing this substring in their name will be returned. Name *string `json:"-"` // Status: status to filter on, only clusters with this status will be returned. // Default value: unknown Status ClusterStatus `json:"-"` // Type: type to filter on, only clusters with this type will be returned. Type *string `json:"-"` // PrivateNetworkID: private Network ID to filter on, only clusters within this Private Network will be returned. PrivateNetworkID *string `json:"-"` } // ListClustersResponse: list clusters response. type ListClustersResponse struct { // TotalCount: total number of clusters. TotalCount uint32 `json:"total_count"` // Clusters: paginated returned clusters. Clusters []*Cluster `json:"clusters"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListClustersResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListClustersResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListClustersResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Clusters = append(r.Clusters, results.Clusters...) r.TotalCount += uint32(len(results.Clusters)) return uint32(len(results.Clusters)), nil } // ListNodesRequest: list nodes request. type ListNodesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ClusterID: cluster ID from which the nodes will be listed from. ClusterID string `json:"-"` // PoolID: pool ID on which to filter the returned nodes. PoolID *string `json:"-"` // OrderBy: sort order of the returned nodes. // Default value: created_at_asc OrderBy ListNodesRequestOrderBy `json:"-"` // Page: page number for the returned nodes. Page *int32 `json:"-"` // PageSize: maximum number of nodes per page. PageSize *uint32 `json:"-"` // Name: name to filter on, only nodes containing this substring in their name will be returned. Name *string `json:"-"` // Status: status to filter on, only nodes with this status will be returned. // Default value: unknown Status NodeStatus `json:"-"` } // ListNodesResponse: list nodes response. type ListNodesResponse struct { // TotalCount: total number of nodes. TotalCount uint32 `json:"total_count"` // Nodes: paginated returned nodes. Nodes []*Node `json:"nodes"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListNodesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListNodesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListNodesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Nodes = append(r.Nodes, results.Nodes...) r.TotalCount += uint32(len(results.Nodes)) return uint32(len(results.Nodes)), nil } // ListPoolsRequest: list pools request. type ListPoolsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ClusterID: ID of the cluster whose pools will be listed. ClusterID string `json:"-"` // OrderBy: sort order of returned pools. // Default value: created_at_asc OrderBy ListPoolsRequestOrderBy `json:"-"` // Page: page number for the returned pools. Page *int32 `json:"-"` // PageSize: maximum number of pools per page. PageSize *uint32 `json:"-"` // Name: name to filter on, only pools containing this substring in their name will be returned. Name *string `json:"-"` // Status: status to filter on, only pools with this status will be returned. // Default value: unknown Status PoolStatus `json:"-"` } // ListPoolsResponse: list pools response. type ListPoolsResponse struct { // TotalCount: total number of pools that exists for the cluster. TotalCount uint32 `json:"total_count"` // Pools: paginated returned pools. Pools []*Pool `json:"pools"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListPoolsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListPoolsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListPoolsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Pools = append(r.Pools, results.Pools...) r.TotalCount += uint32(len(results.Pools)) return uint32(len(results.Pools)), nil } // ListVersionsRequest: list versions request. type ListVersionsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` } // ListVersionsResponse: list versions response. type ListVersionsResponse struct { // Versions: available Kubernetes versions. Versions []*Version `json:"versions"` } // MigrateToPrivateNetworkClusterRequest: migrate to private network cluster request. type MigrateToPrivateNetworkClusterRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ClusterID: ID of the cluster to migrate. ClusterID string `json:"-"` // PrivateNetworkID: ID of the Private Network to link to the cluster. PrivateNetworkID string `json:"private_network_id"` } // RebootNodeRequest: reboot node request. type RebootNodeRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NodeID: ID of the node to reboot. NodeID string `json:"-"` } // ReplaceNodeRequest: replace node request. type ReplaceNodeRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NodeID: ID of the node to replace. NodeID string `json:"-"` } // ResetClusterAdminTokenRequest: reset cluster admin token request. type ResetClusterAdminTokenRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ClusterID: cluster ID on which the admin token will be renewed. ClusterID string `json:"-"` } // SetClusterTypeRequest: set cluster type request. type SetClusterTypeRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ClusterID: ID of the cluster to migrate from one type to another. ClusterID string `json:"-"` // Type: type of the cluster. Note that some migrations are not possible (please refer to product documentation). Type string `json:"type"` } // UpdateClusterRequest: update cluster request. type UpdateClusterRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ClusterID: ID of the cluster to update. ClusterID string `json:"-"` // Name: new external name for the cluster. Name *string `json:"name,omitempty"` // Description: new description for the cluster. Description *string `json:"description,omitempty"` // Tags: new tags associated with the cluster. Tags *[]string `json:"tags,omitempty"` // AutoscalerConfig: new autoscaler config for the cluster. AutoscalerConfig *UpdateClusterRequestAutoscalerConfig `json:"autoscaler_config,omitempty"` // AutoUpgrade: new auto upgrade configuration for the cluster. Note that all fields need to be set. AutoUpgrade *UpdateClusterRequestAutoUpgrade `json:"auto_upgrade,omitempty"` // FeatureGates: list of feature gates to enable. FeatureGates *[]string `json:"feature_gates,omitempty"` // AdmissionPlugins: list of admission plugins to enable. AdmissionPlugins *[]string `json:"admission_plugins,omitempty"` // OpenIDConnectConfig: openID Connect configuration of the cluster. This configuration enables to update the OpenID Connect configuration of the Kubernetes API server. OpenIDConnectConfig *UpdateClusterRequestOpenIDConnectConfig `json:"open_id_connect_config,omitempty"` // ApiserverCertSans: additional Subject Alternative Names for the Kubernetes API server certificate. ApiserverCertSans *[]string `json:"apiserver_cert_sans,omitempty"` } // UpdatePoolRequest: update pool request. type UpdatePoolRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // PoolID: ID of the pool to update. PoolID string `json:"-"` // Autoscaling: new value for the pool autoscaling enablement. Autoscaling *bool `json:"autoscaling,omitempty"` // Size: new desired pool size. Size *uint32 `json:"size,omitempty"` // MinSize: new minimum size for the pool. MinSize *uint32 `json:"min_size,omitempty"` // MaxSize: new maximum size for the pool. MaxSize *uint32 `json:"max_size,omitempty"` // Autohealing: new value for the pool autohealing enablement. Autohealing *bool `json:"autohealing,omitempty"` // Tags: new tags associated with the pool. Tags *[]string `json:"tags,omitempty"` // KubeletArgs: new Kubelet arguments to be used by this pool. Note that this feature is experimental. KubeletArgs *map[string]string `json:"kubelet_args,omitempty"` // UpgradePolicy: new upgrade policy for the pool. UpgradePolicy *UpdatePoolRequestUpgradePolicy `json:"upgrade_policy,omitempty"` } // UpgradeClusterRequest: upgrade cluster request. type UpgradeClusterRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ClusterID: ID of the cluster to upgrade. ClusterID string `json:"-"` // Version: new Kubernetes version of the cluster. Note that the version should either be a higher patch version of the same minor version or the direct minor version after the current one. Version string `json:"version"` // UpgradePools: defines whether pools will also be upgraded once the control plane is upgraded. UpgradePools bool `json:"upgrade_pools"` } // UpgradePoolRequest: upgrade pool request. type UpgradePoolRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // PoolID: ID of the pool to upgrade. PoolID string `json:"-"` // Version: new Kubernetes version for the pool. Version string `json:"version"` } // Kubernetes API. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Regions() []scw.Region { return []scw.Region{scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw} } // ListClusters: List all existing Kubernetes clusters in a specific region. func (s *API) ListClusters(req *ListClustersRequest, opts ...scw.RequestOption) (*ListClustersResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "status", req.Status) parameter.AddToQuery(query, "type", req.Type) parameter.AddToQuery(query, "private_network_id", req.PrivateNetworkID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters", Query: query, } var resp ListClustersResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateCluster: Create a new Kubernetes cluster in a Scaleway region. func (s *API) CreateCluster(req *CreateClusterRequest, opts ...scw.RequestOption) (*Cluster, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultProjectID, exist := s.client.GetDefaultProjectID() if exist && req.ProjectID == nil && req.OrganizationID == nil { req.ProjectID = &defaultProjectID } defaultOrganizationID, exist := s.client.GetDefaultOrganizationID() if exist && req.ProjectID == nil && req.OrganizationID == nil { req.OrganizationID = &defaultOrganizationID } if req.Name == "" { req.Name = namegenerator.GetRandomName("k8s") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Cluster err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetCluster: Retrieve information about a specific Kubernetes cluster. func (s *API) GetCluster(req *GetClusterRequest, opts ...scw.RequestOption) (*Cluster, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "", } var resp Cluster err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateCluster: Update information on a specific Kubernetes cluster. You can update details such as its name, description, tags and configuration. To upgrade a cluster, you will need to use the dedicated endpoint. func (s *API) UpdateCluster(req *UpdateClusterRequest, opts ...scw.RequestOption) (*Cluster, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Cluster err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteCluster: Delete a specific Kubernetes cluster and all its associated pools and nodes. Note that this method will not delete any Load Balancer or Block Volume that are associated with the cluster. func (s *API) DeleteCluster(req *DeleteClusterRequest, opts ...scw.RequestOption) (*Cluster, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } query := url.Values{} parameter.AddToQuery(query, "with_additional_resources", req.WithAdditionalResources) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "", Query: query, } var resp Cluster err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpgradeCluster: Upgrade a specific Kubernetes cluster and possibly its associated pools to a specific and supported Kubernetes version. func (s *API) UpgradeCluster(req *UpgradeClusterRequest, opts ...scw.RequestOption) (*Cluster, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/upgrade", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Cluster err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SetClusterType: Change the type of a specific Kubernetes cluster. To see the possible values you can enter for the `type` field, [list available cluster types](#path-clusters-list-available-cluster-types-for-a-cluster). func (s *API) SetClusterType(req *SetClusterTypeRequest, opts ...scw.RequestOption) (*Cluster, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/set-type", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Cluster err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListClusterAvailableVersions: List the versions that a specific Kubernetes cluster is allowed to upgrade to. Results will include every patch version greater than the current patch, as well as one minor version ahead of the current version. Any upgrade skipping a minor version will not work. func (s *API) ListClusterAvailableVersions(req *ListClusterAvailableVersionsRequest, opts ...scw.RequestOption) (*ListClusterAvailableVersionsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/available-versions", } var resp ListClusterAvailableVersionsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListClusterAvailableTypes: List the cluster types that a specific Kubernetes cluster is allowed to switch to. func (s *API) ListClusterAvailableTypes(req *ListClusterAvailableTypesRequest, opts ...scw.RequestOption) (*ListClusterAvailableTypesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/available-types", } var resp ListClusterAvailableTypesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // getClusterKubeConfig: Download the Kubernetes cluster config file (also known as `kubeconfig`) for a specific cluster to use it with `kubectl`. // Tip: add `?dl=1` at the end of the URL to directly retrieve the base64 decoded kubeconfig. If you choose not to, the kubeconfig will be base64 encoded. func (s *API) getClusterKubeConfig(req *GetClusterKubeConfigRequest, opts ...scw.RequestOption) (*scw.File, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } query := url.Values{} parameter.AddToQuery(query, "redacted", req.Redacted) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/kubeconfig", Query: query, } var resp scw.File err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ResetClusterAdminToken: Reset the admin token for a specific Kubernetes cluster. This will revoke the old admin token (which will not be usable afterwards) and create a new one. Note that you will need to download kubeconfig again to keep interacting with the cluster. func (s *API) ResetClusterAdminToken(req *ResetClusterAdminTokenRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/reset-admin-token", } err = scwReq.SetBody(req) if err != nil { return err } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // MigrateToPrivateNetworkCluster: Migrate a cluster that was created before the release of Private Network clusters to a new one with a Private Network. func (s *API) MigrateToPrivateNetworkCluster(req *MigrateToPrivateNetworkClusterRequest, opts ...scw.RequestOption) (*Cluster, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/migrate-to-private-network", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Cluster err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListPools: List all the existing pools for a specific Kubernetes cluster. func (s *API) ListPools(req *ListPoolsRequest, opts ...scw.RequestOption) (*ListPoolsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "status", req.Status) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/pools", Query: query, } var resp ListPoolsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreatePool: Create a new pool in a specific Kubernetes cluster. func (s *API) CreatePool(req *CreatePoolRequest, opts ...scw.RequestOption) (*Pool, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if req.Name == "" { req.Name = namegenerator.GetRandomName("pool") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/pools", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Pool err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetPool: Retrieve details about a specific pool in a Kubernetes cluster. func (s *API) GetPool(req *GetPoolRequest, opts ...scw.RequestOption) (*Pool, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.PoolID) == "" { return nil, errors.New("field PoolID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/pools/" + fmt.Sprint(req.PoolID) + "", } var resp Pool err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpgradePool: Upgrade the Kubernetes version of a specific pool. Note that it only works if the targeted version matches the cluster's version. func (s *API) UpgradePool(req *UpgradePoolRequest, opts ...scw.RequestOption) (*Pool, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.PoolID) == "" { return nil, errors.New("field PoolID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/pools/" + fmt.Sprint(req.PoolID) + "/upgrade", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Pool err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdatePool: Update the attributes of a specific pool, such as its desired size, autoscaling settings, and tags. func (s *API) UpdatePool(req *UpdatePoolRequest, opts ...scw.RequestOption) (*Pool, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.PoolID) == "" { return nil, errors.New("field PoolID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/pools/" + fmt.Sprint(req.PoolID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Pool err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeletePool: Delete a specific pool from a cluster. Note that all the pool's nodes will also be deleted. func (s *API) DeletePool(req *DeletePoolRequest, opts ...scw.RequestOption) (*Pool, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.PoolID) == "" { return nil, errors.New("field PoolID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/pools/" + fmt.Sprint(req.PoolID) + "", } var resp Pool err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateExternalNode: Retrieve metadata for a Kosmos node. This method is not intended to be called by end users but rather programmatically by the kapsule-node-agent. func (s *API) CreateExternalNode(req *CreateExternalNodeRequest, opts ...scw.RequestOption) (*ExternalNode, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.PoolID) == "" { return nil, errors.New("field PoolID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/pools/" + fmt.Sprint(req.PoolID) + "/external-nodes", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp ExternalNode err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListNodes: List all the existing nodes for a specific Kubernetes cluster. func (s *API) ListNodes(req *ListNodesRequest, opts ...scw.RequestOption) (*ListNodesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "pool_id", req.PoolID) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "status", req.Status) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/nodes", Query: query, } var resp ListNodesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetNode: Retrieve details about a specific Kubernetes Node. func (s *API) GetNode(req *GetNodeRequest, opts ...scw.RequestOption) (*Node, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NodeID) == "" { return nil, errors.New("field NodeID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/nodes/" + fmt.Sprint(req.NodeID) + "", } var resp Node err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // Deprecated: ReplaceNode: Replace a specific Node. The node will first be cordoned (scheduling will be disabled on it). The existing pods on the node will then be drained and rescheduled onto another schedulable node. Note that when there is not enough space to reschedule all the pods (such as in a one-node cluster), disruption of your applications can be expected. func (s *API) ReplaceNode(req *ReplaceNodeRequest, opts ...scw.RequestOption) (*Node, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NodeID) == "" { return nil, errors.New("field NodeID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/nodes/" + fmt.Sprint(req.NodeID) + "/replace", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Node err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // RebootNode: Reboot a specific Node. The node will first be cordoned (scheduling will be disabled on it). The existing pods on the node will then be drained and rescheduled onto another schedulable node. Note that when there is not enough space to reschedule all the pods (such as in a one-node cluster), disruption of your applications can be expected. func (s *API) RebootNode(req *RebootNodeRequest, opts ...scw.RequestOption) (*Node, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NodeID) == "" { return nil, errors.New("field NodeID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/nodes/" + fmt.Sprint(req.NodeID) + "/reboot", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Node err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteNode: Delete a specific Node. Note that when there is not enough space to reschedule all the pods (such as in a one-node cluster), disruption of your applications can be expected. func (s *API) DeleteNode(req *DeleteNodeRequest, opts ...scw.RequestOption) (*Node, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } query := url.Values{} parameter.AddToQuery(query, "skip_drain", req.SkipDrain) parameter.AddToQuery(query, "replace", req.Replace) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NodeID) == "" { return nil, errors.New("field NodeID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/nodes/" + fmt.Sprint(req.NodeID) + "", Query: query, } var resp Node err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListVersions: List all available versions for the creation of a new Kubernetes cluster. func (s *API) ListVersions(req *ListVersionsRequest, opts ...scw.RequestOption) (*ListVersionsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/versions", } var resp ListVersionsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetVersion: Retrieve a specific Kubernetes version and its details. func (s *API) GetVersion(req *GetVersionRequest, opts ...scw.RequestOption) (*Version, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.VersionName) == "" { return nil, errors.New("field VersionName cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/versions/" + fmt.Sprint(req.VersionName) + "", } var resp Version err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListClusterTypes: List available cluster types and their technical details. func (s *API) ListClusterTypes(req *ListClusterTypesRequest, opts ...scw.RequestOption) (*ListClusterTypesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/k8s/v1/regions/" + fmt.Sprint(req.Region) + "/cluster-types", Query: query, } var resp ListClusterTypesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/k8s/v1/kubeconfig.go000066400000000000000000000073751456366605600265410ustar00rootroot00000000000000package k8s import ( "io/ioutil" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" "gopkg.in/yaml.v2" ) // Kubeconfig represents a kubernetes kubeconfig file type Kubeconfig struct { raw []byte APIVersion string `yaml:"apiVersion"` Kind string `yaml:"kind"` CurrentContext string `yaml:"current-context"` Clusters []*KubeconfigClusterWithName `yaml:"clusters"` Contexts []*KubeconfigContextWithName `yaml:"contexts"` Users []*KubeconfigUserWithName `yaml:"users"` } // KubeconfigUserWithName represents a named cluster in the kubeconfig file type KubeconfigClusterWithName struct { Name string `yaml:"name"` Cluster KubeconfigCluster `yaml:"cluster"` } // KubeconfigCluster represents a cluster in the kubeconfig file type KubeconfigCluster struct { Server string `yaml:"server,omitempty"` CertificateAuthorityData string `yaml:"certificate-authority-data,omitempty"` } // KubeconfigContextWithName represents a named context in the kubeconfig file type KubeconfigContextWithName struct { Name string `yaml:"name"` Context KubeconfigContext `yaml:"context"` } // KubeconfigContext represents a context in the kubeconfig file type KubeconfigContext struct { Cluster string `yaml:"cluster"` Namespace string `yaml:"namespace,omitempty"` User string `yaml:"user"` } // KubeconfigUserWithName represents a named user in the kubeconfig file type KubeconfigUserWithName struct { Name string `yaml:"name"` User KubeconfigUser `yaml:"user"` } // KubeconfigUser represents a user in the kubeconfig file type KubeconfigUser struct { ClientCertificateData string `yaml:"client-certificate-data,omitempty"` ClientKeyData string `yaml:"client-key-data,omitempty"` Password string `yaml:"password,omitempty"` Username string `yaml:"username,omitempty"` Token string `yaml:"token,omitempty"` } // GetRaw returns the raw bytes of the kubeconfig func (k *Kubeconfig) GetRaw() []byte { return k.raw } // GetServer returns the server URL of the cluster in the kubeconfig func (k *Kubeconfig) GetServer() (string, error) { if len(k.Clusters) != 1 { return "", errors.New("kubeconfig should have only one cluster") } return k.Clusters[0].Cluster.Server, nil } // GetCertificateAuthorityData returns the server certificate authority data of the cluster in the kubeconfig func (k *Kubeconfig) GetCertificateAuthorityData() (string, error) { if len(k.Clusters) != 1 { return "", errors.New("kubeconfig should have only one cluster") } return k.Clusters[0].Cluster.CertificateAuthorityData, nil } // GetToken returns the token for the cluster in the kubeconfig func (k *Kubeconfig) GetToken() (string, error) { if len(k.Users) != 1 { return "", errors.New("kubeconfig should have only one user") } return k.Users[0].User.Token, nil } // GetClusterKubeConfig downloads the kubeconfig for the given cluster func (s *API) GetClusterKubeConfig(req *GetClusterKubeConfigRequest, opts ...scw.RequestOption) (*Kubeconfig, error) { kubeconfigFile, err := s.getClusterKubeConfig(&GetClusterKubeConfigRequest{ Region: req.Region, ClusterID: req.ClusterID, }) if err != nil { return nil, errors.Wrap(err, "error getting cluster kubeconfig") } kubeconfigContent, err := ioutil.ReadAll(kubeconfigFile.Content) if err != nil { return nil, errors.Wrap(err, "error reading kubeconfig content") } var kubeconfig Kubeconfig err = yaml.Unmarshal(kubeconfigContent, &kubeconfig) if err != nil { return nil, errors.Wrap(err, "error unmarshaling kubeconfig") } kubeconfig.raw = kubeconfigContent return &kubeconfig, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/lb/000077500000000000000000000000001456366605600234245ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/lb/v1/000077500000000000000000000000001456366605600237525ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/lb/v1/lb_sdk.go000066400000000000000000007521531456366605600255540ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package lb provides methods and message types of the lb v1 API. package lb import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type ACLActionRedirectRedirectType string const ( ACLActionRedirectRedirectTypeLocation = ACLActionRedirectRedirectType("location") ACLActionRedirectRedirectTypeScheme = ACLActionRedirectRedirectType("scheme") ) func (enum ACLActionRedirectRedirectType) String() string { if enum == "" { // return default value if empty return "location" } return string(enum) } func (enum ACLActionRedirectRedirectType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ACLActionRedirectRedirectType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ACLActionRedirectRedirectType(ACLActionRedirectRedirectType(tmp).String()) return nil } type ACLActionType string const ( ACLActionTypeAllow = ACLActionType("allow") ACLActionTypeDeny = ACLActionType("deny") ACLActionTypeRedirect = ACLActionType("redirect") ) func (enum ACLActionType) String() string { if enum == "" { // return default value if empty return "allow" } return string(enum) } func (enum ACLActionType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ACLActionType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ACLActionType(ACLActionType(tmp).String()) return nil } type ACLHTTPFilter string const ( ACLHTTPFilterACLHTTPFilterNone = ACLHTTPFilter("acl_http_filter_none") ACLHTTPFilterPathBegin = ACLHTTPFilter("path_begin") ACLHTTPFilterPathEnd = ACLHTTPFilter("path_end") ACLHTTPFilterRegex = ACLHTTPFilter("regex") ACLHTTPFilterHTTPHeaderMatch = ACLHTTPFilter("http_header_match") ) func (enum ACLHTTPFilter) String() string { if enum == "" { // return default value if empty return "acl_http_filter_none" } return string(enum) } func (enum ACLHTTPFilter) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ACLHTTPFilter) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ACLHTTPFilter(ACLHTTPFilter(tmp).String()) return nil } type BackendServerStatsHealthCheckStatus string const ( BackendServerStatsHealthCheckStatusUnknown = BackendServerStatsHealthCheckStatus("unknown") BackendServerStatsHealthCheckStatusNeutral = BackendServerStatsHealthCheckStatus("neutral") BackendServerStatsHealthCheckStatusFailed = BackendServerStatsHealthCheckStatus("failed") BackendServerStatsHealthCheckStatusPassed = BackendServerStatsHealthCheckStatus("passed") BackendServerStatsHealthCheckStatusCondpass = BackendServerStatsHealthCheckStatus("condpass") ) func (enum BackendServerStatsHealthCheckStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum BackendServerStatsHealthCheckStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *BackendServerStatsHealthCheckStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = BackendServerStatsHealthCheckStatus(BackendServerStatsHealthCheckStatus(tmp).String()) return nil } type BackendServerStatsServerState string const ( BackendServerStatsServerStateStopped = BackendServerStatsServerState("stopped") BackendServerStatsServerStateStarting = BackendServerStatsServerState("starting") BackendServerStatsServerStateRunning = BackendServerStatsServerState("running") BackendServerStatsServerStateStopping = BackendServerStatsServerState("stopping") ) func (enum BackendServerStatsServerState) String() string { if enum == "" { // return default value if empty return "stopped" } return string(enum) } func (enum BackendServerStatsServerState) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *BackendServerStatsServerState) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = BackendServerStatsServerState(BackendServerStatsServerState(tmp).String()) return nil } type CertificateStatus string const ( CertificateStatusPending = CertificateStatus("pending") CertificateStatusReady = CertificateStatus("ready") CertificateStatusError = CertificateStatus("error") ) func (enum CertificateStatus) String() string { if enum == "" { // return default value if empty return "pending" } return string(enum) } func (enum CertificateStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *CertificateStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = CertificateStatus(CertificateStatus(tmp).String()) return nil } type CertificateType string const ( CertificateTypeLetsencryt = CertificateType("letsencryt") CertificateTypeCustom = CertificateType("custom") ) func (enum CertificateType) String() string { if enum == "" { // return default value if empty return "letsencryt" } return string(enum) } func (enum CertificateType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *CertificateType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = CertificateType(CertificateType(tmp).String()) return nil } type ForwardPortAlgorithm string const ( ForwardPortAlgorithmRoundrobin = ForwardPortAlgorithm("roundrobin") ForwardPortAlgorithmLeastconn = ForwardPortAlgorithm("leastconn") ForwardPortAlgorithmFirst = ForwardPortAlgorithm("first") ) func (enum ForwardPortAlgorithm) String() string { if enum == "" { // return default value if empty return "roundrobin" } return string(enum) } func (enum ForwardPortAlgorithm) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ForwardPortAlgorithm) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ForwardPortAlgorithm(ForwardPortAlgorithm(tmp).String()) return nil } type InstanceStatus string const ( InstanceStatusUnknown = InstanceStatus("unknown") InstanceStatusReady = InstanceStatus("ready") InstanceStatusPending = InstanceStatus("pending") InstanceStatusStopped = InstanceStatus("stopped") InstanceStatusError = InstanceStatus("error") InstanceStatusLocked = InstanceStatus("locked") InstanceStatusMigrating = InstanceStatus("migrating") ) func (enum InstanceStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum InstanceStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *InstanceStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = InstanceStatus(InstanceStatus(tmp).String()) return nil } type LBStatus string const ( LBStatusUnknown = LBStatus("unknown") LBStatusReady = LBStatus("ready") LBStatusPending = LBStatus("pending") LBStatusStopped = LBStatus("stopped") LBStatusError = LBStatus("error") LBStatusLocked = LBStatus("locked") LBStatusMigrating = LBStatus("migrating") LBStatusToCreate = LBStatus("to_create") LBStatusCreating = LBStatus("creating") LBStatusToDelete = LBStatus("to_delete") LBStatusDeleting = LBStatus("deleting") ) func (enum LBStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum LBStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *LBStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = LBStatus(LBStatus(tmp).String()) return nil } type LBTypeStock string const ( LBTypeStockUnknown = LBTypeStock("unknown") LBTypeStockLowStock = LBTypeStock("low_stock") LBTypeStockOutOfStock = LBTypeStock("out_of_stock") LBTypeStockAvailable = LBTypeStock("available") ) func (enum LBTypeStock) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum LBTypeStock) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *LBTypeStock) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = LBTypeStock(LBTypeStock(tmp).String()) return nil } type ListACLRequestOrderBy string const ( ListACLRequestOrderByCreatedAtAsc = ListACLRequestOrderBy("created_at_asc") ListACLRequestOrderByCreatedAtDesc = ListACLRequestOrderBy("created_at_desc") ListACLRequestOrderByNameAsc = ListACLRequestOrderBy("name_asc") ListACLRequestOrderByNameDesc = ListACLRequestOrderBy("name_desc") ) func (enum ListACLRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListACLRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListACLRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListACLRequestOrderBy(ListACLRequestOrderBy(tmp).String()) return nil } type ListBackendsRequestOrderBy string const ( ListBackendsRequestOrderByCreatedAtAsc = ListBackendsRequestOrderBy("created_at_asc") ListBackendsRequestOrderByCreatedAtDesc = ListBackendsRequestOrderBy("created_at_desc") ListBackendsRequestOrderByNameAsc = ListBackendsRequestOrderBy("name_asc") ListBackendsRequestOrderByNameDesc = ListBackendsRequestOrderBy("name_desc") ) func (enum ListBackendsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListBackendsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListBackendsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListBackendsRequestOrderBy(ListBackendsRequestOrderBy(tmp).String()) return nil } type ListCertificatesRequestOrderBy string const ( ListCertificatesRequestOrderByCreatedAtAsc = ListCertificatesRequestOrderBy("created_at_asc") ListCertificatesRequestOrderByCreatedAtDesc = ListCertificatesRequestOrderBy("created_at_desc") ListCertificatesRequestOrderByNameAsc = ListCertificatesRequestOrderBy("name_asc") ListCertificatesRequestOrderByNameDesc = ListCertificatesRequestOrderBy("name_desc") ) func (enum ListCertificatesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListCertificatesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListCertificatesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListCertificatesRequestOrderBy(ListCertificatesRequestOrderBy(tmp).String()) return nil } type ListFrontendsRequestOrderBy string const ( ListFrontendsRequestOrderByCreatedAtAsc = ListFrontendsRequestOrderBy("created_at_asc") ListFrontendsRequestOrderByCreatedAtDesc = ListFrontendsRequestOrderBy("created_at_desc") ListFrontendsRequestOrderByNameAsc = ListFrontendsRequestOrderBy("name_asc") ListFrontendsRequestOrderByNameDesc = ListFrontendsRequestOrderBy("name_desc") ) func (enum ListFrontendsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListFrontendsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListFrontendsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListFrontendsRequestOrderBy(ListFrontendsRequestOrderBy(tmp).String()) return nil } type ListIPsRequestIPType string const ( ListIPsRequestIPTypeAll = ListIPsRequestIPType("all") ListIPsRequestIPTypeIPv4 = ListIPsRequestIPType("ipv4") ListIPsRequestIPTypeIPv6 = ListIPsRequestIPType("ipv6") ) func (enum ListIPsRequestIPType) String() string { if enum == "" { // return default value if empty return "all" } return string(enum) } func (enum ListIPsRequestIPType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListIPsRequestIPType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListIPsRequestIPType(ListIPsRequestIPType(tmp).String()) return nil } type ListLBsRequestOrderBy string const ( ListLBsRequestOrderByCreatedAtAsc = ListLBsRequestOrderBy("created_at_asc") ListLBsRequestOrderByCreatedAtDesc = ListLBsRequestOrderBy("created_at_desc") ListLBsRequestOrderByNameAsc = ListLBsRequestOrderBy("name_asc") ListLBsRequestOrderByNameDesc = ListLBsRequestOrderBy("name_desc") ) func (enum ListLBsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListLBsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListLBsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListLBsRequestOrderBy(ListLBsRequestOrderBy(tmp).String()) return nil } type ListPrivateNetworksRequestOrderBy string const ( ListPrivateNetworksRequestOrderByCreatedAtAsc = ListPrivateNetworksRequestOrderBy("created_at_asc") ListPrivateNetworksRequestOrderByCreatedAtDesc = ListPrivateNetworksRequestOrderBy("created_at_desc") ) func (enum ListPrivateNetworksRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListPrivateNetworksRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListPrivateNetworksRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListPrivateNetworksRequestOrderBy(ListPrivateNetworksRequestOrderBy(tmp).String()) return nil } type ListRoutesRequestOrderBy string const ( ListRoutesRequestOrderByCreatedAtAsc = ListRoutesRequestOrderBy("created_at_asc") ListRoutesRequestOrderByCreatedAtDesc = ListRoutesRequestOrderBy("created_at_desc") ) func (enum ListRoutesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListRoutesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListRoutesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListRoutesRequestOrderBy(ListRoutesRequestOrderBy(tmp).String()) return nil } type ListSubscriberRequestOrderBy string const ( ListSubscriberRequestOrderByCreatedAtAsc = ListSubscriberRequestOrderBy("created_at_asc") ListSubscriberRequestOrderByCreatedAtDesc = ListSubscriberRequestOrderBy("created_at_desc") ListSubscriberRequestOrderByNameAsc = ListSubscriberRequestOrderBy("name_asc") ListSubscriberRequestOrderByNameDesc = ListSubscriberRequestOrderBy("name_desc") ) func (enum ListSubscriberRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListSubscriberRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListSubscriberRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListSubscriberRequestOrderBy(ListSubscriberRequestOrderBy(tmp).String()) return nil } type OnMarkedDownAction string const ( OnMarkedDownActionOnMarkedDownActionNone = OnMarkedDownAction("on_marked_down_action_none") OnMarkedDownActionShutdownSessions = OnMarkedDownAction("shutdown_sessions") ) func (enum OnMarkedDownAction) String() string { if enum == "" { // return default value if empty return "on_marked_down_action_none" } return string(enum) } func (enum OnMarkedDownAction) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *OnMarkedDownAction) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = OnMarkedDownAction(OnMarkedDownAction(tmp).String()) return nil } type PrivateNetworkStatus string const ( PrivateNetworkStatusUnknown = PrivateNetworkStatus("unknown") PrivateNetworkStatusReady = PrivateNetworkStatus("ready") PrivateNetworkStatusPending = PrivateNetworkStatus("pending") PrivateNetworkStatusError = PrivateNetworkStatus("error") ) func (enum PrivateNetworkStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum PrivateNetworkStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *PrivateNetworkStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = PrivateNetworkStatus(PrivateNetworkStatus(tmp).String()) return nil } type Protocol string const ( ProtocolTCP = Protocol("tcp") ProtocolHTTP = Protocol("http") ) func (enum Protocol) String() string { if enum == "" { // return default value if empty return "tcp" } return string(enum) } func (enum Protocol) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *Protocol) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = Protocol(Protocol(tmp).String()) return nil } type ProxyProtocol string const ( ProxyProtocolProxyProtocolUnknown = ProxyProtocol("proxy_protocol_unknown") ProxyProtocolProxyProtocolNone = ProxyProtocol("proxy_protocol_none") ProxyProtocolProxyProtocolV1 = ProxyProtocol("proxy_protocol_v1") ProxyProtocolProxyProtocolV2 = ProxyProtocol("proxy_protocol_v2") ProxyProtocolProxyProtocolV2Ssl = ProxyProtocol("proxy_protocol_v2_ssl") ProxyProtocolProxyProtocolV2SslCn = ProxyProtocol("proxy_protocol_v2_ssl_cn") ) func (enum ProxyProtocol) String() string { if enum == "" { // return default value if empty return "proxy_protocol_unknown" } return string(enum) } func (enum ProxyProtocol) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ProxyProtocol) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ProxyProtocol(ProxyProtocol(tmp).String()) return nil } type SSLCompatibilityLevel string const ( SSLCompatibilityLevelSslCompatibilityLevelUnknown = SSLCompatibilityLevel("ssl_compatibility_level_unknown") SSLCompatibilityLevelSslCompatibilityLevelIntermediate = SSLCompatibilityLevel("ssl_compatibility_level_intermediate") SSLCompatibilityLevelSslCompatibilityLevelModern = SSLCompatibilityLevel("ssl_compatibility_level_modern") SSLCompatibilityLevelSslCompatibilityLevelOld = SSLCompatibilityLevel("ssl_compatibility_level_old") ) func (enum SSLCompatibilityLevel) String() string { if enum == "" { // return default value if empty return "ssl_compatibility_level_unknown" } return string(enum) } func (enum SSLCompatibilityLevel) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *SSLCompatibilityLevel) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = SSLCompatibilityLevel(SSLCompatibilityLevel(tmp).String()) return nil } type StickySessionsType string const ( StickySessionsTypeNone = StickySessionsType("none") StickySessionsTypeCookie = StickySessionsType("cookie") StickySessionsTypeTable = StickySessionsType("table") ) func (enum StickySessionsType) String() string { if enum == "" { // return default value if empty return "none" } return string(enum) } func (enum StickySessionsType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *StickySessionsType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = StickySessionsType(StickySessionsType(tmp).String()) return nil } // SubscriberEmailConfig: subscriber email config. type SubscriberEmailConfig struct { // Email: email address to send alerts to. Email string `json:"email"` } // SubscriberWebhookConfig: Webhook alert of subscriber. type SubscriberWebhookConfig struct { // URI: URI to receive POST requests. URI string `json:"uri"` } // HealthCheckHTTPConfig: health check http config. type HealthCheckHTTPConfig struct { // URI: the HTTP URI to use when performing a health check on backend servers. URI string `json:"uri"` // Method: the HTTP method used when performing a health check on backend servers. Method string `json:"method"` // Code: the HTTP response code that should be returned for a health check to be considered successful. Code *int32 `json:"code"` // HostHeader: the HTTP host header used when performing a health check on backend servers. HostHeader string `json:"host_header"` } // HealthCheckHTTPSConfig: health check https config. type HealthCheckHTTPSConfig struct { // URI: the HTTP URI to use when performing a health check on backend servers. URI string `json:"uri"` // Method: the HTTP method used when performing a health check on backend servers. Method string `json:"method"` // Code: the HTTP response code that should be returned for a health check to be considered successful. Code *int32 `json:"code"` // HostHeader: the HTTP host header used when performing a health check on backend servers. HostHeader string `json:"host_header"` // Sni: the SNI value used when performing a health check on backend servers over SSL. Sni string `json:"sni"` } // HealthCheckLdapConfig: health check ldap config. type HealthCheckLdapConfig struct { } // HealthCheckMysqlConfig: health check mysql config. type HealthCheckMysqlConfig struct { // User: mySQL user to use for the health check. User string `json:"user"` } // HealthCheckPgsqlConfig: health check pgsql config. type HealthCheckPgsqlConfig struct { // User: postgreSQL user to use for the health check. User string `json:"user"` } // HealthCheckRedisConfig: health check redis config. type HealthCheckRedisConfig struct { } // HealthCheckTCPConfig: health check tcp config. type HealthCheckTCPConfig struct { } // IP: ip. type IP struct { // ID: IP address ID. ID string `json:"id"` // IPAddress: IP address. IPAddress string `json:"ip_address"` // OrganizationID: organization ID of the Scaleway Organization the IP address is in. OrganizationID string `json:"organization_id"` // ProjectID: project ID of the Scaleway Project the IP address is in. ProjectID string `json:"project_id"` // LBID: load Balancer ID. LBID *string `json:"lb_id"` // Reverse: reverse DNS (domain name) of the IP address. Reverse string `json:"reverse"` // Deprecated: Region: the region the IP address is in. Region *scw.Region `json:"region,omitempty"` // Zone: the zone the IP address is in. Zone scw.Zone `json:"zone"` } // Instance: instance. type Instance struct { // ID: underlying Instance ID. ID string `json:"id"` // Status: instance status. // Default value: unknown Status InstanceStatus `json:"status"` // IPAddress: instance IP address. IPAddress string `json:"ip_address"` // CreatedAt: date on which the Instance was created. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date on which the Instance was last updated. UpdatedAt *time.Time `json:"updated_at"` // Deprecated: Region: the region the Instance is in. Region *scw.Region `json:"region,omitempty"` // Zone: the zone the Instance is in. Zone scw.Zone `json:"zone"` } // Subscriber: Subscriber. type Subscriber struct { // ID: subscriber ID. ID string `json:"id"` // Name: subscriber name. Name string `json:"name"` // EmailConfig: email address of subscriber. // Precisely one of EmailConfig, WebhookConfig must be set. EmailConfig *SubscriberEmailConfig `json:"email_config,omitempty"` // WebhookConfig: webhook URI of subscriber. // Precisely one of EmailConfig, WebhookConfig must be set. WebhookConfig *SubscriberWebhookConfig `json:"webhook_config,omitempty"` } // HealthCheck: health check. type HealthCheck struct { // Port: port to use for the backend server health check. Port int32 `json:"port"` // CheckDelay: time to wait between two consecutive health checks. CheckDelay *time.Duration `json:"check_delay"` // CheckTimeout: maximum time a backend server has to reply to the health check. CheckTimeout *time.Duration `json:"check_timeout"` // CheckMaxRetries: number of consecutive unsuccessful health checks after which the server will be considered dead. CheckMaxRetries int32 `json:"check_max_retries"` // TCPConfig: object to configure a basic TCP health check. // Precisely one of TCPConfig, MysqlConfig, PgsqlConfig, LdapConfig, RedisConfig, HTTPConfig, HTTPSConfig must be set. TCPConfig *HealthCheckTCPConfig `json:"tcp_config,omitempty"` // MysqlConfig: object to configure a MySQL health check. The check requires MySQL >=3.22, for older versions, use a TCP health check. // Precisely one of TCPConfig, MysqlConfig, PgsqlConfig, LdapConfig, RedisConfig, HTTPConfig, HTTPSConfig must be set. MysqlConfig *HealthCheckMysqlConfig `json:"mysql_config,omitempty"` // PgsqlConfig: object to configure a PostgreSQL health check. // Precisely one of TCPConfig, MysqlConfig, PgsqlConfig, LdapConfig, RedisConfig, HTTPConfig, HTTPSConfig must be set. PgsqlConfig *HealthCheckPgsqlConfig `json:"pgsql_config,omitempty"` // LdapConfig: object to configure an LDAP health check. The response is analyzed to find the LDAPv3 response message. // Precisely one of TCPConfig, MysqlConfig, PgsqlConfig, LdapConfig, RedisConfig, HTTPConfig, HTTPSConfig must be set. LdapConfig *HealthCheckLdapConfig `json:"ldap_config,omitempty"` // RedisConfig: object to configure a Redis health check. The response is analyzed to find the +PONG response message. // Precisely one of TCPConfig, MysqlConfig, PgsqlConfig, LdapConfig, RedisConfig, HTTPConfig, HTTPSConfig must be set. RedisConfig *HealthCheckRedisConfig `json:"redis_config,omitempty"` // HTTPConfig: object to configure an HTTP health check. // Precisely one of TCPConfig, MysqlConfig, PgsqlConfig, LdapConfig, RedisConfig, HTTPConfig, HTTPSConfig must be set. HTTPConfig *HealthCheckHTTPConfig `json:"http_config,omitempty"` // HTTPSConfig: object to configure an HTTPS health check. // Precisely one of TCPConfig, MysqlConfig, PgsqlConfig, LdapConfig, RedisConfig, HTTPConfig, HTTPSConfig must be set. HTTPSConfig *HealthCheckHTTPSConfig `json:"https_config,omitempty"` // CheckSendProxy: defines whether proxy protocol should be activated for the health check. CheckSendProxy bool `json:"check_send_proxy"` // TransientCheckDelay: time to wait between two consecutive health checks when a backend server is in a transient state (going UP or DOWN). TransientCheckDelay *scw.Duration `json:"transient_check_delay"` } func (m *HealthCheck) UnmarshalJSON(b []byte) error { type tmpType HealthCheck tmp := struct { tmpType TmpCheckDelay *marshaler.Duration `json:"check_delay"` TmpCheckTimeout *marshaler.Duration `json:"check_timeout"` }{} err := json.Unmarshal(b, &tmp) if err != nil { return err } *m = HealthCheck(tmp.tmpType) m.CheckDelay = tmp.TmpCheckDelay.Standard() m.CheckTimeout = tmp.TmpCheckTimeout.Standard() return nil } func (m HealthCheck) MarshalJSON() ([]byte, error) { type tmpType HealthCheck tmp := struct { tmpType TmpCheckDelay *marshaler.Duration `json:"check_delay"` TmpCheckTimeout *marshaler.Duration `json:"check_timeout"` }{ tmpType: tmpType(m), TmpCheckDelay: marshaler.NewDuration(m.CheckDelay), TmpCheckTimeout: marshaler.NewDuration(m.CheckTimeout), } return json.Marshal(tmp) } // LB: lb. type LB struct { // ID: underlying Instance ID. ID string `json:"id"` // Name: load Balancer name. Name string `json:"name"` // Description: load Balancer description. Description string `json:"description"` // Status: load Balancer status. // Default value: unknown Status LBStatus `json:"status"` // Instances: list of underlying Instances. Instances []*Instance `json:"instances"` // OrganizationID: scaleway Organization ID. OrganizationID string `json:"organization_id"` // ProjectID: scaleway Project ID. ProjectID string `json:"project_id"` // IP: list of IP addresses attached to the Load Balancer. IP []*IP `json:"ip"` // Tags: load Balancer tags. Tags []string `json:"tags"` // FrontendCount: number of frontends the Load Balancer has. FrontendCount int32 `json:"frontend_count"` // BackendCount: number of backends the Load Balancer has. BackendCount int32 `json:"backend_count"` // Type: load Balancer offer type. Type string `json:"type"` // Subscriber: subscriber information. Subscriber *Subscriber `json:"subscriber"` // SslCompatibilityLevel: determines the minimal SSL version which needs to be supported on client side. // Default value: ssl_compatibility_level_unknown SslCompatibilityLevel SSLCompatibilityLevel `json:"ssl_compatibility_level"` // CreatedAt: date on which the Load Balancer was created. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date on which the Load Balancer was last updated. UpdatedAt *time.Time `json:"updated_at"` // PrivateNetworkCount: number of Private Networks attached to the Load Balancer. PrivateNetworkCount int32 `json:"private_network_count"` // RouteCount: number of routes configured on the Load Balancer. RouteCount int32 `json:"route_count"` // Deprecated: Region: the region the Load Balancer is in. Region *scw.Region `json:"region,omitempty"` // Zone: the zone the Load Balancer is in. Zone scw.Zone `json:"zone"` } // ACLActionRedirect: acl action redirect. type ACLActionRedirect struct { // Type: redirect type. // Default value: location Type ACLActionRedirectRedirectType `json:"type"` // Target: redirect target. For a location redirect, you can use a URL e.g. `https://scaleway.com`. Using a scheme name (e.g. `https`, `http`, `ftp`, `git`) will replace the request's original scheme. This can be useful to implement HTTP to HTTPS redirects. Valid placeholders that can be used in a `location` redirect to preserve parts of the original request in the redirection URL are \{\{host\}\}, \{\{query\}\}, \{\{path\}\} and \{\{scheme\}\}. Target string `json:"target"` // Code: HTTP redirect code to use. Valid values are 301, 302, 303, 307 and 308. Default value is 302. Code *int32 `json:"code"` } // Backend: backend. type Backend struct { // ID: backend ID. ID string `json:"id"` // Name: name of the backend. Name string `json:"name"` // ForwardProtocol: protocol used by the backend when forwarding traffic to backend servers. // Default value: tcp ForwardProtocol Protocol `json:"forward_protocol"` // ForwardPort: port used by the backend when forwarding traffic to backend servers. ForwardPort int32 `json:"forward_port"` // ForwardPortAlgorithm: load balancing algorithm to use when determining which backend server to forward new traffic to. // Default value: roundrobin ForwardPortAlgorithm ForwardPortAlgorithm `json:"forward_port_algorithm"` // StickySessions: defines whether sticky sessions (binding a particular session to a particular backend server) are activated and the method to use if so. None disables sticky sessions. Cookie-based uses an HTTP cookie to stick a session to a backend server. Table-based uses the source (client) IP address to stick a session to a backend server. // Default value: none StickySessions StickySessionsType `json:"sticky_sessions"` // StickySessionsCookieName: cookie name for cookie-based sticky sessions. StickySessionsCookieName string `json:"sticky_sessions_cookie_name"` // HealthCheck: object defining the health check to be carried out by the backend when checking the status and health of backend servers. HealthCheck *HealthCheck `json:"health_check"` // Pool: list of IP addresses of backend servers attached to this backend. Pool []string `json:"pool"` // LB: load Balancer the backend is attached to. LB *LB `json:"lb"` // Deprecated: SendProxyV2: deprecated in favor of proxy_protocol field. SendProxyV2 *bool `json:"send_proxy_v2,omitempty"` // TimeoutServer: maximum allowed time for a backend server to process a request. TimeoutServer *time.Duration `json:"timeout_server"` // TimeoutConnect: maximum allowed time for establishing a connection to a backend server. TimeoutConnect *time.Duration `json:"timeout_connect"` // TimeoutTunnel: maximum allowed tunnel inactivity time after Websocket is established (takes precedence over client and server timeout). TimeoutTunnel *time.Duration `json:"timeout_tunnel"` // OnMarkedDownAction: action to take when a backend server is marked as down. // Default value: on_marked_down_action_none OnMarkedDownAction OnMarkedDownAction `json:"on_marked_down_action"` // ProxyProtocol: protocol to use between the Load Balancer and backend servers. Allows the backend servers to be informed of the client's real IP address. The PROXY protocol must be supported by the backend servers' software. // Default value: proxy_protocol_unknown ProxyProtocol ProxyProtocol `json:"proxy_protocol"` // CreatedAt: date at which the backend was created. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date at which the backend was updated. UpdatedAt *time.Time `json:"updated_at"` // FailoverHost: scaleway S3 bucket website to be served as failover if all backend servers are down, e.g. failover-website.s3-website.fr-par.scw.cloud. FailoverHost *string `json:"failover_host"` // SslBridging: defines whether to enable SSL bridging between the Load Balancer and backend servers. SslBridging *bool `json:"ssl_bridging"` // IgnoreSslServerVerify: defines whether the server certificate verification should be ignored. IgnoreSslServerVerify *bool `json:"ignore_ssl_server_verify"` // RedispatchAttemptCount: whether to use another backend server on each attempt. RedispatchAttemptCount *int32 `json:"redispatch_attempt_count"` // MaxRetries: number of retries when a backend server connection failed. MaxRetries *int32 `json:"max_retries"` // MaxConnections: maximum number of connections allowed per backend server. MaxConnections *int32 `json:"max_connections"` // TimeoutQueue: maximum time for a request to be left pending in queue when `max_connections` is reached. TimeoutQueue *scw.Duration `json:"timeout_queue"` } func (m *Backend) UnmarshalJSON(b []byte) error { type tmpType Backend tmp := struct { tmpType TmpTimeoutServer *marshaler.Duration `json:"timeout_server"` TmpTimeoutConnect *marshaler.Duration `json:"timeout_connect"` TmpTimeoutTunnel *marshaler.Duration `json:"timeout_tunnel"` }{} err := json.Unmarshal(b, &tmp) if err != nil { return err } *m = Backend(tmp.tmpType) m.TimeoutServer = tmp.TmpTimeoutServer.Standard() m.TimeoutConnect = tmp.TmpTimeoutConnect.Standard() m.TimeoutTunnel = tmp.TmpTimeoutTunnel.Standard() return nil } func (m Backend) MarshalJSON() ([]byte, error) { type tmpType Backend tmp := struct { tmpType TmpTimeoutServer *marshaler.Duration `json:"timeout_server"` TmpTimeoutConnect *marshaler.Duration `json:"timeout_connect"` TmpTimeoutTunnel *marshaler.Duration `json:"timeout_tunnel"` }{ tmpType: tmpType(m), TmpTimeoutServer: marshaler.NewDuration(m.TimeoutServer), TmpTimeoutConnect: marshaler.NewDuration(m.TimeoutConnect), TmpTimeoutTunnel: marshaler.NewDuration(m.TimeoutTunnel), } return json.Marshal(tmp) } // Certificate: certificate. type Certificate struct { // Type: certificate type (Let's Encrypt or custom). // Default value: letsencryt Type CertificateType `json:"type"` // ID: certificate ID. ID string `json:"id"` // CommonName: main domain name of certificate. CommonName string `json:"common_name"` // SubjectAlternativeName: alternative domain names. SubjectAlternativeName []string `json:"subject_alternative_name"` // Fingerprint: identifier (SHA-1) of the certificate. Fingerprint string `json:"fingerprint"` // NotValidBefore: lower validity bound. NotValidBefore *time.Time `json:"not_valid_before"` // NotValidAfter: upper validity bound. NotValidAfter *time.Time `json:"not_valid_after"` // Status: certificate status. // Default value: pending Status CertificateStatus `json:"status"` // LB: load Balancer object the certificate is attached to. LB *LB `json:"lb"` // Name: certificate name. Name string `json:"name"` // CreatedAt: date on which the certificate was created. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date on which the certificate was last updated. UpdatedAt *time.Time `json:"updated_at"` // StatusDetails: additional information about the certificate status (useful in case of certificate generation failure, for example). StatusDetails *string `json:"status_details"` } // ACLAction: acl action. type ACLAction struct { // Type: action to take when incoming traffic matches an ACL filter. // Default value: allow Type ACLActionType `json:"type"` // Redirect: redirection parameters when using an ACL with a `redirect` action. Redirect *ACLActionRedirect `json:"redirect"` } // ACLMatch: acl match. type ACLMatch struct { // IPSubnet: list of IPs or CIDR v4/v6 addresses to filter for from the client side. IPSubnet []*string `json:"ip_subnet"` // HTTPFilter: type of HTTP filter to match. Extracts the request's URL path, which starts at the first slash and ends before the question mark (without the host part). Defines where to filter for the http_filter_value. Only supported for HTTP backends. // Default value: acl_http_filter_none HTTPFilter ACLHTTPFilter `json:"http_filter"` // HTTPFilterValue: list of values to filter for. HTTPFilterValue []*string `json:"http_filter_value"` // HTTPFilterOption: name of the HTTP header to filter on if `http_header_match` was selected in `http_filter`. HTTPFilterOption *string `json:"http_filter_option"` // Invert: defines whether to invert the match condition. If set to `true`, the ACL carries out its action when the condition DOES NOT match. Invert bool `json:"invert"` } // Frontend: frontend. type Frontend struct { // ID: frontend ID. ID string `json:"id"` // Name: name of the frontend. Name string `json:"name"` // InboundPort: port the frontend listens on. InboundPort int32 `json:"inbound_port"` // Backend: backend object the frontend is attached to. Backend *Backend `json:"backend"` // LB: load Balancer object the frontend is attached to. LB *LB `json:"lb"` // TimeoutClient: maximum allowed inactivity time on the client side. TimeoutClient *time.Duration `json:"timeout_client"` // Deprecated: Certificate: certificate, deprecated in favor of certificate_ids array. Certificate *Certificate `json:"certificate,omitempty"` // CertificateIDs: list of SSL/TLS certificate IDs to bind to the frontend. CertificateIDs []string `json:"certificate_ids"` // CreatedAt: date on which the frontend was created. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date on which the frontend was last updated. UpdatedAt *time.Time `json:"updated_at"` // EnableHTTP3: defines whether to enable HTTP/3 protocol on the frontend. EnableHTTP3 bool `json:"enable_http3"` } func (m *Frontend) UnmarshalJSON(b []byte) error { type tmpType Frontend tmp := struct { tmpType TmpTimeoutClient *marshaler.Duration `json:"timeout_client"` }{} err := json.Unmarshal(b, &tmp) if err != nil { return err } *m = Frontend(tmp.tmpType) m.TimeoutClient = tmp.TmpTimeoutClient.Standard() return nil } func (m Frontend) MarshalJSON() ([]byte, error) { type tmpType Frontend tmp := struct { tmpType TmpTimeoutClient *marshaler.Duration `json:"timeout_client"` }{ tmpType: tmpType(m), TmpTimeoutClient: marshaler.NewDuration(m.TimeoutClient), } return json.Marshal(tmp) } // PrivateNetworkDHCPConfig: private network dhcp config. type PrivateNetworkDHCPConfig struct { // Deprecated IPID *string `json:"ip_id,omitempty"` } // PrivateNetworkIpamConfig: private network ipam config. type PrivateNetworkIpamConfig struct { } // PrivateNetworkStaticConfig: private network static config. type PrivateNetworkStaticConfig struct { // Deprecated: IPAddress: array of a local IP address for the Load Balancer on this Private Network. IPAddress *[]string `json:"ip_address,omitempty"` } // RouteMatch: route match. type RouteMatch struct { // Sni: value to match in the Server Name Indication TLS extension (SNI) field from an incoming connection made via an SSL/TLS transport layer. This field should be set for routes on TCP Load Balancers. // Precisely one of Sni, HostHeader must be set. Sni *string `json:"sni,omitempty"` // HostHeader: value to match in the HTTP Host request header from an incoming connection. This field should be set for routes on HTTP Load Balancers. // Precisely one of Sni, HostHeader must be set. HostHeader *string `json:"host_header,omitempty"` } // CreateCertificateRequestCustomCertificate: create certificate request custom certificate. type CreateCertificateRequestCustomCertificate struct { // CertificateChain: full PEM-formatted certificate, consisting of the entire certificate chain including public key, private key, and (optionally) Certificate Authorities. CertificateChain string `json:"certificate_chain"` } // CreateCertificateRequestLetsencryptConfig: create certificate request letsencrypt config. type CreateCertificateRequestLetsencryptConfig struct { // CommonName: main domain name of certificate (this domain must exist and resolve to your Load Balancer IP address). CommonName string `json:"common_name"` // SubjectAlternativeName: alternative domain names (all domain names must exist and resolve to your Load Balancer IP address). SubjectAlternativeName []string `json:"subject_alternative_name"` } // BackendServerStats: backend server stats. type BackendServerStats struct { // InstanceID: ID of your Load Balancer's underlying Instance. InstanceID string `json:"instance_id"` // BackendID: backend ID. BackendID string `json:"backend_id"` // IP: iPv4 or IPv6 address of the backend server. IP string `json:"ip"` // ServerState: server operational state (stopped/starting/running/stopping). // Default value: stopped ServerState BackendServerStatsServerState `json:"server_state"` // ServerStateChangedAt: time since last operational change. ServerStateChangedAt *time.Time `json:"server_state_changed_at"` // LastHealthCheckStatus: last health check status (unknown/neutral/failed/passed/condpass). // Default value: unknown LastHealthCheckStatus BackendServerStatsHealthCheckStatus `json:"last_health_check_status"` } // ACL: acl. type ACL struct { // ID: ACL ID. ID string `json:"id"` // Name: ACL name. Name string `json:"name"` // Match: ACL match filter object. One of `ip_subnet` or `http_filter` & `http_filter_value` are required. Match *ACLMatch `json:"match"` // Action: action to take when incoming traffic matches an ACL filter. Action *ACLAction `json:"action"` // Frontend: ACL is attached to this frontend object. Frontend *Frontend `json:"frontend"` // Index: priority of this ACL (ACLs are applied in ascending order, 0 is the first ACL executed). Index int32 `json:"index"` // CreatedAt: date on which the ACL was created. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date on which the ACL was last updated. UpdatedAt *time.Time `json:"updated_at"` // Description: ACL description. Description string `json:"description"` } // PrivateNetwork: private network. type PrivateNetwork struct { // LB: load Balancer object which is attached to the Private Network. LB *LB `json:"lb"` // IpamIDs: iPAM IDs of the booked IP addresses. IpamIDs []string `json:"ipam_ids"` // Deprecated: StaticConfig: object containing an array of a local IP address for the Load Balancer on this Private Network. // Precisely one of StaticConfig, DHCPConfig, IpamConfig must be set. StaticConfig *PrivateNetworkStaticConfig `json:"static_config,omitempty"` // Deprecated: DHCPConfig: object containing DHCP-assigned IP addresses. // Precisely one of StaticConfig, DHCPConfig, IpamConfig must be set. DHCPConfig *PrivateNetworkDHCPConfig `json:"dhcp_config,omitempty"` // Deprecated: IpamConfig: for internal use only. // Precisely one of StaticConfig, DHCPConfig, IpamConfig must be set. IpamConfig *PrivateNetworkIpamConfig `json:"ipam_config,omitempty"` // PrivateNetworkID: private Network ID. PrivateNetworkID string `json:"private_network_id"` // Status: status of Private Network connection. // Default value: unknown Status PrivateNetworkStatus `json:"status"` // CreatedAt: date on which the Private Network was created. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date on which the PN was last updated. UpdatedAt *time.Time `json:"updated_at"` } // LBType: lb type. type LBType struct { // Name: load Balancer commercial offer type name. Name string `json:"name"` // StockStatus: current stock status for a given Load Balancer type. // Default value: unknown StockStatus LBTypeStock `json:"stock_status"` // Description: load Balancer commercial offer type description. Description string `json:"description"` // Deprecated: Region: the region the Load Balancer stock is in. Region *scw.Region `json:"region,omitempty"` // Zone: the zone the Load Balancer stock is in. Zone scw.Zone `json:"zone"` } // Route: route. type Route struct { // ID: route ID. ID string `json:"id"` // FrontendID: ID of the source frontend. FrontendID string `json:"frontend_id"` // BackendID: ID of the target backend. BackendID string `json:"backend_id"` // Match: object defining the match condition for a route to be applied. If an incoming client session matches the specified condition (i.e. it has a matching SNI value or HTTP Host header value), it will be passed to the target backend. Match *RouteMatch `json:"match"` // CreatedAt: date on which the route was created. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date on which the route was last updated. UpdatedAt *time.Time `json:"updated_at"` } // ACLSpec: acl spec. type ACLSpec struct { // Name: ACL name. Name string `json:"name"` // Action: action to take when incoming traffic matches an ACL filter. Action *ACLAction `json:"action"` // Match: ACL match filter object. One of `ip_subnet` or `http_filter` and `http_filter_value` are required. Match *ACLMatch `json:"match"` // Index: priority of this ACL (ACLs are applied in ascending order, 0 is the first ACL executed). Index int32 `json:"index"` // Description: ACL description. Description string `json:"description"` } // AddBackendServersRequest: add backend servers request. type AddBackendServersRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // BackendID: backend ID. BackendID string `json:"-"` // ServerIP: list of IP addresses to add to backend servers. ServerIP []string `json:"server_ip"` } // AttachPrivateNetworkRequest: attach private network request. type AttachPrivateNetworkRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // PrivateNetworkID: private Network ID. PrivateNetworkID string `json:"-"` // Deprecated: StaticConfig: object containing an array of a local IP address for the Load Balancer on this Private Network. // Precisely one of StaticConfig, DHCPConfig, IpamConfig must be set. StaticConfig *PrivateNetworkStaticConfig `json:"static_config,omitempty"` // Deprecated: DHCPConfig: defines whether to let DHCP assign IP addresses. // Precisely one of StaticConfig, DHCPConfig, IpamConfig must be set. DHCPConfig *PrivateNetworkDHCPConfig `json:"dhcp_config,omitempty"` // Deprecated: IpamConfig: for internal use only. // Precisely one of StaticConfig, DHCPConfig, IpamConfig must be set. IpamConfig *PrivateNetworkIpamConfig `json:"ipam_config,omitempty"` } // CreateACLRequest: Add an ACL to a Load Balancer frontend. type CreateACLRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // FrontendID: frontend ID to attach the ACL to. FrontendID string `json:"-"` // Name: ACL name. Name string `json:"name"` // Action: action to take when incoming traffic matches an ACL filter. Action *ACLAction `json:"action"` // Match: ACL match filter object. One of `ip_subnet` or `http_filter` & `http_filter_value` are required. Match *ACLMatch `json:"match,omitempty"` // Index: priority of this ACL (ACLs are applied in ascending order, 0 is the first ACL executed). Index int32 `json:"index"` // Description: ACL description. Description string `json:"description"` } // CreateBackendRequest: create backend request. type CreateBackendRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // Name: name for the backend. Name string `json:"name"` // ForwardProtocol: protocol to be used by the backend when forwarding traffic to backend servers. // Default value: tcp ForwardProtocol Protocol `json:"forward_protocol"` // ForwardPort: port to be used by the backend when forwarding traffic to backend servers. ForwardPort int32 `json:"forward_port"` // ForwardPortAlgorithm: load balancing algorithm to be used when determining which backend server to forward new traffic to. // Default value: roundrobin ForwardPortAlgorithm ForwardPortAlgorithm `json:"forward_port_algorithm"` // StickySessions: defines whether to activate sticky sessions (binding a particular session to a particular backend server) and the method to use if so. None disables sticky sessions. Cookie-based uses an HTTP cookie TO stick a session to a backend server. Table-based uses the source (client) IP address to stick a session to a backend server. // Default value: none StickySessions StickySessionsType `json:"sticky_sessions"` // StickySessionsCookieName: cookie name for cookie-based sticky sessions. StickySessionsCookieName string `json:"sticky_sessions_cookie_name"` // HealthCheck: object defining the health check to be carried out by the backend when checking the status and health of backend servers. HealthCheck *HealthCheck `json:"health_check"` // ServerIP: list of backend server IP addresses (IPv4 or IPv6) the backend should forward traffic to. ServerIP []string `json:"server_ip"` // Deprecated: SendProxyV2: deprecated in favor of proxy_protocol field. SendProxyV2 *bool `json:"send_proxy_v2,omitempty"` // TimeoutServer: maximum allowed time for a backend server to process a request. TimeoutServer *time.Duration `json:"timeout_server,omitempty"` // TimeoutConnect: maximum allowed time for establishing a connection to a backend server. TimeoutConnect *time.Duration `json:"timeout_connect,omitempty"` // TimeoutTunnel: maximum allowed tunnel inactivity time after Websocket is established (takes precedence over client and server timeout). TimeoutTunnel *time.Duration `json:"timeout_tunnel,omitempty"` // OnMarkedDownAction: action to take when a backend server is marked as down. // Default value: on_marked_down_action_none OnMarkedDownAction OnMarkedDownAction `json:"on_marked_down_action"` // ProxyProtocol: protocol to use between the Load Balancer and backend servers. Allows the backend servers to be informed of the client's real IP address. The PROXY protocol must be supported by the backend servers' software. // Default value: proxy_protocol_unknown ProxyProtocol ProxyProtocol `json:"proxy_protocol"` // FailoverHost: scaleway S3 bucket website to be served as failover if all backend servers are down, e.g. failover-website.s3-website.fr-par.scw.cloud. FailoverHost *string `json:"failover_host,omitempty"` // SslBridging: defines whether to enable SSL bridging between the Load Balancer and backend servers. SslBridging *bool `json:"ssl_bridging,omitempty"` // IgnoreSslServerVerify: defines whether the server certificate verification should be ignored. IgnoreSslServerVerify *bool `json:"ignore_ssl_server_verify,omitempty"` // RedispatchAttemptCount: whether to use another backend server on each attempt. RedispatchAttemptCount *int32 `json:"redispatch_attempt_count,omitempty"` // MaxRetries: number of retries when a backend server connection failed. MaxRetries *int32 `json:"max_retries,omitempty"` // MaxConnections: maximum number of connections allowed per backend server. MaxConnections *int32 `json:"max_connections,omitempty"` // TimeoutQueue: maximum time for a request to be left pending in queue when `max_connections` is reached. TimeoutQueue *scw.Duration `json:"timeout_queue,omitempty"` } func (m *CreateBackendRequest) UnmarshalJSON(b []byte) error { type tmpType CreateBackendRequest tmp := struct { tmpType TmpTimeoutServer *marshaler.Duration `json:"timeout_server,omitempty"` TmpTimeoutConnect *marshaler.Duration `json:"timeout_connect,omitempty"` TmpTimeoutTunnel *marshaler.Duration `json:"timeout_tunnel,omitempty"` }{} err := json.Unmarshal(b, &tmp) if err != nil { return err } *m = CreateBackendRequest(tmp.tmpType) m.TimeoutServer = tmp.TmpTimeoutServer.Standard() m.TimeoutConnect = tmp.TmpTimeoutConnect.Standard() m.TimeoutTunnel = tmp.TmpTimeoutTunnel.Standard() return nil } func (m CreateBackendRequest) MarshalJSON() ([]byte, error) { type tmpType CreateBackendRequest tmp := struct { tmpType TmpTimeoutServer *marshaler.Duration `json:"timeout_server,omitempty"` TmpTimeoutConnect *marshaler.Duration `json:"timeout_connect,omitempty"` TmpTimeoutTunnel *marshaler.Duration `json:"timeout_tunnel,omitempty"` }{ tmpType: tmpType(m), TmpTimeoutServer: marshaler.NewDuration(m.TimeoutServer), TmpTimeoutConnect: marshaler.NewDuration(m.TimeoutConnect), TmpTimeoutTunnel: marshaler.NewDuration(m.TimeoutTunnel), } return json.Marshal(tmp) } // CreateCertificateRequest: create certificate request. type CreateCertificateRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // Name: name for the certificate. Name string `json:"name"` // Letsencrypt: object to define a new Let's Encrypt certificate to be generated. // Precisely one of Letsencrypt, CustomCertificate must be set. Letsencrypt *CreateCertificateRequestLetsencryptConfig `json:"letsencrypt,omitempty"` // CustomCertificate: object to define an existing custom certificate to be imported. // Precisely one of Letsencrypt, CustomCertificate must be set. CustomCertificate *CreateCertificateRequestCustomCertificate `json:"custom_certificate,omitempty"` } // CreateFrontendRequest: create frontend request. type CreateFrontendRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // LBID: load Balancer ID (ID of the Load Balancer to attach the frontend to). LBID string `json:"-"` // Name: name for the frontend. Name string `json:"name"` // InboundPort: port the frontend should listen on. InboundPort int32 `json:"inbound_port"` // BackendID: backend ID (ID of the backend the frontend should pass traffic to). BackendID string `json:"backend_id"` // TimeoutClient: maximum allowed inactivity time on the client side. TimeoutClient *time.Duration `json:"timeout_client,omitempty"` // Deprecated: CertificateID: certificate ID, deprecated in favor of certificate_ids array. CertificateID *string `json:"certificate_id,omitempty"` // CertificateIDs: list of SSL/TLS certificate IDs to bind to the frontend. CertificateIDs *[]string `json:"certificate_ids,omitempty"` // EnableHTTP3: defines whether to enable HTTP/3 protocol on the frontend. EnableHTTP3 bool `json:"enable_http3"` } func (m *CreateFrontendRequest) UnmarshalJSON(b []byte) error { type tmpType CreateFrontendRequest tmp := struct { tmpType TmpTimeoutClient *marshaler.Duration `json:"timeout_client,omitempty"` }{} err := json.Unmarshal(b, &tmp) if err != nil { return err } *m = CreateFrontendRequest(tmp.tmpType) m.TimeoutClient = tmp.TmpTimeoutClient.Standard() return nil } func (m CreateFrontendRequest) MarshalJSON() ([]byte, error) { type tmpType CreateFrontendRequest tmp := struct { tmpType TmpTimeoutClient *marshaler.Duration `json:"timeout_client,omitempty"` }{ tmpType: tmpType(m), TmpTimeoutClient: marshaler.NewDuration(m.TimeoutClient), } return json.Marshal(tmp) } // CreateIPRequest: create ip request. type CreateIPRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Deprecated: OrganizationID: organization ID of the Organization where the IP address should be created. // Precisely one of ProjectID, OrganizationID must be set. OrganizationID *string `json:"organization_id,omitempty"` // ProjectID: project ID of the Project where the IP address should be created. // Precisely one of ProjectID, OrganizationID must be set. ProjectID *string `json:"project_id,omitempty"` // Reverse: reverse DNS (domain name) for the IP address. Reverse *string `json:"reverse,omitempty"` // IsIPv6: if true, creates a Flexible IP with an ipv6 address. IsIPv6 bool `json:"is_ipv6"` } // CreateLBRequest: create lb request. type CreateLBRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Deprecated: OrganizationID: scaleway Organization to create the Load Balancer in. // Precisely one of ProjectID, OrganizationID must be set. OrganizationID *string `json:"organization_id,omitempty"` // ProjectID: scaleway Project to create the Load Balancer in. // Precisely one of ProjectID, OrganizationID must be set. ProjectID *string `json:"project_id,omitempty"` // Name: name for the Load Balancer. Name string `json:"name"` // Description: description for the Load Balancer. Description string `json:"description"` // Deprecated: IPID: ID of an existing flexible IP address to attach to the Load Balancer. IPID *string `json:"ip_id,omitempty"` // AssignFlexibleIP: defines whether to automatically assign a flexible public IP to lb. Default value is `false` (do not assign). AssignFlexibleIP *bool `json:"assign_flexible_ip,omitempty"` // AssignFlexibleIPv6: defines whether to automatically assign a flexible public IPv6 to the Load Balancer. Default value is `false` (do not assign). AssignFlexibleIPv6 *bool `json:"assign_flexible_ipv6,omitempty"` // IPIDs: list of IP IDs to attach to the Load Balancer. IPIDs []string `json:"ip_ids"` // Tags: list of tags for the Load Balancer. Tags []string `json:"tags"` // Type: load Balancer commercial offer type. Use the Load Balancer types endpoint to retrieve a list of available offer types. Type string `json:"type"` // SslCompatibilityLevel: determines the minimal SSL version which needs to be supported on the client side, in an SSL/TLS offloading context. Intermediate is suitable for general-purpose servers with a variety of clients, recommended for almost all systems. Modern is suitable for services with clients that support TLS 1.3 and do not need backward compatibility. Old is compatible with a small number of very old clients and should be used only as a last resort. // Default value: ssl_compatibility_level_unknown SslCompatibilityLevel SSLCompatibilityLevel `json:"ssl_compatibility_level"` } // CreateRouteRequest: create route request. type CreateRouteRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // FrontendID: ID of the source frontend to create the route on. FrontendID string `json:"frontend_id"` // BackendID: ID of the target backend for the route. BackendID string `json:"backend_id"` // Match: object defining the match condition for a route to be applied. If an incoming client session matches the specified condition (i.e. it has a matching SNI value or HTTP Host header value), it will be passed to the target backend. Match *RouteMatch `json:"match,omitempty"` } // CreateSubscriberRequest: Create a new alert subscriber (webhook or email). type CreateSubscriberRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Name: subscriber name. Name string `json:"name"` // EmailConfig: email address configuration. // Precisely one of EmailConfig, WebhookConfig must be set. EmailConfig *SubscriberEmailConfig `json:"email_config,omitempty"` // WebhookConfig: webHook URI configuration. // Precisely one of EmailConfig, WebhookConfig must be set. WebhookConfig *SubscriberWebhookConfig `json:"webhook_config,omitempty"` // Deprecated: OrganizationID: organization ID to create the subscriber in. // Precisely one of ProjectID, OrganizationID must be set. OrganizationID *string `json:"organization_id,omitempty"` // ProjectID: project ID to create the subscriber in. // Precisely one of ProjectID, OrganizationID must be set. ProjectID *string `json:"project_id,omitempty"` } // DeleteACLRequest: delete acl request. type DeleteACLRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ACLID: ACL ID. ACLID string `json:"-"` } // DeleteBackendRequest: delete backend request. type DeleteBackendRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // BackendID: ID of the backend to delete. BackendID string `json:"-"` } // DeleteCertificateRequest: delete certificate request. type DeleteCertificateRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // CertificateID: certificate ID. CertificateID string `json:"-"` } // DeleteFrontendRequest: delete frontend request. type DeleteFrontendRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // FrontendID: ID of the frontend to delete. FrontendID string `json:"-"` } // DeleteLBRequest: delete lb request. type DeleteLBRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // LBID: ID of the Load Balancer to delete. LBID string `json:"-"` // ReleaseIP: defines whether the Load Balancer's flexible IP should be deleted. Set to true to release the flexible IP, or false to keep it available in your account for future Load Balancers. ReleaseIP bool `json:"release_ip"` } // DeleteRouteRequest: delete route request. type DeleteRouteRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // RouteID: route ID. RouteID string `json:"-"` } // DeleteSubscriberRequest: delete subscriber request. type DeleteSubscriberRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SubscriberID: subscriber ID. SubscriberID string `json:"-"` } // DetachPrivateNetworkRequest: detach private network request. type DetachPrivateNetworkRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // LBID: load balancer ID. LBID string `json:"-"` // PrivateNetworkID: set your instance private network id. PrivateNetworkID string `json:"-"` } // GetACLRequest: get acl request. type GetACLRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ACLID: ACL ID. ACLID string `json:"-"` } // GetBackendRequest: get backend request. type GetBackendRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // BackendID: backend ID. BackendID string `json:"-"` } // GetCertificateRequest: get certificate request. type GetCertificateRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // CertificateID: certificate ID. CertificateID string `json:"-"` } // GetFrontendRequest: get frontend request. type GetFrontendRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // FrontendID: frontend ID. FrontendID string `json:"-"` } // GetIPRequest: get ip request. type GetIPRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // IPID: IP address ID. IPID string `json:"-"` } // GetLBRequest: get lb request. type GetLBRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` } // GetLBStatsRequest: Get Load Balancer stats. type GetLBStatsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // BackendID: ID of the backend. BackendID *string `json:"backend_id,omitempty"` } // GetRouteRequest: get route request. type GetRouteRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // RouteID: route ID. RouteID string `json:"-"` } // GetSubscriberRequest: get subscriber request. type GetSubscriberRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SubscriberID: subscriber ID. SubscriberID string `json:"-"` } // LBStats: lb stats. type LBStats struct { // BackendServersStats: list of objects containing Load Balancer statistics. BackendServersStats []*BackendServerStats `json:"backend_servers_stats"` } // ListACLResponse: list acl response. type ListACLResponse struct { // ACLs: list of ACL objects. ACLs []*ACL `json:"acls"` // TotalCount: the total number of objects. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListACLResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListACLResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListACLResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.ACLs = append(r.ACLs, results.ACLs...) r.TotalCount += uint32(len(results.ACLs)) return uint32(len(results.ACLs)), nil } // ListACLsRequest: list ac ls request. type ListACLsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // FrontendID: frontend ID (ACLs attached to this frontend will be returned in the response). FrontendID string `json:"-"` // OrderBy: sort order of ACLs in the response. // Default value: created_at_asc OrderBy ListACLRequestOrderBy `json:"-"` // Page: the page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: the number of ACLs to return. PageSize *uint32 `json:"-"` // Name: ACL name to filter for. Name *string `json:"-"` } // ListBackendStatsRequest: list backend stats request. type ListBackendStatsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // Page: the page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: number of items to return. PageSize *uint32 `json:"-"` // BackendID: ID of the backend. BackendID *string `json:"-"` } // ListBackendStatsResponse: list backend stats response. type ListBackendStatsResponse struct { // BackendServersStats: list of objects containing backend server statistics. BackendServersStats []*BackendServerStats `json:"backend_servers_stats"` // TotalCount: the total number of objects. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListBackendStatsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListBackendStatsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListBackendStatsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.BackendServersStats = append(r.BackendServersStats, results.BackendServersStats...) r.TotalCount += uint32(len(results.BackendServersStats)) return uint32(len(results.BackendServersStats)), nil } // ListBackendsRequest: list backends request. type ListBackendsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // Name: name of the backend to filter for. Name *string `json:"-"` // OrderBy: sort order of backends in the response. // Default value: created_at_asc OrderBy ListBackendsRequestOrderBy `json:"-"` // Page: the page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: number of backends to return. PageSize *uint32 `json:"-"` } // ListBackendsResponse: list backends response. type ListBackendsResponse struct { // Backends: list of backend objects of a given Load Balancer. Backends []*Backend `json:"backends"` // TotalCount: total count of backend objects, without pagination. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListBackendsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListBackendsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListBackendsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Backends = append(r.Backends, results.Backends...) r.TotalCount += uint32(len(results.Backends)) return uint32(len(results.Backends)), nil } // ListCertificatesRequest: list certificates request. type ListCertificatesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // OrderBy: sort order of certificates in the response. // Default value: created_at_asc OrderBy ListCertificatesRequestOrderBy `json:"-"` // Page: the page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: number of certificates to return. PageSize *uint32 `json:"-"` // Name: certificate name to filter for, only certificates of this name will be returned. Name *string `json:"-"` } // ListCertificatesResponse: list certificates response. type ListCertificatesResponse struct { // Certificates: list of certificate objects. Certificates []*Certificate `json:"certificates"` // TotalCount: the total number of objects. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListCertificatesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListCertificatesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListCertificatesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Certificates = append(r.Certificates, results.Certificates...) r.TotalCount += uint32(len(results.Certificates)) return uint32(len(results.Certificates)), nil } // ListFrontendsRequest: list frontends request. type ListFrontendsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // Name: name of the frontend to filter for. Name *string `json:"-"` // OrderBy: sort order of frontends in the response. // Default value: created_at_asc OrderBy ListFrontendsRequestOrderBy `json:"-"` // Page: the page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: number of frontends to return. PageSize *uint32 `json:"-"` } // ListFrontendsResponse: list frontends response. type ListFrontendsResponse struct { // Frontends: list of frontend objects of a given Load Balancer. Frontends []*Frontend `json:"frontends"` // TotalCount: total count of frontend objects, without pagination. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListFrontendsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListFrontendsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListFrontendsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Frontends = append(r.Frontends, results.Frontends...) r.TotalCount += uint32(len(results.Frontends)) return uint32(len(results.Frontends)), nil } // ListIPsRequest: list i ps request. type ListIPsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: the page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: number of IP addresses to return. PageSize *uint32 `json:"-"` // IPAddress: IP address to filter for. IPAddress *string `json:"-"` // OrganizationID: organization ID to filter for, only Load Balancer IP addresses from this Organization will be returned. OrganizationID *string `json:"-"` // ProjectID: project ID to filter for, only Load Balancer IP addresses from this Project will be returned. ProjectID *string `json:"-"` // IPType: IP type to filter for. // Default value: all IPType ListIPsRequestIPType `json:"-"` } // ListIPsResponse: list i ps response. type ListIPsResponse struct { // IPs: list of IP address objects. IPs []*IP `json:"ips"` // TotalCount: total count of IP address objects, without pagination. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListIPsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListIPsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListIPsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.IPs = append(r.IPs, results.IPs...) r.TotalCount += uint32(len(results.IPs)) return uint32(len(results.IPs)), nil } // ListLBPrivateNetworksRequest: list lb private networks request. type ListLBPrivateNetworksRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // OrderBy: sort order of Private Network objects in the response. // Default value: created_at_asc OrderBy ListPrivateNetworksRequestOrderBy `json:"-"` // PageSize: number of objects to return. PageSize *uint32 `json:"-"` // Page: the page number to return, from the paginated results. Page *int32 `json:"-"` } // ListLBPrivateNetworksResponse: list lb private networks response. type ListLBPrivateNetworksResponse struct { // PrivateNetwork: list of Private Network objects attached to the Load Balancer. PrivateNetwork []*PrivateNetwork `json:"private_network"` // TotalCount: total number of objects in the response. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListLBPrivateNetworksResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListLBPrivateNetworksResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListLBPrivateNetworksResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.PrivateNetwork = append(r.PrivateNetwork, results.PrivateNetwork...) r.TotalCount += uint32(len(results.PrivateNetwork)) return uint32(len(results.PrivateNetwork)), nil } // ListLBTypesRequest: list lb types request. type ListLBTypesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: the page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: the number of items to return. PageSize *uint32 `json:"-"` } // ListLBTypesResponse: list lb types response. type ListLBTypesResponse struct { // LBTypes: list of Load Balancer commercial offer type objects. LBTypes []*LBType `json:"lb_types"` // TotalCount: total number of Load Balancer offer type objects. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListLBTypesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListLBTypesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListLBTypesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.LBTypes = append(r.LBTypes, results.LBTypes...) r.TotalCount += uint32(len(results.LBTypes)) return uint32(len(results.LBTypes)), nil } // ListLBsRequest: list l bs request. type ListLBsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Name: load Balancer name to filter for. Name *string `json:"-"` // OrderBy: sort order of Load Balancers in the response. // Default value: created_at_asc OrderBy ListLBsRequestOrderBy `json:"-"` // PageSize: number of Load Balancers to return. PageSize *uint32 `json:"-"` // Page: page number to return, from the paginated results. Page *int32 `json:"-"` // OrganizationID: organization ID to filter for, only Load Balancers from this Organization will be returned. OrganizationID *string `json:"-"` // ProjectID: project ID to filter for, only Load Balancers from this Project will be returned. ProjectID *string `json:"-"` } // ListLBsResponse: list l bs response. type ListLBsResponse struct { // LBs: list of Load Balancer objects. LBs []*LB `json:"lbs"` // TotalCount: the total number of Load Balancer objects. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListLBsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListLBsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListLBsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.LBs = append(r.LBs, results.LBs...) r.TotalCount += uint32(len(results.LBs)) return uint32(len(results.LBs)), nil } // ListRoutesRequest: list routes request. type ListRoutesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // OrderBy: sort order of routes in the response. // Default value: created_at_asc OrderBy ListRoutesRequestOrderBy `json:"-"` // PageSize: the number of route objects to return. PageSize *uint32 `json:"-"` // Page: the page number to return, from the paginated results. Page *int32 `json:"-"` // FrontendID: frontend ID to filter for, only Routes from this Frontend will be returned. FrontendID *string `json:"-"` } // ListRoutesResponse: list routes response. type ListRoutesResponse struct { // Routes: list of route objects. Routes []*Route `json:"routes"` // TotalCount: the total number of route objects. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListRoutesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListRoutesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListRoutesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Routes = append(r.Routes, results.Routes...) r.TotalCount += uint32(len(results.Routes)) return uint32(len(results.Routes)), nil } // ListSubscriberRequest: list subscriber request. type ListSubscriberRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // OrderBy: sort order of subscribers in the response. // Default value: created_at_asc OrderBy ListSubscriberRequestOrderBy `json:"-"` // Page: the page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: the number of items to return. PageSize *uint32 `json:"-"` // Name: subscriber name to search for. Name *string `json:"-"` // OrganizationID: filter subscribers by Organization ID. OrganizationID *string `json:"-"` // ProjectID: filter subscribers by Project ID. ProjectID *string `json:"-"` } // ListSubscriberResponse: list subscriber response. type ListSubscriberResponse struct { // Subscribers: list of subscriber objects. Subscribers []*Subscriber `json:"subscribers"` // TotalCount: the total number of objects. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListSubscriberResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListSubscriberResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListSubscriberResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Subscribers = append(r.Subscribers, results.Subscribers...) r.TotalCount += uint32(len(results.Subscribers)) return uint32(len(results.Subscribers)), nil } // MigrateLBRequest: migrate lb request. type MigrateLBRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // Type: load Balancer type to migrate to (use the List all Load Balancer offer types endpoint to get a list of available offer types). Type string `json:"type"` } // ReleaseIPRequest: release ip request. type ReleaseIPRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // IPID: IP address ID. IPID string `json:"-"` } // RemoveBackendServersRequest: remove backend servers request. type RemoveBackendServersRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // BackendID: backend ID. BackendID string `json:"-"` // ServerIP: list of IP addresses to remove from backend servers. ServerIP []string `json:"server_ip"` } // SetACLsResponse: set ac ls response. type SetACLsResponse struct { // ACLs: list of ACL objects. ACLs []*ACL `json:"acls"` // TotalCount: the total number of ACL objects. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *SetACLsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *SetACLsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*SetACLsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.ACLs = append(r.ACLs, results.ACLs...) r.TotalCount += uint32(len(results.ACLs)) return uint32(len(results.ACLs)), nil } // SetBackendServersRequest: set backend servers request. type SetBackendServersRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // BackendID: backend ID. BackendID string `json:"-"` // ServerIP: list of IP addresses for backend servers. Any other existing backend servers will be removed. ServerIP []string `json:"server_ip"` } // SubscribeToLBRequest: subscribe to lb request. type SubscribeToLBRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // SubscriberID: subscriber ID. SubscriberID string `json:"subscriber_id"` } // UnsubscribeFromLBRequest: unsubscribe from lb request. type UnsubscribeFromLBRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` } // UpdateACLRequest: update acl request. type UpdateACLRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ACLID: ACL ID. ACLID string `json:"-"` // Name: ACL name. Name string `json:"name"` // Action: action to take when incoming traffic matches an ACL filter. Action *ACLAction `json:"action"` // Match: ACL match filter object. One of `ip_subnet` or `http_filter` & `http_filter_value` are required. Match *ACLMatch `json:"match,omitempty"` // Index: priority of this ACL (ACLs are applied in ascending order, 0 is the first ACL executed). Index int32 `json:"index"` // Description: ACL description. Description *string `json:"description,omitempty"` } // UpdateBackendRequest: update backend request. type UpdateBackendRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // BackendID: backend ID. BackendID string `json:"-"` // Name: backend name. Name string `json:"name"` // ForwardProtocol: protocol to be used by the backend when forwarding traffic to backend servers. // Default value: tcp ForwardProtocol Protocol `json:"forward_protocol"` // ForwardPort: port to be used by the backend when forwarding traffic to backend servers. ForwardPort int32 `json:"forward_port"` // ForwardPortAlgorithm: load balancing algorithm to be used when determining which backend server to forward new traffic to. // Default value: roundrobin ForwardPortAlgorithm ForwardPortAlgorithm `json:"forward_port_algorithm"` // StickySessions: defines whether to activate sticky sessions (binding a particular session to a particular backend server) and the method to use if so. None disables sticky sessions. Cookie-based uses an HTTP cookie to stick a session to a backend server. Table-based uses the source (client) IP address to stick a session to a backend server. // Default value: none StickySessions StickySessionsType `json:"sticky_sessions"` // StickySessionsCookieName: cookie name for cookie-based sticky sessions. StickySessionsCookieName string `json:"sticky_sessions_cookie_name"` // Deprecated: SendProxyV2: deprecated in favor of proxy_protocol field. SendProxyV2 *bool `json:"send_proxy_v2,omitempty"` // TimeoutServer: maximum allowed time for a backend server to process a request. TimeoutServer *time.Duration `json:"timeout_server,omitempty"` // TimeoutConnect: maximum allowed time for establishing a connection to a backend server. TimeoutConnect *time.Duration `json:"timeout_connect,omitempty"` // TimeoutTunnel: maximum allowed tunnel inactivity time after Websocket is established (takes precedence over client and server timeout). TimeoutTunnel *time.Duration `json:"timeout_tunnel,omitempty"` // OnMarkedDownAction: action to take when a backend server is marked as down. // Default value: on_marked_down_action_none OnMarkedDownAction OnMarkedDownAction `json:"on_marked_down_action"` // ProxyProtocol: protocol to use between the Load Balancer and backend servers. Allows the backend servers to be informed of the client's real IP address. The PROXY protocol must be supported by the backend servers' software. // Default value: proxy_protocol_unknown ProxyProtocol ProxyProtocol `json:"proxy_protocol"` // FailoverHost: scaleway S3 bucket website to be served as failover if all backend servers are down, e.g. failover-website.s3-website.fr-par.scw.cloud. FailoverHost *string `json:"failover_host,omitempty"` // SslBridging: defines whether to enable SSL bridging between the Load Balancer and backend servers. SslBridging *bool `json:"ssl_bridging,omitempty"` // IgnoreSslServerVerify: defines whether the server certificate verification should be ignored. IgnoreSslServerVerify *bool `json:"ignore_ssl_server_verify,omitempty"` // RedispatchAttemptCount: whether to use another backend server on each attempt. RedispatchAttemptCount *int32 `json:"redispatch_attempt_count,omitempty"` // MaxRetries: number of retries when a backend server connection failed. MaxRetries *int32 `json:"max_retries,omitempty"` // MaxConnections: maximum number of connections allowed per backend server. MaxConnections *int32 `json:"max_connections,omitempty"` // TimeoutQueue: maximum time for a request to be left pending in queue when `max_connections` is reached. TimeoutQueue *scw.Duration `json:"timeout_queue,omitempty"` } func (m *UpdateBackendRequest) UnmarshalJSON(b []byte) error { type tmpType UpdateBackendRequest tmp := struct { tmpType TmpTimeoutServer *marshaler.Duration `json:"timeout_server,omitempty"` TmpTimeoutConnect *marshaler.Duration `json:"timeout_connect,omitempty"` TmpTimeoutTunnel *marshaler.Duration `json:"timeout_tunnel,omitempty"` }{} err := json.Unmarshal(b, &tmp) if err != nil { return err } *m = UpdateBackendRequest(tmp.tmpType) m.TimeoutServer = tmp.TmpTimeoutServer.Standard() m.TimeoutConnect = tmp.TmpTimeoutConnect.Standard() m.TimeoutTunnel = tmp.TmpTimeoutTunnel.Standard() return nil } func (m UpdateBackendRequest) MarshalJSON() ([]byte, error) { type tmpType UpdateBackendRequest tmp := struct { tmpType TmpTimeoutServer *marshaler.Duration `json:"timeout_server,omitempty"` TmpTimeoutConnect *marshaler.Duration `json:"timeout_connect,omitempty"` TmpTimeoutTunnel *marshaler.Duration `json:"timeout_tunnel,omitempty"` }{ tmpType: tmpType(m), TmpTimeoutServer: marshaler.NewDuration(m.TimeoutServer), TmpTimeoutConnect: marshaler.NewDuration(m.TimeoutConnect), TmpTimeoutTunnel: marshaler.NewDuration(m.TimeoutTunnel), } return json.Marshal(tmp) } // UpdateCertificateRequest: update certificate request. type UpdateCertificateRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // CertificateID: certificate ID. CertificateID string `json:"-"` // Name: certificate name. Name string `json:"name"` } // UpdateFrontendRequest: update frontend request. type UpdateFrontendRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // FrontendID: frontend ID. FrontendID string `json:"-"` // Name: frontend name. Name string `json:"name"` // InboundPort: port the frontend should listen on. InboundPort int32 `json:"inbound_port"` // BackendID: backend ID (ID of the backend the frontend should pass traffic to). BackendID string `json:"backend_id"` // TimeoutClient: maximum allowed inactivity time on the client side. TimeoutClient *time.Duration `json:"timeout_client,omitempty"` // Deprecated: CertificateID: certificate ID, deprecated in favor of certificate_ids array. CertificateID *string `json:"certificate_id,omitempty"` // CertificateIDs: list of SSL/TLS certificate IDs to bind to the frontend. CertificateIDs *[]string `json:"certificate_ids,omitempty"` // EnableHTTP3: defines whether to enable HTTP/3 protocol on the frontend. EnableHTTP3 bool `json:"enable_http3"` } func (m *UpdateFrontendRequest) UnmarshalJSON(b []byte) error { type tmpType UpdateFrontendRequest tmp := struct { tmpType TmpTimeoutClient *marshaler.Duration `json:"timeout_client,omitempty"` }{} err := json.Unmarshal(b, &tmp) if err != nil { return err } *m = UpdateFrontendRequest(tmp.tmpType) m.TimeoutClient = tmp.TmpTimeoutClient.Standard() return nil } func (m UpdateFrontendRequest) MarshalJSON() ([]byte, error) { type tmpType UpdateFrontendRequest tmp := struct { tmpType TmpTimeoutClient *marshaler.Duration `json:"timeout_client,omitempty"` }{ tmpType: tmpType(m), TmpTimeoutClient: marshaler.NewDuration(m.TimeoutClient), } return json.Marshal(tmp) } // UpdateHealthCheckRequest: update health check request. type UpdateHealthCheckRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // BackendID: backend ID. BackendID string `json:"-"` // Port: port to use for the backend server health check. Port int32 `json:"port"` // CheckDelay: time to wait between two consecutive health checks. CheckDelay *time.Duration `json:"check_delay,omitempty"` // CheckTimeout: maximum time a backend server has to reply to the health check. CheckTimeout *time.Duration `json:"check_timeout,omitempty"` // CheckMaxRetries: number of consecutive unsuccessful health checks after which the server will be considered dead. CheckMaxRetries int32 `json:"check_max_retries"` // CheckSendProxy: defines whether proxy protocol should be activated for the health check. CheckSendProxy bool `json:"check_send_proxy"` // TCPConfig: object to configure a basic TCP health check. // Precisely one of TCPConfig, MysqlConfig, PgsqlConfig, LdapConfig, RedisConfig, HTTPConfig, HTTPSConfig must be set. TCPConfig *HealthCheckTCPConfig `json:"tcp_config,omitempty"` // MysqlConfig: object to configure a MySQL health check. The check requires MySQL >=3.22, for older versions, use a TCP health check. // Precisely one of TCPConfig, MysqlConfig, PgsqlConfig, LdapConfig, RedisConfig, HTTPConfig, HTTPSConfig must be set. MysqlConfig *HealthCheckMysqlConfig `json:"mysql_config,omitempty"` // PgsqlConfig: object to configure a PostgreSQL health check. // Precisely one of TCPConfig, MysqlConfig, PgsqlConfig, LdapConfig, RedisConfig, HTTPConfig, HTTPSConfig must be set. PgsqlConfig *HealthCheckPgsqlConfig `json:"pgsql_config,omitempty"` // LdapConfig: object to configure an LDAP health check. The response is analyzed to find the LDAPv3 response message. // Precisely one of TCPConfig, MysqlConfig, PgsqlConfig, LdapConfig, RedisConfig, HTTPConfig, HTTPSConfig must be set. LdapConfig *HealthCheckLdapConfig `json:"ldap_config,omitempty"` // RedisConfig: object to configure a Redis health check. The response is analyzed to find the +PONG response message. // Precisely one of TCPConfig, MysqlConfig, PgsqlConfig, LdapConfig, RedisConfig, HTTPConfig, HTTPSConfig must be set. RedisConfig *HealthCheckRedisConfig `json:"redis_config,omitempty"` // HTTPConfig: object to configure an HTTP health check. // Precisely one of TCPConfig, MysqlConfig, PgsqlConfig, LdapConfig, RedisConfig, HTTPConfig, HTTPSConfig must be set. HTTPConfig *HealthCheckHTTPConfig `json:"http_config,omitempty"` // HTTPSConfig: object to configure an HTTPS health check. // Precisely one of TCPConfig, MysqlConfig, PgsqlConfig, LdapConfig, RedisConfig, HTTPConfig, HTTPSConfig must be set. HTTPSConfig *HealthCheckHTTPSConfig `json:"https_config,omitempty"` // TransientCheckDelay: time to wait between two consecutive health checks when a backend server is in a transient state (going UP or DOWN). TransientCheckDelay *scw.Duration `json:"transient_check_delay,omitempty"` } func (m *UpdateHealthCheckRequest) UnmarshalJSON(b []byte) error { type tmpType UpdateHealthCheckRequest tmp := struct { tmpType TmpCheckDelay *marshaler.Duration `json:"check_delay,omitempty"` TmpCheckTimeout *marshaler.Duration `json:"check_timeout,omitempty"` }{} err := json.Unmarshal(b, &tmp) if err != nil { return err } *m = UpdateHealthCheckRequest(tmp.tmpType) m.CheckDelay = tmp.TmpCheckDelay.Standard() m.CheckTimeout = tmp.TmpCheckTimeout.Standard() return nil } func (m UpdateHealthCheckRequest) MarshalJSON() ([]byte, error) { type tmpType UpdateHealthCheckRequest tmp := struct { tmpType TmpCheckDelay *marshaler.Duration `json:"check_delay,omitempty"` TmpCheckTimeout *marshaler.Duration `json:"check_timeout,omitempty"` }{ tmpType: tmpType(m), TmpCheckDelay: marshaler.NewDuration(m.CheckDelay), TmpCheckTimeout: marshaler.NewDuration(m.CheckTimeout), } return json.Marshal(tmp) } // UpdateIPRequest: update ip request. type UpdateIPRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // IPID: IP address ID. IPID string `json:"-"` // Reverse: reverse DNS (domain name) for the IP address. Reverse *string `json:"reverse,omitempty"` // LBID: ID of the server on which to attach the flexible IP. LBID *string `json:"lb_id,omitempty"` } // UpdateLBRequest: update lb request. type UpdateLBRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // Name: load Balancer name. Name string `json:"name"` // Description: load Balancer description. Description string `json:"description"` // Tags: list of tags for the Load Balancer. Tags []string `json:"tags"` // SslCompatibilityLevel: determines the minimal SSL version which needs to be supported on the client side, in an SSL/TLS offloading context. Intermediate is suitable for general-purpose servers with a variety of clients, recommended for almost all systems. Modern is suitable for services with clients that support TLS 1.3 and don't need backward compatibility. Old is compatible with a small number of very old clients and should be used only as a last resort. // Default value: ssl_compatibility_level_unknown SslCompatibilityLevel SSLCompatibilityLevel `json:"ssl_compatibility_level"` } // UpdateRouteRequest: update route request. type UpdateRouteRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // RouteID: route ID. RouteID string `json:"-"` // BackendID: ID of the target backend for the route. BackendID string `json:"backend_id"` // Match: object defining the match condition for a route to be applied. If an incoming client session matches the specified condition (i.e. it has a matching SNI value or HTTP Host header value), it will be passed to the target backend. Match *RouteMatch `json:"match,omitempty"` } // UpdateSubscriberRequest: update subscriber request. type UpdateSubscriberRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SubscriberID: subscriber ID. SubscriberID string `json:"-"` // Name: subscriber name. Name string `json:"name"` // EmailConfig: email address configuration. // Precisely one of EmailConfig, WebhookConfig must be set. EmailConfig *SubscriberEmailConfig `json:"email_config,omitempty"` // WebhookConfig: webhook URI configuration. // Precisely one of EmailConfig, WebhookConfig must be set. WebhookConfig *SubscriberWebhookConfig `json:"webhook_config,omitempty"` } // ZonedAPIAddBackendServersRequest: zoned api add backend servers request. type ZonedAPIAddBackendServersRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // BackendID: backend ID. BackendID string `json:"-"` // ServerIP: list of IP addresses to add to backend servers. ServerIP []string `json:"server_ip"` } // ZonedAPIAttachPrivateNetworkRequest: zoned api attach private network request. type ZonedAPIAttachPrivateNetworkRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // PrivateNetworkID: private Network ID. PrivateNetworkID string `json:"-"` // Deprecated: StaticConfig: object containing an array of a local IP address for the Load Balancer on this Private Network. // Precisely one of StaticConfig, DHCPConfig, IpamConfig must be set. StaticConfig *PrivateNetworkStaticConfig `json:"static_config,omitempty"` // Deprecated: DHCPConfig: defines whether to let DHCP assign IP addresses. // Precisely one of StaticConfig, DHCPConfig, IpamConfig must be set. DHCPConfig *PrivateNetworkDHCPConfig `json:"dhcp_config,omitempty"` // Deprecated: IpamConfig: for internal use only. // Precisely one of StaticConfig, DHCPConfig, IpamConfig must be set. IpamConfig *PrivateNetworkIpamConfig `json:"ipam_config,omitempty"` } // ZonedAPICreateACLRequest: Add an ACL to a Load Balancer frontend. type ZonedAPICreateACLRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // FrontendID: frontend ID to attach the ACL to. FrontendID string `json:"-"` // Name: ACL name. Name string `json:"name"` // Action: action to take when incoming traffic matches an ACL filter. Action *ACLAction `json:"action"` // Match: ACL match filter object. One of `ip_subnet` or `http_filter` & `http_filter_value` are required. Match *ACLMatch `json:"match,omitempty"` // Index: priority of this ACL (ACLs are applied in ascending order, 0 is the first ACL executed). Index int32 `json:"index"` // Description: ACL description. Description string `json:"description"` } // ZonedAPICreateBackendRequest: zoned api create backend request. type ZonedAPICreateBackendRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // Name: name for the backend. Name string `json:"name"` // ForwardProtocol: protocol to be used by the backend when forwarding traffic to backend servers. // Default value: tcp ForwardProtocol Protocol `json:"forward_protocol"` // ForwardPort: port to be used by the backend when forwarding traffic to backend servers. ForwardPort int32 `json:"forward_port"` // ForwardPortAlgorithm: load balancing algorithm to be used when determining which backend server to forward new traffic to. // Default value: roundrobin ForwardPortAlgorithm ForwardPortAlgorithm `json:"forward_port_algorithm"` // StickySessions: defines whether to activate sticky sessions (binding a particular session to a particular backend server) and the method to use if so. None disables sticky sessions. Cookie-based uses an HTTP cookie TO stick a session to a backend server. Table-based uses the source (client) IP address to stick a session to a backend server. // Default value: none StickySessions StickySessionsType `json:"sticky_sessions"` // StickySessionsCookieName: cookie name for cookie-based sticky sessions. StickySessionsCookieName string `json:"sticky_sessions_cookie_name"` // HealthCheck: object defining the health check to be carried out by the backend when checking the status and health of backend servers. HealthCheck *HealthCheck `json:"health_check"` // ServerIP: list of backend server IP addresses (IPv4 or IPv6) the backend should forward traffic to. ServerIP []string `json:"server_ip"` // Deprecated: SendProxyV2: deprecated in favor of proxy_protocol field. SendProxyV2 *bool `json:"send_proxy_v2,omitempty"` // TimeoutServer: maximum allowed time for a backend server to process a request. TimeoutServer *time.Duration `json:"timeout_server,omitempty"` // TimeoutConnect: maximum allowed time for establishing a connection to a backend server. TimeoutConnect *time.Duration `json:"timeout_connect,omitempty"` // TimeoutTunnel: maximum allowed tunnel inactivity time after Websocket is established (takes precedence over client and server timeout). TimeoutTunnel *time.Duration `json:"timeout_tunnel,omitempty"` // OnMarkedDownAction: action to take when a backend server is marked as down. // Default value: on_marked_down_action_none OnMarkedDownAction OnMarkedDownAction `json:"on_marked_down_action"` // ProxyProtocol: protocol to use between the Load Balancer and backend servers. Allows the backend servers to be informed of the client's real IP address. The PROXY protocol must be supported by the backend servers' software. // Default value: proxy_protocol_unknown ProxyProtocol ProxyProtocol `json:"proxy_protocol"` // FailoverHost: scaleway S3 bucket website to be served as failover if all backend servers are down, e.g. failover-website.s3-website.fr-par.scw.cloud. FailoverHost *string `json:"failover_host,omitempty"` // SslBridging: defines whether to enable SSL bridging between the Load Balancer and backend servers. SslBridging *bool `json:"ssl_bridging,omitempty"` // IgnoreSslServerVerify: defines whether the server certificate verification should be ignored. IgnoreSslServerVerify *bool `json:"ignore_ssl_server_verify,omitempty"` // RedispatchAttemptCount: whether to use another backend server on each attempt. RedispatchAttemptCount *int32 `json:"redispatch_attempt_count,omitempty"` // MaxRetries: number of retries when a backend server connection failed. MaxRetries *int32 `json:"max_retries,omitempty"` // MaxConnections: maximum number of connections allowed per backend server. MaxConnections *int32 `json:"max_connections,omitempty"` // TimeoutQueue: maximum time for a request to be left pending in queue when `max_connections` is reached. TimeoutQueue *scw.Duration `json:"timeout_queue,omitempty"` } func (m *ZonedAPICreateBackendRequest) UnmarshalJSON(b []byte) error { type tmpType ZonedAPICreateBackendRequest tmp := struct { tmpType TmpTimeoutServer *marshaler.Duration `json:"timeout_server,omitempty"` TmpTimeoutConnect *marshaler.Duration `json:"timeout_connect,omitempty"` TmpTimeoutTunnel *marshaler.Duration `json:"timeout_tunnel,omitempty"` }{} err := json.Unmarshal(b, &tmp) if err != nil { return err } *m = ZonedAPICreateBackendRequest(tmp.tmpType) m.TimeoutServer = tmp.TmpTimeoutServer.Standard() m.TimeoutConnect = tmp.TmpTimeoutConnect.Standard() m.TimeoutTunnel = tmp.TmpTimeoutTunnel.Standard() return nil } func (m ZonedAPICreateBackendRequest) MarshalJSON() ([]byte, error) { type tmpType ZonedAPICreateBackendRequest tmp := struct { tmpType TmpTimeoutServer *marshaler.Duration `json:"timeout_server,omitempty"` TmpTimeoutConnect *marshaler.Duration `json:"timeout_connect,omitempty"` TmpTimeoutTunnel *marshaler.Duration `json:"timeout_tunnel,omitempty"` }{ tmpType: tmpType(m), TmpTimeoutServer: marshaler.NewDuration(m.TimeoutServer), TmpTimeoutConnect: marshaler.NewDuration(m.TimeoutConnect), TmpTimeoutTunnel: marshaler.NewDuration(m.TimeoutTunnel), } return json.Marshal(tmp) } // ZonedAPICreateCertificateRequest: zoned api create certificate request. type ZonedAPICreateCertificateRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // Name: name for the certificate. Name string `json:"name"` // Letsencrypt: object to define a new Let's Encrypt certificate to be generated. // Precisely one of Letsencrypt, CustomCertificate must be set. Letsencrypt *CreateCertificateRequestLetsencryptConfig `json:"letsencrypt,omitempty"` // CustomCertificate: object to define an existing custom certificate to be imported. // Precisely one of Letsencrypt, CustomCertificate must be set. CustomCertificate *CreateCertificateRequestCustomCertificate `json:"custom_certificate,omitempty"` } // ZonedAPICreateFrontendRequest: zoned api create frontend request. type ZonedAPICreateFrontendRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // LBID: load Balancer ID (ID of the Load Balancer to attach the frontend to). LBID string `json:"-"` // Name: name for the frontend. Name string `json:"name"` // InboundPort: port the frontend should listen on. InboundPort int32 `json:"inbound_port"` // BackendID: backend ID (ID of the backend the frontend should pass traffic to). BackendID string `json:"backend_id"` // TimeoutClient: maximum allowed inactivity time on the client side. TimeoutClient *time.Duration `json:"timeout_client,omitempty"` // Deprecated: CertificateID: certificate ID, deprecated in favor of certificate_ids array. CertificateID *string `json:"certificate_id,omitempty"` // CertificateIDs: list of SSL/TLS certificate IDs to bind to the frontend. CertificateIDs *[]string `json:"certificate_ids,omitempty"` // EnableHTTP3: defines whether to enable HTTP/3 protocol on the frontend. EnableHTTP3 bool `json:"enable_http3"` } func (m *ZonedAPICreateFrontendRequest) UnmarshalJSON(b []byte) error { type tmpType ZonedAPICreateFrontendRequest tmp := struct { tmpType TmpTimeoutClient *marshaler.Duration `json:"timeout_client,omitempty"` }{} err := json.Unmarshal(b, &tmp) if err != nil { return err } *m = ZonedAPICreateFrontendRequest(tmp.tmpType) m.TimeoutClient = tmp.TmpTimeoutClient.Standard() return nil } func (m ZonedAPICreateFrontendRequest) MarshalJSON() ([]byte, error) { type tmpType ZonedAPICreateFrontendRequest tmp := struct { tmpType TmpTimeoutClient *marshaler.Duration `json:"timeout_client,omitempty"` }{ tmpType: tmpType(m), TmpTimeoutClient: marshaler.NewDuration(m.TimeoutClient), } return json.Marshal(tmp) } // ZonedAPICreateIPRequest: zoned api create ip request. type ZonedAPICreateIPRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Deprecated: OrganizationID: organization ID of the Organization where the IP address should be created. // Precisely one of ProjectID, OrganizationID must be set. OrganizationID *string `json:"organization_id,omitempty"` // ProjectID: project ID of the Project where the IP address should be created. // Precisely one of ProjectID, OrganizationID must be set. ProjectID *string `json:"project_id,omitempty"` // Reverse: reverse DNS (domain name) for the IP address. Reverse *string `json:"reverse,omitempty"` // IsIPv6: if true, creates a Flexible IP with an ipv6 address. IsIPv6 bool `json:"is_ipv6"` } // ZonedAPICreateLBRequest: zoned api create lb request. type ZonedAPICreateLBRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Deprecated: OrganizationID: scaleway Organization to create the Load Balancer in. // Precisely one of ProjectID, OrganizationID must be set. OrganizationID *string `json:"organization_id,omitempty"` // ProjectID: scaleway Project to create the Load Balancer in. // Precisely one of ProjectID, OrganizationID must be set. ProjectID *string `json:"project_id,omitempty"` // Name: name for the Load Balancer. Name string `json:"name"` // Description: description for the Load Balancer. Description string `json:"description"` // Deprecated: IPID: ID of an existing flexible IP address to attach to the Load Balancer. IPID *string `json:"ip_id,omitempty"` // AssignFlexibleIP: defines whether to automatically assign a flexible public IP to lb. Default value is `false` (do not assign). AssignFlexibleIP *bool `json:"assign_flexible_ip,omitempty"` // AssignFlexibleIPv6: defines whether to automatically assign a flexible public IPv6 to the Load Balancer. Default value is `false` (do not assign). AssignFlexibleIPv6 *bool `json:"assign_flexible_ipv6,omitempty"` // IPIDs: list of IP IDs to attach to the Load Balancer. IPIDs []string `json:"ip_ids"` // Tags: list of tags for the Load Balancer. Tags []string `json:"tags"` // Type: load Balancer commercial offer type. Use the Load Balancer types endpoint to retrieve a list of available offer types. Type string `json:"type"` // SslCompatibilityLevel: determines the minimal SSL version which needs to be supported on the client side, in an SSL/TLS offloading context. Intermediate is suitable for general-purpose servers with a variety of clients, recommended for almost all systems. Modern is suitable for services with clients that support TLS 1.3 and do not need backward compatibility. Old is compatible with a small number of very old clients and should be used only as a last resort. // Default value: ssl_compatibility_level_unknown SslCompatibilityLevel SSLCompatibilityLevel `json:"ssl_compatibility_level"` } // ZonedAPICreateRouteRequest: zoned api create route request. type ZonedAPICreateRouteRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // FrontendID: ID of the source frontend to create the route on. FrontendID string `json:"frontend_id"` // BackendID: ID of the target backend for the route. BackendID string `json:"backend_id"` // Match: object defining the match condition for a route to be applied. If an incoming client session matches the specified condition (i.e. it has a matching SNI value or HTTP Host header value), it will be passed to the target backend. Match *RouteMatch `json:"match,omitempty"` } // ZonedAPICreateSubscriberRequest: Create a new alert subscriber (webhook or email). type ZonedAPICreateSubscriberRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Name: subscriber name. Name string `json:"name"` // EmailConfig: email address configuration. // Precisely one of EmailConfig, WebhookConfig must be set. EmailConfig *SubscriberEmailConfig `json:"email_config,omitempty"` // WebhookConfig: webHook URI configuration. // Precisely one of EmailConfig, WebhookConfig must be set. WebhookConfig *SubscriberWebhookConfig `json:"webhook_config,omitempty"` // Deprecated: OrganizationID: organization ID to create the subscriber in. // Precisely one of ProjectID, OrganizationID must be set. OrganizationID *string `json:"organization_id,omitempty"` // ProjectID: project ID to create the subscriber in. // Precisely one of ProjectID, OrganizationID must be set. ProjectID *string `json:"project_id,omitempty"` } // ZonedAPIDeleteACLRequest: zoned api delete acl request. type ZonedAPIDeleteACLRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ACLID: ACL ID. ACLID string `json:"-"` } // ZonedAPIDeleteBackendRequest: zoned api delete backend request. type ZonedAPIDeleteBackendRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // BackendID: ID of the backend to delete. BackendID string `json:"-"` } // ZonedAPIDeleteCertificateRequest: zoned api delete certificate request. type ZonedAPIDeleteCertificateRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // CertificateID: certificate ID. CertificateID string `json:"-"` } // ZonedAPIDeleteFrontendRequest: zoned api delete frontend request. type ZonedAPIDeleteFrontendRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // FrontendID: ID of the frontend to delete. FrontendID string `json:"-"` } // ZonedAPIDeleteLBRequest: zoned api delete lb request. type ZonedAPIDeleteLBRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // LBID: ID of the Load Balancer to delete. LBID string `json:"-"` // ReleaseIP: defines whether the Load Balancer's flexible IP should be deleted. Set to true to release the flexible IP, or false to keep it available in your account for future Load Balancers. ReleaseIP bool `json:"release_ip"` } // ZonedAPIDeleteRouteRequest: zoned api delete route request. type ZonedAPIDeleteRouteRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // RouteID: route ID. RouteID string `json:"-"` } // ZonedAPIDeleteSubscriberRequest: zoned api delete subscriber request. type ZonedAPIDeleteSubscriberRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // SubscriberID: subscriber ID. SubscriberID string `json:"-"` } // ZonedAPIDetachPrivateNetworkRequest: zoned api detach private network request. type ZonedAPIDetachPrivateNetworkRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // LBID: load balancer ID. LBID string `json:"-"` // PrivateNetworkID: set your instance private network id. PrivateNetworkID string `json:"-"` } // ZonedAPIGetACLRequest: zoned api get acl request. type ZonedAPIGetACLRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ACLID: ACL ID. ACLID string `json:"-"` } // ZonedAPIGetBackendRequest: zoned api get backend request. type ZonedAPIGetBackendRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // BackendID: backend ID. BackendID string `json:"-"` } // ZonedAPIGetCertificateRequest: zoned api get certificate request. type ZonedAPIGetCertificateRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // CertificateID: certificate ID. CertificateID string `json:"-"` } // ZonedAPIGetFrontendRequest: zoned api get frontend request. type ZonedAPIGetFrontendRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // FrontendID: frontend ID. FrontendID string `json:"-"` } // ZonedAPIGetIPRequest: zoned api get ip request. type ZonedAPIGetIPRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // IPID: IP address ID. IPID string `json:"-"` } // ZonedAPIGetLBRequest: zoned api get lb request. type ZonedAPIGetLBRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` } // ZonedAPIGetLBStatsRequest: Get Load Balancer stats. type ZonedAPIGetLBStatsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // BackendID: ID of the backend. BackendID *string `json:"backend_id,omitempty"` } // ZonedAPIGetRouteRequest: zoned api get route request. type ZonedAPIGetRouteRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // RouteID: route ID. RouteID string `json:"-"` } // ZonedAPIGetSubscriberRequest: zoned api get subscriber request. type ZonedAPIGetSubscriberRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // SubscriberID: subscriber ID. SubscriberID string `json:"-"` } // ZonedAPIListACLsRequest: zoned api list ac ls request. type ZonedAPIListACLsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // FrontendID: frontend ID (ACLs attached to this frontend will be returned in the response). FrontendID string `json:"-"` // OrderBy: sort order of ACLs in the response. // Default value: created_at_asc OrderBy ListACLRequestOrderBy `json:"-"` // Page: the page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: the number of ACLs to return. PageSize *uint32 `json:"-"` // Name: ACL name to filter for. Name *string `json:"-"` } // ZonedAPIListBackendStatsRequest: zoned api list backend stats request. type ZonedAPIListBackendStatsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // Page: the page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: number of items to return. PageSize *uint32 `json:"-"` // BackendID: ID of the backend. BackendID *string `json:"-"` } // ZonedAPIListBackendsRequest: zoned api list backends request. type ZonedAPIListBackendsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // Name: name of the backend to filter for. Name *string `json:"-"` // OrderBy: sort order of backends in the response. // Default value: created_at_asc OrderBy ListBackendsRequestOrderBy `json:"-"` // Page: the page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: number of backends to return. PageSize *uint32 `json:"-"` } // ZonedAPIListCertificatesRequest: zoned api list certificates request. type ZonedAPIListCertificatesRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // OrderBy: sort order of certificates in the response. // Default value: created_at_asc OrderBy ListCertificatesRequestOrderBy `json:"-"` // Page: the page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: number of certificates to return. PageSize *uint32 `json:"-"` // Name: certificate name to filter for, only certificates of this name will be returned. Name *string `json:"-"` } // ZonedAPIListFrontendsRequest: zoned api list frontends request. type ZonedAPIListFrontendsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // Name: name of the frontend to filter for. Name *string `json:"-"` // OrderBy: sort order of frontends in the response. // Default value: created_at_asc OrderBy ListFrontendsRequestOrderBy `json:"-"` // Page: the page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: number of frontends to return. PageSize *uint32 `json:"-"` } // ZonedAPIListIPsRequest: zoned api list i ps request. type ZonedAPIListIPsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Page: the page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: number of IP addresses to return. PageSize *uint32 `json:"-"` // IPAddress: IP address to filter for. IPAddress *string `json:"-"` // OrganizationID: organization ID to filter for, only Load Balancer IP addresses from this Organization will be returned. OrganizationID *string `json:"-"` // ProjectID: project ID to filter for, only Load Balancer IP addresses from this Project will be returned. ProjectID *string `json:"-"` // IPType: IP type to filter for. // Default value: all IPType ListIPsRequestIPType `json:"-"` } // ZonedAPIListLBPrivateNetworksRequest: zoned api list lb private networks request. type ZonedAPIListLBPrivateNetworksRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // OrderBy: sort order of Private Network objects in the response. // Default value: created_at_asc OrderBy ListPrivateNetworksRequestOrderBy `json:"-"` // PageSize: number of objects to return. PageSize *uint32 `json:"-"` // Page: the page number to return, from the paginated results. Page *int32 `json:"-"` } // ZonedAPIListLBTypesRequest: zoned api list lb types request. type ZonedAPIListLBTypesRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Page: the page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: the number of items to return. PageSize *uint32 `json:"-"` } // ZonedAPIListLBsRequest: zoned api list l bs request. type ZonedAPIListLBsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Name: load Balancer name to filter for. Name *string `json:"-"` // OrderBy: sort order of Load Balancers in the response. // Default value: created_at_asc OrderBy ListLBsRequestOrderBy `json:"-"` // PageSize: number of Load Balancers to return. PageSize *uint32 `json:"-"` // Page: page number to return, from the paginated results. Page *int32 `json:"-"` // OrganizationID: organization ID to filter for, only Load Balancers from this Organization will be returned. OrganizationID *string `json:"-"` // ProjectID: project ID to filter for, only Load Balancers from this Project will be returned. ProjectID *string `json:"-"` } // ZonedAPIListRoutesRequest: zoned api list routes request. type ZonedAPIListRoutesRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // OrderBy: sort order of routes in the response. // Default value: created_at_asc OrderBy ListRoutesRequestOrderBy `json:"-"` // PageSize: the number of route objects to return. PageSize *uint32 `json:"-"` // Page: the page number to return, from the paginated results. Page *int32 `json:"-"` // FrontendID: frontend ID to filter for, only Routes from this Frontend will be returned. FrontendID *string `json:"-"` } // ZonedAPIListSubscriberRequest: zoned api list subscriber request. type ZonedAPIListSubscriberRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // OrderBy: sort order of subscribers in the response. // Default value: created_at_asc OrderBy ListSubscriberRequestOrderBy `json:"-"` // Page: the page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: the number of items to return. PageSize *uint32 `json:"-"` // Name: subscriber name to search for. Name *string `json:"-"` // OrganizationID: filter subscribers by Organization ID. OrganizationID *string `json:"-"` // ProjectID: filter subscribers by Project ID. ProjectID *string `json:"-"` } // ZonedAPIMigrateLBRequest: zoned api migrate lb request. type ZonedAPIMigrateLBRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // Type: load Balancer type to migrate to (use the List all Load Balancer offer types endpoint to get a list of available offer types). Type string `json:"type"` } // ZonedAPIReleaseIPRequest: zoned api release ip request. type ZonedAPIReleaseIPRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // IPID: IP address ID. IPID string `json:"-"` } // ZonedAPIRemoveBackendServersRequest: zoned api remove backend servers request. type ZonedAPIRemoveBackendServersRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // BackendID: backend ID. BackendID string `json:"-"` // ServerIP: list of IP addresses to remove from backend servers. ServerIP []string `json:"server_ip"` } // ZonedAPISetACLsRequest: zoned api set ac ls request. type ZonedAPISetACLsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // FrontendID: frontend ID. FrontendID string `json:"-"` // ACLs: list of ACLs for this frontend. Any other existing ACLs on this frontend will be removed. ACLs []*ACLSpec `json:"acls"` } // ZonedAPISetBackendServersRequest: zoned api set backend servers request. type ZonedAPISetBackendServersRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // BackendID: backend ID. BackendID string `json:"-"` // ServerIP: list of IP addresses for backend servers. Any other existing backend servers will be removed. ServerIP []string `json:"server_ip"` } // ZonedAPISubscribeToLBRequest: zoned api subscribe to lb request. type ZonedAPISubscribeToLBRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // SubscriberID: subscriber ID. SubscriberID string `json:"subscriber_id"` } // ZonedAPIUnsubscribeFromLBRequest: zoned api unsubscribe from lb request. type ZonedAPIUnsubscribeFromLBRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` } // ZonedAPIUpdateACLRequest: zoned api update acl request. type ZonedAPIUpdateACLRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ACLID: ACL ID. ACLID string `json:"-"` // Name: ACL name. Name string `json:"name"` // Action: action to take when incoming traffic matches an ACL filter. Action *ACLAction `json:"action"` // Match: ACL match filter object. One of `ip_subnet` or `http_filter` & `http_filter_value` are required. Match *ACLMatch `json:"match,omitempty"` // Index: priority of this ACL (ACLs are applied in ascending order, 0 is the first ACL executed). Index int32 `json:"index"` // Description: ACL description. Description *string `json:"description,omitempty"` } // ZonedAPIUpdateBackendRequest: zoned api update backend request. type ZonedAPIUpdateBackendRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // BackendID: backend ID. BackendID string `json:"-"` // Name: backend name. Name string `json:"name"` // ForwardProtocol: protocol to be used by the backend when forwarding traffic to backend servers. // Default value: tcp ForwardProtocol Protocol `json:"forward_protocol"` // ForwardPort: port to be used by the backend when forwarding traffic to backend servers. ForwardPort int32 `json:"forward_port"` // ForwardPortAlgorithm: load balancing algorithm to be used when determining which backend server to forward new traffic to. // Default value: roundrobin ForwardPortAlgorithm ForwardPortAlgorithm `json:"forward_port_algorithm"` // StickySessions: defines whether to activate sticky sessions (binding a particular session to a particular backend server) and the method to use if so. None disables sticky sessions. Cookie-based uses an HTTP cookie to stick a session to a backend server. Table-based uses the source (client) IP address to stick a session to a backend server. // Default value: none StickySessions StickySessionsType `json:"sticky_sessions"` // StickySessionsCookieName: cookie name for cookie-based sticky sessions. StickySessionsCookieName string `json:"sticky_sessions_cookie_name"` // Deprecated: SendProxyV2: deprecated in favor of proxy_protocol field. SendProxyV2 *bool `json:"send_proxy_v2,omitempty"` // TimeoutServer: maximum allowed time for a backend server to process a request. TimeoutServer *time.Duration `json:"timeout_server,omitempty"` // TimeoutConnect: maximum allowed time for establishing a connection to a backend server. TimeoutConnect *time.Duration `json:"timeout_connect,omitempty"` // TimeoutTunnel: maximum allowed tunnel inactivity time after Websocket is established (takes precedence over client and server timeout). TimeoutTunnel *time.Duration `json:"timeout_tunnel,omitempty"` // OnMarkedDownAction: action to take when a backend server is marked as down. // Default value: on_marked_down_action_none OnMarkedDownAction OnMarkedDownAction `json:"on_marked_down_action"` // ProxyProtocol: protocol to use between the Load Balancer and backend servers. Allows the backend servers to be informed of the client's real IP address. The PROXY protocol must be supported by the backend servers' software. // Default value: proxy_protocol_unknown ProxyProtocol ProxyProtocol `json:"proxy_protocol"` // FailoverHost: scaleway S3 bucket website to be served as failover if all backend servers are down, e.g. failover-website.s3-website.fr-par.scw.cloud. FailoverHost *string `json:"failover_host,omitempty"` // SslBridging: defines whether to enable SSL bridging between the Load Balancer and backend servers. SslBridging *bool `json:"ssl_bridging,omitempty"` // IgnoreSslServerVerify: defines whether the server certificate verification should be ignored. IgnoreSslServerVerify *bool `json:"ignore_ssl_server_verify,omitempty"` // RedispatchAttemptCount: whether to use another backend server on each attempt. RedispatchAttemptCount *int32 `json:"redispatch_attempt_count,omitempty"` // MaxRetries: number of retries when a backend server connection failed. MaxRetries *int32 `json:"max_retries,omitempty"` // MaxConnections: maximum number of connections allowed per backend server. MaxConnections *int32 `json:"max_connections,omitempty"` // TimeoutQueue: maximum time for a request to be left pending in queue when `max_connections` is reached. TimeoutQueue *scw.Duration `json:"timeout_queue,omitempty"` } func (m *ZonedAPIUpdateBackendRequest) UnmarshalJSON(b []byte) error { type tmpType ZonedAPIUpdateBackendRequest tmp := struct { tmpType TmpTimeoutServer *marshaler.Duration `json:"timeout_server,omitempty"` TmpTimeoutConnect *marshaler.Duration `json:"timeout_connect,omitempty"` TmpTimeoutTunnel *marshaler.Duration `json:"timeout_tunnel,omitempty"` }{} err := json.Unmarshal(b, &tmp) if err != nil { return err } *m = ZonedAPIUpdateBackendRequest(tmp.tmpType) m.TimeoutServer = tmp.TmpTimeoutServer.Standard() m.TimeoutConnect = tmp.TmpTimeoutConnect.Standard() m.TimeoutTunnel = tmp.TmpTimeoutTunnel.Standard() return nil } func (m ZonedAPIUpdateBackendRequest) MarshalJSON() ([]byte, error) { type tmpType ZonedAPIUpdateBackendRequest tmp := struct { tmpType TmpTimeoutServer *marshaler.Duration `json:"timeout_server,omitempty"` TmpTimeoutConnect *marshaler.Duration `json:"timeout_connect,omitempty"` TmpTimeoutTunnel *marshaler.Duration `json:"timeout_tunnel,omitempty"` }{ tmpType: tmpType(m), TmpTimeoutServer: marshaler.NewDuration(m.TimeoutServer), TmpTimeoutConnect: marshaler.NewDuration(m.TimeoutConnect), TmpTimeoutTunnel: marshaler.NewDuration(m.TimeoutTunnel), } return json.Marshal(tmp) } // ZonedAPIUpdateCertificateRequest: zoned api update certificate request. type ZonedAPIUpdateCertificateRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // CertificateID: certificate ID. CertificateID string `json:"-"` // Name: certificate name. Name string `json:"name"` } // ZonedAPIUpdateFrontendRequest: zoned api update frontend request. type ZonedAPIUpdateFrontendRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // FrontendID: frontend ID. FrontendID string `json:"-"` // Name: frontend name. Name string `json:"name"` // InboundPort: port the frontend should listen on. InboundPort int32 `json:"inbound_port"` // BackendID: backend ID (ID of the backend the frontend should pass traffic to). BackendID string `json:"backend_id"` // TimeoutClient: maximum allowed inactivity time on the client side. TimeoutClient *time.Duration `json:"timeout_client,omitempty"` // Deprecated: CertificateID: certificate ID, deprecated in favor of certificate_ids array. CertificateID *string `json:"certificate_id,omitempty"` // CertificateIDs: list of SSL/TLS certificate IDs to bind to the frontend. CertificateIDs *[]string `json:"certificate_ids,omitempty"` // EnableHTTP3: defines whether to enable HTTP/3 protocol on the frontend. EnableHTTP3 bool `json:"enable_http3"` } func (m *ZonedAPIUpdateFrontendRequest) UnmarshalJSON(b []byte) error { type tmpType ZonedAPIUpdateFrontendRequest tmp := struct { tmpType TmpTimeoutClient *marshaler.Duration `json:"timeout_client,omitempty"` }{} err := json.Unmarshal(b, &tmp) if err != nil { return err } *m = ZonedAPIUpdateFrontendRequest(tmp.tmpType) m.TimeoutClient = tmp.TmpTimeoutClient.Standard() return nil } func (m ZonedAPIUpdateFrontendRequest) MarshalJSON() ([]byte, error) { type tmpType ZonedAPIUpdateFrontendRequest tmp := struct { tmpType TmpTimeoutClient *marshaler.Duration `json:"timeout_client,omitempty"` }{ tmpType: tmpType(m), TmpTimeoutClient: marshaler.NewDuration(m.TimeoutClient), } return json.Marshal(tmp) } // ZonedAPIUpdateHealthCheckRequest: zoned api update health check request. type ZonedAPIUpdateHealthCheckRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // BackendID: backend ID. BackendID string `json:"-"` // Port: port to use for the backend server health check. Port int32 `json:"port"` // CheckDelay: time to wait between two consecutive health checks. CheckDelay *time.Duration `json:"check_delay,omitempty"` // CheckTimeout: maximum time a backend server has to reply to the health check. CheckTimeout *time.Duration `json:"check_timeout,omitempty"` // CheckMaxRetries: number of consecutive unsuccessful health checks after which the server will be considered dead. CheckMaxRetries int32 `json:"check_max_retries"` // CheckSendProxy: defines whether proxy protocol should be activated for the health check. CheckSendProxy bool `json:"check_send_proxy"` // TCPConfig: object to configure a basic TCP health check. // Precisely one of TCPConfig, MysqlConfig, PgsqlConfig, LdapConfig, RedisConfig, HTTPConfig, HTTPSConfig must be set. TCPConfig *HealthCheckTCPConfig `json:"tcp_config,omitempty"` // MysqlConfig: object to configure a MySQL health check. The check requires MySQL >=3.22, for older versions, use a TCP health check. // Precisely one of TCPConfig, MysqlConfig, PgsqlConfig, LdapConfig, RedisConfig, HTTPConfig, HTTPSConfig must be set. MysqlConfig *HealthCheckMysqlConfig `json:"mysql_config,omitempty"` // PgsqlConfig: object to configure a PostgreSQL health check. // Precisely one of TCPConfig, MysqlConfig, PgsqlConfig, LdapConfig, RedisConfig, HTTPConfig, HTTPSConfig must be set. PgsqlConfig *HealthCheckPgsqlConfig `json:"pgsql_config,omitempty"` // LdapConfig: object to configure an LDAP health check. The response is analyzed to find the LDAPv3 response message. // Precisely one of TCPConfig, MysqlConfig, PgsqlConfig, LdapConfig, RedisConfig, HTTPConfig, HTTPSConfig must be set. LdapConfig *HealthCheckLdapConfig `json:"ldap_config,omitempty"` // RedisConfig: object to configure a Redis health check. The response is analyzed to find the +PONG response message. // Precisely one of TCPConfig, MysqlConfig, PgsqlConfig, LdapConfig, RedisConfig, HTTPConfig, HTTPSConfig must be set. RedisConfig *HealthCheckRedisConfig `json:"redis_config,omitempty"` // HTTPConfig: object to configure an HTTP health check. // Precisely one of TCPConfig, MysqlConfig, PgsqlConfig, LdapConfig, RedisConfig, HTTPConfig, HTTPSConfig must be set. HTTPConfig *HealthCheckHTTPConfig `json:"http_config,omitempty"` // HTTPSConfig: object to configure an HTTPS health check. // Precisely one of TCPConfig, MysqlConfig, PgsqlConfig, LdapConfig, RedisConfig, HTTPConfig, HTTPSConfig must be set. HTTPSConfig *HealthCheckHTTPSConfig `json:"https_config,omitempty"` // TransientCheckDelay: time to wait between two consecutive health checks when a backend server is in a transient state (going UP or DOWN). TransientCheckDelay *scw.Duration `json:"transient_check_delay,omitempty"` } func (m *ZonedAPIUpdateHealthCheckRequest) UnmarshalJSON(b []byte) error { type tmpType ZonedAPIUpdateHealthCheckRequest tmp := struct { tmpType TmpCheckDelay *marshaler.Duration `json:"check_delay,omitempty"` TmpCheckTimeout *marshaler.Duration `json:"check_timeout,omitempty"` }{} err := json.Unmarshal(b, &tmp) if err != nil { return err } *m = ZonedAPIUpdateHealthCheckRequest(tmp.tmpType) m.CheckDelay = tmp.TmpCheckDelay.Standard() m.CheckTimeout = tmp.TmpCheckTimeout.Standard() return nil } func (m ZonedAPIUpdateHealthCheckRequest) MarshalJSON() ([]byte, error) { type tmpType ZonedAPIUpdateHealthCheckRequest tmp := struct { tmpType TmpCheckDelay *marshaler.Duration `json:"check_delay,omitempty"` TmpCheckTimeout *marshaler.Duration `json:"check_timeout,omitempty"` }{ tmpType: tmpType(m), TmpCheckDelay: marshaler.NewDuration(m.CheckDelay), TmpCheckTimeout: marshaler.NewDuration(m.CheckTimeout), } return json.Marshal(tmp) } // ZonedAPIUpdateIPRequest: zoned api update ip request. type ZonedAPIUpdateIPRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // IPID: IP address ID. IPID string `json:"-"` // Reverse: reverse DNS (domain name) for the IP address. Reverse *string `json:"reverse,omitempty"` // LBID: ID of the server on which to attach the flexible IP. LBID *string `json:"lb_id,omitempty"` } // ZonedAPIUpdateLBRequest: zoned api update lb request. type ZonedAPIUpdateLBRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // LBID: load Balancer ID. LBID string `json:"-"` // Name: load Balancer name. Name string `json:"name"` // Description: load Balancer description. Description string `json:"description"` // Tags: list of tags for the Load Balancer. Tags []string `json:"tags"` // SslCompatibilityLevel: determines the minimal SSL version which needs to be supported on the client side, in an SSL/TLS offloading context. Intermediate is suitable for general-purpose servers with a variety of clients, recommended for almost all systems. Modern is suitable for services with clients that support TLS 1.3 and don't need backward compatibility. Old is compatible with a small number of very old clients and should be used only as a last resort. // Default value: ssl_compatibility_level_unknown SslCompatibilityLevel SSLCompatibilityLevel `json:"ssl_compatibility_level"` } // ZonedAPIUpdateRouteRequest: zoned api update route request. type ZonedAPIUpdateRouteRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // RouteID: route ID. RouteID string `json:"-"` // BackendID: ID of the target backend for the route. BackendID string `json:"backend_id"` // Match: object defining the match condition for a route to be applied. If an incoming client session matches the specified condition (i.e. it has a matching SNI value or HTTP Host header value), it will be passed to the target backend. Match *RouteMatch `json:"match,omitempty"` } // ZonedAPIUpdateSubscriberRequest: zoned api update subscriber request. type ZonedAPIUpdateSubscriberRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // SubscriberID: subscriber ID. SubscriberID string `json:"-"` // Name: subscriber name. Name string `json:"name"` // EmailConfig: email address configuration. // Precisely one of EmailConfig, WebhookConfig must be set. EmailConfig *SubscriberEmailConfig `json:"email_config,omitempty"` // WebhookConfig: webhook URI configuration. // Precisely one of EmailConfig, WebhookConfig must be set. WebhookConfig *SubscriberWebhookConfig `json:"webhook_config,omitempty"` } // This API allows you to manage your Scaleway Load Balancer services. type ZonedAPI struct { client *scw.Client } // NewZonedAPI returns a ZonedAPI object from a Scaleway client. func NewZonedAPI(client *scw.Client) *ZonedAPI { return &ZonedAPI{ client: client, } } func (s *ZonedAPI) Zones() []scw.Zone { return []scw.Zone{scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.ZonePlWaw3} } // ListLBs: List all Load Balancers in the specified zone, for a Scaleway Organization or Scaleway Project. By default, the Load Balancers returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. func (s *ZonedAPI) ListLBs(req *ZonedAPIListLBsRequest, opts ...scw.RequestOption) (*ListLBsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/lbs", Query: query, } var resp ListLBsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateLB: Create a new Load Balancer. Note that the Load Balancer will be created without frontends or backends; these must be created separately via the dedicated endpoints. func (s *ZonedAPI) CreateLB(req *ZonedAPICreateLBRequest, opts ...scw.RequestOption) (*LB, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultProjectID, exist := s.client.GetDefaultProjectID() if exist && req.ProjectID == nil && req.OrganizationID == nil { req.ProjectID = &defaultProjectID } defaultOrganizationID, exist := s.client.GetDefaultOrganizationID() if exist && req.ProjectID == nil && req.OrganizationID == nil { req.OrganizationID = &defaultOrganizationID } if req.Name == "" { req.Name = namegenerator.GetRandomName("lb") } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/lbs", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp LB err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetLB: Retrieve information about an existing Load Balancer, specified by its Load Balancer ID. Its full details, including name, status and IP address, are returned in the response object. func (s *ZonedAPI) GetLB(req *ZonedAPIGetLBRequest, opts ...scw.RequestOption) (*LB, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/lbs/" + fmt.Sprint(req.LBID) + "", } var resp LB err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateLB: Update the parameters of an existing Load Balancer, specified by its Load Balancer ID. Note that the request type is PUT and not PATCH. You must set all parameters. func (s *ZonedAPI) UpdateLB(req *ZonedAPIUpdateLBRequest, opts ...scw.RequestOption) (*LB, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/lbs/" + fmt.Sprint(req.LBID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp LB err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteLB: Delete an existing Load Balancer, specified by its Load Balancer ID. Deleting a Load Balancer is permanent, and cannot be undone. The Load Balancer's flexible IP address can either be deleted with the Load Balancer, or kept in your account for future use. func (s *ZonedAPI) DeleteLB(req *ZonedAPIDeleteLBRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } query := url.Values{} parameter.AddToQuery(query, "release_ip", req.ReleaseIP) if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/lbs/" + fmt.Sprint(req.LBID) + "", Query: query, } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // MigrateLB: Migrate an existing Load Balancer from one commercial type to another. Allows you to scale your Load Balancer up or down in terms of bandwidth or multi-cloud provision. func (s *ZonedAPI) MigrateLB(req *ZonedAPIMigrateLBRequest, opts ...scw.RequestOption) (*LB, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/lbs/" + fmt.Sprint(req.LBID) + "/migrate", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp LB err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListIPs: List the Load Balancer flexible IP addresses held in the account (filtered by Organization ID or Project ID). It is also possible to search for a specific IP address. func (s *ZonedAPI) ListIPs(req *ZonedAPIListIPsRequest, opts ...scw.RequestOption) (*ListIPsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "ip_address", req.IPAddress) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "ip_type", req.IPType) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/ips", Query: query, } var resp ListIPsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateIP: Create a new Load Balancer flexible IP address, in the specified Scaleway Project. This can be attached to new Load Balancers created in the future. func (s *ZonedAPI) CreateIP(req *ZonedAPICreateIPRequest, opts ...scw.RequestOption) (*IP, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultProjectID, exist := s.client.GetDefaultProjectID() if exist && req.ProjectID == nil && req.OrganizationID == nil { req.ProjectID = &defaultProjectID } defaultOrganizationID, exist := s.client.GetDefaultOrganizationID() if exist && req.ProjectID == nil && req.OrganizationID == nil { req.OrganizationID = &defaultOrganizationID } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/ips", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp IP err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetIP: Retrieve the full details of a Load Balancer flexible IP address. func (s *ZonedAPI) GetIP(req *ZonedAPIGetIPRequest, opts ...scw.RequestOption) (*IP, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.IPID) == "" { return nil, errors.New("field IPID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/ips/" + fmt.Sprint(req.IPID) + "", } var resp IP err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ReleaseIP: Delete a Load Balancer flexible IP address. This action is irreversible, and cannot be undone. func (s *ZonedAPI) ReleaseIP(req *ZonedAPIReleaseIPRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.IPID) == "" { return errors.New("field IPID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/ips/" + fmt.Sprint(req.IPID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // UpdateIP: Update the reverse DNS of a Load Balancer flexible IP address. func (s *ZonedAPI) UpdateIP(req *ZonedAPIUpdateIPRequest, opts ...scw.RequestOption) (*IP, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.IPID) == "" { return nil, errors.New("field IPID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/ips/" + fmt.Sprint(req.IPID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp IP err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListBackends: List all the backends of a Load Balancer, specified by its Load Balancer ID. By default, results are returned in ascending order by the creation date of each backend. The response is an array of backend objects, containing full details of each one including their configuration parameters such as protocol, port and forwarding algorithm. func (s *ZonedAPI) ListBackends(req *ZonedAPIListBackendsRequest, opts ...scw.RequestOption) (*ListBackendsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/lbs/" + fmt.Sprint(req.LBID) + "/backends", Query: query, } var resp ListBackendsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateBackend: Create a new backend for a given Load Balancer, specifying its full configuration including protocol, port and forwarding algorithm. func (s *ZonedAPI) CreateBackend(req *ZonedAPICreateBackendRequest, opts ...scw.RequestOption) (*Backend, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if req.Name == "" { req.Name = namegenerator.GetRandomName("lbb") } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/lbs/" + fmt.Sprint(req.LBID) + "/backends", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Backend err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetBackend: Get the full details of a given backend, specified by its backend ID. The response contains the backend's full configuration parameters including protocol, port and forwarding algorithm. func (s *ZonedAPI) GetBackend(req *ZonedAPIGetBackendRequest, opts ...scw.RequestOption) (*Backend, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.BackendID) == "" { return nil, errors.New("field BackendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/backends/" + fmt.Sprint(req.BackendID) + "", } var resp Backend err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateBackend: Update a backend of a given Load Balancer, specified by its backend ID. Note that the request type is PUT and not PATCH. You must set all parameters. func (s *ZonedAPI) UpdateBackend(req *ZonedAPIUpdateBackendRequest, opts ...scw.RequestOption) (*Backend, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.BackendID) == "" { return nil, errors.New("field BackendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/backends/" + fmt.Sprint(req.BackendID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Backend err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteBackend: Delete a backend of a given Load Balancer, specified by its backend ID. This action is irreversible and cannot be undone. func (s *ZonedAPI) DeleteBackend(req *ZonedAPIDeleteBackendRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.BackendID) == "" { return errors.New("field BackendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/backends/" + fmt.Sprint(req.BackendID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // AddBackendServers: For a given backend specified by its backend ID, add a set of backend servers (identified by their IP addresses) it should forward traffic to. These will be appended to any existing set of backend servers for this backend. func (s *ZonedAPI) AddBackendServers(req *ZonedAPIAddBackendServersRequest, opts ...scw.RequestOption) (*Backend, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.BackendID) == "" { return nil, errors.New("field BackendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/backends/" + fmt.Sprint(req.BackendID) + "/servers", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Backend err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // RemoveBackendServers: For a given backend specified by its backend ID, remove the specified backend servers (identified by their IP addresses) so that it no longer forwards traffic to them. func (s *ZonedAPI) RemoveBackendServers(req *ZonedAPIRemoveBackendServersRequest, opts ...scw.RequestOption) (*Backend, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.BackendID) == "" { return nil, errors.New("field BackendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/backends/" + fmt.Sprint(req.BackendID) + "/servers", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Backend err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SetBackendServers: For a given backend specified by its backend ID, define the set of backend servers (identified by their IP addresses) that it should forward traffic to. Any existing backend servers configured for this backend will be removed. func (s *ZonedAPI) SetBackendServers(req *ZonedAPISetBackendServersRequest, opts ...scw.RequestOption) (*Backend, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.BackendID) == "" { return nil, errors.New("field BackendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/backends/" + fmt.Sprint(req.BackendID) + "/servers", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Backend err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateHealthCheck: Update the configuration of the health check performed by a given backend to verify the health of its backend servers, identified by its backend ID. Note that the request type is PUT and not PATCH. You must set all parameters. func (s *ZonedAPI) UpdateHealthCheck(req *ZonedAPIUpdateHealthCheckRequest, opts ...scw.RequestOption) (*HealthCheck, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.BackendID) == "" { return nil, errors.New("field BackendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/backends/" + fmt.Sprint(req.BackendID) + "/healthcheck", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp HealthCheck err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListFrontends: List all the frontends of a Load Balancer, specified by its Load Balancer ID. By default, results are returned in ascending order by the creation date of each frontend. The response is an array of frontend objects, containing full details of each one including the port they listen on and the backend they are attached to. func (s *ZonedAPI) ListFrontends(req *ZonedAPIListFrontendsRequest, opts ...scw.RequestOption) (*ListFrontendsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/lbs/" + fmt.Sprint(req.LBID) + "/frontends", Query: query, } var resp ListFrontendsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateFrontend: Create a new frontend for a given Load Balancer, specifying its configuration including the port it should listen on and the backend to attach it to. func (s *ZonedAPI) CreateFrontend(req *ZonedAPICreateFrontendRequest, opts ...scw.RequestOption) (*Frontend, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if req.Name == "" { req.Name = namegenerator.GetRandomName("lbf") } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/lbs/" + fmt.Sprint(req.LBID) + "/frontends", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Frontend err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetFrontend: Get the full details of a given frontend, specified by its frontend ID. The response contains the frontend's full configuration parameters including the backend it is attached to, the port it listens on, and any certificates it has. func (s *ZonedAPI) GetFrontend(req *ZonedAPIGetFrontendRequest, opts ...scw.RequestOption) (*Frontend, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.FrontendID) == "" { return nil, errors.New("field FrontendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/frontends/" + fmt.Sprint(req.FrontendID) + "", } var resp Frontend err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateFrontend: Update a given frontend, specified by its frontend ID. You can update configuration parameters including its name and the port it listens on. Note that the request type is PUT and not PATCH. You must set all parameters. func (s *ZonedAPI) UpdateFrontend(req *ZonedAPIUpdateFrontendRequest, opts ...scw.RequestOption) (*Frontend, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.FrontendID) == "" { return nil, errors.New("field FrontendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/frontends/" + fmt.Sprint(req.FrontendID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Frontend err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteFrontend: Delete a given frontend, specified by its frontend ID. This action is irreversible and cannot be undone. func (s *ZonedAPI) DeleteFrontend(req *ZonedAPIDeleteFrontendRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.FrontendID) == "" { return errors.New("field FrontendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/frontends/" + fmt.Sprint(req.FrontendID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListRoutes: List all routes for a given frontend. The response is an array of routes, each one with a specified backend to direct to if a certain condition is matched (based on the value of the SNI field or HTTP Host header). func (s *ZonedAPI) ListRoutes(req *ZonedAPIListRoutesRequest, opts ...scw.RequestOption) (*ListRoutesResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "frontend_id", req.FrontendID) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/routes", Query: query, } var resp ListRoutesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateRoute: Create a new route on a given frontend. To configure a route, specify the backend to direct to if a certain condition is matched (based on the value of the SNI field or HTTP Host header). func (s *ZonedAPI) CreateRoute(req *ZonedAPICreateRouteRequest, opts ...scw.RequestOption) (*Route, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/routes", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Route err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetRoute: Retrieve information about an existing route, specified by its route ID. Its full details, origin frontend, target backend and match condition, are returned in the response object. func (s *ZonedAPI) GetRoute(req *ZonedAPIGetRouteRequest, opts ...scw.RequestOption) (*Route, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.RouteID) == "" { return nil, errors.New("field RouteID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/routes/" + fmt.Sprint(req.RouteID) + "", } var resp Route err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateRoute: Update the configuration of an existing route, specified by its route ID. func (s *ZonedAPI) UpdateRoute(req *ZonedAPIUpdateRouteRequest, opts ...scw.RequestOption) (*Route, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.RouteID) == "" { return nil, errors.New("field RouteID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/routes/" + fmt.Sprint(req.RouteID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Route err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteRoute: Delete an existing route, specified by its route ID. Deleting a route is permanent, and cannot be undone. func (s *ZonedAPI) DeleteRoute(req *ZonedAPIDeleteRouteRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.RouteID) == "" { return errors.New("field RouteID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/routes/" + fmt.Sprint(req.RouteID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // Deprecated: GetLBStats: Get usage statistics of a given Load Balancer. func (s *ZonedAPI) GetLBStats(req *ZonedAPIGetLBStatsRequest, opts ...scw.RequestOption) (*LBStats, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } query := url.Values{} parameter.AddToQuery(query, "backend_id", req.BackendID) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/lbs/" + fmt.Sprint(req.LBID) + "/stats", Query: query, } var resp LBStats err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListBackendStats: List information about your backend servers, including their state and the result of their last health check. func (s *ZonedAPI) ListBackendStats(req *ZonedAPIListBackendStatsRequest, opts ...scw.RequestOption) (*ListBackendStatsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "backend_id", req.BackendID) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/lbs/" + fmt.Sprint(req.LBID) + "/backend-stats", Query: query, } var resp ListBackendStatsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListACLs: List the ACLs for a given frontend, specified by its frontend ID. The response is an array of ACL objects, each one representing an ACL that denies or allows traffic based on certain conditions. func (s *ZonedAPI) ListACLs(req *ZonedAPIListACLsRequest, opts ...scw.RequestOption) (*ListACLResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "name", req.Name) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.FrontendID) == "" { return nil, errors.New("field FrontendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/frontends/" + fmt.Sprint(req.FrontendID) + "/acls", Query: query, } var resp ListACLResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateACL: Create a new ACL for a given frontend. Each ACL must have a name, an action to perform (allow or deny), and a match rule (the action is carried out when the incoming traffic matches the rule). func (s *ZonedAPI) CreateACL(req *ZonedAPICreateACLRequest, opts ...scw.RequestOption) (*ACL, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if req.Name == "" { req.Name = namegenerator.GetRandomName("acl") } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.FrontendID) == "" { return nil, errors.New("field FrontendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/frontends/" + fmt.Sprint(req.FrontendID) + "/acls", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp ACL err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetACL: Get information for a particular ACL, specified by its ACL ID. The response returns full details of the ACL, including its name, action, match rule and frontend. func (s *ZonedAPI) GetACL(req *ZonedAPIGetACLRequest, opts ...scw.RequestOption) (*ACL, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ACLID) == "" { return nil, errors.New("field ACLID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/acls/" + fmt.Sprint(req.ACLID) + "", } var resp ACL err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateACL: Update a particular ACL, specified by its ACL ID. You can update details including its name, action and match rule. func (s *ZonedAPI) UpdateACL(req *ZonedAPIUpdateACLRequest, opts ...scw.RequestOption) (*ACL, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ACLID) == "" { return nil, errors.New("field ACLID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/acls/" + fmt.Sprint(req.ACLID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp ACL err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteACL: Delete an ACL, specified by its ACL ID. Deleting an ACL is irreversible and cannot be undone. func (s *ZonedAPI) DeleteACL(req *ZonedAPIDeleteACLRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ACLID) == "" { return errors.New("field ACLID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/acls/" + fmt.Sprint(req.ACLID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // SetACLs: For a given frontend specified by its frontend ID, define and add the complete set of ACLS for that frontend. Any existing ACLs on this frontend will be removed. func (s *ZonedAPI) SetACLs(req *ZonedAPISetACLsRequest, opts ...scw.RequestOption) (*SetACLsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.FrontendID) == "" { return nil, errors.New("field FrontendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/frontends/" + fmt.Sprint(req.FrontendID) + "/acls", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SetACLsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateCertificate: Generate a new SSL/TLS certificate for a given Load Balancer. You can choose to create a Let's Encrypt certificate, or import a custom certificate. func (s *ZonedAPI) CreateCertificate(req *ZonedAPICreateCertificateRequest, opts ...scw.RequestOption) (*Certificate, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if req.Name == "" { req.Name = namegenerator.GetRandomName("certificate") } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/lbs/" + fmt.Sprint(req.LBID) + "/certificates", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Certificate err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListCertificates: List all the SSL/TLS certificates on a given Load Balancer. The response is an array of certificate objects, which are by default listed in ascending order of creation date. func (s *ZonedAPI) ListCertificates(req *ZonedAPIListCertificatesRequest, opts ...scw.RequestOption) (*ListCertificatesResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "name", req.Name) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/lbs/" + fmt.Sprint(req.LBID) + "/certificates", Query: query, } var resp ListCertificatesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetCertificate: Get information for a particular SSL/TLS certificate, specified by its certificate ID. The response returns full details of the certificate, including its type, main domain name, and alternative domain names. func (s *ZonedAPI) GetCertificate(req *ZonedAPIGetCertificateRequest, opts ...scw.RequestOption) (*Certificate, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.CertificateID) == "" { return nil, errors.New("field CertificateID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/certificates/" + fmt.Sprint(req.CertificateID) + "", } var resp Certificate err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateCertificate: Update the name of a particular SSL/TLS certificate, specified by its certificate ID. func (s *ZonedAPI) UpdateCertificate(req *ZonedAPIUpdateCertificateRequest, opts ...scw.RequestOption) (*Certificate, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.CertificateID) == "" { return nil, errors.New("field CertificateID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/certificates/" + fmt.Sprint(req.CertificateID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Certificate err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteCertificate: Delete an SSL/TLS certificate, specified by its certificate ID. Deleting a certificate is irreversible and cannot be undone. func (s *ZonedAPI) DeleteCertificate(req *ZonedAPIDeleteCertificateRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.CertificateID) == "" { return errors.New("field CertificateID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/certificates/" + fmt.Sprint(req.CertificateID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListLBTypes: List all the different commercial Load Balancer types. The response includes an array of offer types, each with a name, description, and information about its stock availability. func (s *ZonedAPI) ListLBTypes(req *ZonedAPIListLBTypesRequest, opts ...scw.RequestOption) (*ListLBTypesResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/lb-types", Query: query, } var resp ListLBTypesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateSubscriber: Create a new subscriber, either with an email configuration or a webhook configuration, for a specified Scaleway Project. func (s *ZonedAPI) CreateSubscriber(req *ZonedAPICreateSubscriberRequest, opts ...scw.RequestOption) (*Subscriber, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultProjectID, exist := s.client.GetDefaultProjectID() if exist && req.ProjectID == nil && req.OrganizationID == nil { req.ProjectID = &defaultProjectID } defaultOrganizationID, exist := s.client.GetDefaultOrganizationID() if exist && req.ProjectID == nil && req.OrganizationID == nil { req.OrganizationID = &defaultOrganizationID } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/subscribers", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Subscriber err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetSubscriber: Retrieve information about an existing subscriber, specified by its subscriber ID. Its full details, including name and email/webhook configuration, are returned in the response object. func (s *ZonedAPI) GetSubscriber(req *ZonedAPIGetSubscriberRequest, opts ...scw.RequestOption) (*Subscriber, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.SubscriberID) == "" { return nil, errors.New("field SubscriberID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/subscribers/" + fmt.Sprint(req.SubscriberID) + "", } var resp Subscriber err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListSubscriber: List all subscribers to Load Balancer alerts. By default, returns all subscribers to Load Balancer alerts for the Organization associated with the authentication token used for the request. func (s *ZonedAPI) ListSubscriber(req *ZonedAPIListSubscriberRequest, opts ...scw.RequestOption) (*ListSubscriberResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/subscribers", Query: query, } var resp ListSubscriberResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateSubscriber: Update the parameters of a given subscriber (e.g. name, webhook configuration, email configuration), specified by its subscriber ID. func (s *ZonedAPI) UpdateSubscriber(req *ZonedAPIUpdateSubscriberRequest, opts ...scw.RequestOption) (*Subscriber, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.SubscriberID) == "" { return nil, errors.New("field SubscriberID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/subscribers/" + fmt.Sprint(req.SubscriberID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Subscriber err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteSubscriber: Delete an existing subscriber, specified by its subscriber ID. Deleting a subscriber is permanent, and cannot be undone. func (s *ZonedAPI) DeleteSubscriber(req *ZonedAPIDeleteSubscriberRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.SubscriberID) == "" { return errors.New("field SubscriberID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/lb/subscription/" + fmt.Sprint(req.SubscriberID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // SubscribeToLB: Subscribe an existing subscriber to alerts for a given Load Balancer. func (s *ZonedAPI) SubscribeToLB(req *ZonedAPISubscribeToLBRequest, opts ...scw.RequestOption) (*LB, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/lb/" + fmt.Sprint(req.LBID) + "/subscribe", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp LB err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UnsubscribeFromLB: Unsubscribe a subscriber from alerts for a given Load Balancer. The subscriber is not deleted, and can be resubscribed in the future if necessary. func (s *ZonedAPI) UnsubscribeFromLB(req *ZonedAPIUnsubscribeFromLBRequest, opts ...scw.RequestOption) (*LB, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/lb/" + fmt.Sprint(req.LBID) + "/unsubscribe", } var resp LB err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListLBPrivateNetworks: List the Private Networks attached to a given Load Balancer, specified by its Load Balancer ID. The response is an array of Private Network objects, giving information including the status, configuration, name and creation date of each Private Network. func (s *ZonedAPI) ListLBPrivateNetworks(req *ZonedAPIListLBPrivateNetworksRequest, opts ...scw.RequestOption) (*ListLBPrivateNetworksResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "page", req.Page) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/lbs/" + fmt.Sprint(req.LBID) + "/private-networks", Query: query, } var resp ListLBPrivateNetworksResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // AttachPrivateNetwork: Attach a specified Load Balancer to a specified Private Network, defining a static or DHCP configuration for the Load Balancer on the network. func (s *ZonedAPI) AttachPrivateNetwork(req *ZonedAPIAttachPrivateNetworkRequest, opts ...scw.RequestOption) (*PrivateNetwork, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } if fmt.Sprint(req.PrivateNetworkID) == "" { return nil, errors.New("field PrivateNetworkID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/lbs/" + fmt.Sprint(req.LBID) + "/private-networks/" + fmt.Sprint(req.PrivateNetworkID) + "/attach", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp PrivateNetwork err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DetachPrivateNetwork: Detach a specified Load Balancer from a specified Private Network. func (s *ZonedAPI) DetachPrivateNetwork(req *ZonedAPIDetachPrivateNetworkRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return errors.New("field LBID cannot be empty in request") } if fmt.Sprint(req.PrivateNetworkID) == "" { return errors.New("field PrivateNetworkID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/zones/" + fmt.Sprint(req.Zone) + "/lbs/" + fmt.Sprint(req.LBID) + "/private-networks/" + fmt.Sprint(req.PrivateNetworkID) + "/detach", } err = scwReq.SetBody(req) if err != nil { return err } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // This API allows you to manage your load balancer service. type API struct { client *scw.Client } // Deprecated: NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Regions() []scw.Region { return []scw.Region{scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw} } // ListLBs: List load balancers. func (s *API) ListLBs(req *ListLBsRequest, opts ...scw.RequestOption) (*ListLBsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/lbs", Query: query, } var resp ListLBsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateLB: Create a load balancer. func (s *API) CreateLB(req *CreateLBRequest, opts ...scw.RequestOption) (*LB, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultProjectID, exist := s.client.GetDefaultProjectID() if exist && req.ProjectID == nil && req.OrganizationID == nil { req.ProjectID = &defaultProjectID } defaultOrganizationID, exist := s.client.GetDefaultOrganizationID() if exist && req.ProjectID == nil && req.OrganizationID == nil { req.OrganizationID = &defaultOrganizationID } if req.Name == "" { req.Name = namegenerator.GetRandomName("lb") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/lbs", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp LB err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetLB: Get a load balancer. func (s *API) GetLB(req *GetLBRequest, opts ...scw.RequestOption) (*LB, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/lbs/" + fmt.Sprint(req.LBID) + "", } var resp LB err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateLB: Update a load balancer. func (s *API) UpdateLB(req *UpdateLBRequest, opts ...scw.RequestOption) (*LB, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/lbs/" + fmt.Sprint(req.LBID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp LB err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteLB: Delete a load balancer. func (s *API) DeleteLB(req *DeleteLBRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } query := url.Values{} parameter.AddToQuery(query, "release_ip", req.ReleaseIP) if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/lbs/" + fmt.Sprint(req.LBID) + "", Query: query, } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // MigrateLB: Migrate a load balancer. func (s *API) MigrateLB(req *MigrateLBRequest, opts ...scw.RequestOption) (*LB, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/lbs/" + fmt.Sprint(req.LBID) + "/migrate", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp LB err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListIPs: List IPs. func (s *API) ListIPs(req *ListIPsRequest, opts ...scw.RequestOption) (*ListIPsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "ip_address", req.IPAddress) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "ip_type", req.IPType) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/ips", Query: query, } var resp ListIPsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateIP: Create an IP. func (s *API) CreateIP(req *CreateIPRequest, opts ...scw.RequestOption) (*IP, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultProjectID, exist := s.client.GetDefaultProjectID() if exist && req.ProjectID == nil && req.OrganizationID == nil { req.ProjectID = &defaultProjectID } defaultOrganizationID, exist := s.client.GetDefaultOrganizationID() if exist && req.ProjectID == nil && req.OrganizationID == nil { req.OrganizationID = &defaultOrganizationID } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/ips", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp IP err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetIP: Get an IP. func (s *API) GetIP(req *GetIPRequest, opts ...scw.RequestOption) (*IP, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.IPID) == "" { return nil, errors.New("field IPID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/ips/" + fmt.Sprint(req.IPID) + "", } var resp IP err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ReleaseIP: Delete an IP. func (s *API) ReleaseIP(req *ReleaseIPRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.IPID) == "" { return errors.New("field IPID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/ips/" + fmt.Sprint(req.IPID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // UpdateIP: Update an IP. func (s *API) UpdateIP(req *UpdateIPRequest, opts ...scw.RequestOption) (*IP, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.IPID) == "" { return nil, errors.New("field IPID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/ips/" + fmt.Sprint(req.IPID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp IP err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListBackends: List backends in a given load balancer. func (s *API) ListBackends(req *ListBackendsRequest, opts ...scw.RequestOption) (*ListBackendsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/lbs/" + fmt.Sprint(req.LBID) + "/backends", Query: query, } var resp ListBackendsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateBackend: Create a backend in a given load balancer. func (s *API) CreateBackend(req *CreateBackendRequest, opts ...scw.RequestOption) (*Backend, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.Name == "" { req.Name = namegenerator.GetRandomName("lbb") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/lbs/" + fmt.Sprint(req.LBID) + "/backends", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Backend err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetBackend: Get a backend in a given load balancer. func (s *API) GetBackend(req *GetBackendRequest, opts ...scw.RequestOption) (*Backend, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.BackendID) == "" { return nil, errors.New("field BackendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/backends/" + fmt.Sprint(req.BackendID) + "", } var resp Backend err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateBackend: Update a backend in a given load balancer. func (s *API) UpdateBackend(req *UpdateBackendRequest, opts ...scw.RequestOption) (*Backend, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.BackendID) == "" { return nil, errors.New("field BackendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/backends/" + fmt.Sprint(req.BackendID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Backend err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteBackend: Delete a backend in a given load balancer. func (s *API) DeleteBackend(req *DeleteBackendRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.BackendID) == "" { return errors.New("field BackendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/backends/" + fmt.Sprint(req.BackendID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // AddBackendServers: Add a set of servers in a given backend. func (s *API) AddBackendServers(req *AddBackendServersRequest, opts ...scw.RequestOption) (*Backend, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.BackendID) == "" { return nil, errors.New("field BackendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/backends/" + fmt.Sprint(req.BackendID) + "/servers", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Backend err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // RemoveBackendServers: Remove a set of servers for a given backend. func (s *API) RemoveBackendServers(req *RemoveBackendServersRequest, opts ...scw.RequestOption) (*Backend, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.BackendID) == "" { return nil, errors.New("field BackendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/backends/" + fmt.Sprint(req.BackendID) + "/servers", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Backend err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SetBackendServers: Define all servers in a given backend. func (s *API) SetBackendServers(req *SetBackendServersRequest, opts ...scw.RequestOption) (*Backend, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.BackendID) == "" { return nil, errors.New("field BackendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/backends/" + fmt.Sprint(req.BackendID) + "/servers", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Backend err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateHealthCheck: Update an health check for a given backend. func (s *API) UpdateHealthCheck(req *UpdateHealthCheckRequest, opts ...scw.RequestOption) (*HealthCheck, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.BackendID) == "" { return nil, errors.New("field BackendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/backends/" + fmt.Sprint(req.BackendID) + "/healthcheck", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp HealthCheck err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListFrontends: List frontends in a given load balancer. func (s *API) ListFrontends(req *ListFrontendsRequest, opts ...scw.RequestOption) (*ListFrontendsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/lbs/" + fmt.Sprint(req.LBID) + "/frontends", Query: query, } var resp ListFrontendsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateFrontend: Create a frontend in a given load balancer. func (s *API) CreateFrontend(req *CreateFrontendRequest, opts ...scw.RequestOption) (*Frontend, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.Name == "" { req.Name = namegenerator.GetRandomName("lbf") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/lbs/" + fmt.Sprint(req.LBID) + "/frontends", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Frontend err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetFrontend: Get a frontend. func (s *API) GetFrontend(req *GetFrontendRequest, opts ...scw.RequestOption) (*Frontend, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.FrontendID) == "" { return nil, errors.New("field FrontendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/frontends/" + fmt.Sprint(req.FrontendID) + "", } var resp Frontend err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateFrontend: Update a frontend. func (s *API) UpdateFrontend(req *UpdateFrontendRequest, opts ...scw.RequestOption) (*Frontend, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.FrontendID) == "" { return nil, errors.New("field FrontendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/frontends/" + fmt.Sprint(req.FrontendID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Frontend err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteFrontend: Delete a frontend. func (s *API) DeleteFrontend(req *DeleteFrontendRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.FrontendID) == "" { return errors.New("field FrontendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/frontends/" + fmt.Sprint(req.FrontendID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListRoutes: List all backend redirections. func (s *API) ListRoutes(req *ListRoutesRequest, opts ...scw.RequestOption) (*ListRoutesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "frontend_id", req.FrontendID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/routes", Query: query, } var resp ListRoutesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateRoute: Create a backend redirection. func (s *API) CreateRoute(req *CreateRouteRequest, opts ...scw.RequestOption) (*Route, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/routes", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Route err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetRoute: Get single backend redirection. func (s *API) GetRoute(req *GetRouteRequest, opts ...scw.RequestOption) (*Route, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.RouteID) == "" { return nil, errors.New("field RouteID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/routes/" + fmt.Sprint(req.RouteID) + "", } var resp Route err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateRoute: Edit a backend redirection. func (s *API) UpdateRoute(req *UpdateRouteRequest, opts ...scw.RequestOption) (*Route, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.RouteID) == "" { return nil, errors.New("field RouteID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/routes/" + fmt.Sprint(req.RouteID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Route err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteRoute: Delete a backend redirection. func (s *API) DeleteRoute(req *DeleteRouteRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.RouteID) == "" { return errors.New("field RouteID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/routes/" + fmt.Sprint(req.RouteID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // Deprecated: GetLBStats: Get usage statistics of a given load balancer. func (s *API) GetLBStats(req *GetLBStatsRequest, opts ...scw.RequestOption) (*LBStats, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } query := url.Values{} parameter.AddToQuery(query, "backend_id", req.BackendID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/lbs/" + fmt.Sprint(req.LBID) + "/stats", Query: query, } var resp LBStats err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListBackendStats: List backend server statistics. func (s *API) ListBackendStats(req *ListBackendStatsRequest, opts ...scw.RequestOption) (*ListBackendStatsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "backend_id", req.BackendID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/lbs/" + fmt.Sprint(req.LBID) + "/backend-stats", Query: query, } var resp ListBackendStatsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListACLs: List ACL for a given frontend. func (s *API) ListACLs(req *ListACLsRequest, opts ...scw.RequestOption) (*ListACLResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "name", req.Name) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.FrontendID) == "" { return nil, errors.New("field FrontendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/frontends/" + fmt.Sprint(req.FrontendID) + "/acls", Query: query, } var resp ListACLResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateACL: Create an ACL for a given frontend. func (s *API) CreateACL(req *CreateACLRequest, opts ...scw.RequestOption) (*ACL, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.Name == "" { req.Name = namegenerator.GetRandomName("acl") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.FrontendID) == "" { return nil, errors.New("field FrontendID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/frontends/" + fmt.Sprint(req.FrontendID) + "/acls", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp ACL err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetACL: Get an ACL. func (s *API) GetACL(req *GetACLRequest, opts ...scw.RequestOption) (*ACL, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ACLID) == "" { return nil, errors.New("field ACLID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/acls/" + fmt.Sprint(req.ACLID) + "", } var resp ACL err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateACL: Update an ACL. func (s *API) UpdateACL(req *UpdateACLRequest, opts ...scw.RequestOption) (*ACL, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ACLID) == "" { return nil, errors.New("field ACLID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/acls/" + fmt.Sprint(req.ACLID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp ACL err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteACL: Delete an ACL. func (s *API) DeleteACL(req *DeleteACLRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ACLID) == "" { return errors.New("field ACLID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/acls/" + fmt.Sprint(req.ACLID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // CreateCertificate: Generate a new TLS certificate using Let's Encrypt or import your certificate. func (s *API) CreateCertificate(req *CreateCertificateRequest, opts ...scw.RequestOption) (*Certificate, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.Name == "" { req.Name = namegenerator.GetRandomName("certificate") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/lbs/" + fmt.Sprint(req.LBID) + "/certificates", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Certificate err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListCertificates: List all TLS certificates on a given load balancer. func (s *API) ListCertificates(req *ListCertificatesRequest, opts ...scw.RequestOption) (*ListCertificatesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "name", req.Name) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/lbs/" + fmt.Sprint(req.LBID) + "/certificates", Query: query, } var resp ListCertificatesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetCertificate: Get a TLS certificate. func (s *API) GetCertificate(req *GetCertificateRequest, opts ...scw.RequestOption) (*Certificate, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.CertificateID) == "" { return nil, errors.New("field CertificateID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/certificates/" + fmt.Sprint(req.CertificateID) + "", } var resp Certificate err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateCertificate: Update a TLS certificate. func (s *API) UpdateCertificate(req *UpdateCertificateRequest, opts ...scw.RequestOption) (*Certificate, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.CertificateID) == "" { return nil, errors.New("field CertificateID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/certificates/" + fmt.Sprint(req.CertificateID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Certificate err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteCertificate: Delete a TLS certificate. func (s *API) DeleteCertificate(req *DeleteCertificateRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.CertificateID) == "" { return errors.New("field CertificateID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/certificates/" + fmt.Sprint(req.CertificateID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListLBTypes: List all load balancer offer type. func (s *API) ListLBTypes(req *ListLBTypesRequest, opts ...scw.RequestOption) (*ListLBTypesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/lb-types", Query: query, } var resp ListLBTypesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateSubscriber: Create a subscriber, webhook or email. func (s *API) CreateSubscriber(req *CreateSubscriberRequest, opts ...scw.RequestOption) (*Subscriber, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultProjectID, exist := s.client.GetDefaultProjectID() if exist && req.ProjectID == nil && req.OrganizationID == nil { req.ProjectID = &defaultProjectID } defaultOrganizationID, exist := s.client.GetDefaultOrganizationID() if exist && req.ProjectID == nil && req.OrganizationID == nil { req.OrganizationID = &defaultOrganizationID } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/subscribers", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Subscriber err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetSubscriber: Get a subscriber. func (s *API) GetSubscriber(req *GetSubscriberRequest, opts ...scw.RequestOption) (*Subscriber, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SubscriberID) == "" { return nil, errors.New("field SubscriberID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/subscribers/" + fmt.Sprint(req.SubscriberID) + "", } var resp Subscriber err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListSubscriber: List all subscriber. func (s *API) ListSubscriber(req *ListSubscriberRequest, opts ...scw.RequestOption) (*ListSubscriberResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/subscribers", Query: query, } var resp ListSubscriberResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateSubscriber: Update a subscriber. func (s *API) UpdateSubscriber(req *UpdateSubscriberRequest, opts ...scw.RequestOption) (*Subscriber, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SubscriberID) == "" { return nil, errors.New("field SubscriberID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/subscribers/" + fmt.Sprint(req.SubscriberID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Subscriber err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteSubscriber: Delete a subscriber. func (s *API) DeleteSubscriber(req *DeleteSubscriberRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SubscriberID) == "" { return errors.New("field SubscriberID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/lb/subscriber/" + fmt.Sprint(req.SubscriberID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // SubscribeToLB: Subscribe a subscriber to a given load balancer. func (s *API) SubscribeToLB(req *SubscribeToLBRequest, opts ...scw.RequestOption) (*LB, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/lb/" + fmt.Sprint(req.LBID) + "/subscribe", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp LB err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UnsubscribeFromLB: Unsubscribe a subscriber from a given load balancer. func (s *API) UnsubscribeFromLB(req *UnsubscribeFromLBRequest, opts ...scw.RequestOption) (*LB, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/lb/" + fmt.Sprint(req.LBID) + "/unsubscribe", } var resp LB err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListLBPrivateNetworks: List attached private network of load balancer. func (s *API) ListLBPrivateNetworks(req *ListLBPrivateNetworksRequest, opts ...scw.RequestOption) (*ListLBPrivateNetworksResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "page", req.Page) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/lbs/" + fmt.Sprint(req.LBID) + "/private-networks", Query: query, } var resp ListLBPrivateNetworksResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // AttachPrivateNetwork: Add load balancer on instance private network. func (s *API) AttachPrivateNetwork(req *AttachPrivateNetworkRequest, opts ...scw.RequestOption) (*PrivateNetwork, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return nil, errors.New("field LBID cannot be empty in request") } if fmt.Sprint(req.PrivateNetworkID) == "" { return nil, errors.New("field PrivateNetworkID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/lbs/" + fmt.Sprint(req.LBID) + "/private-networks/" + fmt.Sprint(req.PrivateNetworkID) + "/attach", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp PrivateNetwork err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DetachPrivateNetwork: Remove load balancer of private network. func (s *API) DetachPrivateNetwork(req *DetachPrivateNetworkRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.LBID) == "" { return errors.New("field LBID cannot be empty in request") } if fmt.Sprint(req.PrivateNetworkID) == "" { return errors.New("field PrivateNetworkID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/lb/v1/regions/" + fmt.Sprint(req.Region) + "/lbs/" + fmt.Sprint(req.LBID) + "/private-networks/" + fmt.Sprint(req.PrivateNetworkID) + "/detach", } err = scwReq.SetBody(req) if err != nil { return err } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/lb/v1/lb_utils.go000066400000000000000000000165401456366605600261240ustar00rootroot00000000000000package lb import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) const ( defaultRetryInterval = 2 * time.Second defaultTimeout = 5 * time.Minute ) // WaitForLBRequest is used by WaitForLb method. type WaitForLBRequest struct { LBID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForLb waits for the lb to be in a "terminal state" before returning. // This function can be used to wait for a lb to be ready for example. func (s *API) WaitForLb(req *WaitForLBRequest, opts ...scw.RequestOption) (*LB, error) { return waitForLb(req.Timeout, req.RetryInterval, func() (*LB, error) { return s.GetLB(&GetLBRequest{ Region: req.Region, LBID: req.LBID, }, opts...) }) } // ZonedAPIWaitForLBRequest is used by WaitForLb method. type ZonedAPIWaitForLBRequest struct { LBID string Zone scw.Zone Timeout *time.Duration RetryInterval *time.Duration } // WaitForLb waits for the lb to be in a "terminal state" before returning. // This function can be used to wait for a lb to be ready for example. func (s *ZonedAPI) WaitForLb(req *ZonedAPIWaitForLBRequest, opts ...scw.RequestOption) (*LB, error) { return waitForLb(req.Timeout, req.RetryInterval, func() (*LB, error) { return s.GetLB(&ZonedAPIGetLBRequest{ Zone: req.Zone, LBID: req.LBID, }, opts...) }) } func waitForLb(timeout *time.Duration, retryInterval *time.Duration, getLB func() (*LB, error)) (*LB, error) { t := defaultTimeout if timeout != nil { t = *timeout } r := defaultRetryInterval if retryInterval != nil { r = *retryInterval } terminalStatus := map[LBStatus]struct{}{ LBStatusReady: {}, LBStatusStopped: {}, LBStatusError: {}, LBStatusLocked: {}, } lb, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := getLB() if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.Status] return res, isTerminal, nil }, Timeout: t, IntervalStrategy: async.LinearIntervalStrategy(r), }) if err != nil { return nil, errors.Wrap(err, "waiting for lb failed") } return lb.(*LB), nil } // ZonedAPIWaitForLBInstancesRequest is used by WaitForLb method. type ZonedAPIWaitForLBInstancesRequest struct { LBID string Zone scw.Zone Timeout *time.Duration RetryInterval *time.Duration } // WaitForLbInstances waits for the lb to be in a "terminal state" and the attached instances before returning. func (s *ZonedAPI) WaitForLbInstances(req *ZonedAPIWaitForLBInstancesRequest, opts ...scw.RequestOption) (*LB, error) { return waitForLbInstances(req.Timeout, req.RetryInterval, func() (*LB, error) { return s.GetLB(&ZonedAPIGetLBRequest{ Zone: req.Zone, LBID: req.LBID, }, opts...) }) } func waitForLbInstances(timeout *time.Duration, retryInterval *time.Duration, getLB func() (*LB, error)) (*LB, error) { t := defaultTimeout if timeout != nil { t = *timeout } r := defaultRetryInterval if retryInterval != nil { r = *retryInterval } terminalLBStatus := map[LBStatus]struct{}{ LBStatusReady: {}, LBStatusStopped: {}, LBStatusError: {}, LBStatusLocked: {}, } terminalInstanceStatus := map[InstanceStatus]struct{}{ InstanceStatusReady: {}, InstanceStatusStopped: {}, InstanceStatusError: {}, InstanceStatusLocked: {}, } lb, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := getLB() if err != nil { return nil, false, err } _, isTerminal := terminalLBStatus[res.Status] for _, i := range res.Instances { _, isInstanceTerminal := terminalInstanceStatus[i.Status] if !isInstanceTerminal { return res, isTerminal, nil } } return res, isTerminal, nil }, Timeout: t, IntervalStrategy: async.LinearIntervalStrategy(r), }) if err != nil { return nil, errors.Wrap(err, "waiting for lb failed") } return lb.(*LB), nil } // ZonedAPIWaitForLBPNRequest is used by WaitForLBPN method. type ZonedAPIWaitForLBPNRequest struct { LBID string Zone scw.Zone Timeout *time.Duration RetryInterval *time.Duration } func waitForPNLb(timeout *time.Duration, retryInterval *time.Duration, getPNs func() ([]*PrivateNetwork, error)) ([]*PrivateNetwork, error) { t := defaultTimeout if timeout != nil { t = *timeout } r := defaultRetryInterval if retryInterval != nil { r = *retryInterval } terminalStatus := map[PrivateNetworkStatus]struct{}{ PrivateNetworkStatusReady: {}, PrivateNetworkStatusError: {}, } pn, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { pns, err := getPNs() for _, pn := range pns { if err != nil { return nil, false, err } //wait at the first not terminal state _, isTerminal := terminalStatus[pn.Status] if !isTerminal { return pns, isTerminal, nil } } return pns, true, nil }, Timeout: t, IntervalStrategy: async.LinearIntervalStrategy(r), }) if err != nil { return nil, errors.Wrap(err, "waiting for attachment failed") } return pn.([]*PrivateNetwork), nil } // WaitForLBPN waits for the private_network attached status on a load balancer // to be in a "terminal state" before returning. // This function can be used to wait for an attached private_network to be ready for example. func (s *ZonedAPI) WaitForLBPN(req *ZonedAPIWaitForLBPNRequest, opts ...scw.RequestOption) ([]*PrivateNetwork, error) { return waitForPNLb(req.Timeout, req.RetryInterval, func() ([]*PrivateNetwork, error) { lbPNs, err := s.ListLBPrivateNetworks(&ZonedAPIListLBPrivateNetworksRequest{ Zone: req.Zone, LBID: req.LBID, }, opts...) if err != nil { return nil, err } return lbPNs.PrivateNetwork, nil }) } // ZonedAPIWaitForLBCertificateRequest is used by WaitForLbCertificate method. type ZonedAPIWaitForLBCertificateRequest struct { CertID string Zone scw.Zone Timeout *time.Duration RetryInterval *time.Duration } // WaitForLBCertificate waits for the certificate to be in a "terminal state" func (s *ZonedAPI) WaitForLBCertificate(req *ZonedAPIWaitForLBCertificateRequest, opts ...scw.RequestOption) (*Certificate, error) { return waitForLBCertificate(req.Timeout, req.RetryInterval, func() (*Certificate, error) { return s.GetCertificate(&ZonedAPIGetCertificateRequest{ Zone: req.Zone, CertificateID: req.CertID, }, opts...) }) } func waitForLBCertificate(timeout *time.Duration, retryInterval *time.Duration, getCertificate func() (*Certificate, error)) (*Certificate, error) { t := defaultTimeout if timeout != nil { t = *timeout } r := defaultRetryInterval if retryInterval != nil { r = *retryInterval } terminalStatus := map[CertificateStatus]struct{}{ CertificateStatusError: {}, CertificateStatusReady: {}, } crt, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := getCertificate() if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.Status] return res, isTerminal, nil }, Timeout: t, IntervalStrategy: async.LinearIntervalStrategy(r), }) if err != nil { return nil, errors.Wrap(err, "waiting for lb failed") } return crt.(*Certificate), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/marketplace/000077500000000000000000000000001456366605600253175ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/marketplace/v1/000077500000000000000000000000001456366605600256455ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/marketplace/v1/marketplace_sdk.go000066400000000000000000000126541456366605600313350ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package marketplace provides methods and message types of the marketplace v1 API. package marketplace import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) // LocalImage: local image. type LocalImage struct { // ID: version you will typically use to define an image in an API call. ID string `json:"id"` // CompatibleCommercialTypes: list of all commercial types that are compatible with this local image. CompatibleCommercialTypes []string `json:"compatible_commercial_types"` // Arch: supported architecture for this local image. Arch string `json:"arch"` // Zone: availability Zone where this local image is available. Zone scw.Zone `json:"zone"` } // Organization: organization. type Organization struct { ID string `json:"id"` Name string `json:"name"` } // Version: version. type Version struct { // ID: UUID of this version. ID string `json:"id"` // Name: name of this version. Name string `json:"name"` // CreationDate: creation date of this image version. CreationDate *time.Time `json:"creation_date"` // ModificationDate: date of the last modification of this version. ModificationDate *time.Time `json:"modification_date"` // LocalImages: list of local images available in this version. LocalImages []*LocalImage `json:"local_images"` } // Image: image. type Image struct { // ID: UUID of this image. ID string `json:"id"` // Name: name of the image. Name string `json:"name"` // Description: text description of this image. Description string `json:"description"` // Logo: URL of this image's logo. Logo string `json:"logo"` // Categories: list of categories this image belongs to. Categories []string `json:"categories"` // CreationDate: creation date of this image. CreationDate *time.Time `json:"creation_date"` // ModificationDate: date of the last modification of this image. ModificationDate *time.Time `json:"modification_date"` // ValidUntil: expiration date of this image. ValidUntil *time.Time `json:"valid_until"` // Label: typically an identifier for a distribution (ex. "ubuntu_focal"). Label string `json:"label"` // Versions: list of versions of this image. Versions []*Version `json:"versions"` // Organization: organization this image belongs to. Organization *Organization `json:"organization"` CurrentPublicVersion string `json:"current_public_version"` } // GetImageRequest: get image request. type GetImageRequest struct { // ImageID: display the image name. ImageID string `json:"-"` } // GetImageResponse: get image response. type GetImageResponse struct { Image *Image `json:"image"` } // ListImagesRequest: list images request. type ListImagesRequest struct { // PerPage: a positive integer lower or equal to 100 to select the number of items to display. PerPage *uint32 `json:"-"` // Page: a positive integer to choose the page to display. Page *int32 `json:"-"` } // ListImagesResponse: list images response. type ListImagesResponse struct { Images []*Image `json:"images"` TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListImagesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListImagesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListImagesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Images = append(r.Images, results.Images...) r.TotalCount += uint32(len(results.Images)) return uint32(len(results.Images)), nil } // Marketplace API. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } // ListImages: List marketplace images. func (s *API) ListImages(req *ListImagesRequest, opts ...scw.RequestOption) (*ListImagesResponse, error) { var err error query := url.Values{} parameter.AddToQuery(query, "per_page", req.PerPage) parameter.AddToQuery(query, "page", req.Page) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/marketplace/v1/images", Query: query, } var resp ListImagesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetImage: Get a specific marketplace image. func (s *API) GetImage(req *GetImageRequest, opts ...scw.RequestOption) (*GetImageResponse, error) { var err error if fmt.Sprint(req.ImageID) == "" { return nil, errors.New("field ImageID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/marketplace/v1/images/" + fmt.Sprint(req.ImageID) + "", } var resp GetImageResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/marketplace/v1/marketplace_utils.go000066400000000000000000000060551456366605600317120ustar00rootroot00000000000000package marketplace import ( "fmt" "strings" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) // getLocalImage returns the correct local version of an image matching // the current zone and the compatible commercial type func (version *Version) getLocalImage(zone scw.Zone, commercialType string) (*LocalImage, error) { for _, localImage := range version.LocalImages { // Check if in correct zone if localImage.Zone != zone { continue } // Check if compatible with wanted commercial type for _, compatibleCommercialType := range localImage.CompatibleCommercialTypes { if compatibleCommercialType == commercialType { return localImage, nil } } } return nil, fmt.Errorf("couldn't find compatible local image for this image version (%s)", version.ID) } // getLatestVersion returns the current/latest version on an image, // or an error in case the image doesn't have a public version. func (image *Image) getLatestVersion() (*Version, error) { for _, version := range image.Versions { if version.ID == image.CurrentPublicVersion { return version, nil } } return nil, errors.New("latest version could not be found for image %s", image.Label) } // GetLocalImageIDByLabelRequest is used by GetLocalImageIDByLabel type GetLocalImageIDByLabelRequest struct { ImageLabel string Zone scw.Zone CommercialType string } // GetLocalImageIDByLabel search for an image with the given label (exact match) in the given region // it returns the latest version of this specific image. func (s *API) GetLocalImageIDByLabel(req *GetLocalImageIDByLabelRequest, opts ...scw.RequestOption) (string, error) { if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } listImageRequest := &ListImagesRequest{} opts = append(opts, scw.WithAllPages()) listImageResponse, err := s.ListImages(listImageRequest, opts...) if err != nil { return "", err } images := listImageResponse.Images label := strings.Replace(req.ImageLabel, "-", "_", -1) commercialType := strings.ToUpper(req.CommercialType) for _, image := range images { // Match label of the image if label == image.Label { latestVersion, err := image.getLatestVersion() if err != nil { return "", errors.Wrap(err, "couldn't find a matching image for the given label (%s), zone (%s) and commercial type (%s)", req.ImageLabel, req.Zone, req.CommercialType) } localImage, err := latestVersion.getLocalImage(req.Zone, commercialType) if err != nil { return "", errors.Wrap(err, "couldn't find a matching image for the given label (%s), zone (%s) and commercial type (%s)", req.ImageLabel, req.Zone, req.CommercialType) } return localImage.ID, nil } } return "", errors.New("couldn't find a matching image for the given label (%s), zone (%s) and commercial type (%s)", req.ImageLabel, req.Zone, req.CommercialType) } // UnsafeSetTotalCount should not be used // Internal usage only func (r *ListImagesResponse) UnsafeSetTotalCount(totalCount int) { r.TotalCount = uint32(totalCount) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/marketplace/v1/marketplace_utils_test.go000066400000000000000000000041751456366605600327520ustar00rootroot00000000000000package marketplace import ( "testing" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers/httprecorder" "github.com/scaleway/scaleway-sdk-go/scw" ) func TestGetImageByLabel(t *testing.T) { client, r, err := httprecorder.CreateRecordedScwClient("go-vcr") testhelpers.AssertNoError(t, err) defer func() { testhelpers.AssertNoError(t, r.Stop()) // Make sure recorder is stopped once done with it }() t.Run("matching input for GetLocalImageIDByLabel", func(t *testing.T) { // Create SDK objects for Scaleway Instance product marketplaceAPI := NewAPI(client) imageID, err := marketplaceAPI.GetLocalImageIDByLabel(&GetLocalImageIDByLabelRequest{ Zone: scw.ZoneFrPar1, CommercialType: "DEV1-S", ImageLabel: "ubuntu_focal", }) testhelpers.AssertNoError(t, err) // ubuntu_focal DEV1-S at par1: 365a8b9c-0c6e-4875-a887-dc3213db9e20 testhelpers.Equals(t, "365a8b9c-0c6e-4875-a887-dc3213db9e20", imageID) }) t.Run("matching input for GetLocalImageIDByLabel with lowercase image label", func(t *testing.T) { // Create SDK objects for Scaleway Instance product marketplaceAPI := NewAPI(client) imageID, err := marketplaceAPI.GetLocalImageIDByLabel(&GetLocalImageIDByLabelRequest{ Zone: scw.ZoneFrPar1, CommercialType: "dev1-s", ImageLabel: "ubuntu_focal", }) testhelpers.AssertNoError(t, err) // ubuntu_focal DEV1-S at par1: 365a8b9c-0c6e-4875-a887-dc3213db9e20 testhelpers.Equals(t, "365a8b9c-0c6e-4875-a887-dc3213db9e20", imageID) }) t.Run("non-matching label for GetLocalImageIDByLabel", func(t *testing.T) { // Create SDK objects for Scaleway Instance product marketplaceAPI := NewAPI(client) _, err := marketplaceAPI.GetLocalImageIDByLabel(&GetLocalImageIDByLabelRequest{ Zone: scw.ZoneFrPar1, CommercialType: "DEV1-S", ImageLabel: "foo-bar-image", }) testhelpers.Assert(t, err != nil, "Should have error") testhelpers.Equals(t, "scaleway-sdk-go: couldn't find a matching image for the given label (foo-bar-image), zone (fr-par-1) and commercial type (DEV1-S)", err.Error()) }) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/marketplace/v1/testdata/000077500000000000000000000000001456366605600274565ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/marketplace/v1/testdata/go-vcr.yaml000066400000000000000000005276171456366605600315610ustar00rootroot00000000000000--- version: 1 interactions: - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.3; darwin; amd64) url: https://api.scaleway.com/marketplace/v1/images?page=1 method: GET response: body: '{"images": [{"valid_until": null, "description": "Ubuntu is the ideal distribution for scale-out computing, Ubuntu Server helps you make the most of your infrastructure.", "creation_date": "2018-04-27T14:07:25.221998+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "b381b2bf-804a-4b12-91f6-9f4ff273462f", "categories": ["distribution"], "name": "Ubuntu Bionic", "modification_date": "2019-03-26T14:00:51.745705+00:00", "versions": [{"creation_date": "2019-03-05T16:39:34.893732+00:00", "modification_date": "2019-03-05T16:39:34.893732+00:00", "id": "e640c621-305b-45f5-975f-a3f80c1cec66", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f974feac-abae-4365-b988-8ec7d1cec10d", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "f63fe42a-900f-4a5e-ba99-ab0e59469b7e", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "b4bdbee1-e1f1-4436-8de4-bdb1b6ba4803", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "9444d178-2285-4842-ac35-5e86eda8da91", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "a5076337-734f-4b99-95ed-9a5bc73b9b09", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "7663c62b-40e3-4e6b-a835-70723ec2050b", "zone": "ams1"}], "name": "2019-03-05T16:39:34.377275"}], "current_public_version": "e640c621-305b-45f5-975f-a3f80c1cec66", "label": "ubuntu_bionic", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Ubuntu is the ideal distribution for scale-out computing, Ubuntu Server helps you make the most of your infrastructure.", "creation_date": "2016-04-22T13:27:33.769932+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "acf93867-88d9-40ee-99ea-6b2bb1ee8f0c", "categories": ["distribution"], "name": "Ubuntu Xenial", "modification_date": "2020-01-20T09:04:40.661026+00:00", "versions": [{"creation_date": "2020-01-17T14:31:06.041118+00:00", "modification_date": "2020-01-17T14:31:06.041118+00:00", "id": "24cd2ef0-bbc5-4b1a-8b08-99f617eab446", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "3d6804e0-086e-4a06-8124-7240a657668d", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "245e5cea-a9b4-4a36-9055-27185afe8690", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "c40fbabc-efc8-4e04-91ea-5e1e22daece1", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "bd859e89-fb2d-466a-a546-383630a1ead1", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "6c34a3f3-5e8a-455b-9bc2-f07c4c35bf89", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a5f6bb77-3d64-4f7f-abe0-72492b1bc020", "zone": "par1"}], "name": "2020-01-17T14:31:06.031136"}], "current_public_version": "24cd2ef0-bbc5-4b1a-8b08-99f617eab446", "label": "ubuntu_xenial", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Debian is a free, powerful and stable operating system.", "creation_date": "2017-06-26T15:37:13.460764+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/debian.png", "id": "c94b5df7-e698-4ac9-b273-565d18f5f8d2", "categories": ["distribution"], "name": "Debian Stretch", "modification_date": "2020-01-20T09:04:42.765883+00:00", "versions": [{"creation_date": "2020-01-15T11:38:06.396694+00:00", "modification_date": "2020-01-15T11:38:06.396694+00:00", "id": "8342f5d0-46aa-46e7-8a6f-f41188c97fba", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "5f7ab0cd-d10e-49a0-91c8-315ed8a6a1a4", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "d954dc33-c52e-4960-93e1-b69c85d169be", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "22a1bd8d-4498-4800-a8e5-4bc85001176c", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "37938de8-e3be-479a-895d-095158f76212", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "86740237-62fc-4538-9b70-4373942f53d3", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "bd6ba96e-d4c4-41f9-88e2-8dad3e6f085b", "zone": "par1"}], "name": "2020-01-15T11:38:06.390074"}], "current_public_version": "8342f5d0-46aa-46e7-8a6f-f41188c97fba", "label": "debian_stretch", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Debian is a free, powerful and stable operating system.", "creation_date": "2016-03-05T14:52:36.322319+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/debian.png", "id": "fb619bdf-834e-4c71-b7b8-15b5546d18bd", "categories": ["distribution"], "name": "Debian Jessie", "modification_date": "2019-03-26T14:00:50.449502+00:00", "versions": [{"creation_date": "2018-04-10T22:31:04.322822+00:00", "modification_date": "2018-04-10T22:31:04.322822+00:00", "id": "d3846a7b-8219-4938-ad96-cc2173e22481", "local_images": [{"compatible_commercial_types": ["C1"], "arch": "arm", "id": "2dfad6d2-e527-4e93-8eb1-8dc57803b310", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "610f68d5-cbad-4923-98ae-782af8f3b527", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "dc22e553-2d2e-4689-94f8-8817db824202", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "2e570f53-199e-47cc-95dd-f7bc392496e3", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "abf9e3a2-7171-4764-91ef-57f30b21193d", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "69cbdd54-88a1-4458-b75e-662a0848a7ce", "zone": "ams1"}], "name": "2018-04-10T22:31:04.321157"}], "current_public_version": "d3846a7b-8219-4938-ad96-cc2173e22481", "label": "debian_jessie", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "The CentOS Project is a community-driven free software effort focused on delivering a robust open source ecosystem.", "creation_date": "2019-03-06T11:27:48.406290+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/centos.png", "id": "1d47b370-ac63-43b1-9f34-7328675e5e18", "categories": ["distribution"], "name": "CentOS 7.6", "modification_date": "2019-03-26T14:00:50.839069+00:00", "versions": [{"creation_date": "2019-03-18T09:29:00.247544+00:00", "modification_date": "2019-03-18T09:29:00.247544+00:00", "id": "53138072-3099-4566-8b18-de7b2739696a", "local_images": [{"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "05794ee5-c6d2-4d69-86dd-f1fc9032921d", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "0f44b130-2bc7-4f82-993e-de9d1042c56e", "zone": "par1"}], "name": "2019-03-18T09:29:00.168590"}], "current_public_version": "53138072-3099-4566-8b18-de7b2739696a", "label": "centos_7.6", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "The CentOS Project is a community-driven free software effort focused on delivering a robust open source ecosystem.", "creation_date": "2018-04-19T10:12:28.968536+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/centos.png", "id": "98fc244a-ed4c-4523-bd17-b9c4070b8e7e", "categories": ["distribution"], "name": "CentOS 7.4", "modification_date": "2019-03-26T14:00:53.445597+00:00", "versions": [{"creation_date": "2018-04-20T13:55:06.824033+00:00", "modification_date": "2018-04-20T13:55:06.824033+00:00", "id": "31be34e5-074d-4c63-8c77-454459f77c3f", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "ec8b431e-ad39-4523-8b94-f3fa7f3cbd06", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "7220ac63-bac8-484b-9d44-93e3bd01f5a6", "zone": "ams1"}], "name": "2018-04-20T13:55:06.817954"}], "current_public_version": "31be34e5-074d-4c63-8c77-454459f77c3f", "label": "centos_7.4", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Fedora is a powerful, flexible operating system that includes the best and latest datacenter technologies. It puts you in control of all your infrastructure and services.", "creation_date": "2019-03-06T09:07:51.652433+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/fedora.png", "id": "69adec15-f1a7-469a-9ba5-868577832521", "categories": ["distribution"], "name": "Fedora 29", "modification_date": "2019-03-26T14:00:51.848785+00:00", "versions": [{"creation_date": "2019-03-06T09:08:01.112958+00:00", "modification_date": "2019-03-06T09:08:01.112958+00:00", "id": "a0f02365-f1af-48cb-b82d-75853a4e05e1", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "541f4562-5417-4b59-85d6-caaf64c1f127", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "3c0f706e-0947-47a3-88a3-595c29f7567a", "zone": "ams1"}], "name": "2019-03-06T09:08:01.016040"}], "current_public_version": "a0f02365-f1af-48cb-b82d-75853a4e05e1", "label": "fedora_29", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "Fedora is a powerful, flexible operating system that includes the best and latest datacenter technologies. It puts you in control of all your infrastructure and services.", "creation_date": "2018-05-03T09:51:57.274011+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/fedora.png", "id": "30d0f04f-6422-4b74-9ce9-1c2267419978", "categories": ["distribution"], "name": "Fedora 28", "modification_date": "2019-03-26T14:00:50.156015+00:00", "versions": [{"creation_date": "2018-05-03T12:01:10.147973+00:00", "modification_date": "2018-05-03T12:01:10.147973+00:00", "id": "49e33199-28cc-44d6-bb2e-a6147944ad5c", "local_images": [{"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "830aad94-24e5-4363-b2c3-e62921bd9294", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "c9cd1782-2159-44b8-83b1-9c48ed6c8a63", "zone": "par1"}], "name": "2018-05-03T12:01:10.135200"}], "current_public_version": "49e33199-28cc-44d6-bb2e-a6147944ad5c", "label": "fedora_28", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Fedora is a powerful, flexible operating system that includes the best and latest datacenter technologies. It puts you in control of all your infrastructure and services.", "creation_date": "2018-04-19T10:14:08.648100+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/fedora.png", "id": "4bff4f37-3ef9-457e-9e8d-4a786cb2a5f2", "categories": ["distribution"], "name": "Fedora 27", "modification_date": "2019-03-26T14:00:53.140907+00:00", "versions": [{"creation_date": "2018-09-06T10:51:13.009967+00:00", "modification_date": "2018-09-06T10:51:13.009967+00:00", "id": "45b5823f-8ddf-4ea8-b106-33d2df127cdf", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "097a100e-fd2f-4918-8a5b-d86de5a489be", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "73f0bcd8-a152-4665-ac09-1b105905a475", "zone": "ams1"}], "name": "2018-09-06T10:51:13.011044"}], "current_public_version": "45b5823f-8ddf-4ea8-b106-33d2df127cdf", "label": "fedora_27", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Arch Linux is an independently developed Linux distribution versatile enough to suit any role.", "creation_date": "2016-03-07T20:55:32.213089+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/archlinux.png", "id": "8f60c5dd-e659-48da-97e3-fb7de42195f5", "categories": ["distribution"], "name": "Arch Linux", "modification_date": "2019-03-26T14:00:49.327070+00:00", "versions": [{"creation_date": "2018-04-20T15:59:04.594929+00:00", "modification_date": "2018-04-20T15:59:04.594929+00:00", "id": "f7696517-bc49-448b-9869-f2c84e7c2a96", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f21defd0-9fd9-4fb2-a29a-22844a6be3cd", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "3c904f73-080e-4c6f-8b28-8426cfdcb3c7", "zone": "ams1"}], "name": "2018-04-20T15:59:04.593811"}], "current_public_version": "f7696517-bc49-448b-9869-f2c84e7c2a96", "label": "arch_linux", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Alpine Linux is security-oriented, lightweight Linux distribution based on musl libc and busybox.", "creation_date": "2016-03-05T14:49:50.255568+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/alpinelinux.png", "id": "c0649a2a-e6bf-4712-9303-8d967153209c", "categories": ["distribution"], "name": "Alpine Linux", "modification_date": "2019-03-26T14:00:54.425917+00:00", "versions": [{"creation_date": "2018-04-26T10:18:10.201002+00:00", "modification_date": "2018-04-26T10:18:10.201002+00:00", "id": "be2293b6-9eba-4497-9659-2cfb927483b5", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "24141068-1043-4885-bf2b-8290f617e273", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "241b0bb3-9eed-4a7b-b0fd-71c45452ac95", "zone": "ams1"}], "name": "2018-04-26T10:18:10.196011"}], "current_public_version": "be2293b6-9eba-4497-9659-2cfb927483b5", "label": "alpine_linux", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Debian is a free operating system, developed by thousands of volunteers from all over the world who collaborate via the Internet.", "creation_date": "2019-07-16T13:55:36.377559+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/debian.png", "id": "7bdc1afb-231f-486a-9b85-1b0478bc0e4a", "categories": ["distribution"], "name": "Debian Buster", "modification_date": "2020-01-20T09:04:41.730609+00:00", "versions": [{"creation_date": "2020-01-15T11:52:04.860098+00:00", "modification_date": "2020-01-15T11:52:04.860098+00:00", "id": "763b45ed-2e31-4ba0-9beb-efb195503a2d", "local_images": [{"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "61010e34-7f1e-402b-a253-028a714a6678", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "4720c10f-59e3-4e20-915b-dcee1fc34c11", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "9d6e8a2c-31a9-439c-a4c5-9fba1c5b96ed", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "cc9188b3-3938-47d7-b091-c9ecad1fe507", "zone": "par1"}], "name": "2020-01-15T11:52:04.849401"}], "current_public_version": "763b45ed-2e31-4ba0-9beb-efb195503a2d", "label": "debian_buster", "organization": {"id": "51b656e3-4865-41e8-adbc-0c45bdd780db", "name": "Instances User Resources Build System"}}, {"valid_until": null, "description": "Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications.", "creation_date": "2016-03-05T15:11:26.847640+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/docker.png", "id": "c1b530d8-0ca0-45c4-80db-ba06608287b2", "categories": ["instantapp"], "name": "Docker", "modification_date": "2019-03-26T14:00:49.524465+00:00", "versions": [{"creation_date": "2019-03-07T17:07:39.090644+00:00", "modification_date": "2019-03-07T17:07:39.090644+00:00", "id": "bf30c937-6e89-4019-ad2a-92156a62cf3e", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "89c80d27-ddf4-4ffa-8215-b335cce3fd05", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "99e2a9c6-f0b9-42b6-8823-8b0d86ffe9bf", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "45a7e942-1fb0-48c0-bbf6-0acb9af24604", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "c669011a-ee16-42b6-b0c3-ecd19e419539", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "dcf35840-c007-4c8b-a48b-227cfd8a347b", "zone": "ams1"}], "name": "2019-03-07T17:07:39.004809"}], "current_public_version": "bf30c937-6e89-4019-ad2a-92156a62cf3e", "label": "docker", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "GitLab is a web-based Git repository manager with wiki and issue tracking features.", "creation_date": "2016-03-07T21:06:22.770864+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/gitlab.png", "id": "233074b9-e2ba-4e78-818e-dd4930ce6bee", "categories": ["instantapp"], "name": "GitLab", "modification_date": "2019-04-09T13:31:04.022755+00:00", "versions": [{"creation_date": "2019-04-09T13:31:03.648676+00:00", "modification_date": "2019-04-09T13:31:03.648676+00:00", "id": "a389c94b-8b19-4528-a4f6-0b7cac3425e9", "local_images": [{"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "06a2a6e9-922d-4353-9472-bbb1f79fda63", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "4527e41c-0e90-43a8-857e-d9584bf8467f", "zone": "par1"}], "name": "2019-04-09T13:31:03.352588"}], "current_public_version": "a389c94b-8b19-4528-a4f6-0b7cac3425e9", "label": "gitlab", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "A painless self-hosted Git service.", "creation_date": "2016-03-07T21:00:44.946716+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/gogs.png", "id": "90d512b8-e4b7-4821-98e9-78241d73a7e6", "categories": ["instantapp"], "name": "Gogs", "modification_date": "2019-03-26T14:00:54.513196+00:00", "versions": [{"creation_date": "2018-05-16T15:11:25.881343+00:00", "modification_date": "2018-05-16T15:11:25.881343+00:00", "id": "1b9e22e3-6a29-4f42-acfd-281ad086ee1d", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "776705c4-be8e-4a27-b740-2e8bbba518c5", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a513a250-e6e9-4687-892e-9d10b29e3972", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "d1341ece-ffda-4386-ad3a-27d60b650401", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "69b8bc0e-7771-42af-a4ad-ca756c31a18a", "zone": "ams1"}], "name": "2018-05-16T15:11:25.303762"}], "current_public_version": "1b9e22e3-6a29-4f42-acfd-281ad086ee1d", "label": "gogs", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.A dynamic, open source programming language with a focus on simplicity and productivity.", "creation_date": "2016-03-08T07:01:11.482482+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/golang.png", "id": "6c8d25c0-cb6f-4220-98aa-830b7e479ba5", "categories": ["instantapp"], "name": "Golang", "modification_date": "2019-03-26T14:00:52.861225+00:00", "versions": [{"creation_date": "2018-04-18T08:00:48.175340+00:00", "modification_date": "2018-04-18T08:00:48.175340+00:00", "id": "880194c8-53ce-4b6b-a274-4f79307e2f8e", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "43213956-c7a3-44b8-9d96-d51fa7457969", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "5ffb52aa-ea55-4596-9d0f-e403701b6624", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "bef7a6af-1bab-490a-a6cb-6a07c1b9ac7b", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "f0b7d9b8-aa31-45b4-9f7e-a68aa164ce6f", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "76ca1eb7-f68f-4770-a7a1-ab7665ae3297", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "0d954c34-341c-483a-be1c-71cf197343ed", "zone": "ams1"}], "name": "2018-04-18T08:00:48.129246"}], "current_public_version": "880194c8-53ce-4b6b-a274-4f79307e2f8e", "label": "golang", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Java is a computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible.", "creation_date": "2016-03-07T21:07:46.908969+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/java.png", "id": "d72d1b73-7460-446b-91fb-b451d079aa4d", "categories": ["instantapp"], "name": "Java", "modification_date": "2019-03-26T14:00:49.430836+00:00", "versions": [{"creation_date": "2018-04-18T10:11:18.535736+00:00", "modification_date": "2018-04-18T10:11:18.535736+00:00", "id": "f3f69cca-aadb-4e5e-94b0-254ce05a6639", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "c50cb4b2-bf7b-47e2-ab5f-3a9d3d4c1aef", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "98c93894-26a8-463b-a72b-c9d2b531b95d", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "43c43b5e-1e4f-4905-baef-71df3c565b4d", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "0c3f9f03-f490-444b-a05e-f342e917fed0", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "5e07622b-ad8b-4f65-b55f-cca18c3c0bbf", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "c0330755-e5d0-4c2c-ad0e-70687e1dccbb", "zone": "par1"}], "name": "2018-04-18T10:11:18.477156"}], "current_public_version": "f3f69cca-aadb-4e5e-94b0-254ce05a6639", "label": "java", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "LEMP stack is a version where Apache has been replaced with the more lightweight web server Nginx.", "creation_date": "2016-03-07T21:06:53.552980+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/lemp.png", "id": "986ba672-b489-4f66-9e3b-90194ac336d4", "categories": ["instantapp"], "name": "LEMP stack", "modification_date": "2019-04-09T13:31:12.129567+00:00", "versions": [{"creation_date": "2019-04-09T13:31:11.315416+00:00", "modification_date": "2019-04-09T13:31:11.315416+00:00", "id": "a2e5ed1a-6f01-4f20-aabd-4115c67df590", "local_images": [{"compatible_commercial_types": ["C1"], "arch": "arm", "id": "32332006-1420-4260-97c7-c1da586f68cd", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "d16622f6-32c1-4d16-a3ca-38b23d3a25fb", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "1bd37d60-4494-485f-9a82-0a211005489c", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "415d3727-0013-419a-abc6-1a688b096730", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "26c3727a-5b77-4b26-89c9-445ea2006f07", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "155ab61a-e069-4acb-bae3-e8217c5c0376", "zone": "ams1"}], "name": "2019-04-09T13:31:10.613803"}], "current_public_version": "a2e5ed1a-6f01-4f20-aabd-4115c67df590", "label": "lemp_stack", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "self-hosted Slack-alternative", "creation_date": "2016-07-11T14:52:57.803007+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/mattermost.png", "id": "98ad7ccb-cc7f-4828-9da3-113e9c1bd2db", "categories": ["instantapp"], "name": "Mattermost", "modification_date": "2019-03-26T14:00:51.938920+00:00", "versions": [{"creation_date": "2018-05-03T10:27:55.610920+00:00", "modification_date": "2018-05-03T10:27:55.610920+00:00", "id": "42371bf7-c1ca-4889-a6d4-43febda865ca", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "486e128c-fde7-42d7-9200-5d91b8dc2761", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "eb2ed407-177c-4195-a4ca-f3baa85e62ed", "zone": "ams1"}], "name": "2018-05-03T10:27:55.021511"}], "current_public_version": "42371bf7-c1ca-4889-a6d4-43febda865ca", "label": "mattermost", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Nextcloud is an open source, self-hosted file share and communication platform.", "creation_date": "2019-04-16T12:22:56.930842+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/nextcloud.png", "id": "7d4a7cb1-1fd5-4a64-920b-c79f47367254", "categories": ["instantapp"], "name": "NextCloud", "modification_date": "2019-04-16T12:25:38.758921+00:00", "versions": [{"creation_date": "2019-04-16T12:25:38.052537+00:00", "modification_date": "2019-04-16T12:25:38.052537+00:00", "id": "2fe66cc6-8985-4b5f-8325-83acc0589436", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "e9af0a24-4312-4305-9386-b3a79e02f92d", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "c38073cf-ee40-4dc2-8059-ec2845f38f46", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "b9e319f5-ac4c-400d-8ff6-a6a769755190", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "0390c3e0-186d-4b24-8d0d-0e08b74fb59a", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "900971a4-3a3e-4ef9-b92f-b33c366c9f5c", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "7b7d4dde-6fe1-4586-a5a5-ae1af2ca2605", "zone": "par1"}], "name": "2019-04-16T12:25:37.374676"}], "current_public_version": "2fe66cc6-8985-4b5f-8325-83acc0589436", "label": "nextcloud", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "Node.js is an open source, cross-platform runtime environment for server-side and networking applications.", "creation_date": "2016-03-07T21:06:07.014951+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/nodejs.png", "id": "d11d7cc2-6ec8-4f95-a286-24fb5bac9e39", "categories": ["instantapp"], "name": "Node.js", "modification_date": "2019-03-26T14:00:51.148549+00:00", "versions": [{"creation_date": "2018-04-18T10:07:15.744660+00:00", "modification_date": "2018-04-18T10:07:15.744660+00:00", "id": "af308511-bcb3-4583-b0e0-79dbb1eea63e", "local_images": [{"compatible_commercial_types": [], "arch": "arm", "id": "a8020f20-8a66-43f3-8253-35941db3d237", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "3cc79cc6-4649-46d9-a2b6-698f1236e1d0", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "c9fb2bed-a9b8-4e1a-bf15-db8e763fe7a7", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f01db1d0-092a-47de-a32e-09bd6bda7715", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "6f2e99e8-da99-4990-b689-7294e8a604fa", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "03980aee-14cd-44f1-be3c-508c8b8a19e6", "zone": "par1"}], "name": "2018-04-18T10:07:15.691016"}], "current_public_version": "af308511-bcb3-4583-b0e0-79dbb1eea63e", "label": "node.js", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Surf the web in a secure and anonymous way with OpenVPN InstantApp.", "creation_date": "2016-03-07T21:04:57.667667+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/openvpn.png", "id": "b6f4edc8-21e6-4aa2-8f52-1030cf6d4dd8", "categories": ["instantapp"], "name": "OpenVPN", "modification_date": "2019-03-26T14:00:52.955853+00:00", "versions": [{"creation_date": "2019-03-25T13:06:02.622633+00:00", "modification_date": "2019-03-25T13:06:02.622633+00:00", "id": "d812e374-1169-4c91-aa90-c72acceeecb2", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "b15ddb1a-0611-412e-881a-3aed1b36392b", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "02906ae8-bf44-4dd0-bd05-6312dd9fa234", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "3aa3622c-45d4-4388-9618-cce6974c71a0", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a5430536-2a51-425d-8613-ef84dae91e27", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "51573d2d-301f-4d24-b0d6-f151728c82f5", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "cac79531-98d5-48fa-aba1-8250214b88a3", "zone": "par1"}], "name": "2019-03-25T13:06:01.961936"}], "current_public_version": "d812e374-1169-4c91-aa90-c72acceeecb2", "label": "openvpn", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "ownCloud lets you sync & share your files, calendar, contacts and more. Access your data from all your devices, on an open platform you can extend and modify.", "creation_date": "2016-03-07T21:05:14.365925+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/owncloud.png", "id": "e22a5d54-ecb5-4fdd-a130-a473737ff7ab", "categories": ["instantapp"], "name": "ownCloud", "modification_date": "2019-03-26T14:00:52.457272+00:00", "versions": [{"creation_date": "2018-04-18T10:09:39.010195+00:00", "modification_date": "2018-04-18T10:09:39.010195+00:00", "id": "c9c02a9c-e072-48af-aefd-bf6be9028022", "local_images": [{"compatible_commercial_types": [], "arch": "arm", "id": "a5fb716a-1c60-4740-a179-98ce315ca3d7", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "2fdbbbb4-3b63-403b-9604-27713971efd6", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "4208a611-a789-40ea-ac0e-fb3001ee39a9", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "93de8eae-535f-47bd-88fa-84af7b5eaf76", "zone": "par1"}], "name": "2018-04-18T10:09:38.952503"}], "current_public_version": "c9c02a9c-e072-48af-aefd-bf6be9028022", "label": "owncloud", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "PrestaShop is a free, open source e-commerce solution.", "creation_date": "2016-03-07T21:01:47.997930+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/prestashop.png", "id": "58a551e0-1b8b-4c83-82e7-1b4602ad43d1", "categories": ["instantapp"], "name": "PrestaShop", "modification_date": "2019-03-26T14:00:50.067950+00:00", "versions": [{"creation_date": "2018-05-16T14:57:16.059809+00:00", "modification_date": "2018-05-16T14:57:16.059809+00:00", "id": "6c459ab1-4f1a-4f87-b92e-c00849c93fde", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "4d07fcfa-ccda-4945-81aa-8de2206b39c0", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "73db574d-d5a0-49d5-b6ca-dd662895fac3", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "c97dc20f-8066-4d56-aabf-2b75162c0f9f", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "c78c3206-eb2b-4217-ad7c-0aca98dec145", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "7f91941c-f06a-4103-91a4-793f03b11fda", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "271a9c1f-73ef-4943-bac7-799130228040", "zone": "ams1"}], "name": "2018-05-16T14:57:15.505378"}], "current_public_version": "6c459ab1-4f1a-4f87-b92e-c00849c93fde", "label": "prestashop", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "The intended audience of this InstantApp is Python developers who want to bootstrap or test a Python application easily, in seconds.", "creation_date": "2016-03-07T21:05:46.642023+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/python.png", "id": "5c0f7971-c308-442e-82ab-2eb147439bd7", "categories": ["instantapp"], "name": "Python", "modification_date": "2019-03-26T14:00:49.970905+00:00", "versions": [{"creation_date": "2018-04-17T16:43:36.089412+00:00", "modification_date": "2018-04-17T16:43:36.089412+00:00", "id": "2642a982-e61d-4a58-8105-8838a69a85e3", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "70b9c9cf-c2d9-4a80-b450-a7aef8226d96", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "5218fa4e-8239-4831-ac2a-c96e23f387a2", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "f205e2a6-621a-4534-a5d1-36f6cf1f8376", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "613a5226-3d97-4f0e-abe2-99385a050784", "zone": "ams1"}], "name": "2018-04-17T16:43:36.031203"}], "current_public_version": "2642a982-e61d-4a58-8105-8838a69a85e3", "label": "python", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "A dynamic, open source programming language with a focus on simplicity and productivity.", "creation_date": "2016-03-07T22:15:25.347873+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ruby.png", "id": "42866fbe-9168-4f77-8271-09beb6049a07", "categories": ["instantapp"], "name": "Ruby", "modification_date": "2019-03-26T14:00:54.119256+00:00", "versions": [{"creation_date": "2018-04-18T10:21:49.119857+00:00", "modification_date": "2018-04-18T10:21:49.119857+00:00", "id": "5b8c935b-5047-43fd-a423-045dae3e0d78", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "09c71ada-00c6-43de-ad44-c77c5b857a05", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "24f2e8ee-80f1-4a8d-83c4-74ed8cd80ed0", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "e2479a13-414b-4a0c-ba50-d01e67ee8600", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "f83a03fa-58eb-4b35-bda9-1a42b6d6d90d", "zone": "ams1"}], "name": "2018-04-18T10:21:49.057120"}], "current_public_version": "5b8c935b-5047-43fd-a423-045dae3e0d78", "label": "ruby", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "The torrents InstantApp spawns a private server to upload and download your digital files.", "creation_date": "2016-03-07T21:08:02.980958+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/seedbox.png", "id": "4e18f1fc-0b66-4692-a38d-bfa4c94f29de", "categories": ["instantapp"], "name": "Torrents", "modification_date": "2019-03-26T14:00:51.427329+00:00", "versions": [{"creation_date": "2019-03-25T13:04:02.099902+00:00", "modification_date": "2019-03-25T13:04:02.099902+00:00", "id": "53d2e4fb-20df-4ba9-8d65-29256f2be480", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "41d0db97-4822-4642-96ec-6f3fbcfc167c", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "3fbe5f72-81da-4a0a-91ef-36ab68fc801e", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "1aed7396-79dc-431d-af03-d3dde35d195f", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "398875b6-de43-4946-976f-ba5189954912", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a3160162-3d72-4632-8e42-4849a1280743", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f5d116e3-2b58-44cf-a83a-cd0682135473", "zone": "par1"}], "name": "2019-03-25T13:04:01.408435"}], "current_public_version": "53d2e4fb-20df-4ba9-8d65-29256f2be480", "label": "torrents", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Ubuntu is the ideal distribution for scale-out computing, Ubuntu Server helps you make the most of your infrastructure.", "creation_date": "2020-02-17T15:50:48.980694+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "3f1b9623-71ba-4fe3-b994-27fcdaa850ba", "categories": ["distribution"], "name": "Ubuntu 20.04 Focal Fossa", "modification_date": "2020-05-12T14:59:11.764621+00:00", "versions": [{"creation_date": "2020-05-12T14:08:49.605637+00:00", "modification_date": "2020-05-12T14:08:49.605637+00:00", "id": "8a23f8ac-240c-4c9c-b20e-c611361e0148", "local_images": [{"compatible_commercial_types": ["VC1S", "VC1M", "VC1L", "START1-XS", "START1-S", "START1-M", "START1-L", "X64-15GB", "X64-30GB", "X64-60GB", "X64-120GB", "GP1-XS", "GP1-S", "GP1-M", "GP1-L", "GP1-XL", "DEV1-S", "DEV1-M", "DEV1-L", "DEV1-XL"], "arch": "x86_64", "id": "365a8b9c-0c6e-4875-a887-dc3213db9e20", "zone": "par1"}, {"compatible_commercial_types": ["VC1S", "VC1M", "VC1L", "START1-XS", "START1-S", "START1-M", "START1-L", "X64-15GB", "X64-30GB", "X64-60GB", "X64-120GB", "GP1-XS", "GP1-S", "GP1-M", "GP1-L", "GP1-XL", "DEV1-S", "DEV1-M", "DEV1-L", "DEV1-XL"], "arch": "x86_64", "id": "80d81811-1bd2-44dc-bd1c-ec070c80c40b", "zone": "ams1"}], "name": "2020-05-12T14:08:49.566279+00:00"}], "current_public_version": "8a23f8ac-240c-4c9c-b20e-c611361e0148", "label": "ubuntu_focal", "organization": {"id": "51b656e3-4865-41e8-adbc-0c45bdd780db", "name": "Instances User Resources Build System"}}, {"valid_until": null, "description": "Ubuntu Bionic for Machine Learning 10.1", "creation_date": "2019-03-06T17:24:56.871317+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "e0808ca5-1e0a-4070-8aff-d2e49e9600c1", "categories": ["Machine Learning"], "name": "Ubuntu Bionic ML 10.1", "modification_date": "2020-02-17T12:56:29.417410+00:00", "versions": [{"creation_date": "2020-02-17T12:50:10.150196+00:00", "modification_date": "2020-02-17T12:50:10.150196+00:00", "id": "50a39102-80cf-4c9b-aed8-919e745df9d5", "local_images": [{"compatible_commercial_types": ["RENDER-S"], "arch": "x86_64", "id": "8fa4f46b-2cb2-40df-813a-727df120b9e4", "zone": "par1"}], "name": "2020-02-17T12:50:10.040529"}], "current_public_version": "50a39102-80cf-4c9b-aed8-919e745df9d5", "label": "ubuntu_bionic_ml_10.1", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "Ubuntu Bionic for Machine Learning 9.2", "creation_date": "2019-03-06T17:24:29.909001+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "7e48e55a-7b46-4e4f-b2d2-6b7316cdca8c", "categories": ["Machine Learning"], "name": "Ubuntu Bionic ML 9.2", "modification_date": "2020-02-17T12:55:53.623681+00:00", "versions": [{"creation_date": "2020-02-17T12:39:31.681271+00:00", "modification_date": "2020-02-17T12:39:31.681271+00:00", "id": "d0602033-62f8-455a-be55-0930291bb43f", "local_images": [{"compatible_commercial_types": ["RENDER-S"], "arch": "x86_64", "id": "1dad4207-f91a-48c3-9fac-6620e90b9434", "zone": "par1"}], "name": "2020-02-17T12:39:31.572184"}], "current_public_version": "d0602033-62f8-455a-be55-0930291bb43f", "label": "ubuntu_bionic_ml_9.2", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "WordPress is the most popular web software you can use to create a beautiful website or blog.", "creation_date": "2016-03-07T21:03:59.783534+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/wordpress.png", "id": "215a50f9-0ba8-4e9c-a4e7-10caf50e3586", "categories": ["instantapp"], "name": "WordPress", "modification_date": "2019-03-26T14:00:50.250657+00:00", "versions": [{"creation_date": "2019-03-08T08:58:28.971149+00:00", "modification_date": "2019-03-08T08:58:28.971149+00:00", "id": "3fb22e1f-de7f-4787-9bf8-32770151a45e", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "8523fb41-500a-4f21-998b-890908da6119", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "5645133b-67a3-4644-9941-16f7e2b428ea", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "757fac76-5265-46f8-8a1f-00c0fb270010", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "7a892c1a-bbdc-491f-9974-4008e3708664", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "726334eb-0733-4b6a-becd-769ff9bfe16d", "zone": "ams1"}], "name": "2019-03-08T08:58:28.893091"}], "current_public_version": "3fb22e1f-de7f-4787-9bf8-32770151a45e", "label": "wordpress", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}]}' headers: Cache-Control: - no-cache Content-Length: - "53981" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 04 Jun 2020 12:09:46 GMT Link: - ; rel="last" Server: - agw_listener_public_anycast Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 7815d166-dda1-440f-92d7-cb02cae7bc0e X-Total-Count: - "31" status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.3; darwin; amd64) url: https://api.scaleway.com/marketplace/v1/images?page=1 method: GET response: body: '{"images": [{"valid_until": null, "description": "Ubuntu is the ideal distribution for scale-out computing, Ubuntu Server helps you make the most of your infrastructure.", "creation_date": "2018-04-27T14:07:25.221998+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "b381b2bf-804a-4b12-91f6-9f4ff273462f", "categories": ["distribution"], "name": "Ubuntu Bionic", "modification_date": "2019-03-26T14:00:51.745705+00:00", "versions": [{"creation_date": "2019-03-05T16:39:34.893732+00:00", "modification_date": "2019-03-05T16:39:34.893732+00:00", "id": "e640c621-305b-45f5-975f-a3f80c1cec66", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f974feac-abae-4365-b988-8ec7d1cec10d", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "f63fe42a-900f-4a5e-ba99-ab0e59469b7e", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "b4bdbee1-e1f1-4436-8de4-bdb1b6ba4803", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "9444d178-2285-4842-ac35-5e86eda8da91", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "a5076337-734f-4b99-95ed-9a5bc73b9b09", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "7663c62b-40e3-4e6b-a835-70723ec2050b", "zone": "ams1"}], "name": "2019-03-05T16:39:34.377275"}], "current_public_version": "e640c621-305b-45f5-975f-a3f80c1cec66", "label": "ubuntu_bionic", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Ubuntu is the ideal distribution for scale-out computing, Ubuntu Server helps you make the most of your infrastructure.", "creation_date": "2016-04-22T13:27:33.769932+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "acf93867-88d9-40ee-99ea-6b2bb1ee8f0c", "categories": ["distribution"], "name": "Ubuntu Xenial", "modification_date": "2020-01-20T09:04:40.661026+00:00", "versions": [{"creation_date": "2020-01-17T14:31:06.041118+00:00", "modification_date": "2020-01-17T14:31:06.041118+00:00", "id": "24cd2ef0-bbc5-4b1a-8b08-99f617eab446", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "3d6804e0-086e-4a06-8124-7240a657668d", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "245e5cea-a9b4-4a36-9055-27185afe8690", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "c40fbabc-efc8-4e04-91ea-5e1e22daece1", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "bd859e89-fb2d-466a-a546-383630a1ead1", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "6c34a3f3-5e8a-455b-9bc2-f07c4c35bf89", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a5f6bb77-3d64-4f7f-abe0-72492b1bc020", "zone": "par1"}], "name": "2020-01-17T14:31:06.031136"}], "current_public_version": "24cd2ef0-bbc5-4b1a-8b08-99f617eab446", "label": "ubuntu_xenial", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Debian is a free, powerful and stable operating system.", "creation_date": "2017-06-26T15:37:13.460764+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/debian.png", "id": "c94b5df7-e698-4ac9-b273-565d18f5f8d2", "categories": ["distribution"], "name": "Debian Stretch", "modification_date": "2020-01-20T09:04:42.765883+00:00", "versions": [{"creation_date": "2020-01-15T11:38:06.396694+00:00", "modification_date": "2020-01-15T11:38:06.396694+00:00", "id": "8342f5d0-46aa-46e7-8a6f-f41188c97fba", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "5f7ab0cd-d10e-49a0-91c8-315ed8a6a1a4", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "d954dc33-c52e-4960-93e1-b69c85d169be", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "22a1bd8d-4498-4800-a8e5-4bc85001176c", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "37938de8-e3be-479a-895d-095158f76212", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "86740237-62fc-4538-9b70-4373942f53d3", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "bd6ba96e-d4c4-41f9-88e2-8dad3e6f085b", "zone": "par1"}], "name": "2020-01-15T11:38:06.390074"}], "current_public_version": "8342f5d0-46aa-46e7-8a6f-f41188c97fba", "label": "debian_stretch", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Debian is a free, powerful and stable operating system.", "creation_date": "2016-03-05T14:52:36.322319+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/debian.png", "id": "fb619bdf-834e-4c71-b7b8-15b5546d18bd", "categories": ["distribution"], "name": "Debian Jessie", "modification_date": "2019-03-26T14:00:50.449502+00:00", "versions": [{"creation_date": "2018-04-10T22:31:04.322822+00:00", "modification_date": "2018-04-10T22:31:04.322822+00:00", "id": "d3846a7b-8219-4938-ad96-cc2173e22481", "local_images": [{"compatible_commercial_types": ["C1"], "arch": "arm", "id": "2dfad6d2-e527-4e93-8eb1-8dc57803b310", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "610f68d5-cbad-4923-98ae-782af8f3b527", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "dc22e553-2d2e-4689-94f8-8817db824202", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "2e570f53-199e-47cc-95dd-f7bc392496e3", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "abf9e3a2-7171-4764-91ef-57f30b21193d", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "69cbdd54-88a1-4458-b75e-662a0848a7ce", "zone": "ams1"}], "name": "2018-04-10T22:31:04.321157"}], "current_public_version": "d3846a7b-8219-4938-ad96-cc2173e22481", "label": "debian_jessie", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "The CentOS Project is a community-driven free software effort focused on delivering a robust open source ecosystem.", "creation_date": "2019-03-06T11:27:48.406290+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/centos.png", "id": "1d47b370-ac63-43b1-9f34-7328675e5e18", "categories": ["distribution"], "name": "CentOS 7.6", "modification_date": "2019-03-26T14:00:50.839069+00:00", "versions": [{"creation_date": "2019-03-18T09:29:00.247544+00:00", "modification_date": "2019-03-18T09:29:00.247544+00:00", "id": "53138072-3099-4566-8b18-de7b2739696a", "local_images": [{"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "05794ee5-c6d2-4d69-86dd-f1fc9032921d", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "0f44b130-2bc7-4f82-993e-de9d1042c56e", "zone": "par1"}], "name": "2019-03-18T09:29:00.168590"}], "current_public_version": "53138072-3099-4566-8b18-de7b2739696a", "label": "centos_7.6", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "The CentOS Project is a community-driven free software effort focused on delivering a robust open source ecosystem.", "creation_date": "2018-04-19T10:12:28.968536+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/centos.png", "id": "98fc244a-ed4c-4523-bd17-b9c4070b8e7e", "categories": ["distribution"], "name": "CentOS 7.4", "modification_date": "2019-03-26T14:00:53.445597+00:00", "versions": [{"creation_date": "2018-04-20T13:55:06.824033+00:00", "modification_date": "2018-04-20T13:55:06.824033+00:00", "id": "31be34e5-074d-4c63-8c77-454459f77c3f", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "ec8b431e-ad39-4523-8b94-f3fa7f3cbd06", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "7220ac63-bac8-484b-9d44-93e3bd01f5a6", "zone": "ams1"}], "name": "2018-04-20T13:55:06.817954"}], "current_public_version": "31be34e5-074d-4c63-8c77-454459f77c3f", "label": "centos_7.4", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Fedora is a powerful, flexible operating system that includes the best and latest datacenter technologies. It puts you in control of all your infrastructure and services.", "creation_date": "2019-03-06T09:07:51.652433+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/fedora.png", "id": "69adec15-f1a7-469a-9ba5-868577832521", "categories": ["distribution"], "name": "Fedora 29", "modification_date": "2019-03-26T14:00:51.848785+00:00", "versions": [{"creation_date": "2019-03-06T09:08:01.112958+00:00", "modification_date": "2019-03-06T09:08:01.112958+00:00", "id": "a0f02365-f1af-48cb-b82d-75853a4e05e1", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "541f4562-5417-4b59-85d6-caaf64c1f127", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "3c0f706e-0947-47a3-88a3-595c29f7567a", "zone": "ams1"}], "name": "2019-03-06T09:08:01.016040"}], "current_public_version": "a0f02365-f1af-48cb-b82d-75853a4e05e1", "label": "fedora_29", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "Fedora is a powerful, flexible operating system that includes the best and latest datacenter technologies. It puts you in control of all your infrastructure and services.", "creation_date": "2018-05-03T09:51:57.274011+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/fedora.png", "id": "30d0f04f-6422-4b74-9ce9-1c2267419978", "categories": ["distribution"], "name": "Fedora 28", "modification_date": "2019-03-26T14:00:50.156015+00:00", "versions": [{"creation_date": "2018-05-03T12:01:10.147973+00:00", "modification_date": "2018-05-03T12:01:10.147973+00:00", "id": "49e33199-28cc-44d6-bb2e-a6147944ad5c", "local_images": [{"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "830aad94-24e5-4363-b2c3-e62921bd9294", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "c9cd1782-2159-44b8-83b1-9c48ed6c8a63", "zone": "par1"}], "name": "2018-05-03T12:01:10.135200"}], "current_public_version": "49e33199-28cc-44d6-bb2e-a6147944ad5c", "label": "fedora_28", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Fedora is a powerful, flexible operating system that includes the best and latest datacenter technologies. It puts you in control of all your infrastructure and services.", "creation_date": "2018-04-19T10:14:08.648100+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/fedora.png", "id": "4bff4f37-3ef9-457e-9e8d-4a786cb2a5f2", "categories": ["distribution"], "name": "Fedora 27", "modification_date": "2019-03-26T14:00:53.140907+00:00", "versions": [{"creation_date": "2018-09-06T10:51:13.009967+00:00", "modification_date": "2018-09-06T10:51:13.009967+00:00", "id": "45b5823f-8ddf-4ea8-b106-33d2df127cdf", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "097a100e-fd2f-4918-8a5b-d86de5a489be", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "73f0bcd8-a152-4665-ac09-1b105905a475", "zone": "ams1"}], "name": "2018-09-06T10:51:13.011044"}], "current_public_version": "45b5823f-8ddf-4ea8-b106-33d2df127cdf", "label": "fedora_27", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Arch Linux is an independently developed Linux distribution versatile enough to suit any role.", "creation_date": "2016-03-07T20:55:32.213089+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/archlinux.png", "id": "8f60c5dd-e659-48da-97e3-fb7de42195f5", "categories": ["distribution"], "name": "Arch Linux", "modification_date": "2019-03-26T14:00:49.327070+00:00", "versions": [{"creation_date": "2018-04-20T15:59:04.594929+00:00", "modification_date": "2018-04-20T15:59:04.594929+00:00", "id": "f7696517-bc49-448b-9869-f2c84e7c2a96", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f21defd0-9fd9-4fb2-a29a-22844a6be3cd", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "3c904f73-080e-4c6f-8b28-8426cfdcb3c7", "zone": "ams1"}], "name": "2018-04-20T15:59:04.593811"}], "current_public_version": "f7696517-bc49-448b-9869-f2c84e7c2a96", "label": "arch_linux", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Alpine Linux is security-oriented, lightweight Linux distribution based on musl libc and busybox.", "creation_date": "2016-03-05T14:49:50.255568+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/alpinelinux.png", "id": "c0649a2a-e6bf-4712-9303-8d967153209c", "categories": ["distribution"], "name": "Alpine Linux", "modification_date": "2019-03-26T14:00:54.425917+00:00", "versions": [{"creation_date": "2018-04-26T10:18:10.201002+00:00", "modification_date": "2018-04-26T10:18:10.201002+00:00", "id": "be2293b6-9eba-4497-9659-2cfb927483b5", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "24141068-1043-4885-bf2b-8290f617e273", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "241b0bb3-9eed-4a7b-b0fd-71c45452ac95", "zone": "ams1"}], "name": "2018-04-26T10:18:10.196011"}], "current_public_version": "be2293b6-9eba-4497-9659-2cfb927483b5", "label": "alpine_linux", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Debian is a free operating system, developed by thousands of volunteers from all over the world who collaborate via the Internet.", "creation_date": "2019-07-16T13:55:36.377559+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/debian.png", "id": "7bdc1afb-231f-486a-9b85-1b0478bc0e4a", "categories": ["distribution"], "name": "Debian Buster", "modification_date": "2020-01-20T09:04:41.730609+00:00", "versions": [{"creation_date": "2020-01-15T11:52:04.860098+00:00", "modification_date": "2020-01-15T11:52:04.860098+00:00", "id": "763b45ed-2e31-4ba0-9beb-efb195503a2d", "local_images": [{"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "61010e34-7f1e-402b-a253-028a714a6678", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "4720c10f-59e3-4e20-915b-dcee1fc34c11", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "9d6e8a2c-31a9-439c-a4c5-9fba1c5b96ed", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "cc9188b3-3938-47d7-b091-c9ecad1fe507", "zone": "par1"}], "name": "2020-01-15T11:52:04.849401"}], "current_public_version": "763b45ed-2e31-4ba0-9beb-efb195503a2d", "label": "debian_buster", "organization": {"id": "51b656e3-4865-41e8-adbc-0c45bdd780db", "name": "Instances User Resources Build System"}}, {"valid_until": null, "description": "Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications.", "creation_date": "2016-03-05T15:11:26.847640+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/docker.png", "id": "c1b530d8-0ca0-45c4-80db-ba06608287b2", "categories": ["instantapp"], "name": "Docker", "modification_date": "2019-03-26T14:00:49.524465+00:00", "versions": [{"creation_date": "2019-03-07T17:07:39.090644+00:00", "modification_date": "2019-03-07T17:07:39.090644+00:00", "id": "bf30c937-6e89-4019-ad2a-92156a62cf3e", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "89c80d27-ddf4-4ffa-8215-b335cce3fd05", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "99e2a9c6-f0b9-42b6-8823-8b0d86ffe9bf", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "45a7e942-1fb0-48c0-bbf6-0acb9af24604", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "c669011a-ee16-42b6-b0c3-ecd19e419539", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "dcf35840-c007-4c8b-a48b-227cfd8a347b", "zone": "ams1"}], "name": "2019-03-07T17:07:39.004809"}], "current_public_version": "bf30c937-6e89-4019-ad2a-92156a62cf3e", "label": "docker", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "GitLab is a web-based Git repository manager with wiki and issue tracking features.", "creation_date": "2016-03-07T21:06:22.770864+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/gitlab.png", "id": "233074b9-e2ba-4e78-818e-dd4930ce6bee", "categories": ["instantapp"], "name": "GitLab", "modification_date": "2019-04-09T13:31:04.022755+00:00", "versions": [{"creation_date": "2019-04-09T13:31:03.648676+00:00", "modification_date": "2019-04-09T13:31:03.648676+00:00", "id": "a389c94b-8b19-4528-a4f6-0b7cac3425e9", "local_images": [{"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "06a2a6e9-922d-4353-9472-bbb1f79fda63", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "4527e41c-0e90-43a8-857e-d9584bf8467f", "zone": "par1"}], "name": "2019-04-09T13:31:03.352588"}], "current_public_version": "a389c94b-8b19-4528-a4f6-0b7cac3425e9", "label": "gitlab", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "A painless self-hosted Git service.", "creation_date": "2016-03-07T21:00:44.946716+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/gogs.png", "id": "90d512b8-e4b7-4821-98e9-78241d73a7e6", "categories": ["instantapp"], "name": "Gogs", "modification_date": "2019-03-26T14:00:54.513196+00:00", "versions": [{"creation_date": "2018-05-16T15:11:25.881343+00:00", "modification_date": "2018-05-16T15:11:25.881343+00:00", "id": "1b9e22e3-6a29-4f42-acfd-281ad086ee1d", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "776705c4-be8e-4a27-b740-2e8bbba518c5", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a513a250-e6e9-4687-892e-9d10b29e3972", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "d1341ece-ffda-4386-ad3a-27d60b650401", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "69b8bc0e-7771-42af-a4ad-ca756c31a18a", "zone": "ams1"}], "name": "2018-05-16T15:11:25.303762"}], "current_public_version": "1b9e22e3-6a29-4f42-acfd-281ad086ee1d", "label": "gogs", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.A dynamic, open source programming language with a focus on simplicity and productivity.", "creation_date": "2016-03-08T07:01:11.482482+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/golang.png", "id": "6c8d25c0-cb6f-4220-98aa-830b7e479ba5", "categories": ["instantapp"], "name": "Golang", "modification_date": "2019-03-26T14:00:52.861225+00:00", "versions": [{"creation_date": "2018-04-18T08:00:48.175340+00:00", "modification_date": "2018-04-18T08:00:48.175340+00:00", "id": "880194c8-53ce-4b6b-a274-4f79307e2f8e", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "43213956-c7a3-44b8-9d96-d51fa7457969", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "5ffb52aa-ea55-4596-9d0f-e403701b6624", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "bef7a6af-1bab-490a-a6cb-6a07c1b9ac7b", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "f0b7d9b8-aa31-45b4-9f7e-a68aa164ce6f", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "76ca1eb7-f68f-4770-a7a1-ab7665ae3297", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "0d954c34-341c-483a-be1c-71cf197343ed", "zone": "ams1"}], "name": "2018-04-18T08:00:48.129246"}], "current_public_version": "880194c8-53ce-4b6b-a274-4f79307e2f8e", "label": "golang", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Java is a computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible.", "creation_date": "2016-03-07T21:07:46.908969+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/java.png", "id": "d72d1b73-7460-446b-91fb-b451d079aa4d", "categories": ["instantapp"], "name": "Java", "modification_date": "2019-03-26T14:00:49.430836+00:00", "versions": [{"creation_date": "2018-04-18T10:11:18.535736+00:00", "modification_date": "2018-04-18T10:11:18.535736+00:00", "id": "f3f69cca-aadb-4e5e-94b0-254ce05a6639", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "c50cb4b2-bf7b-47e2-ab5f-3a9d3d4c1aef", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "98c93894-26a8-463b-a72b-c9d2b531b95d", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "43c43b5e-1e4f-4905-baef-71df3c565b4d", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "0c3f9f03-f490-444b-a05e-f342e917fed0", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "5e07622b-ad8b-4f65-b55f-cca18c3c0bbf", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "c0330755-e5d0-4c2c-ad0e-70687e1dccbb", "zone": "par1"}], "name": "2018-04-18T10:11:18.477156"}], "current_public_version": "f3f69cca-aadb-4e5e-94b0-254ce05a6639", "label": "java", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "LEMP stack is a version where Apache has been replaced with the more lightweight web server Nginx.", "creation_date": "2016-03-07T21:06:53.552980+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/lemp.png", "id": "986ba672-b489-4f66-9e3b-90194ac336d4", "categories": ["instantapp"], "name": "LEMP stack", "modification_date": "2019-04-09T13:31:12.129567+00:00", "versions": [{"creation_date": "2019-04-09T13:31:11.315416+00:00", "modification_date": "2019-04-09T13:31:11.315416+00:00", "id": "a2e5ed1a-6f01-4f20-aabd-4115c67df590", "local_images": [{"compatible_commercial_types": ["C1"], "arch": "arm", "id": "32332006-1420-4260-97c7-c1da586f68cd", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "d16622f6-32c1-4d16-a3ca-38b23d3a25fb", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "1bd37d60-4494-485f-9a82-0a211005489c", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "415d3727-0013-419a-abc6-1a688b096730", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "26c3727a-5b77-4b26-89c9-445ea2006f07", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "155ab61a-e069-4acb-bae3-e8217c5c0376", "zone": "ams1"}], "name": "2019-04-09T13:31:10.613803"}], "current_public_version": "a2e5ed1a-6f01-4f20-aabd-4115c67df590", "label": "lemp_stack", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "self-hosted Slack-alternative", "creation_date": "2016-07-11T14:52:57.803007+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/mattermost.png", "id": "98ad7ccb-cc7f-4828-9da3-113e9c1bd2db", "categories": ["instantapp"], "name": "Mattermost", "modification_date": "2019-03-26T14:00:51.938920+00:00", "versions": [{"creation_date": "2018-05-03T10:27:55.610920+00:00", "modification_date": "2018-05-03T10:27:55.610920+00:00", "id": "42371bf7-c1ca-4889-a6d4-43febda865ca", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "486e128c-fde7-42d7-9200-5d91b8dc2761", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "eb2ed407-177c-4195-a4ca-f3baa85e62ed", "zone": "ams1"}], "name": "2018-05-03T10:27:55.021511"}], "current_public_version": "42371bf7-c1ca-4889-a6d4-43febda865ca", "label": "mattermost", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Nextcloud is an open source, self-hosted file share and communication platform.", "creation_date": "2019-04-16T12:22:56.930842+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/nextcloud.png", "id": "7d4a7cb1-1fd5-4a64-920b-c79f47367254", "categories": ["instantapp"], "name": "NextCloud", "modification_date": "2019-04-16T12:25:38.758921+00:00", "versions": [{"creation_date": "2019-04-16T12:25:38.052537+00:00", "modification_date": "2019-04-16T12:25:38.052537+00:00", "id": "2fe66cc6-8985-4b5f-8325-83acc0589436", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "e9af0a24-4312-4305-9386-b3a79e02f92d", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "c38073cf-ee40-4dc2-8059-ec2845f38f46", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "b9e319f5-ac4c-400d-8ff6-a6a769755190", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "0390c3e0-186d-4b24-8d0d-0e08b74fb59a", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "900971a4-3a3e-4ef9-b92f-b33c366c9f5c", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "7b7d4dde-6fe1-4586-a5a5-ae1af2ca2605", "zone": "par1"}], "name": "2019-04-16T12:25:37.374676"}], "current_public_version": "2fe66cc6-8985-4b5f-8325-83acc0589436", "label": "nextcloud", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "Node.js is an open source, cross-platform runtime environment for server-side and networking applications.", "creation_date": "2016-03-07T21:06:07.014951+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/nodejs.png", "id": "d11d7cc2-6ec8-4f95-a286-24fb5bac9e39", "categories": ["instantapp"], "name": "Node.js", "modification_date": "2019-03-26T14:00:51.148549+00:00", "versions": [{"creation_date": "2018-04-18T10:07:15.744660+00:00", "modification_date": "2018-04-18T10:07:15.744660+00:00", "id": "af308511-bcb3-4583-b0e0-79dbb1eea63e", "local_images": [{"compatible_commercial_types": [], "arch": "arm", "id": "a8020f20-8a66-43f3-8253-35941db3d237", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "3cc79cc6-4649-46d9-a2b6-698f1236e1d0", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "c9fb2bed-a9b8-4e1a-bf15-db8e763fe7a7", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f01db1d0-092a-47de-a32e-09bd6bda7715", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "6f2e99e8-da99-4990-b689-7294e8a604fa", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "03980aee-14cd-44f1-be3c-508c8b8a19e6", "zone": "par1"}], "name": "2018-04-18T10:07:15.691016"}], "current_public_version": "af308511-bcb3-4583-b0e0-79dbb1eea63e", "label": "node.js", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Surf the web in a secure and anonymous way with OpenVPN InstantApp.", "creation_date": "2016-03-07T21:04:57.667667+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/openvpn.png", "id": "b6f4edc8-21e6-4aa2-8f52-1030cf6d4dd8", "categories": ["instantapp"], "name": "OpenVPN", "modification_date": "2019-03-26T14:00:52.955853+00:00", "versions": [{"creation_date": "2019-03-25T13:06:02.622633+00:00", "modification_date": "2019-03-25T13:06:02.622633+00:00", "id": "d812e374-1169-4c91-aa90-c72acceeecb2", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "b15ddb1a-0611-412e-881a-3aed1b36392b", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "02906ae8-bf44-4dd0-bd05-6312dd9fa234", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "3aa3622c-45d4-4388-9618-cce6974c71a0", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a5430536-2a51-425d-8613-ef84dae91e27", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "51573d2d-301f-4d24-b0d6-f151728c82f5", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "cac79531-98d5-48fa-aba1-8250214b88a3", "zone": "par1"}], "name": "2019-03-25T13:06:01.961936"}], "current_public_version": "d812e374-1169-4c91-aa90-c72acceeecb2", "label": "openvpn", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "ownCloud lets you sync & share your files, calendar, contacts and more. Access your data from all your devices, on an open platform you can extend and modify.", "creation_date": "2016-03-07T21:05:14.365925+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/owncloud.png", "id": "e22a5d54-ecb5-4fdd-a130-a473737ff7ab", "categories": ["instantapp"], "name": "ownCloud", "modification_date": "2019-03-26T14:00:52.457272+00:00", "versions": [{"creation_date": "2018-04-18T10:09:39.010195+00:00", "modification_date": "2018-04-18T10:09:39.010195+00:00", "id": "c9c02a9c-e072-48af-aefd-bf6be9028022", "local_images": [{"compatible_commercial_types": [], "arch": "arm", "id": "a5fb716a-1c60-4740-a179-98ce315ca3d7", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "2fdbbbb4-3b63-403b-9604-27713971efd6", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "4208a611-a789-40ea-ac0e-fb3001ee39a9", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "93de8eae-535f-47bd-88fa-84af7b5eaf76", "zone": "par1"}], "name": "2018-04-18T10:09:38.952503"}], "current_public_version": "c9c02a9c-e072-48af-aefd-bf6be9028022", "label": "owncloud", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "PrestaShop is a free, open source e-commerce solution.", "creation_date": "2016-03-07T21:01:47.997930+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/prestashop.png", "id": "58a551e0-1b8b-4c83-82e7-1b4602ad43d1", "categories": ["instantapp"], "name": "PrestaShop", "modification_date": "2019-03-26T14:00:50.067950+00:00", "versions": [{"creation_date": "2018-05-16T14:57:16.059809+00:00", "modification_date": "2018-05-16T14:57:16.059809+00:00", "id": "6c459ab1-4f1a-4f87-b92e-c00849c93fde", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "4d07fcfa-ccda-4945-81aa-8de2206b39c0", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "73db574d-d5a0-49d5-b6ca-dd662895fac3", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "c97dc20f-8066-4d56-aabf-2b75162c0f9f", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "c78c3206-eb2b-4217-ad7c-0aca98dec145", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "7f91941c-f06a-4103-91a4-793f03b11fda", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "271a9c1f-73ef-4943-bac7-799130228040", "zone": "ams1"}], "name": "2018-05-16T14:57:15.505378"}], "current_public_version": "6c459ab1-4f1a-4f87-b92e-c00849c93fde", "label": "prestashop", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "The intended audience of this InstantApp is Python developers who want to bootstrap or test a Python application easily, in seconds.", "creation_date": "2016-03-07T21:05:46.642023+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/python.png", "id": "5c0f7971-c308-442e-82ab-2eb147439bd7", "categories": ["instantapp"], "name": "Python", "modification_date": "2019-03-26T14:00:49.970905+00:00", "versions": [{"creation_date": "2018-04-17T16:43:36.089412+00:00", "modification_date": "2018-04-17T16:43:36.089412+00:00", "id": "2642a982-e61d-4a58-8105-8838a69a85e3", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "70b9c9cf-c2d9-4a80-b450-a7aef8226d96", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "5218fa4e-8239-4831-ac2a-c96e23f387a2", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "f205e2a6-621a-4534-a5d1-36f6cf1f8376", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "613a5226-3d97-4f0e-abe2-99385a050784", "zone": "ams1"}], "name": "2018-04-17T16:43:36.031203"}], "current_public_version": "2642a982-e61d-4a58-8105-8838a69a85e3", "label": "python", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "A dynamic, open source programming language with a focus on simplicity and productivity.", "creation_date": "2016-03-07T22:15:25.347873+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ruby.png", "id": "42866fbe-9168-4f77-8271-09beb6049a07", "categories": ["instantapp"], "name": "Ruby", "modification_date": "2019-03-26T14:00:54.119256+00:00", "versions": [{"creation_date": "2018-04-18T10:21:49.119857+00:00", "modification_date": "2018-04-18T10:21:49.119857+00:00", "id": "5b8c935b-5047-43fd-a423-045dae3e0d78", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "09c71ada-00c6-43de-ad44-c77c5b857a05", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "24f2e8ee-80f1-4a8d-83c4-74ed8cd80ed0", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "e2479a13-414b-4a0c-ba50-d01e67ee8600", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "f83a03fa-58eb-4b35-bda9-1a42b6d6d90d", "zone": "ams1"}], "name": "2018-04-18T10:21:49.057120"}], "current_public_version": "5b8c935b-5047-43fd-a423-045dae3e0d78", "label": "ruby", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "The torrents InstantApp spawns a private server to upload and download your digital files.", "creation_date": "2016-03-07T21:08:02.980958+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/seedbox.png", "id": "4e18f1fc-0b66-4692-a38d-bfa4c94f29de", "categories": ["instantapp"], "name": "Torrents", "modification_date": "2019-03-26T14:00:51.427329+00:00", "versions": [{"creation_date": "2019-03-25T13:04:02.099902+00:00", "modification_date": "2019-03-25T13:04:02.099902+00:00", "id": "53d2e4fb-20df-4ba9-8d65-29256f2be480", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "41d0db97-4822-4642-96ec-6f3fbcfc167c", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "3fbe5f72-81da-4a0a-91ef-36ab68fc801e", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "1aed7396-79dc-431d-af03-d3dde35d195f", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "398875b6-de43-4946-976f-ba5189954912", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a3160162-3d72-4632-8e42-4849a1280743", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f5d116e3-2b58-44cf-a83a-cd0682135473", "zone": "par1"}], "name": "2019-03-25T13:04:01.408435"}], "current_public_version": "53d2e4fb-20df-4ba9-8d65-29256f2be480", "label": "torrents", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Ubuntu is the ideal distribution for scale-out computing, Ubuntu Server helps you make the most of your infrastructure.", "creation_date": "2020-02-17T15:50:48.980694+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "3f1b9623-71ba-4fe3-b994-27fcdaa850ba", "categories": ["distribution"], "name": "Ubuntu 20.04 Focal Fossa", "modification_date": "2020-05-12T14:59:11.764621+00:00", "versions": [{"creation_date": "2020-05-12T14:08:49.605637+00:00", "modification_date": "2020-05-12T14:08:49.605637+00:00", "id": "8a23f8ac-240c-4c9c-b20e-c611361e0148", "local_images": [{"compatible_commercial_types": ["VC1S", "VC1M", "VC1L", "START1-XS", "START1-S", "START1-M", "START1-L", "X64-15GB", "X64-30GB", "X64-60GB", "X64-120GB", "GP1-XS", "GP1-S", "GP1-M", "GP1-L", "GP1-XL", "DEV1-S", "DEV1-M", "DEV1-L", "DEV1-XL"], "arch": "x86_64", "id": "365a8b9c-0c6e-4875-a887-dc3213db9e20", "zone": "par1"}, {"compatible_commercial_types": ["VC1S", "VC1M", "VC1L", "START1-XS", "START1-S", "START1-M", "START1-L", "X64-15GB", "X64-30GB", "X64-60GB", "X64-120GB", "GP1-XS", "GP1-S", "GP1-M", "GP1-L", "GP1-XL", "DEV1-S", "DEV1-M", "DEV1-L", "DEV1-XL"], "arch": "x86_64", "id": "80d81811-1bd2-44dc-bd1c-ec070c80c40b", "zone": "ams1"}], "name": "2020-05-12T14:08:49.566279+00:00"}], "current_public_version": "8a23f8ac-240c-4c9c-b20e-c611361e0148", "label": "ubuntu_focal", "organization": {"id": "51b656e3-4865-41e8-adbc-0c45bdd780db", "name": "Instances User Resources Build System"}}, {"valid_until": null, "description": "Ubuntu Bionic for Machine Learning 10.1", "creation_date": "2019-03-06T17:24:56.871317+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "e0808ca5-1e0a-4070-8aff-d2e49e9600c1", "categories": ["Machine Learning"], "name": "Ubuntu Bionic ML 10.1", "modification_date": "2020-02-17T12:56:29.417410+00:00", "versions": [{"creation_date": "2020-02-17T12:50:10.150196+00:00", "modification_date": "2020-02-17T12:50:10.150196+00:00", "id": "50a39102-80cf-4c9b-aed8-919e745df9d5", "local_images": [{"compatible_commercial_types": ["RENDER-S"], "arch": "x86_64", "id": "8fa4f46b-2cb2-40df-813a-727df120b9e4", "zone": "par1"}], "name": "2020-02-17T12:50:10.040529"}], "current_public_version": "50a39102-80cf-4c9b-aed8-919e745df9d5", "label": "ubuntu_bionic_ml_10.1", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "Ubuntu Bionic for Machine Learning 9.2", "creation_date": "2019-03-06T17:24:29.909001+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "7e48e55a-7b46-4e4f-b2d2-6b7316cdca8c", "categories": ["Machine Learning"], "name": "Ubuntu Bionic ML 9.2", "modification_date": "2020-02-17T12:55:53.623681+00:00", "versions": [{"creation_date": "2020-02-17T12:39:31.681271+00:00", "modification_date": "2020-02-17T12:39:31.681271+00:00", "id": "d0602033-62f8-455a-be55-0930291bb43f", "local_images": [{"compatible_commercial_types": ["RENDER-S"], "arch": "x86_64", "id": "1dad4207-f91a-48c3-9fac-6620e90b9434", "zone": "par1"}], "name": "2020-02-17T12:39:31.572184"}], "current_public_version": "d0602033-62f8-455a-be55-0930291bb43f", "label": "ubuntu_bionic_ml_9.2", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "WordPress is the most popular web software you can use to create a beautiful website or blog.", "creation_date": "2016-03-07T21:03:59.783534+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/wordpress.png", "id": "215a50f9-0ba8-4e9c-a4e7-10caf50e3586", "categories": ["instantapp"], "name": "WordPress", "modification_date": "2019-03-26T14:00:50.250657+00:00", "versions": [{"creation_date": "2019-03-08T08:58:28.971149+00:00", "modification_date": "2019-03-08T08:58:28.971149+00:00", "id": "3fb22e1f-de7f-4787-9bf8-32770151a45e", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "8523fb41-500a-4f21-998b-890908da6119", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "5645133b-67a3-4644-9941-16f7e2b428ea", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "757fac76-5265-46f8-8a1f-00c0fb270010", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "7a892c1a-bbdc-491f-9974-4008e3708664", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "726334eb-0733-4b6a-becd-769ff9bfe16d", "zone": "ams1"}], "name": "2019-03-08T08:58:28.893091"}], "current_public_version": "3fb22e1f-de7f-4787-9bf8-32770151a45e", "label": "wordpress", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}]}' headers: Cache-Control: - no-cache Content-Length: - "53981" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 04 Jun 2020 12:09:46 GMT Link: - ; rel="last" Server: - agw_listener_public_anycast Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - aefb7b9f-7807-4d6a-a921-6f780a131f7c X-Total-Count: - "31" status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.6+dev (go1.14.3; darwin; amd64) url: https://api.scaleway.com/marketplace/v1/images?page=1 method: GET response: body: '{"images": [{"valid_until": null, "description": "Ubuntu is the ideal distribution for scale-out computing, Ubuntu Server helps you make the most of your infrastructure.", "creation_date": "2018-04-27T14:07:25.221998+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "b381b2bf-804a-4b12-91f6-9f4ff273462f", "categories": ["distribution"], "name": "Ubuntu Bionic", "modification_date": "2019-03-26T14:00:51.745705+00:00", "versions": [{"creation_date": "2019-03-05T16:39:34.893732+00:00", "modification_date": "2019-03-05T16:39:34.893732+00:00", "id": "e640c621-305b-45f5-975f-a3f80c1cec66", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f974feac-abae-4365-b988-8ec7d1cec10d", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "f63fe42a-900f-4a5e-ba99-ab0e59469b7e", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "b4bdbee1-e1f1-4436-8de4-bdb1b6ba4803", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "9444d178-2285-4842-ac35-5e86eda8da91", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "a5076337-734f-4b99-95ed-9a5bc73b9b09", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "7663c62b-40e3-4e6b-a835-70723ec2050b", "zone": "ams1"}], "name": "2019-03-05T16:39:34.377275"}], "current_public_version": "e640c621-305b-45f5-975f-a3f80c1cec66", "label": "ubuntu_bionic", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Ubuntu is the ideal distribution for scale-out computing, Ubuntu Server helps you make the most of your infrastructure.", "creation_date": "2016-04-22T13:27:33.769932+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "acf93867-88d9-40ee-99ea-6b2bb1ee8f0c", "categories": ["distribution"], "name": "Ubuntu Xenial", "modification_date": "2020-01-20T09:04:40.661026+00:00", "versions": [{"creation_date": "2020-01-17T14:31:06.041118+00:00", "modification_date": "2020-01-17T14:31:06.041118+00:00", "id": "24cd2ef0-bbc5-4b1a-8b08-99f617eab446", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "3d6804e0-086e-4a06-8124-7240a657668d", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "245e5cea-a9b4-4a36-9055-27185afe8690", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "c40fbabc-efc8-4e04-91ea-5e1e22daece1", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "bd859e89-fb2d-466a-a546-383630a1ead1", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "6c34a3f3-5e8a-455b-9bc2-f07c4c35bf89", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a5f6bb77-3d64-4f7f-abe0-72492b1bc020", "zone": "par1"}], "name": "2020-01-17T14:31:06.031136"}], "current_public_version": "24cd2ef0-bbc5-4b1a-8b08-99f617eab446", "label": "ubuntu_xenial", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Debian is a free, powerful and stable operating system.", "creation_date": "2017-06-26T15:37:13.460764+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/debian.png", "id": "c94b5df7-e698-4ac9-b273-565d18f5f8d2", "categories": ["distribution"], "name": "Debian Stretch", "modification_date": "2020-01-20T09:04:42.765883+00:00", "versions": [{"creation_date": "2020-01-15T11:38:06.396694+00:00", "modification_date": "2020-01-15T11:38:06.396694+00:00", "id": "8342f5d0-46aa-46e7-8a6f-f41188c97fba", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "5f7ab0cd-d10e-49a0-91c8-315ed8a6a1a4", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "d954dc33-c52e-4960-93e1-b69c85d169be", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "22a1bd8d-4498-4800-a8e5-4bc85001176c", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "37938de8-e3be-479a-895d-095158f76212", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "86740237-62fc-4538-9b70-4373942f53d3", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "bd6ba96e-d4c4-41f9-88e2-8dad3e6f085b", "zone": "par1"}], "name": "2020-01-15T11:38:06.390074"}], "current_public_version": "8342f5d0-46aa-46e7-8a6f-f41188c97fba", "label": "debian_stretch", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Debian is a free, powerful and stable operating system.", "creation_date": "2016-03-05T14:52:36.322319+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/debian.png", "id": "fb619bdf-834e-4c71-b7b8-15b5546d18bd", "categories": ["distribution"], "name": "Debian Jessie", "modification_date": "2019-03-26T14:00:50.449502+00:00", "versions": [{"creation_date": "2018-04-10T22:31:04.322822+00:00", "modification_date": "2018-04-10T22:31:04.322822+00:00", "id": "d3846a7b-8219-4938-ad96-cc2173e22481", "local_images": [{"compatible_commercial_types": ["C1"], "arch": "arm", "id": "2dfad6d2-e527-4e93-8eb1-8dc57803b310", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "610f68d5-cbad-4923-98ae-782af8f3b527", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "dc22e553-2d2e-4689-94f8-8817db824202", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "2e570f53-199e-47cc-95dd-f7bc392496e3", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "abf9e3a2-7171-4764-91ef-57f30b21193d", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "69cbdd54-88a1-4458-b75e-662a0848a7ce", "zone": "ams1"}], "name": "2018-04-10T22:31:04.321157"}], "current_public_version": "d3846a7b-8219-4938-ad96-cc2173e22481", "label": "debian_jessie", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "The CentOS Project is a community-driven free software effort focused on delivering a robust open source ecosystem.", "creation_date": "2019-03-06T11:27:48.406290+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/centos.png", "id": "1d47b370-ac63-43b1-9f34-7328675e5e18", "categories": ["distribution"], "name": "CentOS 7.6", "modification_date": "2019-03-26T14:00:50.839069+00:00", "versions": [{"creation_date": "2019-03-18T09:29:00.247544+00:00", "modification_date": "2019-03-18T09:29:00.247544+00:00", "id": "53138072-3099-4566-8b18-de7b2739696a", "local_images": [{"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "05794ee5-c6d2-4d69-86dd-f1fc9032921d", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "0f44b130-2bc7-4f82-993e-de9d1042c56e", "zone": "par1"}], "name": "2019-03-18T09:29:00.168590"}], "current_public_version": "53138072-3099-4566-8b18-de7b2739696a", "label": "centos_7.6", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "The CentOS Project is a community-driven free software effort focused on delivering a robust open source ecosystem.", "creation_date": "2018-04-19T10:12:28.968536+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/centos.png", "id": "98fc244a-ed4c-4523-bd17-b9c4070b8e7e", "categories": ["distribution"], "name": "CentOS 7.4", "modification_date": "2019-03-26T14:00:53.445597+00:00", "versions": [{"creation_date": "2018-04-20T13:55:06.824033+00:00", "modification_date": "2018-04-20T13:55:06.824033+00:00", "id": "31be34e5-074d-4c63-8c77-454459f77c3f", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "ec8b431e-ad39-4523-8b94-f3fa7f3cbd06", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "7220ac63-bac8-484b-9d44-93e3bd01f5a6", "zone": "ams1"}], "name": "2018-04-20T13:55:06.817954"}], "current_public_version": "31be34e5-074d-4c63-8c77-454459f77c3f", "label": "centos_7.4", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Fedora is a powerful, flexible operating system that includes the best and latest datacenter technologies. It puts you in control of all your infrastructure and services.", "creation_date": "2019-03-06T09:07:51.652433+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/fedora.png", "id": "69adec15-f1a7-469a-9ba5-868577832521", "categories": ["distribution"], "name": "Fedora 29", "modification_date": "2019-03-26T14:00:51.848785+00:00", "versions": [{"creation_date": "2019-03-06T09:08:01.112958+00:00", "modification_date": "2019-03-06T09:08:01.112958+00:00", "id": "a0f02365-f1af-48cb-b82d-75853a4e05e1", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "541f4562-5417-4b59-85d6-caaf64c1f127", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "3c0f706e-0947-47a3-88a3-595c29f7567a", "zone": "ams1"}], "name": "2019-03-06T09:08:01.016040"}], "current_public_version": "a0f02365-f1af-48cb-b82d-75853a4e05e1", "label": "fedora_29", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "Fedora is a powerful, flexible operating system that includes the best and latest datacenter technologies. It puts you in control of all your infrastructure and services.", "creation_date": "2018-05-03T09:51:57.274011+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/fedora.png", "id": "30d0f04f-6422-4b74-9ce9-1c2267419978", "categories": ["distribution"], "name": "Fedora 28", "modification_date": "2019-03-26T14:00:50.156015+00:00", "versions": [{"creation_date": "2018-05-03T12:01:10.147973+00:00", "modification_date": "2018-05-03T12:01:10.147973+00:00", "id": "49e33199-28cc-44d6-bb2e-a6147944ad5c", "local_images": [{"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "830aad94-24e5-4363-b2c3-e62921bd9294", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "c9cd1782-2159-44b8-83b1-9c48ed6c8a63", "zone": "par1"}], "name": "2018-05-03T12:01:10.135200"}], "current_public_version": "49e33199-28cc-44d6-bb2e-a6147944ad5c", "label": "fedora_28", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Fedora is a powerful, flexible operating system that includes the best and latest datacenter technologies. It puts you in control of all your infrastructure and services.", "creation_date": "2018-04-19T10:14:08.648100+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/fedora.png", "id": "4bff4f37-3ef9-457e-9e8d-4a786cb2a5f2", "categories": ["distribution"], "name": "Fedora 27", "modification_date": "2019-03-26T14:00:53.140907+00:00", "versions": [{"creation_date": "2018-09-06T10:51:13.009967+00:00", "modification_date": "2018-09-06T10:51:13.009967+00:00", "id": "45b5823f-8ddf-4ea8-b106-33d2df127cdf", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "097a100e-fd2f-4918-8a5b-d86de5a489be", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "73f0bcd8-a152-4665-ac09-1b105905a475", "zone": "ams1"}], "name": "2018-09-06T10:51:13.011044"}], "current_public_version": "45b5823f-8ddf-4ea8-b106-33d2df127cdf", "label": "fedora_27", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Arch Linux is an independently developed Linux distribution versatile enough to suit any role.", "creation_date": "2016-03-07T20:55:32.213089+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/archlinux.png", "id": "8f60c5dd-e659-48da-97e3-fb7de42195f5", "categories": ["distribution"], "name": "Arch Linux", "modification_date": "2019-03-26T14:00:49.327070+00:00", "versions": [{"creation_date": "2018-04-20T15:59:04.594929+00:00", "modification_date": "2018-04-20T15:59:04.594929+00:00", "id": "f7696517-bc49-448b-9869-f2c84e7c2a96", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f21defd0-9fd9-4fb2-a29a-22844a6be3cd", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "3c904f73-080e-4c6f-8b28-8426cfdcb3c7", "zone": "ams1"}], "name": "2018-04-20T15:59:04.593811"}], "current_public_version": "f7696517-bc49-448b-9869-f2c84e7c2a96", "label": "arch_linux", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Alpine Linux is security-oriented, lightweight Linux distribution based on musl libc and busybox.", "creation_date": "2016-03-05T14:49:50.255568+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/alpinelinux.png", "id": "c0649a2a-e6bf-4712-9303-8d967153209c", "categories": ["distribution"], "name": "Alpine Linux", "modification_date": "2019-03-26T14:00:54.425917+00:00", "versions": [{"creation_date": "2018-04-26T10:18:10.201002+00:00", "modification_date": "2018-04-26T10:18:10.201002+00:00", "id": "be2293b6-9eba-4497-9659-2cfb927483b5", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "24141068-1043-4885-bf2b-8290f617e273", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "241b0bb3-9eed-4a7b-b0fd-71c45452ac95", "zone": "ams1"}], "name": "2018-04-26T10:18:10.196011"}], "current_public_version": "be2293b6-9eba-4497-9659-2cfb927483b5", "label": "alpine_linux", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Debian is a free operating system, developed by thousands of volunteers from all over the world who collaborate via the Internet.", "creation_date": "2019-07-16T13:55:36.377559+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/debian.png", "id": "7bdc1afb-231f-486a-9b85-1b0478bc0e4a", "categories": ["distribution"], "name": "Debian Buster", "modification_date": "2020-01-20T09:04:41.730609+00:00", "versions": [{"creation_date": "2020-01-15T11:52:04.860098+00:00", "modification_date": "2020-01-15T11:52:04.860098+00:00", "id": "763b45ed-2e31-4ba0-9beb-efb195503a2d", "local_images": [{"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "61010e34-7f1e-402b-a253-028a714a6678", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "4720c10f-59e3-4e20-915b-dcee1fc34c11", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "9d6e8a2c-31a9-439c-a4c5-9fba1c5b96ed", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "cc9188b3-3938-47d7-b091-c9ecad1fe507", "zone": "par1"}], "name": "2020-01-15T11:52:04.849401"}], "current_public_version": "763b45ed-2e31-4ba0-9beb-efb195503a2d", "label": "debian_buster", "organization": {"id": "51b656e3-4865-41e8-adbc-0c45bdd780db", "name": "Instances User Resources Build System"}}, {"valid_until": null, "description": "Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications.", "creation_date": "2016-03-05T15:11:26.847640+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/docker.png", "id": "c1b530d8-0ca0-45c4-80db-ba06608287b2", "categories": ["instantapp"], "name": "Docker", "modification_date": "2019-03-26T14:00:49.524465+00:00", "versions": [{"creation_date": "2019-03-07T17:07:39.090644+00:00", "modification_date": "2019-03-07T17:07:39.090644+00:00", "id": "bf30c937-6e89-4019-ad2a-92156a62cf3e", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "89c80d27-ddf4-4ffa-8215-b335cce3fd05", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "99e2a9c6-f0b9-42b6-8823-8b0d86ffe9bf", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "45a7e942-1fb0-48c0-bbf6-0acb9af24604", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "c669011a-ee16-42b6-b0c3-ecd19e419539", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "dcf35840-c007-4c8b-a48b-227cfd8a347b", "zone": "ams1"}], "name": "2019-03-07T17:07:39.004809"}], "current_public_version": "bf30c937-6e89-4019-ad2a-92156a62cf3e", "label": "docker", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "GitLab is a web-based Git repository manager with wiki and issue tracking features.", "creation_date": "2016-03-07T21:06:22.770864+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/gitlab.png", "id": "233074b9-e2ba-4e78-818e-dd4930ce6bee", "categories": ["instantapp"], "name": "GitLab", "modification_date": "2019-04-09T13:31:04.022755+00:00", "versions": [{"creation_date": "2019-04-09T13:31:03.648676+00:00", "modification_date": "2019-04-09T13:31:03.648676+00:00", "id": "a389c94b-8b19-4528-a4f6-0b7cac3425e9", "local_images": [{"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "06a2a6e9-922d-4353-9472-bbb1f79fda63", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "4527e41c-0e90-43a8-857e-d9584bf8467f", "zone": "par1"}], "name": "2019-04-09T13:31:03.352588"}], "current_public_version": "a389c94b-8b19-4528-a4f6-0b7cac3425e9", "label": "gitlab", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "A painless self-hosted Git service.", "creation_date": "2016-03-07T21:00:44.946716+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/gogs.png", "id": "90d512b8-e4b7-4821-98e9-78241d73a7e6", "categories": ["instantapp"], "name": "Gogs", "modification_date": "2019-03-26T14:00:54.513196+00:00", "versions": [{"creation_date": "2018-05-16T15:11:25.881343+00:00", "modification_date": "2018-05-16T15:11:25.881343+00:00", "id": "1b9e22e3-6a29-4f42-acfd-281ad086ee1d", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "776705c4-be8e-4a27-b740-2e8bbba518c5", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a513a250-e6e9-4687-892e-9d10b29e3972", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "d1341ece-ffda-4386-ad3a-27d60b650401", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "69b8bc0e-7771-42af-a4ad-ca756c31a18a", "zone": "ams1"}], "name": "2018-05-16T15:11:25.303762"}], "current_public_version": "1b9e22e3-6a29-4f42-acfd-281ad086ee1d", "label": "gogs", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.A dynamic, open source programming language with a focus on simplicity and productivity.", "creation_date": "2016-03-08T07:01:11.482482+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/golang.png", "id": "6c8d25c0-cb6f-4220-98aa-830b7e479ba5", "categories": ["instantapp"], "name": "Golang", "modification_date": "2019-03-26T14:00:52.861225+00:00", "versions": [{"creation_date": "2018-04-18T08:00:48.175340+00:00", "modification_date": "2018-04-18T08:00:48.175340+00:00", "id": "880194c8-53ce-4b6b-a274-4f79307e2f8e", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "43213956-c7a3-44b8-9d96-d51fa7457969", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "5ffb52aa-ea55-4596-9d0f-e403701b6624", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "bef7a6af-1bab-490a-a6cb-6a07c1b9ac7b", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "f0b7d9b8-aa31-45b4-9f7e-a68aa164ce6f", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "76ca1eb7-f68f-4770-a7a1-ab7665ae3297", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "0d954c34-341c-483a-be1c-71cf197343ed", "zone": "ams1"}], "name": "2018-04-18T08:00:48.129246"}], "current_public_version": "880194c8-53ce-4b6b-a274-4f79307e2f8e", "label": "golang", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Java is a computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible.", "creation_date": "2016-03-07T21:07:46.908969+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/java.png", "id": "d72d1b73-7460-446b-91fb-b451d079aa4d", "categories": ["instantapp"], "name": "Java", "modification_date": "2019-03-26T14:00:49.430836+00:00", "versions": [{"creation_date": "2018-04-18T10:11:18.535736+00:00", "modification_date": "2018-04-18T10:11:18.535736+00:00", "id": "f3f69cca-aadb-4e5e-94b0-254ce05a6639", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "c50cb4b2-bf7b-47e2-ab5f-3a9d3d4c1aef", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "98c93894-26a8-463b-a72b-c9d2b531b95d", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "43c43b5e-1e4f-4905-baef-71df3c565b4d", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "0c3f9f03-f490-444b-a05e-f342e917fed0", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "5e07622b-ad8b-4f65-b55f-cca18c3c0bbf", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "c0330755-e5d0-4c2c-ad0e-70687e1dccbb", "zone": "par1"}], "name": "2018-04-18T10:11:18.477156"}], "current_public_version": "f3f69cca-aadb-4e5e-94b0-254ce05a6639", "label": "java", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "LEMP stack is a version where Apache has been replaced with the more lightweight web server Nginx.", "creation_date": "2016-03-07T21:06:53.552980+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/lemp.png", "id": "986ba672-b489-4f66-9e3b-90194ac336d4", "categories": ["instantapp"], "name": "LEMP stack", "modification_date": "2019-04-09T13:31:12.129567+00:00", "versions": [{"creation_date": "2019-04-09T13:31:11.315416+00:00", "modification_date": "2019-04-09T13:31:11.315416+00:00", "id": "a2e5ed1a-6f01-4f20-aabd-4115c67df590", "local_images": [{"compatible_commercial_types": ["C1"], "arch": "arm", "id": "32332006-1420-4260-97c7-c1da586f68cd", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "d16622f6-32c1-4d16-a3ca-38b23d3a25fb", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "1bd37d60-4494-485f-9a82-0a211005489c", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "415d3727-0013-419a-abc6-1a688b096730", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "26c3727a-5b77-4b26-89c9-445ea2006f07", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "155ab61a-e069-4acb-bae3-e8217c5c0376", "zone": "ams1"}], "name": "2019-04-09T13:31:10.613803"}], "current_public_version": "a2e5ed1a-6f01-4f20-aabd-4115c67df590", "label": "lemp_stack", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "self-hosted Slack-alternative", "creation_date": "2016-07-11T14:52:57.803007+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/mattermost.png", "id": "98ad7ccb-cc7f-4828-9da3-113e9c1bd2db", "categories": ["instantapp"], "name": "Mattermost", "modification_date": "2019-03-26T14:00:51.938920+00:00", "versions": [{"creation_date": "2018-05-03T10:27:55.610920+00:00", "modification_date": "2018-05-03T10:27:55.610920+00:00", "id": "42371bf7-c1ca-4889-a6d4-43febda865ca", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "486e128c-fde7-42d7-9200-5d91b8dc2761", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "eb2ed407-177c-4195-a4ca-f3baa85e62ed", "zone": "ams1"}], "name": "2018-05-03T10:27:55.021511"}], "current_public_version": "42371bf7-c1ca-4889-a6d4-43febda865ca", "label": "mattermost", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Nextcloud is an open source, self-hosted file share and communication platform.", "creation_date": "2019-04-16T12:22:56.930842+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/nextcloud.png", "id": "7d4a7cb1-1fd5-4a64-920b-c79f47367254", "categories": ["instantapp"], "name": "NextCloud", "modification_date": "2019-04-16T12:25:38.758921+00:00", "versions": [{"creation_date": "2019-04-16T12:25:38.052537+00:00", "modification_date": "2019-04-16T12:25:38.052537+00:00", "id": "2fe66cc6-8985-4b5f-8325-83acc0589436", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "e9af0a24-4312-4305-9386-b3a79e02f92d", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "c38073cf-ee40-4dc2-8059-ec2845f38f46", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "b9e319f5-ac4c-400d-8ff6-a6a769755190", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "0390c3e0-186d-4b24-8d0d-0e08b74fb59a", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "900971a4-3a3e-4ef9-b92f-b33c366c9f5c", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "7b7d4dde-6fe1-4586-a5a5-ae1af2ca2605", "zone": "par1"}], "name": "2019-04-16T12:25:37.374676"}], "current_public_version": "2fe66cc6-8985-4b5f-8325-83acc0589436", "label": "nextcloud", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "Node.js is an open source, cross-platform runtime environment for server-side and networking applications.", "creation_date": "2016-03-07T21:06:07.014951+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/nodejs.png", "id": "d11d7cc2-6ec8-4f95-a286-24fb5bac9e39", "categories": ["instantapp"], "name": "Node.js", "modification_date": "2019-03-26T14:00:51.148549+00:00", "versions": [{"creation_date": "2018-04-18T10:07:15.744660+00:00", "modification_date": "2018-04-18T10:07:15.744660+00:00", "id": "af308511-bcb3-4583-b0e0-79dbb1eea63e", "local_images": [{"compatible_commercial_types": [], "arch": "arm", "id": "a8020f20-8a66-43f3-8253-35941db3d237", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "3cc79cc6-4649-46d9-a2b6-698f1236e1d0", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "c9fb2bed-a9b8-4e1a-bf15-db8e763fe7a7", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f01db1d0-092a-47de-a32e-09bd6bda7715", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "6f2e99e8-da99-4990-b689-7294e8a604fa", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "03980aee-14cd-44f1-be3c-508c8b8a19e6", "zone": "par1"}], "name": "2018-04-18T10:07:15.691016"}], "current_public_version": "af308511-bcb3-4583-b0e0-79dbb1eea63e", "label": "node.js", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Surf the web in a secure and anonymous way with OpenVPN InstantApp.", "creation_date": "2016-03-07T21:04:57.667667+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/openvpn.png", "id": "b6f4edc8-21e6-4aa2-8f52-1030cf6d4dd8", "categories": ["instantapp"], "name": "OpenVPN", "modification_date": "2019-03-26T14:00:52.955853+00:00", "versions": [{"creation_date": "2019-03-25T13:06:02.622633+00:00", "modification_date": "2019-03-25T13:06:02.622633+00:00", "id": "d812e374-1169-4c91-aa90-c72acceeecb2", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "b15ddb1a-0611-412e-881a-3aed1b36392b", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "02906ae8-bf44-4dd0-bd05-6312dd9fa234", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "3aa3622c-45d4-4388-9618-cce6974c71a0", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a5430536-2a51-425d-8613-ef84dae91e27", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "51573d2d-301f-4d24-b0d6-f151728c82f5", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "cac79531-98d5-48fa-aba1-8250214b88a3", "zone": "par1"}], "name": "2019-03-25T13:06:01.961936"}], "current_public_version": "d812e374-1169-4c91-aa90-c72acceeecb2", "label": "openvpn", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "ownCloud lets you sync & share your files, calendar, contacts and more. Access your data from all your devices, on an open platform you can extend and modify.", "creation_date": "2016-03-07T21:05:14.365925+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/owncloud.png", "id": "e22a5d54-ecb5-4fdd-a130-a473737ff7ab", "categories": ["instantapp"], "name": "ownCloud", "modification_date": "2019-03-26T14:00:52.457272+00:00", "versions": [{"creation_date": "2018-04-18T10:09:39.010195+00:00", "modification_date": "2018-04-18T10:09:39.010195+00:00", "id": "c9c02a9c-e072-48af-aefd-bf6be9028022", "local_images": [{"compatible_commercial_types": [], "arch": "arm", "id": "a5fb716a-1c60-4740-a179-98ce315ca3d7", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "2fdbbbb4-3b63-403b-9604-27713971efd6", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "4208a611-a789-40ea-ac0e-fb3001ee39a9", "zone": "ams1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "93de8eae-535f-47bd-88fa-84af7b5eaf76", "zone": "par1"}], "name": "2018-04-18T10:09:38.952503"}], "current_public_version": "c9c02a9c-e072-48af-aefd-bf6be9028022", "label": "owncloud", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "PrestaShop is a free, open source e-commerce solution.", "creation_date": "2016-03-07T21:01:47.997930+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/prestashop.png", "id": "58a551e0-1b8b-4c83-82e7-1b4602ad43d1", "categories": ["instantapp"], "name": "PrestaShop", "modification_date": "2019-03-26T14:00:50.067950+00:00", "versions": [{"creation_date": "2018-05-16T14:57:16.059809+00:00", "modification_date": "2018-05-16T14:57:16.059809+00:00", "id": "6c459ab1-4f1a-4f87-b92e-c00849c93fde", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "4d07fcfa-ccda-4945-81aa-8de2206b39c0", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "73db574d-d5a0-49d5-b6ca-dd662895fac3", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "c97dc20f-8066-4d56-aabf-2b75162c0f9f", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "c78c3206-eb2b-4217-ad7c-0aca98dec145", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "7f91941c-f06a-4103-91a4-793f03b11fda", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "271a9c1f-73ef-4943-bac7-799130228040", "zone": "ams1"}], "name": "2018-05-16T14:57:15.505378"}], "current_public_version": "6c459ab1-4f1a-4f87-b92e-c00849c93fde", "label": "prestashop", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "The intended audience of this InstantApp is Python developers who want to bootstrap or test a Python application easily, in seconds.", "creation_date": "2016-03-07T21:05:46.642023+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/python.png", "id": "5c0f7971-c308-442e-82ab-2eb147439bd7", "categories": ["instantapp"], "name": "Python", "modification_date": "2019-03-26T14:00:49.970905+00:00", "versions": [{"creation_date": "2018-04-17T16:43:36.089412+00:00", "modification_date": "2018-04-17T16:43:36.089412+00:00", "id": "2642a982-e61d-4a58-8105-8838a69a85e3", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "70b9c9cf-c2d9-4a80-b450-a7aef8226d96", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "5218fa4e-8239-4831-ac2a-c96e23f387a2", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "f205e2a6-621a-4534-a5d1-36f6cf1f8376", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "613a5226-3d97-4f0e-abe2-99385a050784", "zone": "ams1"}], "name": "2018-04-17T16:43:36.031203"}], "current_public_version": "2642a982-e61d-4a58-8105-8838a69a85e3", "label": "python", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "A dynamic, open source programming language with a focus on simplicity and productivity.", "creation_date": "2016-03-07T22:15:25.347873+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ruby.png", "id": "42866fbe-9168-4f77-8271-09beb6049a07", "categories": ["instantapp"], "name": "Ruby", "modification_date": "2019-03-26T14:00:54.119256+00:00", "versions": [{"creation_date": "2018-04-18T10:21:49.119857+00:00", "modification_date": "2018-04-18T10:21:49.119857+00:00", "id": "5b8c935b-5047-43fd-a423-045dae3e0d78", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-L", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "09c71ada-00c6-43de-ad44-c77c5b857a05", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "24f2e8ee-80f1-4a8d-83c4-74ed8cd80ed0", "zone": "ams1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "e2479a13-414b-4a0c-ba50-d01e67ee8600", "zone": "par1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "f83a03fa-58eb-4b35-bda9-1a42b6d6d90d", "zone": "ams1"}], "name": "2018-04-18T10:21:49.057120"}], "current_public_version": "5b8c935b-5047-43fd-a423-045dae3e0d78", "label": "ruby", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "The torrents InstantApp spawns a private server to upload and download your digital files.", "creation_date": "2016-03-07T21:08:02.980958+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/seedbox.png", "id": "4e18f1fc-0b66-4692-a38d-bfa4c94f29de", "categories": ["instantapp"], "name": "Torrents", "modification_date": "2019-03-26T14:00:51.427329+00:00", "versions": [{"creation_date": "2019-03-25T13:04:02.099902+00:00", "modification_date": "2019-03-25T13:04:02.099902+00:00", "id": "53d2e4fb-20df-4ba9-8d65-29256f2be480", "local_images": [{"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "41d0db97-4822-4642-96ec-6f3fbcfc167c", "zone": "ams1"}, {"compatible_commercial_types": [], "arch": "arm", "id": "3fbe5f72-81da-4a0a-91ef-36ab68fc801e", "zone": "ams1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "1aed7396-79dc-431d-af03-d3dde35d195f", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "398875b6-de43-4946-976f-ba5189954912", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "a3160162-3d72-4632-8e42-4849a1280743", "zone": "par1"}, {"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "f5d116e3-2b58-44cf-a83a-cd0682135473", "zone": "par1"}], "name": "2019-03-25T13:04:01.408435"}], "current_public_version": "53d2e4fb-20df-4ba9-8d65-29256f2be480", "label": "torrents", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}, {"valid_until": null, "description": "Ubuntu is the ideal distribution for scale-out computing, Ubuntu Server helps you make the most of your infrastructure.", "creation_date": "2020-02-17T15:50:48.980694+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "3f1b9623-71ba-4fe3-b994-27fcdaa850ba", "categories": ["distribution"], "name": "Ubuntu 20.04 Focal Fossa", "modification_date": "2020-05-12T14:59:11.764621+00:00", "versions": [{"creation_date": "2020-05-12T14:08:49.605637+00:00", "modification_date": "2020-05-12T14:08:49.605637+00:00", "id": "8a23f8ac-240c-4c9c-b20e-c611361e0148", "local_images": [{"compatible_commercial_types": ["VC1S", "VC1M", "VC1L", "START1-XS", "START1-S", "START1-M", "START1-L", "X64-15GB", "X64-30GB", "X64-60GB", "X64-120GB", "GP1-XS", "GP1-S", "GP1-M", "GP1-L", "GP1-XL", "DEV1-S", "DEV1-M", "DEV1-L", "DEV1-XL"], "arch": "x86_64", "id": "365a8b9c-0c6e-4875-a887-dc3213db9e20", "zone": "par1"}, {"compatible_commercial_types": ["VC1S", "VC1M", "VC1L", "START1-XS", "START1-S", "START1-M", "START1-L", "X64-15GB", "X64-30GB", "X64-60GB", "X64-120GB", "GP1-XS", "GP1-S", "GP1-M", "GP1-L", "GP1-XL", "DEV1-S", "DEV1-M", "DEV1-L", "DEV1-XL"], "arch": "x86_64", "id": "80d81811-1bd2-44dc-bd1c-ec070c80c40b", "zone": "ams1"}], "name": "2020-05-12T14:08:49.566279+00:00"}], "current_public_version": "8a23f8ac-240c-4c9c-b20e-c611361e0148", "label": "ubuntu_focal", "organization": {"id": "51b656e3-4865-41e8-adbc-0c45bdd780db", "name": "Instances User Resources Build System"}}, {"valid_until": null, "description": "Ubuntu Bionic for Machine Learning 10.1", "creation_date": "2019-03-06T17:24:56.871317+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "e0808ca5-1e0a-4070-8aff-d2e49e9600c1", "categories": ["Machine Learning"], "name": "Ubuntu Bionic ML 10.1", "modification_date": "2020-02-17T12:56:29.417410+00:00", "versions": [{"creation_date": "2020-02-17T12:50:10.150196+00:00", "modification_date": "2020-02-17T12:50:10.150196+00:00", "id": "50a39102-80cf-4c9b-aed8-919e745df9d5", "local_images": [{"compatible_commercial_types": ["RENDER-S"], "arch": "x86_64", "id": "8fa4f46b-2cb2-40df-813a-727df120b9e4", "zone": "par1"}], "name": "2020-02-17T12:50:10.040529"}], "current_public_version": "50a39102-80cf-4c9b-aed8-919e745df9d5", "label": "ubuntu_bionic_ml_10.1", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "Ubuntu Bionic for Machine Learning 9.2", "creation_date": "2019-03-06T17:24:29.909001+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/ubuntu.png", "id": "7e48e55a-7b46-4e4f-b2d2-6b7316cdca8c", "categories": ["Machine Learning"], "name": "Ubuntu Bionic ML 9.2", "modification_date": "2020-02-17T12:55:53.623681+00:00", "versions": [{"creation_date": "2020-02-17T12:39:31.681271+00:00", "modification_date": "2020-02-17T12:39:31.681271+00:00", "id": "d0602033-62f8-455a-be55-0930291bb43f", "local_images": [{"compatible_commercial_types": ["RENDER-S"], "arch": "x86_64", "id": "1dad4207-f91a-48c3-9fac-6620e90b9434", "zone": "par1"}], "name": "2020-02-17T12:39:31.572184"}], "current_public_version": "d0602033-62f8-455a-be55-0930291bb43f", "label": "ubuntu_bionic_ml_9.2", "organization": {"id": "11111111-1111-4111-8111-111111111111", "name": "OCS"}}, {"valid_until": null, "description": "WordPress is the most popular web software you can use to create a beautiful website or blog.", "creation_date": "2016-03-07T21:03:59.783534+00:00", "logo": "https://marketplace-logos.s3.nl-ams.scw.cloud/wordpress.png", "id": "215a50f9-0ba8-4e9c-a4e7-10caf50e3586", "categories": ["instantapp"], "name": "WordPress", "modification_date": "2019-03-26T14:00:50.250657+00:00", "versions": [{"creation_date": "2019-03-08T08:58:28.971149+00:00", "modification_date": "2019-03-08T08:58:28.971149+00:00", "id": "3fb22e1f-de7f-4787-9bf8-32770151a45e", "local_images": [{"compatible_commercial_types": ["GP1-XS", "DEV1-M", "DEV1-L", "START1-XS", "DEV1-S", "RENDER-S", "GP1-XL", "C2S", "X64-15GB", "DEV1-XL", "C2L", "C2M", "VC1S", "START1-S", "X64-30GB", "GP1-L", "GP1-M", "GP1-S", "START1-L", "START1-M", "VC1L", "VC1M", "X64-120GB", "X64-60GB"], "arch": "x86_64", "id": "8523fb41-500a-4f21-998b-890908da6119", "zone": "par1"}, {"compatible_commercial_types": ["C1"], "arch": "arm", "id": "5645133b-67a3-4644-9941-16f7e2b428ea", "zone": "par1"}, {"compatible_commercial_types": ["ARM64-8GB", "ARM64-2GB", "ARM64-32GB", "ARM64-128GB", "ARM64-4GB", "ARM64-64GB", "ARM64-16GB"], "arch": "arm64", "id": "757fac76-5265-46f8-8a1f-00c0fb270010", "zone": "par1"}, {"compatible_commercial_types": ["X64-120GB", "C2M", "START1-S", "VC1S", "START1-XS", "C2L", "X64-15GB", "C2S", "X64-30GB", "START1-L", "START1-M", "X64-60GB", "VC1L", "VC1M"], "arch": "x86_64", "id": "7a892c1a-bbdc-491f-9974-4008e3708664", "zone": "ams1"}, {"compatible_commercial_types": ["ARM64-4GB", "ARM64-128GB", "ARM64-16GB", "ARM64-32GB", "ARM64-8GB", "ARM64-2GB", "ARM64-64GB"], "arch": "arm64", "id": "726334eb-0733-4b6a-becd-769ff9bfe16d", "zone": "ams1"}], "name": "2019-03-08T08:58:28.893091"}], "current_public_version": "3fb22e1f-de7f-4787-9bf8-32770151a45e", "label": "wordpress", "organization": {"id": "6d6b64e5-6bad-4cc6-b7ef-2030884c3e11", "name": "mtouron@ocs.online.net"}}]}' headers: Cache-Control: - no-cache Content-Length: - "53981" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Thu, 04 Jun 2020 12:09:46 GMT Link: - ; rel="last" Server: - agw_listener_public_anycast Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 8130b2d9-fb73-47fe-a0e3-2b64d65939f1 X-Total-Count: - "31" status: 200 OK code: 200 duration: "" golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/marketplace/v2/000077500000000000000000000000001456366605600256465ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/marketplace/v2/marketplace_sdk.go000066400000000000000000000437411456366605600313370ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package marketplace provides methods and message types of the marketplace v2 API. package marketplace import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type ListImagesRequestOrderBy string const ( ListImagesRequestOrderByNameAsc = ListImagesRequestOrderBy("name_asc") ListImagesRequestOrderByNameDesc = ListImagesRequestOrderBy("name_desc") ListImagesRequestOrderByCreatedAtAsc = ListImagesRequestOrderBy("created_at_asc") ListImagesRequestOrderByCreatedAtDesc = ListImagesRequestOrderBy("created_at_desc") ListImagesRequestOrderByUpdatedAtAsc = ListImagesRequestOrderBy("updated_at_asc") ListImagesRequestOrderByUpdatedAtDesc = ListImagesRequestOrderBy("updated_at_desc") ) func (enum ListImagesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "name_asc" } return string(enum) } func (enum ListImagesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListImagesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListImagesRequestOrderBy(ListImagesRequestOrderBy(tmp).String()) return nil } type ListLocalImagesRequestOrderBy string const ( ListLocalImagesRequestOrderByCreatedAtAsc = ListLocalImagesRequestOrderBy("created_at_asc") ListLocalImagesRequestOrderByCreatedAtDesc = ListLocalImagesRequestOrderBy("created_at_desc") ) func (enum ListLocalImagesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListLocalImagesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListLocalImagesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListLocalImagesRequestOrderBy(ListLocalImagesRequestOrderBy(tmp).String()) return nil } type ListVersionsRequestOrderBy string const ( ListVersionsRequestOrderByCreatedAtAsc = ListVersionsRequestOrderBy("created_at_asc") ListVersionsRequestOrderByCreatedAtDesc = ListVersionsRequestOrderBy("created_at_desc") ) func (enum ListVersionsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListVersionsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListVersionsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListVersionsRequestOrderBy(ListVersionsRequestOrderBy(tmp).String()) return nil } type LocalImageType string const ( // Unspecified image type. LocalImageTypeUnknownType = LocalImageType("unknown_type") // An image type that can be used to create volumes which are managed via the Instance API. LocalImageTypeInstanceLocal = LocalImageType("instance_local") // An image type that can be used to create volumes which are managed via the Scaleway Block Storage (SBS) API. LocalImageTypeInstanceSbs = LocalImageType("instance_sbs") ) func (enum LocalImageType) String() string { if enum == "" { // return default value if empty return "unknown_type" } return string(enum) } func (enum LocalImageType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *LocalImageType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = LocalImageType(LocalImageType(tmp).String()) return nil } // Category: category. type Category struct { ID string `json:"id"` Name string `json:"name"` Description string `json:"description"` } // Image: image. type Image struct { // ID: UUID of this image. ID string `json:"id"` // Name: name of the image. Name string `json:"name"` // Description: text description of this image. Description string `json:"description"` // Logo: URL of this image's logo. Logo string `json:"logo"` // Categories: list of categories this image belongs to. Categories []string `json:"categories"` // CreatedAt: creation date of this image. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date of the last modification of this image. UpdatedAt *time.Time `json:"updated_at"` // ValidUntil: expiration date of this image. ValidUntil *time.Time `json:"valid_until"` // Label: typically an identifier for a distribution (ex. "ubuntu_focal"). Label string `json:"label"` } // LocalImage: local image. type LocalImage struct { // ID: version you will typically use to define an image in an API call. ID string `json:"id"` // CompatibleCommercialTypes: list of all commercial types that are compatible with this local image. CompatibleCommercialTypes []string `json:"compatible_commercial_types"` // Arch: supported architecture for this local image. Arch string `json:"arch"` // Zone: availability Zone where this local image is available. Zone scw.Zone `json:"zone"` // Label: image label this image belongs to. Label string `json:"label"` // Type: type of this local image. // Default value: unknown_type Type LocalImageType `json:"type"` } // Version: version. type Version struct { // ID: UUID of this version. ID string `json:"id"` // Name: name of this version. Name string `json:"name"` // CreatedAt: creation date of this image version. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date of the last modification of this version. UpdatedAt *time.Time `json:"updated_at"` // PublishedAt: date this version was officially published. PublishedAt *time.Time `json:"published_at"` } // GetCategoryRequest: get category request. type GetCategoryRequest struct { CategoryID string `json:"-"` } // GetImageRequest: get image request. type GetImageRequest struct { // ImageID: display the image name. ImageID string `json:"-"` } // GetLocalImageRequest: get local image request. type GetLocalImageRequest struct { LocalImageID string `json:"-"` } // GetVersionRequest: get version request. type GetVersionRequest struct { VersionID string `json:"-"` } // ListCategoriesRequest: list categories request. type ListCategoriesRequest struct { PageSize *uint32 `json:"-"` Page *int32 `json:"-"` } // ListCategoriesResponse: list categories response. type ListCategoriesResponse struct { Categories []*Category `json:"categories"` TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListCategoriesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListCategoriesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListCategoriesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Categories = append(r.Categories, results.Categories...) r.TotalCount += uint32(len(results.Categories)) return uint32(len(results.Categories)), nil } // ListImagesRequest: list images request. type ListImagesRequest struct { // PageSize: a positive integer lower or equal to 100 to select the number of items to display. PageSize *uint32 `json:"-"` // Page: a positive integer to choose the page to display. Page *int32 `json:"-"` // OrderBy: ordering to use. // Default value: name_asc OrderBy ListImagesRequestOrderBy `json:"-"` // Arch: choose for which machine architecture to return images. Arch *string `json:"-"` // Category: choose the category of images to get. Category *string `json:"-"` // IncludeEol: choose to include end-of-life images. IncludeEol bool `json:"-"` } // ListImagesResponse: list images response. type ListImagesResponse struct { Images []*Image `json:"images"` TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListImagesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListImagesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListImagesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Images = append(r.Images, results.Images...) r.TotalCount += uint32(len(results.Images)) return uint32(len(results.Images)), nil } // ListLocalImagesRequest: list local images request. type ListLocalImagesRequest struct { // Precisely one of ImageID, VersionID, ImageLabel must be set. ImageID *string `json:"image_id,omitempty"` // Precisely one of ImageID, VersionID, ImageLabel must be set. VersionID *string `json:"version_id,omitempty"` PageSize *uint32 `json:"-"` Page *int32 `json:"-"` // OrderBy: default value: created_at_asc OrderBy ListLocalImagesRequestOrderBy `json:"-"` // Precisely one of ImageID, VersionID, ImageLabel must be set. ImageLabel *string `json:"image_label,omitempty"` // Zone: zone to target. If none is passed will use default zone from the config. Zone *scw.Zone `json:"-"` // Type: default value: unknown_type Type LocalImageType `json:"-"` } // ListLocalImagesResponse: list local images response. type ListLocalImagesResponse struct { LocalImages []*LocalImage `json:"local_images"` TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListLocalImagesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListLocalImagesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListLocalImagesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.LocalImages = append(r.LocalImages, results.LocalImages...) r.TotalCount += uint32(len(results.LocalImages)) return uint32(len(results.LocalImages)), nil } // ListVersionsRequest: list versions request. type ListVersionsRequest struct { ImageID string `json:"-"` PageSize *uint32 `json:"-"` Page *int32 `json:"-"` // OrderBy: default value: created_at_asc OrderBy ListVersionsRequestOrderBy `json:"-"` } // ListVersionsResponse: list versions response. type ListVersionsResponse struct { Versions []*Version `json:"versions"` TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListVersionsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListVersionsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListVersionsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Versions = append(r.Versions, results.Versions...) r.TotalCount += uint32(len(results.Versions)) return uint32(len(results.Versions)), nil } type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } // ListImages: List all available images on the marketplace, their UUID, CPU architecture and description. func (s *API) ListImages(req *ListImagesRequest, opts ...scw.RequestOption) (*ListImagesResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "arch", req.Arch) parameter.AddToQuery(query, "category", req.Category) parameter.AddToQuery(query, "include_eol", req.IncludeEol) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/marketplace/v2/images", Query: query, } var resp ListImagesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetImage: Get detailed information about a marketplace image, specified by its `image_id` (UUID format). func (s *API) GetImage(req *GetImageRequest, opts ...scw.RequestOption) (*Image, error) { var err error if fmt.Sprint(req.ImageID) == "" { return nil, errors.New("field ImageID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/marketplace/v2/images/" + fmt.Sprint(req.ImageID) + "", } var resp Image err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListVersions: Get a list of all available version of an image, specified by its `image_id` (UUID format). func (s *API) ListVersions(req *ListVersionsRequest, opts ...scw.RequestOption) (*ListVersionsResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "image_id", req.ImageID) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "order_by", req.OrderBy) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/marketplace/v2/versions", Query: query, } var resp ListVersionsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetVersion: Get information such as the name, creation date, last update and published date for an image version specified by its `version_id` (UUID format). func (s *API) GetVersion(req *GetVersionRequest, opts ...scw.RequestOption) (*Version, error) { var err error if fmt.Sprint(req.VersionID) == "" { return nil, errors.New("field VersionID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/marketplace/v2/versions/" + fmt.Sprint(req.VersionID) + "", } var resp Version err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListLocalImages: List information about local images in a specific Availability Zone, specified by its `image_id` (UUID format), `version_id` (UUID format) or `image_label`. Only one of these three parameters may be set. func (s *API) ListLocalImages(req *ListLocalImagesRequest, opts ...scw.RequestOption) (*ListLocalImagesResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } defaultZone, exist := s.client.GetDefaultZone() if (req.Zone == nil || *req.Zone == "") && exist { req.Zone = &defaultZone } query := url.Values{} parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "zone", req.Zone) parameter.AddToQuery(query, "type", req.Type) parameter.AddToQuery(query, "image_id", req.ImageID) parameter.AddToQuery(query, "version_id", req.VersionID) parameter.AddToQuery(query, "image_label", req.ImageLabel) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/marketplace/v2/local-images", Query: query, } var resp ListLocalImagesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetLocalImage: Get detailed information about a local image, including compatible commercial types, supported architecture, labels and the Availability Zone of the image, specified by its `local_image_id` (UUID format). func (s *API) GetLocalImage(req *GetLocalImageRequest, opts ...scw.RequestOption) (*LocalImage, error) { var err error if fmt.Sprint(req.LocalImageID) == "" { return nil, errors.New("field LocalImageID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/marketplace/v2/local-images/" + fmt.Sprint(req.LocalImageID) + "", } var resp LocalImage err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListCategories: Get a list of all existing categories. The output can be paginated. func (s *API) ListCategories(req *ListCategoriesRequest, opts ...scw.RequestOption) (*ListCategoriesResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "page", req.Page) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/marketplace/v2/categories", Query: query, } var resp ListCategoriesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetCategory: Get information about a specific category of the marketplace catalog, specified by its `category_id` (UUID format). func (s *API) GetCategory(req *GetCategoryRequest, opts ...scw.RequestOption) (*Category, error) { var err error if fmt.Sprint(req.CategoryID) == "" { return nil, errors.New("field CategoryID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/marketplace/v2/categories/" + fmt.Sprint(req.CategoryID) + "", } var resp Category err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/marketplace/v2/marketplace_utils.go000066400000000000000000000047241456366605600317140ustar00rootroot00000000000000package marketplace import ( "strings" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) // FindByLabel returns the first image with the given label in the image list // Cannot find an image if it is not in the ListImagesResponse struct // Use scw.WithAllPages when listing image to get all images func (r *ListImagesResponse) FindByLabel(label string) *Image { for _, image := range r.Images { if image.Label == label { return image } } return nil } type GetImageByLabelRequest struct { Label string } // GetImageByLabel returns the image with the given label func (s *API) GetImageByLabel(req *GetImageByLabelRequest, opts ...scw.RequestOption) (*Image, error) { listImagesRequest := &ListImagesRequest{} opts = append(opts, scw.WithAllPages()) listImagesResponse, err := s.ListImages(listImagesRequest, opts...) if err != nil { return nil, err } image := listImagesResponse.FindByLabel(req.Label) if image == nil { return nil, errors.New("couldn't find a matching image for the given label (%s)", req.Label) } return image, nil } type GetLocalImageByLabelRequest struct { ImageLabel string Zone scw.Zone CommercialType string Type LocalImageType } // GetLocalImageByLabel returns the local image for the given image label in the given zone and compatible with given commercial type func (s *API) GetLocalImageByLabel(req *GetLocalImageByLabelRequest, opts ...scw.RequestOption) (*LocalImage, error) { if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } req.CommercialType = strings.ToUpper(req.CommercialType) resp, err := s.ListLocalImages(&ListLocalImagesRequest{ ImageLabel: scw.StringPtr(req.ImageLabel), Zone: &req.Zone, Type: req.Type, }, opts...) if err != nil { return nil, err } for _, localImage := range resp.LocalImages { if localImage.IsCompatible(req.CommercialType) { return localImage, nil } } return nil, errors.New("couldn't find a local image for the given zone (%s) and commercial type (%s)", req.Zone, req.CommercialType) } // IsCompatible returns true if a local image is compatible with the given instance type // commercialType should be an uppercase string ex: DEV1-S func (li *LocalImage) IsCompatible(commercialType string) bool { for _, compatibleCommercialType := range li.CompatibleCommercialTypes { if compatibleCommercialType == commercialType { return true } } return false } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/marketplace/v2/marketplace_utils_test.go000066400000000000000000000041031456366605600327420ustar00rootroot00000000000000package marketplace import ( "testing" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers/httprecorder" "github.com/scaleway/scaleway-sdk-go/scw" ) func TestGetImageByLabel(t *testing.T) { client, r, err := httprecorder.CreateRecordedScwClient("go-vcr") testhelpers.AssertNoError(t, err) defer func() { testhelpers.AssertNoError(t, r.Stop()) // Make sure recorder is stopped once done with it }() t.Run("matching input for GetLocalImageIDByLabel", func(t *testing.T) { // Create SDK objects for Scaleway Instance product marketplaceAPI := NewAPI(client) image, err := marketplaceAPI.GetLocalImageByLabel(&GetLocalImageByLabelRequest{ Zone: scw.ZoneFrPar1, CommercialType: "DEV1-S", ImageLabel: "ubuntu_focal", }) testhelpers.AssertNoError(t, err) // ubuntu_focal DEV1-S at par1: 68cf470e-6c35-4741-bbff-4ce788616461 testhelpers.Equals(t, "68cf470e-6c35-4741-bbff-4ce788616461", image.ID) }) t.Run("matching input for GetLocalImageIDByLabel with lowercase image label", func(t *testing.T) { // Create SDK objects for Scaleway Instance product marketplaceAPI := NewAPI(client) image, err := marketplaceAPI.GetLocalImageByLabel(&GetLocalImageByLabelRequest{ Zone: scw.ZoneFrPar1, CommercialType: "dev1-s", ImageLabel: "ubuntu_focal", }) testhelpers.AssertNoError(t, err) // ubuntu_focal DEV1-S at par1: 68cf470e-6c35-4741-bbff-4ce788616461 testhelpers.Equals(t, "68cf470e-6c35-4741-bbff-4ce788616461", image.ID) }) t.Run("non-matching label for GetLocalImageIDByLabel", func(t *testing.T) { // Create SDK objects for Scaleway Instance product marketplaceAPI := NewAPI(client) _, err := marketplaceAPI.GetLocalImageByLabel(&GetLocalImageByLabelRequest{ Zone: scw.ZoneFrPar1, CommercialType: "DEV1-S", ImageLabel: "foo-bar-image", }) testhelpers.Assert(t, err != nil, "Should have error") //testhelpers.Equals(t, "scaleway-sdk-go: couldn't find a matching image for the given label (foo-bar-image)", err.Error()) }) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/marketplace/v2/testdata/000077500000000000000000000000001456366605600274575ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/marketplace/v2/testdata/go-vcr.yaml000066400000000000000000000117061456366605600315450ustar00rootroot00000000000000--- version: 1 interactions: - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.20.1; linux; amd64) url: https://api.scaleway.com/marketplace/v2/local-images?image_label=ubuntu_focal&order_by=created_at_asc&type=unknown_type&zone=fr-par-1 method: GET response: body: '{"local_images":[{"id":"2fedb0c7-1686-4529-8344-be9e198e4dd2", "arch":"arm64", "zone":"fr-par-1", "compatible_commercial_types":["AMP2-C1", "AMP2-C2", "AMP2-C4", "AMP2-C8", "AMP2-C12", "AMP2-C24", "AMP2-C48", "AMP2-C60"], "label":"ubuntu_focal"}, {"id":"68cf470e-6c35-4741-bbff-4ce788616461", "arch":"x86_64", "zone":"fr-par-1", "compatible_commercial_types":["DEV1-L", "DEV1-M", "DEV1-S", "DEV1-XL", "GP1-L", "GP1-M", "GP1-S", "GP1-XL", "GP1-XS", "START1-L", "START1-M", "START1-S", "START1-XS", "VC1L", "VC1M", "VC1S", "X64-120GB", "X64-15GB", "X64-30GB", "X64-60GB", "ENT1-XXS", "ENT1-XS", "ENT1-S", "ENT1-M", "ENT1-L", "ENT1-XL", "ENT1-2XL", "PRO2-XXS", "PRO2-XS", "PRO2-S", "PRO2-M", "PRO2-L", "STARDUST1-S", "PLAY2-MICRO", "PLAY2-NANO", "PLAY2-PICO", "POP2-2C-8G", "POP2-4C-16G", "POP2-8C-32G", "POP2-16C-64G", "POP2-32C-128G", "POP2-64C-256G", "POP2-HM-2C-16G", "POP2-HM-4C-32G", "POP2-HM-8C-64G", "POP2-HM-16C-128G", "POP2-HM-32C-256G", "POP2-HM-64C-512G", "POP2-HC-2C-4G", "POP2-HC-4C-8G", "POP2-HC-8C-16G", "POP2-HC-16C-32G", "POP2-HC-32C-64G", "POP2-HC-64C-128G"], "label":"ubuntu_focal"}], "total_count":2}' headers: Content-Length: - "1118" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 27 Jun 2023 16:13:38 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - c2b145ac-de80-4e34-a74c-3282af6d4ac3 status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.20.1; linux; amd64) url: https://api.scaleway.com/marketplace/v2/local-images?image_label=ubuntu_focal&order_by=created_at_asc&type=unknown_type&zone=fr-par-1 method: GET response: body: '{"local_images":[{"id":"2fedb0c7-1686-4529-8344-be9e198e4dd2", "arch":"arm64", "zone":"fr-par-1", "compatible_commercial_types":["AMP2-C1", "AMP2-C2", "AMP2-C4", "AMP2-C8", "AMP2-C12", "AMP2-C24", "AMP2-C48", "AMP2-C60"], "label":"ubuntu_focal"}, {"id":"68cf470e-6c35-4741-bbff-4ce788616461", "arch":"x86_64", "zone":"fr-par-1", "compatible_commercial_types":["DEV1-L", "DEV1-M", "DEV1-S", "DEV1-XL", "GP1-L", "GP1-M", "GP1-S", "GP1-XL", "GP1-XS", "START1-L", "START1-M", "START1-S", "START1-XS", "VC1L", "VC1M", "VC1S", "X64-120GB", "X64-15GB", "X64-30GB", "X64-60GB", "ENT1-XXS", "ENT1-XS", "ENT1-S", "ENT1-M", "ENT1-L", "ENT1-XL", "ENT1-2XL", "PRO2-XXS", "PRO2-XS", "PRO2-S", "PRO2-M", "PRO2-L", "STARDUST1-S", "PLAY2-MICRO", "PLAY2-NANO", "PLAY2-PICO", "POP2-2C-8G", "POP2-4C-16G", "POP2-8C-32G", "POP2-16C-64G", "POP2-32C-128G", "POP2-64C-256G", "POP2-HM-2C-16G", "POP2-HM-4C-32G", "POP2-HM-8C-64G", "POP2-HM-16C-128G", "POP2-HM-32C-256G", "POP2-HM-64C-512G", "POP2-HC-2C-4G", "POP2-HC-4C-8G", "POP2-HC-8C-16G", "POP2-HC-16C-32G", "POP2-HC-32C-64G", "POP2-HC-64C-128G"], "label":"ubuntu_focal"}], "total_count":2}' headers: Content-Length: - "1118" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 27 Jun 2023 16:13:38 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - ab9603eb-e0f3-44ee-be8a-c1ce93b16b5c status: 200 OK code: 200 duration: "" - request: body: "" form: {} headers: User-Agent: - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.20.1; linux; amd64) url: https://api.scaleway.com/marketplace/v2/local-images?image_label=foo-bar-image&order_by=created_at_asc&type=unknown_type&zone=fr-par-1 method: GET response: body: '{"message":"Not found","resource":"MarketplaceImage","resource_id":"foo-bar-image","type":"not_found"}' headers: Content-Length: - "102" Content-Security-Policy: - default-src 'none'; frame-ancestors 'none' Content-Type: - application/json Date: - Tue, 27 Jun 2023 16:13:38 GMT Server: - Scaleway API-Gateway Strict-Transport-Security: - max-age=63072000 X-Content-Type-Options: - nosniff X-Frame-Options: - DENY X-Request-Id: - 9929f165-243c-42f2-b5b8-c9b08497d6c9 status: 404 Not Found code: 404 duration: "" golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/mnq/000077500000000000000000000000001456366605600236225ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/mnq/v1beta1/000077500000000000000000000000001456366605600250655ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/mnq/v1beta1/mnq_sdk.go000066400000000000000000001533051456366605600270570ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package mnq provides methods and message types of the mnq v1beta1 API. package mnq import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type ListNatsAccountsRequestOrderBy string const ( // Order by creation date (ascending chronological order). ListNatsAccountsRequestOrderByCreatedAtAsc = ListNatsAccountsRequestOrderBy("created_at_asc") // Order by creation date (descending chronological order). ListNatsAccountsRequestOrderByCreatedAtDesc = ListNatsAccountsRequestOrderBy("created_at_desc") // Order by last update date (ascending chronological order). ListNatsAccountsRequestOrderByUpdatedAtAsc = ListNatsAccountsRequestOrderBy("updated_at_asc") // Order by last update date (descending chronological order). ListNatsAccountsRequestOrderByUpdatedAtDesc = ListNatsAccountsRequestOrderBy("updated_at_desc") // Order by name (ascending alphabetical order). ListNatsAccountsRequestOrderByNameAsc = ListNatsAccountsRequestOrderBy("name_asc") // Order by name (descending alphabetical order). ListNatsAccountsRequestOrderByNameDesc = ListNatsAccountsRequestOrderBy("name_desc") ) func (enum ListNatsAccountsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListNatsAccountsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListNatsAccountsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListNatsAccountsRequestOrderBy(ListNatsAccountsRequestOrderBy(tmp).String()) return nil } type ListNatsCredentialsRequestOrderBy string const ( // Order by creation date (ascending chronological order). ListNatsCredentialsRequestOrderByCreatedAtAsc = ListNatsCredentialsRequestOrderBy("created_at_asc") // Order by creation date (descending chronological order). ListNatsCredentialsRequestOrderByCreatedAtDesc = ListNatsCredentialsRequestOrderBy("created_at_desc") // Order by last update date (ascending chronological order). ListNatsCredentialsRequestOrderByUpdatedAtAsc = ListNatsCredentialsRequestOrderBy("updated_at_asc") // Order by last update date (descending chronological order). ListNatsCredentialsRequestOrderByUpdatedAtDesc = ListNatsCredentialsRequestOrderBy("updated_at_desc") // Order by name (ascending alphabetical order). ListNatsCredentialsRequestOrderByNameAsc = ListNatsCredentialsRequestOrderBy("name_asc") // Order by name (descending alphabetical order). ListNatsCredentialsRequestOrderByNameDesc = ListNatsCredentialsRequestOrderBy("name_desc") ) func (enum ListNatsCredentialsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListNatsCredentialsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListNatsCredentialsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListNatsCredentialsRequestOrderBy(ListNatsCredentialsRequestOrderBy(tmp).String()) return nil } type ListSnsCredentialsRequestOrderBy string const ( // Order by creation date (ascending chronological order). ListSnsCredentialsRequestOrderByCreatedAtAsc = ListSnsCredentialsRequestOrderBy("created_at_asc") // Order by creation date (descending chronological order). ListSnsCredentialsRequestOrderByCreatedAtDesc = ListSnsCredentialsRequestOrderBy("created_at_desc") // Order by last update date (ascending chronological order). ListSnsCredentialsRequestOrderByUpdatedAtAsc = ListSnsCredentialsRequestOrderBy("updated_at_asc") // Order by last update date (descending chronological order). ListSnsCredentialsRequestOrderByUpdatedAtDesc = ListSnsCredentialsRequestOrderBy("updated_at_desc") // Order by name (ascending alphabetical order). ListSnsCredentialsRequestOrderByNameAsc = ListSnsCredentialsRequestOrderBy("name_asc") // Order by name (descending alphabetical order). ListSnsCredentialsRequestOrderByNameDesc = ListSnsCredentialsRequestOrderBy("name_desc") ) func (enum ListSnsCredentialsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListSnsCredentialsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListSnsCredentialsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListSnsCredentialsRequestOrderBy(ListSnsCredentialsRequestOrderBy(tmp).String()) return nil } type ListSqsCredentialsRequestOrderBy string const ( // Order by creation date (ascending chronological order). ListSqsCredentialsRequestOrderByCreatedAtAsc = ListSqsCredentialsRequestOrderBy("created_at_asc") // Order by creation date (descending chronological order). ListSqsCredentialsRequestOrderByCreatedAtDesc = ListSqsCredentialsRequestOrderBy("created_at_desc") // Order by last update date (ascending chronological order). ListSqsCredentialsRequestOrderByUpdatedAtAsc = ListSqsCredentialsRequestOrderBy("updated_at_asc") // Order by last update date (descending chronological order). ListSqsCredentialsRequestOrderByUpdatedAtDesc = ListSqsCredentialsRequestOrderBy("updated_at_desc") // Order by name (ascending alphabetical order). ListSqsCredentialsRequestOrderByNameAsc = ListSqsCredentialsRequestOrderBy("name_asc") // Order by name (descending alphabetical order). ListSqsCredentialsRequestOrderByNameDesc = ListSqsCredentialsRequestOrderBy("name_desc") ) func (enum ListSqsCredentialsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListSqsCredentialsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListSqsCredentialsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListSqsCredentialsRequestOrderBy(ListSqsCredentialsRequestOrderBy(tmp).String()) return nil } type SnsInfoStatus string const ( // Unknown status. SnsInfoStatusUnknownStatus = SnsInfoStatus("unknown_status") // Enabled status. SnsInfoStatusEnabled = SnsInfoStatus("enabled") // Disabled status. SnsInfoStatusDisabled = SnsInfoStatus("disabled") ) func (enum SnsInfoStatus) String() string { if enum == "" { // return default value if empty return "unknown_status" } return string(enum) } func (enum SnsInfoStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *SnsInfoStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = SnsInfoStatus(SnsInfoStatus(tmp).String()) return nil } type SqsInfoStatus string const ( // Unknown status. SqsInfoStatusUnknownStatus = SqsInfoStatus("unknown_status") // Enabled status. SqsInfoStatusEnabled = SqsInfoStatus("enabled") // Disabled status. SqsInfoStatusDisabled = SqsInfoStatus("disabled") ) func (enum SqsInfoStatus) String() string { if enum == "" { // return default value if empty return "unknown_status" } return string(enum) } func (enum SqsInfoStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *SqsInfoStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = SqsInfoStatus(SqsInfoStatus(tmp).String()) return nil } // File: file. type File struct { // Name: file name. Name string `json:"name"` // Content: file content. Content string `json:"content"` } // SnsPermissions: sns permissions. type SnsPermissions struct { // CanPublish: defines whether the credentials bearer can publish messages to the service (publish to SNS topics). CanPublish *bool `json:"can_publish"` // CanReceive: defines whether the credentials bearer can receive messages from the service (configure subscriptions). CanReceive *bool `json:"can_receive"` // CanManage: defines whether the credentials bearer can manage the associated SNS topics or subscriptions. CanManage *bool `json:"can_manage"` } // SqsPermissions: sqs permissions. type SqsPermissions struct { // CanPublish: defines whether the credentials bearer can publish messages to the service (send messages to SQS queues). CanPublish *bool `json:"can_publish"` // CanReceive: defines whether the credentials bearer can receive messages from SQS queues. CanReceive *bool `json:"can_receive"` // CanManage: defines whether the credentials bearer can manage the associated SQS queues. CanManage *bool `json:"can_manage"` } // NatsAccount: nats account. type NatsAccount struct { // ID: nATS account ID. ID string `json:"id"` // Name: nATS account name. Name string `json:"name"` // Endpoint: endpoint of the NATS service for this account. Endpoint string `json:"endpoint"` // ProjectID: project ID of the Project containing the NATS account. ProjectID string `json:"project_id"` // Region: region where the NATS account is deployed. Region scw.Region `json:"region"` // CreatedAt: nATS account creation date. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: nATS account last modification date. UpdatedAt *time.Time `json:"updated_at"` } // NatsCredentials: nats credentials. type NatsCredentials struct { // ID: ID of the credentials. ID string `json:"id"` // Name: name of the credentials. Name string `json:"name"` // NatsAccountID: nATS account containing the credentials. NatsAccountID string `json:"nats_account_id"` // CreatedAt: nATS credentials creation date. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: nATS credentials last modification date. UpdatedAt *time.Time `json:"updated_at"` // Credentials: object containing the credentials file (Only returned by **Create Nats Credentials** call). Credentials *File `json:"credentials"` // Checksum: checksum of the credentials file. Checksum string `json:"checksum"` } // SnsCredentials: sns credentials. type SnsCredentials struct { // ID: ID of the credentials. ID string `json:"id"` // Name: name of the credentials. Name string `json:"name"` // ProjectID: project ID of the Project containing the credentials. ProjectID string `json:"project_id"` // Region: region where the credentials exists. Region scw.Region `json:"region"` // CreatedAt: credentials creation date. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: credentials last modification date. UpdatedAt *time.Time `json:"updated_at"` // AccessKey: access key ID. AccessKey string `json:"access_key"` // SecretKey: secret key ID (Only returned by **Create SNS Credentials** call). SecretKey string `json:"secret_key"` // SecretChecksum: checksum of the Secret key. SecretChecksum string `json:"secret_checksum"` // Permissions: permissions associated with these credentials. Permissions *SnsPermissions `json:"permissions"` } // SqsCredentials: sqs credentials. type SqsCredentials struct { // ID: ID of the credentials. ID string `json:"id"` // Name: name of the credentials. Name string `json:"name"` // ProjectID: project ID of the Project containing the credentials. ProjectID string `json:"project_id"` // Region: region where the credentials exists. Region scw.Region `json:"region"` // CreatedAt: credentials creation date. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: credentials last modification date. UpdatedAt *time.Time `json:"updated_at"` // AccessKey: access key ID. AccessKey string `json:"access_key"` // SecretKey: secret key ID (Only returned by **Create SQS Credentials** call). SecretKey string `json:"secret_key"` // SecretChecksum: checksum of the Secret key. SecretChecksum string `json:"secret_checksum"` // Permissions: permissions associated with these credentials. Permissions *SqsPermissions `json:"permissions"` } // ListNatsAccountsResponse: list nats accounts response. type ListNatsAccountsResponse struct { // TotalCount: total count of existing NATS accounts (matching any filters specified). TotalCount uint64 `json:"total_count"` // NatsAccounts: nATS accounts on this page. NatsAccounts []*NatsAccount `json:"nats_accounts"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListNatsAccountsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListNatsAccountsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListNatsAccountsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.NatsAccounts = append(r.NatsAccounts, results.NatsAccounts...) r.TotalCount += uint64(len(results.NatsAccounts)) return uint64(len(results.NatsAccounts)), nil } // ListNatsCredentialsResponse: list nats credentials response. type ListNatsCredentialsResponse struct { // TotalCount: total count of existing credentials (matching any filters specified). TotalCount uint64 `json:"total_count"` // NatsCredentials: credentials on this page. NatsCredentials []*NatsCredentials `json:"nats_credentials"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListNatsCredentialsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListNatsCredentialsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListNatsCredentialsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.NatsCredentials = append(r.NatsCredentials, results.NatsCredentials...) r.TotalCount += uint64(len(results.NatsCredentials)) return uint64(len(results.NatsCredentials)), nil } // ListSnsCredentialsResponse: list sns credentials response. type ListSnsCredentialsResponse struct { // TotalCount: total count of existing credentials (matching any filters specified). TotalCount uint64 `json:"total_count"` // SnsCredentials: sNS credentials on this page. SnsCredentials []*SnsCredentials `json:"sns_credentials"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListSnsCredentialsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListSnsCredentialsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListSnsCredentialsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.SnsCredentials = append(r.SnsCredentials, results.SnsCredentials...) r.TotalCount += uint64(len(results.SnsCredentials)) return uint64(len(results.SnsCredentials)), nil } // ListSqsCredentialsResponse: list sqs credentials response. type ListSqsCredentialsResponse struct { // TotalCount: total count of existing credentials (matching any filters specified). TotalCount uint64 `json:"total_count"` // SqsCredentials: sQS credentials on this page. SqsCredentials []*SqsCredentials `json:"sqs_credentials"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListSqsCredentialsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListSqsCredentialsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListSqsCredentialsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.SqsCredentials = append(r.SqsCredentials, results.SqsCredentials...) r.TotalCount += uint64(len(results.SqsCredentials)) return uint64(len(results.SqsCredentials)), nil } // NatsAPICreateNatsAccountRequest: nats api create nats account request. type NatsAPICreateNatsAccountRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Name: nATS account name. Name string `json:"name"` // ProjectID: project containing the NATS account. ProjectID string `json:"project_id"` } // NatsAPICreateNatsCredentialsRequest: nats api create nats credentials request. type NatsAPICreateNatsCredentialsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NatsAccountID: nATS account containing the credentials. NatsAccountID string `json:"nats_account_id"` // Name: name of the credentials. Name string `json:"name"` } // NatsAPIDeleteNatsAccountRequest: nats api delete nats account request. type NatsAPIDeleteNatsAccountRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NatsAccountID: ID of the NATS account to delete. NatsAccountID string `json:"-"` } // NatsAPIDeleteNatsCredentialsRequest: nats api delete nats credentials request. type NatsAPIDeleteNatsCredentialsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NatsCredentialsID: ID of the credentials to delete. NatsCredentialsID string `json:"-"` } // NatsAPIGetNatsAccountRequest: nats api get nats account request. type NatsAPIGetNatsAccountRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NatsAccountID: ID of the NATS account to get. NatsAccountID string `json:"-"` } // NatsAPIGetNatsCredentialsRequest: nats api get nats credentials request. type NatsAPIGetNatsCredentialsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NatsCredentialsID: ID of the credentials to get. NatsCredentialsID string `json:"-"` } // NatsAPIListNatsAccountsRequest: nats api list nats accounts request. type NatsAPIListNatsAccountsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: include only NATS accounts in this Project. ProjectID *string `json:"-"` // Page: page number to return. Page *int32 `json:"-"` // PageSize: maximum number of NATS accounts to return per page. PageSize *uint32 `json:"-"` // OrderBy: order in which to return results. // Default value: created_at_asc OrderBy ListNatsAccountsRequestOrderBy `json:"-"` } // NatsAPIListNatsCredentialsRequest: nats api list nats credentials request. type NatsAPIListNatsCredentialsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NatsAccountID: include only credentials for this NATS account. NatsAccountID *string `json:"-"` // Page: page number to return. Page *int32 `json:"-"` // PageSize: maximum number of credentials to return per page. PageSize *uint32 `json:"-"` // OrderBy: order in which to return results. // Default value: created_at_asc OrderBy ListNatsCredentialsRequestOrderBy `json:"-"` } // NatsAPIUpdateNatsAccountRequest: nats api update nats account request. type NatsAPIUpdateNatsAccountRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NatsAccountID: ID of the NATS account to update. NatsAccountID string `json:"-"` // Name: nATS account name. Name *string `json:"name,omitempty"` } // SnsAPIActivateSnsRequest: sns api activate sns request. type SnsAPIActivateSnsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: project on which to activate the SNS service. ProjectID string `json:"project_id"` } // SnsAPICreateSnsCredentialsRequest: sns api create sns credentials request. type SnsAPICreateSnsCredentialsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: project containing the SNS credentials. ProjectID string `json:"project_id"` // Name: name of the credentials. Name string `json:"name"` // Permissions: permissions associated with these credentials. Permissions *SnsPermissions `json:"permissions,omitempty"` } // SnsAPIDeactivateSnsRequest: sns api deactivate sns request. type SnsAPIDeactivateSnsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: project on which to deactivate the SNS service. ProjectID string `json:"project_id"` } // SnsAPIDeleteSnsCredentialsRequest: sns api delete sns credentials request. type SnsAPIDeleteSnsCredentialsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SnsCredentialsID: ID of the credentials to delete. SnsCredentialsID string `json:"-"` } // SnsAPIGetSnsCredentialsRequest: sns api get sns credentials request. type SnsAPIGetSnsCredentialsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SnsCredentialsID: ID of the SNS credentials to get. SnsCredentialsID string `json:"-"` } // SnsAPIGetSnsInfoRequest: sns api get sns info request. type SnsAPIGetSnsInfoRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: project to retrieve SNS info from. ProjectID string `json:"project_id"` } // SnsAPIListSnsCredentialsRequest: sns api list sns credentials request. type SnsAPIListSnsCredentialsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: include only SNS credentials in this Project. ProjectID *string `json:"-"` // Page: page number to return. Page *int32 `json:"-"` // PageSize: maximum number of credentials to return per page. PageSize *uint32 `json:"-"` // OrderBy: order in which to return results. // Default value: created_at_asc OrderBy ListSnsCredentialsRequestOrderBy `json:"-"` } // SnsAPIUpdateSnsCredentialsRequest: sns api update sns credentials request. type SnsAPIUpdateSnsCredentialsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SnsCredentialsID: ID of the SNS credentials to update. SnsCredentialsID string `json:"-"` // Name: name of the credentials. Name *string `json:"name,omitempty"` // Permissions: permissions associated with these credentials. Permissions *SnsPermissions `json:"permissions,omitempty"` } // SnsInfo: sns info. type SnsInfo struct { // ProjectID: project ID of the Project containing the service. ProjectID string `json:"project_id"` // Region: region of the service. Region scw.Region `json:"region"` // CreatedAt: sNS creation date. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: sNS last modification date. UpdatedAt *time.Time `json:"updated_at"` // Status: sNS activation status. // Default value: unknown_status Status SnsInfoStatus `json:"status"` // SnsEndpointURL: endpoint of the SNS service for this region and project. SnsEndpointURL string `json:"sns_endpoint_url"` } // SqsAPIActivateSqsRequest: sqs api activate sqs request. type SqsAPIActivateSqsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: project on which to activate the SQS service. ProjectID string `json:"project_id"` } // SqsAPICreateSqsCredentialsRequest: sqs api create sqs credentials request. type SqsAPICreateSqsCredentialsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: project containing the SQS credentials. ProjectID string `json:"project_id"` // Name: name of the credentials. Name string `json:"name"` // Permissions: permissions associated with these credentials. Permissions *SqsPermissions `json:"permissions,omitempty"` } // SqsAPIDeactivateSqsRequest: sqs api deactivate sqs request. type SqsAPIDeactivateSqsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: project on which to deactivate the SQS service. ProjectID string `json:"project_id"` } // SqsAPIDeleteSqsCredentialsRequest: sqs api delete sqs credentials request. type SqsAPIDeleteSqsCredentialsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SqsCredentialsID: ID of the credentials to delete. SqsCredentialsID string `json:"-"` } // SqsAPIGetSqsCredentialsRequest: sqs api get sqs credentials request. type SqsAPIGetSqsCredentialsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SqsCredentialsID: ID of the SQS credentials to get. SqsCredentialsID string `json:"-"` } // SqsAPIGetSqsInfoRequest: sqs api get sqs info request. type SqsAPIGetSqsInfoRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: project to retrieve SQS info from. ProjectID string `json:"project_id"` } // SqsAPIListSqsCredentialsRequest: sqs api list sqs credentials request. type SqsAPIListSqsCredentialsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: include only SQS credentials in this Project. ProjectID *string `json:"-"` // Page: page number to return. Page *int32 `json:"-"` // PageSize: maximum number of credentials to return per page. PageSize *uint32 `json:"-"` // OrderBy: order in which to return results. // Default value: created_at_asc OrderBy ListSqsCredentialsRequestOrderBy `json:"-"` } // SqsAPIUpdateSqsCredentialsRequest: sqs api update sqs credentials request. type SqsAPIUpdateSqsCredentialsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SqsCredentialsID: ID of the SQS credentials to update. SqsCredentialsID string `json:"-"` // Name: name of the credentials. Name *string `json:"name,omitempty"` // Permissions: permissions associated with these credentials. Permissions *SqsPermissions `json:"permissions,omitempty"` } // SqsInfo: sqs info. type SqsInfo struct { // ProjectID: project ID of the Project containing the service. ProjectID string `json:"project_id"` // Region: region of the service. Region scw.Region `json:"region"` // CreatedAt: sQS creation date. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: sQS last modification date. UpdatedAt *time.Time `json:"updated_at"` // Status: sQS activation status. // Default value: unknown_status Status SqsInfoStatus `json:"status"` // SqsEndpointURL: endpoint of the SQS service for this region and project. SqsEndpointURL string `json:"sqs_endpoint_url"` } // This API allows you to manage Scaleway Messaging and Queueing NATS accounts. type NatsAPI struct { client *scw.Client } // NewNatsAPI returns a NatsAPI object from a Scaleway client. func NewNatsAPI(client *scw.Client) *NatsAPI { return &NatsAPI{ client: client, } } func (s *NatsAPI) Regions() []scw.Region { return []scw.Region{scw.RegionFrPar} } // CreateNatsAccount: Create a NATS account associated with a Project. func (s *NatsAPI) CreateNatsAccount(req *NatsAPICreateNatsAccountRequest, opts ...scw.RequestOption) (*NatsAccount, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if req.Name == "" { req.Name = namegenerator.GetRandomName("mnq") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/nats-accounts", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp NatsAccount err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteNatsAccount: Delete a NATS account, specified by its NATS account ID. Note that deleting a NATS account is irreversible, and any credentials, streams, consumer and stored messages belonging to this NATS account will also be deleted. func (s *NatsAPI) DeleteNatsAccount(req *NatsAPIDeleteNatsAccountRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NatsAccountID) == "" { return errors.New("field NatsAccountID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/nats-accounts/" + fmt.Sprint(req.NatsAccountID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // UpdateNatsAccount: Update the name of a NATS account, specified by its NATS account ID. func (s *NatsAPI) UpdateNatsAccount(req *NatsAPIUpdateNatsAccountRequest, opts ...scw.RequestOption) (*NatsAccount, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NatsAccountID) == "" { return nil, errors.New("field NatsAccountID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/nats-accounts/" + fmt.Sprint(req.NatsAccountID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp NatsAccount err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetNatsAccount: Retrieve information about an existing NATS account identified by its NATS account ID. Its full details, including name and endpoint, are returned in the response. func (s *NatsAPI) GetNatsAccount(req *NatsAPIGetNatsAccountRequest, opts ...scw.RequestOption) (*NatsAccount, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NatsAccountID) == "" { return nil, errors.New("field NatsAccountID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/nats-accounts/" + fmt.Sprint(req.NatsAccountID) + "", } var resp NatsAccount err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListNatsAccounts: List all NATS accounts in the specified region, for a Scaleway Organization or Project. By default, the NATS accounts returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. func (s *NatsAPI) ListNatsAccounts(req *NatsAPIListNatsAccountsRequest, opts ...scw.RequestOption) (*ListNatsAccountsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/nats-accounts", Query: query, } var resp ListNatsAccountsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateNatsCredentials: Create a set of credentials for a NATS account, specified by its NATS account ID. func (s *NatsAPI) CreateNatsCredentials(req *NatsAPICreateNatsCredentialsRequest, opts ...scw.RequestOption) (*NatsCredentials, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.Name == "" { req.Name = namegenerator.GetRandomName("mnq") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/nats-credentials", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp NatsCredentials err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteNatsCredentials: Delete a set of credentials, specified by their credentials ID. Deleting credentials is irreversible and cannot be undone. The credentials can no longer be used to access the NATS account, and active connections using this credentials will be closed. func (s *NatsAPI) DeleteNatsCredentials(req *NatsAPIDeleteNatsCredentialsRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NatsCredentialsID) == "" { return errors.New("field NatsCredentialsID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/nats-credentials/" + fmt.Sprint(req.NatsCredentialsID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // GetNatsCredentials: Retrieve an existing set of credentials, identified by the `nats_credentials_id`. The credentials themselves are NOT returned, only their metadata (NATS account ID, credentials name, etc), are returned in the response. func (s *NatsAPI) GetNatsCredentials(req *NatsAPIGetNatsCredentialsRequest, opts ...scw.RequestOption) (*NatsCredentials, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NatsCredentialsID) == "" { return nil, errors.New("field NatsCredentialsID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/nats-credentials/" + fmt.Sprint(req.NatsCredentialsID) + "", } var resp NatsCredentials err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListNatsCredentials: List existing credentials in the specified NATS account. The response contains only the metadata for the credentials, not the credentials themselves, which are only returned after a **Create Credentials** call. func (s *NatsAPI) ListNatsCredentials(req *NatsAPIListNatsCredentialsRequest, opts ...scw.RequestOption) (*ListNatsCredentialsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "nats_account_id", req.NatsAccountID) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/nats-credentials", Query: query, } var resp ListNatsCredentialsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // This API allows you to manage Scaleway Messaging and Queueing SNS brokers. type SnsAPI struct { client *scw.Client } // NewSnsAPI returns a SnsAPI object from a Scaleway client. func NewSnsAPI(client *scw.Client) *SnsAPI { return &SnsAPI{ client: client, } } func (s *SnsAPI) Regions() []scw.Region { return []scw.Region{scw.RegionFrPar} } // ActivateSns: Activate SNS for the specified Project ID. SNS must be activated before any usage. Activating SNS does not trigger any billing, and you can deactivate at any time. func (s *SnsAPI) ActivateSns(req *SnsAPIActivateSnsRequest, opts ...scw.RequestOption) (*SnsInfo, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/activate-sns", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SnsInfo err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetSnsInfo: Retrieve the SNS information of the specified Project ID. Informations include the activation status and the SNS API endpoint URL. func (s *SnsAPI) GetSnsInfo(req *SnsAPIGetSnsInfoRequest, opts ...scw.RequestOption) (*SnsInfo, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } query := url.Values{} parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/sns-info", Query: query, } var resp SnsInfo err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeactivateSns: Deactivate SNS for the specified Project ID.You must delete all topics and credentials before this call or you need to set the force_delete parameter. func (s *SnsAPI) DeactivateSns(req *SnsAPIDeactivateSnsRequest, opts ...scw.RequestOption) (*SnsInfo, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/deactivate-sns", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SnsInfo err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateSnsCredentials: Create a set of credentials for SNS, specified by a Project ID. Credentials give the bearer access to topics, and the level of permissions can be defined granularly. func (s *SnsAPI) CreateSnsCredentials(req *SnsAPICreateSnsCredentialsRequest, opts ...scw.RequestOption) (*SnsCredentials, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if req.Name == "" { req.Name = namegenerator.GetRandomName("mnq_sns") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/sns-credentials", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SnsCredentials err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteSnsCredentials: Delete a set of SNS credentials, specified by their credentials ID. Deleting credentials is irreversible and cannot be undone. The credentials can then no longer be used to access SNS. func (s *SnsAPI) DeleteSnsCredentials(req *SnsAPIDeleteSnsCredentialsRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SnsCredentialsID) == "" { return errors.New("field SnsCredentialsID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/sns-credentials/" + fmt.Sprint(req.SnsCredentialsID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // UpdateSnsCredentials: Update a set of SNS credentials. You can update the credentials' name, or their permissions. func (s *SnsAPI) UpdateSnsCredentials(req *SnsAPIUpdateSnsCredentialsRequest, opts ...scw.RequestOption) (*SnsCredentials, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SnsCredentialsID) == "" { return nil, errors.New("field SnsCredentialsID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/sns-credentials/" + fmt.Sprint(req.SnsCredentialsID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SnsCredentials err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetSnsCredentials: Retrieve an existing set of credentials, identified by the `credentials_id`. The credentials themselves, as well as their metadata (name, project ID etc), are returned in the response. func (s *SnsAPI) GetSnsCredentials(req *SnsAPIGetSnsCredentialsRequest, opts ...scw.RequestOption) (*SnsCredentials, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SnsCredentialsID) == "" { return nil, errors.New("field SnsCredentialsID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/sns-credentials/" + fmt.Sprint(req.SnsCredentialsID) + "", } var resp SnsCredentials err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListSnsCredentials: List existing SNS credentials in the specified region. The response contains only the metadata for the credentials, not the credentials themselves. func (s *SnsAPI) ListSnsCredentials(req *SnsAPIListSnsCredentialsRequest, opts ...scw.RequestOption) (*ListSnsCredentialsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/sns-credentials", Query: query, } var resp ListSnsCredentialsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // This API allows you to manage Scaleway Messaging and Queueing SQS brokers. type SqsAPI struct { client *scw.Client } // NewSqsAPI returns a SqsAPI object from a Scaleway client. func NewSqsAPI(client *scw.Client) *SqsAPI { return &SqsAPI{ client: client, } } func (s *SqsAPI) Regions() []scw.Region { return []scw.Region{scw.RegionFrPar} } // ActivateSqs: Activate SQS for the specified Project ID. SQS must be activated before any usage such as creating credentials and queues. Activating SQS does not trigger any billing, and you can deactivate at any time. func (s *SqsAPI) ActivateSqs(req *SqsAPIActivateSqsRequest, opts ...scw.RequestOption) (*SqsInfo, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/activate-sqs", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SqsInfo err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetSqsInfo: Retrieve the SQS information of the specified Project ID. Informations include the activation status and the SQS API endpoint URL. func (s *SqsAPI) GetSqsInfo(req *SqsAPIGetSqsInfoRequest, opts ...scw.RequestOption) (*SqsInfo, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } query := url.Values{} parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/sqs-info", Query: query, } var resp SqsInfo err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeactivateSqs: Deactivate SQS for the specified Project ID. You must delete all queues and credentials before this call or you need to set the force_delete parameter. func (s *SqsAPI) DeactivateSqs(req *SqsAPIDeactivateSqsRequest, opts ...scw.RequestOption) (*SqsInfo, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/deactivate-sqs", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SqsInfo err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateSqsCredentials: Create a set of credentials for SQS, specified by a Project ID. Credentials give the bearer access to queues, and the level of permissions can be defined granularly. func (s *SqsAPI) CreateSqsCredentials(req *SqsAPICreateSqsCredentialsRequest, opts ...scw.RequestOption) (*SqsCredentials, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if req.Name == "" { req.Name = namegenerator.GetRandomName("mnq_sqs") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/sqs-credentials", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SqsCredentials err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteSqsCredentials: Delete a set of SQS credentials, specified by their credentials ID. Deleting credentials is irreversible and cannot be undone. The credentials can then no longer be used to access SQS. func (s *SqsAPI) DeleteSqsCredentials(req *SqsAPIDeleteSqsCredentialsRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SqsCredentialsID) == "" { return errors.New("field SqsCredentialsID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/sqs-credentials/" + fmt.Sprint(req.SqsCredentialsID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // UpdateSqsCredentials: Update a set of SQS credentials. You can update the credentials' name, or their permissions. func (s *SqsAPI) UpdateSqsCredentials(req *SqsAPIUpdateSqsCredentialsRequest, opts ...scw.RequestOption) (*SqsCredentials, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SqsCredentialsID) == "" { return nil, errors.New("field SqsCredentialsID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/sqs-credentials/" + fmt.Sprint(req.SqsCredentialsID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SqsCredentials err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetSqsCredentials: Retrieve an existing set of credentials, identified by the `credentials_id`. The credentials themselves, as well as their metadata (name, project ID etc), are returned in the response. func (s *SqsAPI) GetSqsCredentials(req *SqsAPIGetSqsCredentialsRequest, opts ...scw.RequestOption) (*SqsCredentials, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SqsCredentialsID) == "" { return nil, errors.New("field SqsCredentialsID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/sqs-credentials/" + fmt.Sprint(req.SqsCredentialsID) + "", } var resp SqsCredentials err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListSqsCredentials: List existing SQS credentials in the specified region. The response contains only the metadata for the credentials, not the credentials themselves. func (s *SqsAPI) ListSqsCredentials(req *SqsAPIListSqsCredentialsRequest, opts ...scw.RequestOption) (*ListSqsCredentialsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/mnq/v1beta1/regions/" + fmt.Sprint(req.Region) + "/sqs-credentials", Query: query, } var resp ListSqsCredentialsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/rdb/000077500000000000000000000000001456366605600235765ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/rdb/v1/000077500000000000000000000000001456366605600241245ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/rdb/v1/rdb_sdk.go000066400000000000000000004244501456366605600260740ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package rdb provides methods and message types of the rdb v1 API. package rdb import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type ACLRuleAction string const ( ACLRuleActionAllow = ACLRuleAction("allow") ACLRuleActionDeny = ACLRuleAction("deny") ) func (enum ACLRuleAction) String() string { if enum == "" { // return default value if empty return "allow" } return string(enum) } func (enum ACLRuleAction) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ACLRuleAction) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ACLRuleAction(ACLRuleAction(tmp).String()) return nil } type ACLRuleDirection string const ( ACLRuleDirectionInbound = ACLRuleDirection("inbound") ACLRuleDirectionOutbound = ACLRuleDirection("outbound") ) func (enum ACLRuleDirection) String() string { if enum == "" { // return default value if empty return "inbound" } return string(enum) } func (enum ACLRuleDirection) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ACLRuleDirection) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ACLRuleDirection(ACLRuleDirection(tmp).String()) return nil } type ACLRuleProtocol string const ( ACLRuleProtocolTCP = ACLRuleProtocol("tcp") ACLRuleProtocolUDP = ACLRuleProtocol("udp") ACLRuleProtocolIcmp = ACLRuleProtocol("icmp") ) func (enum ACLRuleProtocol) String() string { if enum == "" { // return default value if empty return "tcp" } return string(enum) } func (enum ACLRuleProtocol) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ACLRuleProtocol) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ACLRuleProtocol(ACLRuleProtocol(tmp).String()) return nil } type DatabaseBackupStatus string const ( DatabaseBackupStatusUnknown = DatabaseBackupStatus("unknown") DatabaseBackupStatusCreating = DatabaseBackupStatus("creating") DatabaseBackupStatusReady = DatabaseBackupStatus("ready") DatabaseBackupStatusRestoring = DatabaseBackupStatus("restoring") DatabaseBackupStatusDeleting = DatabaseBackupStatus("deleting") DatabaseBackupStatusError = DatabaseBackupStatus("error") DatabaseBackupStatusExporting = DatabaseBackupStatus("exporting") DatabaseBackupStatusLocked = DatabaseBackupStatus("locked") ) func (enum DatabaseBackupStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum DatabaseBackupStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DatabaseBackupStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DatabaseBackupStatus(DatabaseBackupStatus(tmp).String()) return nil } type EngineSettingPropertyType string const ( EngineSettingPropertyTypeBOOLEAN = EngineSettingPropertyType("BOOLEAN") EngineSettingPropertyTypeINT = EngineSettingPropertyType("INT") EngineSettingPropertyTypeSTRING = EngineSettingPropertyType("STRING") EngineSettingPropertyTypeFLOAT = EngineSettingPropertyType("FLOAT") ) func (enum EngineSettingPropertyType) String() string { if enum == "" { // return default value if empty return "BOOLEAN" } return string(enum) } func (enum EngineSettingPropertyType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *EngineSettingPropertyType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = EngineSettingPropertyType(EngineSettingPropertyType(tmp).String()) return nil } type InstanceLogStatus string const ( InstanceLogStatusUnknown = InstanceLogStatus("unknown") InstanceLogStatusReady = InstanceLogStatus("ready") InstanceLogStatusCreating = InstanceLogStatus("creating") InstanceLogStatusError = InstanceLogStatus("error") ) func (enum InstanceLogStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum InstanceLogStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *InstanceLogStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = InstanceLogStatus(InstanceLogStatus(tmp).String()) return nil } type InstanceStatus string const ( InstanceStatusUnknown = InstanceStatus("unknown") InstanceStatusReady = InstanceStatus("ready") InstanceStatusProvisioning = InstanceStatus("provisioning") InstanceStatusConfiguring = InstanceStatus("configuring") InstanceStatusDeleting = InstanceStatus("deleting") InstanceStatusError = InstanceStatus("error") InstanceStatusAutohealing = InstanceStatus("autohealing") InstanceStatusLocked = InstanceStatus("locked") InstanceStatusInitializing = InstanceStatus("initializing") InstanceStatusDiskFull = InstanceStatus("disk_full") InstanceStatusBackuping = InstanceStatus("backuping") InstanceStatusSnapshotting = InstanceStatus("snapshotting") InstanceStatusRestarting = InstanceStatus("restarting") ) func (enum InstanceStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum InstanceStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *InstanceStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = InstanceStatus(InstanceStatus(tmp).String()) return nil } type ListDatabaseBackupsRequestOrderBy string const ( ListDatabaseBackupsRequestOrderByCreatedAtAsc = ListDatabaseBackupsRequestOrderBy("created_at_asc") ListDatabaseBackupsRequestOrderByCreatedAtDesc = ListDatabaseBackupsRequestOrderBy("created_at_desc") ListDatabaseBackupsRequestOrderByNameAsc = ListDatabaseBackupsRequestOrderBy("name_asc") ListDatabaseBackupsRequestOrderByNameDesc = ListDatabaseBackupsRequestOrderBy("name_desc") ListDatabaseBackupsRequestOrderByStatusAsc = ListDatabaseBackupsRequestOrderBy("status_asc") ListDatabaseBackupsRequestOrderByStatusDesc = ListDatabaseBackupsRequestOrderBy("status_desc") ) func (enum ListDatabaseBackupsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListDatabaseBackupsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListDatabaseBackupsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListDatabaseBackupsRequestOrderBy(ListDatabaseBackupsRequestOrderBy(tmp).String()) return nil } type ListDatabasesRequestOrderBy string const ( ListDatabasesRequestOrderByNameAsc = ListDatabasesRequestOrderBy("name_asc") ListDatabasesRequestOrderByNameDesc = ListDatabasesRequestOrderBy("name_desc") ListDatabasesRequestOrderBySizeAsc = ListDatabasesRequestOrderBy("size_asc") ListDatabasesRequestOrderBySizeDesc = ListDatabasesRequestOrderBy("size_desc") ) func (enum ListDatabasesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "name_asc" } return string(enum) } func (enum ListDatabasesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListDatabasesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListDatabasesRequestOrderBy(ListDatabasesRequestOrderBy(tmp).String()) return nil } type ListInstanceLogsRequestOrderBy string const ( ListInstanceLogsRequestOrderByCreatedAtAsc = ListInstanceLogsRequestOrderBy("created_at_asc") ListInstanceLogsRequestOrderByCreatedAtDesc = ListInstanceLogsRequestOrderBy("created_at_desc") ) func (enum ListInstanceLogsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListInstanceLogsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListInstanceLogsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListInstanceLogsRequestOrderBy(ListInstanceLogsRequestOrderBy(tmp).String()) return nil } type ListInstancesRequestOrderBy string const ( ListInstancesRequestOrderByCreatedAtAsc = ListInstancesRequestOrderBy("created_at_asc") ListInstancesRequestOrderByCreatedAtDesc = ListInstancesRequestOrderBy("created_at_desc") ListInstancesRequestOrderByNameAsc = ListInstancesRequestOrderBy("name_asc") ListInstancesRequestOrderByNameDesc = ListInstancesRequestOrderBy("name_desc") ListInstancesRequestOrderByRegion = ListInstancesRequestOrderBy("region") ListInstancesRequestOrderByStatusAsc = ListInstancesRequestOrderBy("status_asc") ListInstancesRequestOrderByStatusDesc = ListInstancesRequestOrderBy("status_desc") ) func (enum ListInstancesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListInstancesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListInstancesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListInstancesRequestOrderBy(ListInstancesRequestOrderBy(tmp).String()) return nil } type ListPrivilegesRequestOrderBy string const ( ListPrivilegesRequestOrderByUserNameAsc = ListPrivilegesRequestOrderBy("user_name_asc") ListPrivilegesRequestOrderByUserNameDesc = ListPrivilegesRequestOrderBy("user_name_desc") ListPrivilegesRequestOrderByDatabaseNameAsc = ListPrivilegesRequestOrderBy("database_name_asc") ListPrivilegesRequestOrderByDatabaseNameDesc = ListPrivilegesRequestOrderBy("database_name_desc") ) func (enum ListPrivilegesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "user_name_asc" } return string(enum) } func (enum ListPrivilegesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListPrivilegesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListPrivilegesRequestOrderBy(ListPrivilegesRequestOrderBy(tmp).String()) return nil } type ListSnapshotsRequestOrderBy string const ( ListSnapshotsRequestOrderByCreatedAtAsc = ListSnapshotsRequestOrderBy("created_at_asc") ListSnapshotsRequestOrderByCreatedAtDesc = ListSnapshotsRequestOrderBy("created_at_desc") ListSnapshotsRequestOrderByNameAsc = ListSnapshotsRequestOrderBy("name_asc") ListSnapshotsRequestOrderByNameDesc = ListSnapshotsRequestOrderBy("name_desc") ListSnapshotsRequestOrderByExpiresAtAsc = ListSnapshotsRequestOrderBy("expires_at_asc") ListSnapshotsRequestOrderByExpiresAtDesc = ListSnapshotsRequestOrderBy("expires_at_desc") ) func (enum ListSnapshotsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListSnapshotsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListSnapshotsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListSnapshotsRequestOrderBy(ListSnapshotsRequestOrderBy(tmp).String()) return nil } type ListUsersRequestOrderBy string const ( ListUsersRequestOrderByNameAsc = ListUsersRequestOrderBy("name_asc") ListUsersRequestOrderByNameDesc = ListUsersRequestOrderBy("name_desc") ListUsersRequestOrderByIsAdminAsc = ListUsersRequestOrderBy("is_admin_asc") ListUsersRequestOrderByIsAdminDesc = ListUsersRequestOrderBy("is_admin_desc") ) func (enum ListUsersRequestOrderBy) String() string { if enum == "" { // return default value if empty return "name_asc" } return string(enum) } func (enum ListUsersRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListUsersRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListUsersRequestOrderBy(ListUsersRequestOrderBy(tmp).String()) return nil } type MaintenanceStatus string const ( MaintenanceStatusUnknown = MaintenanceStatus("unknown") MaintenanceStatusPending = MaintenanceStatus("pending") MaintenanceStatusDone = MaintenanceStatus("done") MaintenanceStatusCanceled = MaintenanceStatus("canceled") ) func (enum MaintenanceStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum MaintenanceStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *MaintenanceStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = MaintenanceStatus(MaintenanceStatus(tmp).String()) return nil } type NodeTypeGeneration string const ( NodeTypeGenerationUnknownGeneration = NodeTypeGeneration("unknown_generation") NodeTypeGenerationGenerationV1 = NodeTypeGeneration("generation_v1") NodeTypeGenerationGenerationV2 = NodeTypeGeneration("generation_v2") ) func (enum NodeTypeGeneration) String() string { if enum == "" { // return default value if empty return "unknown_generation" } return string(enum) } func (enum NodeTypeGeneration) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *NodeTypeGeneration) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = NodeTypeGeneration(NodeTypeGeneration(tmp).String()) return nil } type NodeTypeStock string const ( NodeTypeStockUnknown = NodeTypeStock("unknown") NodeTypeStockLowStock = NodeTypeStock("low_stock") NodeTypeStockOutOfStock = NodeTypeStock("out_of_stock") NodeTypeStockAvailable = NodeTypeStock("available") ) func (enum NodeTypeStock) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum NodeTypeStock) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *NodeTypeStock) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = NodeTypeStock(NodeTypeStock(tmp).String()) return nil } type Permission string const ( PermissionReadonly = Permission("readonly") PermissionReadwrite = Permission("readwrite") PermissionAll = Permission("all") PermissionCustom = Permission("custom") PermissionNone = Permission("none") ) func (enum Permission) String() string { if enum == "" { // return default value if empty return "readonly" } return string(enum) } func (enum Permission) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *Permission) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = Permission(Permission(tmp).String()) return nil } type ReadReplicaStatus string const ( ReadReplicaStatusUnknown = ReadReplicaStatus("unknown") ReadReplicaStatusProvisioning = ReadReplicaStatus("provisioning") ReadReplicaStatusInitializing = ReadReplicaStatus("initializing") ReadReplicaStatusReady = ReadReplicaStatus("ready") ReadReplicaStatusDeleting = ReadReplicaStatus("deleting") ReadReplicaStatusError = ReadReplicaStatus("error") ReadReplicaStatusLocked = ReadReplicaStatus("locked") ReadReplicaStatusConfiguring = ReadReplicaStatus("configuring") ReadReplicaStatusPromoting = ReadReplicaStatus("promoting") ) func (enum ReadReplicaStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum ReadReplicaStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ReadReplicaStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ReadReplicaStatus(ReadReplicaStatus(tmp).String()) return nil } type SnapshotStatus string const ( SnapshotStatusUnknown = SnapshotStatus("unknown") SnapshotStatusCreating = SnapshotStatus("creating") SnapshotStatusReady = SnapshotStatus("ready") SnapshotStatusRestoring = SnapshotStatus("restoring") SnapshotStatusDeleting = SnapshotStatus("deleting") SnapshotStatusError = SnapshotStatus("error") SnapshotStatusLocked = SnapshotStatus("locked") ) func (enum SnapshotStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum SnapshotStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *SnapshotStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = SnapshotStatus(SnapshotStatus(tmp).String()) return nil } type StorageClass string const ( StorageClassUnknownStorageClass = StorageClass("unknown_storage_class") StorageClassLssd = StorageClass("lssd") StorageClassBssd = StorageClass("bssd") StorageClassSbs = StorageClass("sbs") ) func (enum StorageClass) String() string { if enum == "" { // return default value if empty return "unknown_storage_class" } return string(enum) } func (enum StorageClass) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *StorageClass) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = StorageClass(StorageClass(tmp).String()) return nil } type VolumeType string const ( VolumeTypeLssd = VolumeType("lssd") VolumeTypeBssd = VolumeType("bssd") VolumeTypeSbs5k = VolumeType("sbs_5k") VolumeTypeSbs15k = VolumeType("sbs_15k") ) func (enum VolumeType) String() string { if enum == "" { // return default value if empty return "lssd" } return string(enum) } func (enum VolumeType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *VolumeType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = VolumeType(VolumeType(tmp).String()) return nil } // EndpointDirectAccessDetails: endpoint direct access details. type EndpointDirectAccessDetails struct { } // EndpointLoadBalancerDetails: endpoint load balancer details. type EndpointLoadBalancerDetails struct { } // EndpointPrivateNetworkDetails: endpoint private network details. type EndpointPrivateNetworkDetails struct { // PrivateNetworkID: UUID of the private network. PrivateNetworkID string `json:"private_network_id"` // ServiceIP: cIDR notation of the endpoint IPv4 address. ServiceIP scw.IPNet `json:"service_ip"` // Zone: private network zone. Zone scw.Zone `json:"zone"` } // EndpointSpecPrivateNetworkIpamConfig: endpoint spec private network ipam config. type EndpointSpecPrivateNetworkIpamConfig struct { } // ReadReplicaEndpointSpecPrivateNetworkIpamConfig: read replica endpoint spec private network ipam config. type ReadReplicaEndpointSpecPrivateNetworkIpamConfig struct { } // EngineSetting: engine setting. type EngineSetting struct { // Name: setting name from the database engine. Name string `json:"name"` // DefaultValue: value set when not specified. DefaultValue string `json:"default_value"` // HotConfigurable: setting can be applied without restarting. HotConfigurable bool `json:"hot_configurable"` // Description: setting description. Description string `json:"description"` // PropertyType: setting type. // Default value: BOOLEAN PropertyType EngineSettingPropertyType `json:"property_type"` // Unit: setting base unit. Unit *string `json:"unit"` // StringConstraint: validation regex for string type settings. StringConstraint *string `json:"string_constraint"` // IntMin: minimum value for int types. IntMin *int32 `json:"int_min"` // IntMax: maximum value for int types. IntMax *int32 `json:"int_max"` // FloatMin: minimum value for float types. FloatMin *float32 `json:"float_min"` // FloatMax: maximum value for float types. FloatMax *float32 `json:"float_max"` } // Endpoint: endpoint. type Endpoint struct { // ID: UUID of the endpoint. ID string `json:"id"` // IP: iPv4 address of the endpoint. // Precisely one of IP, Hostname must be set. IP *net.IP `json:"ip,omitempty"` // Port: TCP port of the endpoint. Port uint32 `json:"port"` // Name: name of the endpoint. Name *string `json:"name"` // PrivateNetwork: private Network details. One maximum per Database Instance or Read Replica (a Database Instance and its Read Replica can have different Private Networks). Cannot be updated (has to be deleted and recreated). // Precisely one of PrivateNetwork, LoadBalancer, DirectAccess must be set. PrivateNetwork *EndpointPrivateNetworkDetails `json:"private_network,omitempty"` // LoadBalancer: load balancer details. Public endpoint for Database Instance which is systematically present. One per Database Instance. // Precisely one of PrivateNetwork, LoadBalancer, DirectAccess must be set. LoadBalancer *EndpointLoadBalancerDetails `json:"load_balancer,omitempty"` // DirectAccess: direct access details. Public endpoint reserved for Read Replicas. One per Read Replica. // Precisely one of PrivateNetwork, LoadBalancer, DirectAccess must be set. DirectAccess *EndpointDirectAccessDetails `json:"direct_access,omitempty"` // Hostname: hostname of the endpoint. // Precisely one of IP, Hostname must be set. Hostname *string `json:"hostname,omitempty"` } // EndpointSpecLoadBalancer: endpoint spec load balancer. type EndpointSpecLoadBalancer struct { } // EndpointSpecPrivateNetwork: endpoint spec private network. type EndpointSpecPrivateNetwork struct { // PrivateNetworkID: UUID of the Private Network to be connected to the Database Instance. PrivateNetworkID string `json:"private_network_id"` // ServiceIP: endpoint IPv4 address with a CIDR notation. Refer to the official Scaleway documentation to learn more about IP and subnet limitations. // Precisely one of ServiceIP, IpamConfig must be set. ServiceIP *scw.IPNet `json:"service_ip,omitempty"` // IpamConfig: automated configuration of your Private Network endpoint with Scaleway IPAM service. One at the most per Database Instance or Read Replica (a Database Instance and its Read Replica can have different Private Networks). Cannot be updated (has to be deleted and recreated). // Precisely one of ServiceIP, IpamConfig must be set. IpamConfig *EndpointSpecPrivateNetworkIpamConfig `json:"ipam_config,omitempty"` } // ReadReplicaEndpointSpecDirectAccess: read replica endpoint spec direct access. type ReadReplicaEndpointSpecDirectAccess struct { } // ReadReplicaEndpointSpecPrivateNetwork: read replica endpoint spec private network. type ReadReplicaEndpointSpecPrivateNetwork struct { // PrivateNetworkID: UUID of the Private Network to be connected to the Read Replica. PrivateNetworkID string `json:"private_network_id"` // ServiceIP: endpoint IPv4 address with a CIDR notation. Refer to the official Scaleway documentation to learn more about IP and subnet limitations. // Precisely one of ServiceIP, IpamConfig must be set. ServiceIP *scw.IPNet `json:"service_ip,omitempty"` // IpamConfig: automated configuration of your Private Network endpoint with Scaleway IPAM service. One at the most per Database Instance or Read Replica (a Database Instance and its Read Replica can have different private networks). Cannot be updated (has to be deleted and recreated). // Precisely one of ServiceIP, IpamConfig must be set. IpamConfig *ReadReplicaEndpointSpecPrivateNetworkIpamConfig `json:"ipam_config,omitempty"` } // EngineVersion: engine version. type EngineVersion struct { // Version: database engine version. Version string `json:"version"` // Name: database engine name. Name string `json:"name"` // EndOfLife: end of life date. EndOfLife *time.Time `json:"end_of_life"` // AvailableSettings: engine settings available to be set. AvailableSettings []*EngineSetting `json:"available_settings"` // Disabled: disabled versions cannot be created. Disabled bool `json:"disabled"` // Beta: beta status of engine version. Beta bool `json:"beta"` // AvailableInitSettings: engine settings available to be set at database initialization. AvailableInitSettings []*EngineSetting `json:"available_init_settings"` } // BackupSchedule: backup schedule. type BackupSchedule struct { // Frequency: frequency of the backup schedule (in hours). Frequency uint32 `json:"frequency"` // Retention: default retention period of backups (in days). Retention uint32 `json:"retention"` // Disabled: defines whether the backup schedule feature is disabled. Disabled bool `json:"disabled"` // NextRunAt: next run of the backup schedule (accurate to 10 minutes). NextRunAt *time.Time `json:"next_run_at"` } // InstanceSetting: instance setting. type InstanceSetting struct { Name string `json:"name"` Value string `json:"value"` } // LogsPolicy: logs policy. type LogsPolicy struct { // MaxAgeRetention: max age (in days) of remote logs to keep on the Database Instance. MaxAgeRetention *uint32 `json:"max_age_retention"` // TotalDiskRetention: max disk size of remote logs to keep on the Database Instance. TotalDiskRetention *scw.Size `json:"total_disk_retention"` } // Maintenance: maintenance. type Maintenance struct { // StartsAt: start date of the maintenance window. StartsAt *time.Time `json:"starts_at"` // StopsAt: end date of the maintenance window. StopsAt *time.Time `json:"stops_at"` // ClosedAt: closed maintenance date. ClosedAt *time.Time `json:"closed_at"` // Reason: maintenance information message. Reason string `json:"reason"` // Status: status of the maintenance. // Default value: unknown Status MaintenanceStatus `json:"status"` } // ReadReplica: read replica. type ReadReplica struct { // ID: UUID of the Read Replica. ID string `json:"id"` // Endpoints: display Read Replica connection information. Endpoints []*Endpoint `json:"endpoints"` // Status: read replica status. // Default value: unknown Status ReadReplicaStatus `json:"status"` // Region: region the Read Replica is in. Region scw.Region `json:"region"` // SameZone: whether the replica is in the same availability zone as the main instance nodes or not. SameZone bool `json:"same_zone"` // InstanceID: UUID of the Database Instance. InstanceID string `json:"instance_id"` } // UpgradableVersion: upgradable version. type UpgradableVersion struct { ID string `json:"id"` Name string `json:"name"` Version string `json:"version"` MinorVersion string `json:"minor_version"` } // Volume: volume. type Volume struct { // Type: default value: lssd Type VolumeType `json:"type"` Size scw.Size `json:"size"` // Class: default value: unknown_storage_class Class StorageClass `json:"class"` } // NodeTypeVolumeConstraintSizes: node type volume constraint sizes. type NodeTypeVolumeConstraintSizes struct { // MinSize: [deprecated] Mimimum size required for the Volume. MinSize scw.Size `json:"min_size"` // MaxSize: [deprecated] Maximum size required for the Volume. MaxSize scw.Size `json:"max_size"` } // NodeTypeVolumeType: node type volume type. type NodeTypeVolumeType struct { // Type: volume Type. // Default value: lssd Type VolumeType `json:"type"` // Description: the description of the Volume. Description string `json:"description"` // MinSize: mimimum size required for the Volume. MinSize scw.Size `json:"min_size"` // MaxSize: maximum size required for the Volume. MaxSize scw.Size `json:"max_size"` // ChunkSize: minimum increment level for a Block Storage volume size. ChunkSize scw.Size `json:"chunk_size"` // Class: the storage class of the volume. // Default value: unknown_storage_class Class StorageClass `json:"class"` } // SnapshotVolumeType: snapshot volume type. type SnapshotVolumeType struct { // Type: default value: lssd Type VolumeType `json:"type"` // Class: default value: unknown_storage_class Class StorageClass `json:"class"` } // ACLRuleRequest: acl rule request. type ACLRuleRequest struct { IP scw.IPNet `json:"ip"` Description string `json:"description"` } // ACLRule: acl rule. type ACLRule struct { IP scw.IPNet `json:"ip"` // Deprecated Port *uint32 `json:"port,omitempty"` // Protocol: default value: tcp Protocol ACLRuleProtocol `json:"protocol"` // Direction: default value: inbound Direction ACLRuleDirection `json:"direction"` // Action: default value: allow Action ACLRuleAction `json:"action"` Description string `json:"description"` } // EndpointSpec: endpoint spec. type EndpointSpec struct { // LoadBalancer: load balancer endpoint specifications. Public endpoint for Database Instance which is systematically present. One per RDB instance. // Precisely one of LoadBalancer, PrivateNetwork must be set. LoadBalancer *EndpointSpecLoadBalancer `json:"load_balancer,omitempty"` // PrivateNetwork: private Network endpoint specifications. One maximum per Database Instance or Read Replica (a Database Instance and its Read Replica can have different Private Networks). Cannot be updated (has to be deleted and recreated). // Precisely one of LoadBalancer, PrivateNetwork must be set. PrivateNetwork *EndpointSpecPrivateNetwork `json:"private_network,omitempty"` } // ReadReplicaEndpointSpec: read replica endpoint spec. type ReadReplicaEndpointSpec struct { // DirectAccess: direct access endpoint specifications. Public endpoint reserved for Read Replicas. One per Read Replica. // Precisely one of DirectAccess, PrivateNetwork must be set. DirectAccess *ReadReplicaEndpointSpecDirectAccess `json:"direct_access,omitempty"` // PrivateNetwork: private Network endpoint specifications. One at the most per Read Replica. Cannot be updated (has to be deleted and recreated). // Precisely one of DirectAccess, PrivateNetwork must be set. PrivateNetwork *ReadReplicaEndpointSpecPrivateNetwork `json:"private_network,omitempty"` } // DatabaseBackup: database backup. type DatabaseBackup struct { // ID: UUID of the database backup. ID string `json:"id"` // InstanceID: UUID of the Database Instance. InstanceID string `json:"instance_id"` // DatabaseName: name of backed up database. DatabaseName string `json:"database_name"` // Name: name of the backup. Name string `json:"name"` // Status: status of the backup. // Default value: unknown Status DatabaseBackupStatus `json:"status"` // Size: size of the database backup. Size *scw.Size `json:"size"` // ExpiresAt: expiration date (must follow the ISO 8601 format). ExpiresAt *time.Time `json:"expires_at"` // CreatedAt: creation date (must follow the ISO 8601 format). CreatedAt *time.Time `json:"created_at"` // UpdatedAt: updated date (must follow the ISO 8601 format). UpdatedAt *time.Time `json:"updated_at"` // InstanceName: name of the Database Instance of the backup. InstanceName string `json:"instance_name"` // DownloadURL: URL you can download the backup from. DownloadURL *string `json:"download_url"` // DownloadURLExpiresAt: expiration date of the download link. DownloadURLExpiresAt *time.Time `json:"download_url_expires_at"` // Region: region of the database backup. Region scw.Region `json:"region"` // SameRegion: store logical backups in the same region as the source Database Instance. SameRegion bool `json:"same_region"` } // DatabaseEngine: database engine. type DatabaseEngine struct { // Name: engine name. Name string `json:"name"` // LogoURL: engine logo URL. LogoURL string `json:"logo_url"` // Versions: available versions. Versions []*EngineVersion `json:"versions"` // Region: region of this Database Instance. Region scw.Region `json:"region"` } // Database: database. type Database struct { // Name: name of the database. Name string `json:"name"` // Owner: name of the database owner. Owner string `json:"owner"` // Managed: defines whether the database is managed or not. Managed bool `json:"managed"` // Size: size of the database. Size scw.Size `json:"size"` } // ListInstanceLogsDetailsResponseInstanceLogDetail: list instance logs details response instance log detail. type ListInstanceLogsDetailsResponseInstanceLogDetail struct { LogName string `json:"log_name"` Size uint64 `json:"size"` } // InstanceLog: instance log. type InstanceLog struct { // DownloadURL: presigned S3 URL to download your log file. DownloadURL *string `json:"download_url"` // ID: UUID of the Database Instance log. ID string `json:"id"` // Status: status of the logs in a Database Instance. // Default value: unknown Status InstanceLogStatus `json:"status"` // NodeName: name of the underlying node. NodeName string `json:"node_name"` // ExpiresAt: expiration date (must follow the ISO 8601 format). ExpiresAt *time.Time `json:"expires_at"` // CreatedAt: creation date (must follow the ISO 8601 format). CreatedAt *time.Time `json:"created_at"` // Region: region the Database Instance is in. Region scw.Region `json:"region"` } // Instance: instance. type Instance struct { // CreatedAt: creation date (must follow the ISO 8601 format). CreatedAt *time.Time `json:"created_at"` // Volume: volumes of the Database Instance. Volume *Volume `json:"volume"` // Region: region the Database Instance is in. Region scw.Region `json:"region"` // ID: UUID of the Database Instance. ID string `json:"id"` // Name: name of the Database Instance. Name string `json:"name"` // OrganizationID: organization ID the Database Instance belongs to. OrganizationID string `json:"organization_id"` // ProjectID: project ID the Database Instance belongs to. ProjectID string `json:"project_id"` // Status: status of the Database Instance. // Default value: unknown Status InstanceStatus `json:"status"` // Engine: database engine of the database (PostgreSQL, MySQL, ...). Engine string `json:"engine"` // UpgradableVersion: available database engine versions for upgrade. UpgradableVersion []*UpgradableVersion `json:"upgradable_version"` // Deprecated: Endpoint: endpoint of the Database Instance. Endpoint *Endpoint `json:"endpoint,omitempty"` // Tags: list of tags applied to the Database Instance. Tags []string `json:"tags"` // Settings: advanced settings of the Database Instance. Settings []*InstanceSetting `json:"settings"` // BackupSchedule: backup schedule of the Database Instance. BackupSchedule *BackupSchedule `json:"backup_schedule"` // IsHaCluster: defines whether or not High-Availability is enabled. IsHaCluster bool `json:"is_ha_cluster"` // ReadReplicas: read Replicas of the Database Instance. ReadReplicas []*ReadReplica `json:"read_replicas"` // NodeType: node type of the Database Instance. NodeType string `json:"node_type"` // InitSettings: list of engine settings to be set at database initialization. InitSettings []*InstanceSetting `json:"init_settings"` // Endpoints: list of Database Instance endpoints. Endpoints []*Endpoint `json:"endpoints"` // LogsPolicy: logs policy of the Database Instance. LogsPolicy *LogsPolicy `json:"logs_policy"` // BackupSameRegion: store logical backups in the same region as the Database Instance. BackupSameRegion bool `json:"backup_same_region"` // Maintenances: list of Database Instance maintenance events. Maintenances []*Maintenance `json:"maintenances"` } // NodeType: node type. type NodeType struct { // Name: node Type name identifier. Name string `json:"name"` // StockStatus: current stock status for the Node Type. // Default value: unknown StockStatus NodeTypeStock `json:"stock_status"` // Description: current specs of the offer. Description string `json:"description"` // Vcpus: number of virtual CPUs. Vcpus uint32 `json:"vcpus"` // Memory: quantity of RAM. Memory scw.Size `json:"memory"` // Deprecated: VolumeConstraint: [deprecated] Node Type volume constraints. VolumeConstraint *NodeTypeVolumeConstraintSizes `json:"volume_constraint,omitempty"` // Deprecated: IsBssdCompatible: the Node Type is compliant with Block Storage. IsBssdCompatible *bool `json:"is_bssd_compatible,omitempty"` // Disabled: the Node Type is currently disabled. Disabled bool `json:"disabled"` // Beta: the Node Type is currently in beta. Beta bool `json:"beta"` // AvailableVolumeTypes: available storage options for the Node Type. AvailableVolumeTypes []*NodeTypeVolumeType `json:"available_volume_types"` // IsHaRequired: the Node Type can be used only with high availability option. IsHaRequired bool `json:"is_ha_required"` // Generation: generation associated with the NodeType offer. // Default value: unknown_generation Generation NodeTypeGeneration `json:"generation"` // InstanceRange: instance range associated with the NodeType offer. InstanceRange string `json:"instance_range"` // Region: region the Node Type is in. Region scw.Region `json:"region"` } // Privilege: privilege. type Privilege struct { // Permission: permission (Read, Read/Write, All, Custom). // Default value: readonly Permission Permission `json:"permission"` // DatabaseName: name of the database. DatabaseName string `json:"database_name"` // UserName: name of the user. UserName string `json:"user_name"` } // Snapshot: snapshot. type Snapshot struct { // ID: UUID of the snapshot. ID string `json:"id"` // InstanceID: UUID of the Database Instance. InstanceID string `json:"instance_id"` // Name: name of the snapshot. Name string `json:"name"` // Status: status of the snapshot. // Default value: unknown Status SnapshotStatus `json:"status"` // Size: size of the snapshot. Size *scw.Size `json:"size"` // ExpiresAt: expiration date (must follow the ISO 8601 format). ExpiresAt *time.Time `json:"expires_at"` // CreatedAt: creation date (must follow the ISO 8601 format). CreatedAt *time.Time `json:"created_at"` // UpdatedAt: updated date (must follow the ISO 8601 format). UpdatedAt *time.Time `json:"updated_at"` // InstanceName: name of the Database Instance of the snapshot. InstanceName string `json:"instance_name"` // NodeType: source node type. NodeType string `json:"node_type"` // VolumeType: type of volume where data is stored (lssd, bssd or sbs). VolumeType *SnapshotVolumeType `json:"volume_type"` // Region: region of this snapshot. Region scw.Region `json:"region"` } // User: user. type User struct { // Name: name of the user (Length must be between 1 and 63 characters for PostgreSQL and between 1 and 32 characters for MySQL. First character must be an alphabet character (a-zA-Z). Your username cannot start with '_rdb' or in PostgreSQL, 'pg_'. Only a-zA-Z0-9_$- characters are accepted). Name string `json:"name"` // IsAdmin: defines whether or not a user got administrative privileges on the Database Instance. IsAdmin bool `json:"is_admin"` } // UpgradeInstanceRequestMajorUpgradeWorkflow: upgrade instance request major upgrade workflow. type UpgradeInstanceRequestMajorUpgradeWorkflow struct { // UpgradableVersionID: this will create a new Database Instance with same specifications as the current one and perform a Database Engine upgrade. UpgradableVersionID string `json:"upgradable_version_id"` // WithEndpoints: at the end of the migration procedure this option let you migrate all your database endpoint to the upgraded instance. WithEndpoints bool `json:"with_endpoints"` } // AddInstanceACLRulesRequest: add instance acl rules request. type AddInstanceACLRulesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you want to add ACL rules to. InstanceID string `json:"-"` // Rules: ACL rules to add to the Database Instance. Rules []*ACLRuleRequest `json:"rules"` } // AddInstanceACLRulesResponse: add instance acl rules response. type AddInstanceACLRulesResponse struct { // Rules: ACL Rules enabled for the Database Instance. Rules []*ACLRule `json:"rules"` } // AddInstanceSettingsRequest: add instance settings request. type AddInstanceSettingsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you want to add settings to. InstanceID string `json:"-"` // Settings: settings to add to the Database Instance. Settings []*InstanceSetting `json:"settings"` } // AddInstanceSettingsResponse: add instance settings response. type AddInstanceSettingsResponse struct { // Settings: settings available on the Database Instance. Settings []*InstanceSetting `json:"settings"` } // CloneInstanceRequest: clone instance request. type CloneInstanceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you want to clone. InstanceID string `json:"-"` // Name: name of the Database Instance clone. Name string `json:"name"` // NodeType: node type of the clone. NodeType *string `json:"node_type,omitempty"` } // CreateDatabaseBackupRequest: create database backup request. type CreateDatabaseBackupRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance. InstanceID string `json:"instance_id"` // DatabaseName: name of the database you want to back up. DatabaseName string `json:"database_name"` // Name: name of the backup. Name string `json:"name"` // ExpiresAt: expiration date (must follow the ISO 8601 format). ExpiresAt *time.Time `json:"expires_at,omitempty"` } // CreateDatabaseRequest: create database request. type CreateDatabaseRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance where to create the database. InstanceID string `json:"-"` // Name: name of the database. Name string `json:"name"` } // CreateEndpointRequest: create endpoint request. type CreateEndpointRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you to which you want to add an endpoint. InstanceID string `json:"-"` // EndpointSpec: specification of the endpoint you want to create. EndpointSpec *EndpointSpec `json:"endpoint_spec,omitempty"` } // CreateInstanceFromSnapshotRequest: create instance from snapshot request. type CreateInstanceFromSnapshotRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SnapshotID: block snapshot of the Database Instance. SnapshotID string `json:"-"` // InstanceName: name of the Database Instance created with the snapshot. InstanceName string `json:"instance_name"` // IsHaCluster: defines whether or not High-Availability is enabled on the new Database Instance. IsHaCluster *bool `json:"is_ha_cluster,omitempty"` // NodeType: the node type used to restore the snapshot. NodeType *string `json:"node_type,omitempty"` } // CreateInstanceRequest: create instance request. type CreateInstanceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Deprecated: OrganizationID: please use project_id instead. // Precisely one of ProjectID, OrganizationID must be set. OrganizationID *string `json:"organization_id,omitempty"` // ProjectID: the Project ID on which the Database Instance will be created. // Precisely one of ProjectID, OrganizationID must be set. ProjectID *string `json:"project_id,omitempty"` // Name: name of the Database Instance. Name string `json:"name"` // Engine: database engine of the Database Instance (PostgreSQL, MySQL, ...). Engine string `json:"engine"` // UserName: username created when the Database Instance is created. UserName string `json:"user_name"` // Password: password of the user. Password string `json:"password"` // NodeType: type of node to use for the Database Instance. NodeType string `json:"node_type"` // IsHaCluster: defines whether or not High-Availability is enabled. IsHaCluster bool `json:"is_ha_cluster"` // DisableBackup: defines whether or not backups are disabled. DisableBackup bool `json:"disable_backup"` // Tags: tags to apply to the Database Instance. Tags []string `json:"tags"` // InitSettings: list of engine settings to be set upon Database Instance initialization. InitSettings []*InstanceSetting `json:"init_settings"` // VolumeType: type of volume where data is stored (lssd, bssd, ...). // Default value: lssd VolumeType VolumeType `json:"volume_type"` // VolumeSize: volume size when volume_type is not lssd. VolumeSize scw.Size `json:"volume_size"` // InitEndpoints: one or multiple EndpointSpec used to expose your Database Instance. A load_balancer public endpoint is systematically created. InitEndpoints []*EndpointSpec `json:"init_endpoints"` // BackupSameRegion: defines whether to or not to store logical backups in the same region as the Database Instance. BackupSameRegion bool `json:"backup_same_region"` } // CreateReadReplicaEndpointRequest: create read replica endpoint request. type CreateReadReplicaEndpointRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ReadReplicaID: UUID of the Read Replica. ReadReplicaID string `json:"-"` // EndpointSpec: specification of the endpoint you want to create. EndpointSpec []*ReadReplicaEndpointSpec `json:"endpoint_spec"` } // CreateReadReplicaRequest: create read replica request. type CreateReadReplicaRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you want to create a Read Replica from. InstanceID string `json:"instance_id"` // EndpointSpec: specification of the endpoint you want to create. EndpointSpec []*ReadReplicaEndpointSpec `json:"endpoint_spec"` // SameZone: defines whether to create the replica in the same availability zone as the main instance nodes or not. SameZone *bool `json:"same_zone,omitempty"` } // CreateSnapshotRequest: create snapshot request. type CreateSnapshotRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance. InstanceID string `json:"-"` // Name: name of the snapshot. Name string `json:"name"` // ExpiresAt: expiration date (must follow the ISO 8601 format). ExpiresAt *time.Time `json:"expires_at,omitempty"` } // CreateUserRequest: create user request. type CreateUserRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance in which you want to create a user. InstanceID string `json:"-"` // Name: name of the user you want to create. Name string `json:"name"` // Password: password of the user you want to create. Password string `json:"password"` // IsAdmin: defines whether the user will have administrative privileges. IsAdmin bool `json:"is_admin"` } // DeleteDatabaseBackupRequest: delete database backup request. type DeleteDatabaseBackupRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DatabaseBackupID: UUID of the database backup to delete. DatabaseBackupID string `json:"-"` } // DeleteDatabaseRequest: delete database request. type DeleteDatabaseRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance where to delete the database. InstanceID string `json:"-"` // Name: name of the database to delete. Name string `json:"-"` } // DeleteEndpointRequest: delete endpoint request. type DeleteEndpointRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // EndpointID: this endpoint can also be used to delete a Read Replica endpoint. EndpointID string `json:"-"` } // DeleteInstanceACLRulesRequest: delete instance acl rules request. type DeleteInstanceACLRulesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you want to delete an ACL rule from. InstanceID string `json:"-"` // ACLRuleIPs: IP addresses defined in the ACL rules of the Database Instance. ACLRuleIPs []string `json:"acl_rule_ips"` } // DeleteInstanceACLRulesResponse: delete instance acl rules response. type DeleteInstanceACLRulesResponse struct { // Rules: IP addresses defined in the ACL rules of the Database Instance. Rules []*ACLRule `json:"rules"` } // DeleteInstanceRequest: delete instance request. type DeleteInstanceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance to delete. InstanceID string `json:"-"` } // DeleteInstanceSettingsRequest: delete instance settings request. type DeleteInstanceSettingsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance to delete settings from. InstanceID string `json:"-"` // SettingNames: settings names to delete. SettingNames []string `json:"setting_names"` } // DeleteInstanceSettingsResponse: delete instance settings response. type DeleteInstanceSettingsResponse struct { // Settings: settings names to delete from the Database Instance. Settings []*InstanceSetting `json:"settings"` } // DeleteReadReplicaRequest: delete read replica request. type DeleteReadReplicaRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ReadReplicaID: UUID of the Read Replica. ReadReplicaID string `json:"-"` } // DeleteSnapshotRequest: delete snapshot request. type DeleteSnapshotRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SnapshotID: UUID of the snapshot to delete. SnapshotID string `json:"-"` } // DeleteUserRequest: delete user request. type DeleteUserRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance to delete the user from. InstanceID string `json:"-"` // Name: name of the user. Name string `json:"-"` } // ExportDatabaseBackupRequest: export database backup request. type ExportDatabaseBackupRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DatabaseBackupID: UUID of the database backup you want to export. DatabaseBackupID string `json:"-"` } // GetDatabaseBackupRequest: get database backup request. type GetDatabaseBackupRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DatabaseBackupID: UUID of the database backup. DatabaseBackupID string `json:"-"` } // GetEndpointRequest: get endpoint request. type GetEndpointRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // EndpointID: UUID of the endpoint you want to get. EndpointID string `json:"-"` } // GetInstanceCertificateRequest: get instance certificate request. type GetInstanceCertificateRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance. InstanceID string `json:"-"` } // GetInstanceLogRequest: get instance log request. type GetInstanceLogRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceLogID: UUID of the instance_log you want. InstanceLogID string `json:"-"` } // GetInstanceMetricsRequest: get instance metrics request. type GetInstanceMetricsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance. InstanceID string `json:"-"` // StartDate: start date to gather metrics from. StartDate *time.Time `json:"-"` // EndDate: end date to gather metrics from. EndDate *time.Time `json:"-"` // MetricName: name of the metric to gather. MetricName *string `json:"-"` } // GetInstanceRequest: get instance request. type GetInstanceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance. InstanceID string `json:"-"` } // GetReadReplicaRequest: get read replica request. type GetReadReplicaRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ReadReplicaID: UUID of the Read Replica. ReadReplicaID string `json:"-"` } // GetSnapshotRequest: get snapshot request. type GetSnapshotRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SnapshotID: UUID of the snapshot. SnapshotID string `json:"-"` } // InstanceMetrics: instance metrics. type InstanceMetrics struct { // Timeseries: time series of metrics of a Database Instance. Timeseries []*scw.TimeSeries `json:"timeseries"` } // ListDatabaseBackupsRequest: list database backups request. type ListDatabaseBackupsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Name: name of the database backups. Name *string `json:"-"` // OrderBy: criteria to use when ordering database backups listing. // Default value: created_at_asc OrderBy ListDatabaseBackupsRequestOrderBy `json:"-"` // InstanceID: UUID of the Database Instance. InstanceID *string `json:"-"` // OrganizationID: organization ID of the Organization the database backups belong to. OrganizationID *string `json:"-"` // ProjectID: project ID of the Project the database backups belong to. ProjectID *string `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` } // ListDatabaseBackupsResponse: list database backups response. type ListDatabaseBackupsResponse struct { // DatabaseBackups: list of database backups. DatabaseBackups []*DatabaseBackup `json:"database_backups"` // TotalCount: total count of database backups available. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListDatabaseBackupsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListDatabaseBackupsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListDatabaseBackupsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.DatabaseBackups = append(r.DatabaseBackups, results.DatabaseBackups...) r.TotalCount += uint32(len(results.DatabaseBackups)) return uint32(len(results.DatabaseBackups)), nil } // ListDatabaseEnginesRequest: list database engines request. type ListDatabaseEnginesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Name: name of the database engine. Name *string `json:"-"` // Version: version of the database engine. Version *string `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` } // ListDatabaseEnginesResponse: list database engines response. type ListDatabaseEnginesResponse struct { // Engines: list of the available database engines. Engines []*DatabaseEngine `json:"engines"` // TotalCount: total count of database engines available. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListDatabaseEnginesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListDatabaseEnginesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListDatabaseEnginesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Engines = append(r.Engines, results.Engines...) r.TotalCount += uint32(len(results.Engines)) return uint32(len(results.Engines)), nil } // ListDatabasesRequest: list databases request. type ListDatabasesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance to list the databases of. InstanceID string `json:"-"` // Name: name of the database. Name *string `json:"-"` // Managed: defines whether or not the database is managed. Managed *bool `json:"-"` // Owner: user that owns this database. Owner *string `json:"-"` // OrderBy: criteria to use when ordering database listing. // Default value: name_asc OrderBy ListDatabasesRequestOrderBy `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` } // ListDatabasesResponse: list databases response. type ListDatabasesResponse struct { // Databases: list of the databases. Databases []*Database `json:"databases"` // TotalCount: total count of databases present on a Database Instance. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListDatabasesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListDatabasesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListDatabasesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Databases = append(r.Databases, results.Databases...) r.TotalCount += uint32(len(results.Databases)) return uint32(len(results.Databases)), nil } // ListInstanceACLRulesRequest: list instance acl rules request. type ListInstanceACLRulesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance. InstanceID string `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` } // ListInstanceACLRulesResponse: list instance acl rules response. type ListInstanceACLRulesResponse struct { // Rules: list of ACL rules present on a Database Instance. Rules []*ACLRule `json:"rules"` // TotalCount: total count of ACL rules present on a Database Instance. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListInstanceACLRulesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListInstanceACLRulesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListInstanceACLRulesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Rules = append(r.Rules, results.Rules...) r.TotalCount += uint32(len(results.Rules)) return uint32(len(results.Rules)), nil } // ListInstanceLogsDetailsRequest: list instance logs details request. type ListInstanceLogsDetailsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you want logs of. InstanceID string `json:"-"` } // ListInstanceLogsDetailsResponse: list instance logs details response. type ListInstanceLogsDetailsResponse struct { // Details: remote Database Instance logs details. Details []*ListInstanceLogsDetailsResponseInstanceLogDetail `json:"details"` } // ListInstanceLogsRequest: list instance logs request. type ListInstanceLogsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you want logs of. InstanceID string `json:"-"` // OrderBy: criteria to use when ordering Database Instance logs listing. // Default value: created_at_asc OrderBy ListInstanceLogsRequestOrderBy `json:"order_by"` } // ListInstanceLogsResponse: list instance logs response. type ListInstanceLogsResponse struct { // InstanceLogs: available logs in a Database Instance. InstanceLogs []*InstanceLog `json:"instance_logs"` } // ListInstancesRequest: list instances request. type ListInstancesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Tags: list Database Instances that have a given tag. Tags []string `json:"-"` // Name: lists Database Instances that match a name pattern. Name *string `json:"-"` // OrderBy: criteria to use when ordering Database Instance listings. // Default value: created_at_asc OrderBy ListInstancesRequestOrderBy `json:"-"` // OrganizationID: please use project_id instead. OrganizationID *string `json:"-"` // ProjectID: project ID to list the Database Instance of. ProjectID *string `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` } // ListInstancesResponse: list instances response. type ListInstancesResponse struct { // Instances: list of all Database Instances available in an Organization or Project. Instances []*Instance `json:"instances"` // TotalCount: total count of Database Instances available in a Organization or Project. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListInstancesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListInstancesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListInstancesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Instances = append(r.Instances, results.Instances...) r.TotalCount += uint32(len(results.Instances)) return uint32(len(results.Instances)), nil } // ListNodeTypesRequest: list node types request. type ListNodeTypesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // IncludeDisabledTypes: defines whether or not to include disabled types. IncludeDisabledTypes bool `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` } // ListNodeTypesResponse: list node types response. type ListNodeTypesResponse struct { // NodeTypes: types of the node. NodeTypes []*NodeType `json:"node_types"` // TotalCount: total count of node-types available. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListNodeTypesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListNodeTypesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListNodeTypesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.NodeTypes = append(r.NodeTypes, results.NodeTypes...) r.TotalCount += uint32(len(results.NodeTypes)) return uint32(len(results.NodeTypes)), nil } // ListPrivilegesRequest: list privileges request. type ListPrivilegesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance. InstanceID string `json:"-"` // OrderBy: criteria to use when ordering privileges listing. // Default value: user_name_asc OrderBy ListPrivilegesRequestOrderBy `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` // DatabaseName: name of the database. DatabaseName *string `json:"-"` // UserName: name of the user. UserName *string `json:"-"` } // ListPrivilegesResponse: list privileges response. type ListPrivilegesResponse struct { // Privileges: privileges of a user in a database in a Database Instance. Privileges []*Privilege `json:"privileges"` // TotalCount: total count of privileges present on a database. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListPrivilegesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListPrivilegesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListPrivilegesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Privileges = append(r.Privileges, results.Privileges...) r.TotalCount += uint32(len(results.Privileges)) return uint32(len(results.Privileges)), nil } // ListSnapshotsRequest: list snapshots request. type ListSnapshotsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Name: name of the snapshot. Name *string `json:"-"` // OrderBy: criteria to use when ordering snapshot listing. // Default value: created_at_asc OrderBy ListSnapshotsRequestOrderBy `json:"-"` // InstanceID: UUID of the Database Instance. InstanceID *string `json:"-"` // OrganizationID: organization ID the snapshots belongs to. OrganizationID *string `json:"-"` // ProjectID: project ID the snapshots belongs to. ProjectID *string `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` } // ListSnapshotsResponse: list snapshots response. type ListSnapshotsResponse struct { // Snapshots: list of snapshots. Snapshots []*Snapshot `json:"snapshots"` // TotalCount: total count of snapshots available. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListSnapshotsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListSnapshotsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListSnapshotsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Snapshots = append(r.Snapshots, results.Snapshots...) r.TotalCount += uint32(len(results.Snapshots)) return uint32(len(results.Snapshots)), nil } // ListUsersRequest: list users request. type ListUsersRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance. InstanceID string `json:"-"` // Name: name of the user. Name *string `json:"-"` // OrderBy: criteria to use when requesting user listing. // Default value: name_asc OrderBy ListUsersRequestOrderBy `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` } // ListUsersResponse: list users response. type ListUsersResponse struct { // Users: list of users in a Database Instance. Users []*User `json:"users"` // TotalCount: total count of users present on a Database Instance. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListUsersResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListUsersResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListUsersResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Users = append(r.Users, results.Users...) r.TotalCount += uint32(len(results.Users)) return uint32(len(results.Users)), nil } // MigrateEndpointRequest: migrate endpoint request. type MigrateEndpointRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // EndpointID: UUID of the endpoint you want to migrate. EndpointID string `json:"-"` // InstanceID: UUID of the instance you want to attach the endpoint to. InstanceID string `json:"instance_id"` } // PrepareInstanceLogsRequest: prepare instance logs request. type PrepareInstanceLogsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you want logs of. InstanceID string `json:"-"` // StartDate: start datetime of your log. (RFC 3339 format). StartDate *time.Time `json:"start_date,omitempty"` // EndDate: end datetime of your log. (RFC 3339 format). EndDate *time.Time `json:"end_date,omitempty"` } // PrepareInstanceLogsResponse: prepare instance logs response. type PrepareInstanceLogsResponse struct { // InstanceLogs: instance logs for a Database Instance between a start and an end date. InstanceLogs []*InstanceLog `json:"instance_logs"` } // PromoteReadReplicaRequest: promote read replica request. type PromoteReadReplicaRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ReadReplicaID: UUID of the Read Replica. ReadReplicaID string `json:"-"` } // PurgeInstanceLogsRequest: purge instance logs request. type PurgeInstanceLogsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you want logs of. InstanceID string `json:"-"` // LogName: given log name to purge. LogName *string `json:"log_name,omitempty"` } // RenewInstanceCertificateRequest: renew instance certificate request. type RenewInstanceCertificateRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you want logs of. InstanceID string `json:"-"` } // ResetReadReplicaRequest: reset read replica request. type ResetReadReplicaRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ReadReplicaID: UUID of the Read Replica. ReadReplicaID string `json:"-"` } // RestartInstanceRequest: restart instance request. type RestartInstanceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you want to restart. InstanceID string `json:"-"` } // RestoreDatabaseBackupRequest: restore database backup request. type RestoreDatabaseBackupRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DatabaseBackupID: backup of a logical database. DatabaseBackupID string `json:"-"` // DatabaseName: defines the destination database to restore into a specified database (the default destination is set to the origin database of the backup). DatabaseName *string `json:"database_name,omitempty"` // InstanceID: defines the Database Instance where the backup has to be restored. InstanceID string `json:"instance_id"` } // SetInstanceACLRulesRequest: set instance acl rules request. type SetInstanceACLRulesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance where the ACL rules must be set. InstanceID string `json:"-"` // Rules: ACL rules to define for the Database Instance. Rules []*ACLRuleRequest `json:"rules"` } // SetInstanceACLRulesResponse: set instance acl rules response. type SetInstanceACLRulesResponse struct { // Rules: aCLs rules configured for a Database Instance. Rules []*ACLRule `json:"rules"` } // SetInstanceSettingsRequest: set instance settings request. type SetInstanceSettingsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance where the settings must be set. InstanceID string `json:"-"` // Settings: settings to define for the Database Instance. Settings []*InstanceSetting `json:"settings"` } // SetInstanceSettingsResponse: set instance settings response. type SetInstanceSettingsResponse struct { // Settings: settings configured for a Database Instance. Settings []*InstanceSetting `json:"settings"` } // SetPrivilegeRequest: set privilege request. type SetPrivilegeRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance. InstanceID string `json:"-"` // DatabaseName: name of the database. DatabaseName string `json:"database_name"` // UserName: name of the user. UserName string `json:"user_name"` // Permission: permission to set (Read, Read/Write, All, Custom). // Default value: readonly Permission Permission `json:"permission"` } // UpdateDatabaseBackupRequest: update database backup request. type UpdateDatabaseBackupRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DatabaseBackupID: UUID of the database backup to update. DatabaseBackupID string `json:"-"` // Name: name of the Database Backup. Name *string `json:"name,omitempty"` // ExpiresAt: expiration date (must follow the ISO 8601 format). ExpiresAt *time.Time `json:"expires_at,omitempty"` } // UpdateInstanceRequest: update instance request. type UpdateInstanceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance to update. InstanceID string `json:"-"` // BackupScheduleFrequency: in hours. BackupScheduleFrequency *uint32 `json:"backup_schedule_frequency,omitempty"` // BackupScheduleRetention: in days. BackupScheduleRetention *uint32 `json:"backup_schedule_retention,omitempty"` // IsBackupScheduleDisabled: defines whether or not the backup schedule is disabled. IsBackupScheduleDisabled *bool `json:"is_backup_schedule_disabled,omitempty"` // Name: name of the Database Instance. Name *string `json:"name,omitempty"` // Tags: tags of a Database Instance. Tags *[]string `json:"tags,omitempty"` // LogsPolicy: logs policy of the Database Instance. LogsPolicy *LogsPolicy `json:"logs_policy,omitempty"` // BackupSameRegion: store logical backups in the same region as the Database Instance. BackupSameRegion *bool `json:"backup_same_region,omitempty"` // BackupScheduleStartHour: defines the start time of the autobackup. BackupScheduleStartHour *uint32 `json:"backup_schedule_start_hour,omitempty"` } // UpdateSnapshotRequest: update snapshot request. type UpdateSnapshotRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SnapshotID: UUID of the snapshot to update. SnapshotID string `json:"-"` // Name: name of the snapshot. Name *string `json:"name,omitempty"` // ExpiresAt: expiration date (must follow the ISO 8601 format). ExpiresAt *time.Time `json:"expires_at,omitempty"` } // UpdateUserRequest: update user request. type UpdateUserRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance the user belongs to. InstanceID string `json:"-"` // Name: name of the database user. Name string `json:"-"` // Password: password of the database user. Password *string `json:"password,omitempty"` // IsAdmin: defines whether or not this user got administrative privileges. IsAdmin *bool `json:"is_admin,omitempty"` } // UpgradeInstanceRequest: upgrade instance request. type UpgradeInstanceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // InstanceID: UUID of the Database Instance you want to upgrade. InstanceID string `json:"-"` // NodeType: node type of the Database Instance you want to upgrade to. // Precisely one of NodeType, EnableHa, VolumeSize, VolumeType, UpgradableVersionID, MajorUpgradeWorkflow must be set. NodeType *string `json:"node_type,omitempty"` // EnableHa: defines whether or not high availability should be enabled on the Database Instance. // Precisely one of NodeType, EnableHa, VolumeSize, VolumeType, UpgradableVersionID, MajorUpgradeWorkflow must be set. EnableHa *bool `json:"enable_ha,omitempty"` // VolumeSize: increase your block storage volume size. // Precisely one of NodeType, EnableHa, VolumeSize, VolumeType, UpgradableVersionID, MajorUpgradeWorkflow must be set. VolumeSize *uint64 `json:"volume_size,omitempty"` // VolumeType: change your Database Instance storage type. // Default value: lssd // Precisely one of NodeType, EnableHa, VolumeSize, VolumeType, UpgradableVersionID, MajorUpgradeWorkflow must be set. VolumeType *VolumeType `json:"volume_type,omitempty"` // UpgradableVersionID: this will create a new Database Instance with same specifications as the current one and perform a Database Engine upgrade. // Precisely one of NodeType, EnableHa, VolumeSize, VolumeType, UpgradableVersionID, MajorUpgradeWorkflow must be set. UpgradableVersionID *string `json:"upgradable_version_id,omitempty"` // MajorUpgradeWorkflow: upgrade your database engine to a new major version including instance endpoints. // Precisely one of NodeType, EnableHa, VolumeSize, VolumeType, UpgradableVersionID, MajorUpgradeWorkflow must be set. MajorUpgradeWorkflow *UpgradeInstanceRequestMajorUpgradeWorkflow `json:"major_upgrade_workflow,omitempty"` } type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Regions() []scw.Region { return []scw.Region{scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw} } // ListDatabaseEngines: List the PostgreSQL and MySQL database engines available at Scaleway. func (s *API) ListDatabaseEngines(req *ListDatabaseEnginesRequest, opts ...scw.RequestOption) (*ListDatabaseEnginesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "version", req.Version) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/database-engines", Query: query, } var resp ListDatabaseEnginesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListNodeTypes: List all available node types. By default, the node types returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. func (s *API) ListNodeTypes(req *ListNodeTypesRequest, opts ...scw.RequestOption) (*ListNodeTypesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "include_disabled_types", req.IncludeDisabledTypes) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/node-types", Query: query, } var resp ListNodeTypesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListDatabaseBackups: List all backups in a specified region, for a given Scaleway Organization or Scaleway Project. By default, the backups listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. func (s *API) ListDatabaseBackups(req *ListDatabaseBackupsRequest, opts ...scw.RequestOption) (*ListDatabaseBackupsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "instance_id", req.InstanceID) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/backups", Query: query, } var resp ListDatabaseBackupsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateDatabaseBackup: Create a new backup. You must set the `instance_id`, `database_name`, `name` and `expires_at` parameters. func (s *API) CreateDatabaseBackup(req *CreateDatabaseBackupRequest, opts ...scw.RequestOption) (*DatabaseBackup, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.Name == "" { req.Name = namegenerator.GetRandomName("bkp") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/backups", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp DatabaseBackup err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetDatabaseBackup: Retrieve information about a given backup, specified by its database backup ID and region. Full details about the backup, like size, URL and expiration date, are returned in the response. func (s *API) GetDatabaseBackup(req *GetDatabaseBackupRequest, opts ...scw.RequestOption) (*DatabaseBackup, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DatabaseBackupID) == "" { return nil, errors.New("field DatabaseBackupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/backups/" + fmt.Sprint(req.DatabaseBackupID) + "", } var resp DatabaseBackup err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateDatabaseBackup: Update the parameters of a backup, including name and expiration date. func (s *API) UpdateDatabaseBackup(req *UpdateDatabaseBackupRequest, opts ...scw.RequestOption) (*DatabaseBackup, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DatabaseBackupID) == "" { return nil, errors.New("field DatabaseBackupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/backups/" + fmt.Sprint(req.DatabaseBackupID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp DatabaseBackup err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteDatabaseBackup: Delete a backup, specified by its database backup ID and region. Deleting a backup is permanent, and cannot be undone. func (s *API) DeleteDatabaseBackup(req *DeleteDatabaseBackupRequest, opts ...scw.RequestOption) (*DatabaseBackup, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DatabaseBackupID) == "" { return nil, errors.New("field DatabaseBackupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/backups/" + fmt.Sprint(req.DatabaseBackupID) + "", } var resp DatabaseBackup err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // RestoreDatabaseBackup: Launch the process of restoring database backup. You must specify the `instance_id` of the Database Instance of destination, where the backup will be restored. Note that large database backups can take up to several hours to restore. func (s *API) RestoreDatabaseBackup(req *RestoreDatabaseBackupRequest, opts ...scw.RequestOption) (*DatabaseBackup, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DatabaseBackupID) == "" { return nil, errors.New("field DatabaseBackupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/backups/" + fmt.Sprint(req.DatabaseBackupID) + "/restore", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp DatabaseBackup err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ExportDatabaseBackup: Export a backup, specified by the `database_backup_id` and the `region` parameters. The download URL is returned in the response. func (s *API) ExportDatabaseBackup(req *ExportDatabaseBackupRequest, opts ...scw.RequestOption) (*DatabaseBackup, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DatabaseBackupID) == "" { return nil, errors.New("field DatabaseBackupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/backups/" + fmt.Sprint(req.DatabaseBackupID) + "/export", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp DatabaseBackup err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpgradeInstance: Upgrade your current Database Instance specifications like node type, high availability, volume, or the database engine version. Note that upon upgrade the `enable_ha` parameter can only be set to `true`. func (s *API) UpgradeInstance(req *UpgradeInstanceRequest, opts ...scw.RequestOption) (*Instance, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/upgrade", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Instance err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListInstances: List all Database Instances in the specified region, for a given Scaleway Organization or Scaleway Project. By default, the Database Instances returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. You can define additional parameters for your query, such as `tags` and `name`. For the `name` parameter, the value you include will be checked against the whole name string to see if it includes the string you put in the parameter. func (s *API) ListInstances(req *ListInstancesRequest, opts ...scw.RequestOption) (*ListInstancesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "tags", req.Tags) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances", Query: query, } var resp ListInstancesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetInstance: Retrieve information about a given Database Instance, specified by the `region` and `instance_id` parameters. Its full details, including name, status, IP address and port, are returned in the response object. func (s *API) GetInstance(req *GetInstanceRequest, opts ...scw.RequestOption) (*Instance, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "", } var resp Instance err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateInstance: Create a new Database Instance. You must set the `engine`, `user_name`, `password` and `node_type` parameters. Optionally, you can specify the volume type and size. func (s *API) CreateInstance(req *CreateInstanceRequest, opts ...scw.RequestOption) (*Instance, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultProjectID, exist := s.client.GetDefaultProjectID() if exist && req.ProjectID == nil && req.OrganizationID == nil { req.ProjectID = &defaultProjectID } defaultOrganizationID, exist := s.client.GetDefaultOrganizationID() if exist && req.ProjectID == nil && req.OrganizationID == nil { req.OrganizationID = &defaultOrganizationID } if req.Name == "" { req.Name = namegenerator.GetRandomName("ins") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Instance err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateInstance: Update the parameters of a Database Instance, including name, tags and backup schedule details. func (s *API) UpdateInstance(req *UpdateInstanceRequest, opts ...scw.RequestOption) (*Instance, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Instance err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteInstance: Delete a given Database Instance, specified by the `region` and `instance_id` parameters. Deleting a Database Instance is permanent, and cannot be undone. Note that upon deletion all your data will be lost. func (s *API) DeleteInstance(req *DeleteInstanceRequest, opts ...scw.RequestOption) (*Instance, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "", } var resp Instance err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CloneInstance: Clone a given Database Instance, specified by the `region` and `instance_id` parameters. The clone feature allows you to create a new Database Instance from an existing one. The clone includes all existing databases, users and permissions. You can create a clone on a Database Instance bigger than your current one. func (s *API) CloneInstance(req *CloneInstanceRequest, opts ...scw.RequestOption) (*Instance, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/clone", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Instance err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // RestartInstance: Restart a given Database Instance, specified by the `region` and `instance_id` parameters. The status of the Database Instance returned in the response. func (s *API) RestartInstance(req *RestartInstanceRequest, opts ...scw.RequestOption) (*Instance, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/restart", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Instance err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetInstanceCertificate: Retrieve information about the TLS certificate of a given Database Instance. Details like name and content are returned in the response. func (s *API) GetInstanceCertificate(req *GetInstanceCertificateRequest, opts ...scw.RequestOption) (*scw.File, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/certificate", } var resp scw.File err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // RenewInstanceCertificate: Renew a TLS for a Database Instance. Renewing a certificate means that you will not be able to connect to your Database Instance using the previous certificate. You will also need to download and update the new certificate for all database clients. func (s *API) RenewInstanceCertificate(req *RenewInstanceCertificateRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/renew-certificate", } err = scwReq.SetBody(req) if err != nil { return err } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // GetInstanceMetrics: Retrieve the time series metrics of a given Database Instance. You can define the period from which to retrieve metrics by specifying the `start_date` and `end_date`. func (s *API) GetInstanceMetrics(req *GetInstanceMetricsRequest, opts ...scw.RequestOption) (*InstanceMetrics, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } query := url.Values{} parameter.AddToQuery(query, "start_date", req.StartDate) parameter.AddToQuery(query, "end_date", req.EndDate) parameter.AddToQuery(query, "metric_name", req.MetricName) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/metrics", Query: query, } var resp InstanceMetrics err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateReadReplica: Create a new Read Replica of a Database Instance. You must specify the `region` and the `instance_id`. You can only create a maximum of 3 Read Replicas per Database Instance. func (s *API) CreateReadReplica(req *CreateReadReplicaRequest, opts ...scw.RequestOption) (*ReadReplica, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/read-replicas", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp ReadReplica err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetReadReplica: Retrieve information about a Database Instance Read Replica. Full details about the Read Replica, like `endpoints`, `status` and `region` are returned in the response. func (s *API) GetReadReplica(req *GetReadReplicaRequest, opts ...scw.RequestOption) (*ReadReplica, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ReadReplicaID) == "" { return nil, errors.New("field ReadReplicaID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/read-replicas/" + fmt.Sprint(req.ReadReplicaID) + "", } var resp ReadReplica err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteReadReplica: Delete a Read Replica of a Database Instance. You must specify the `region` and `read_replica_id` parameters of the Read Replica you want to delete. func (s *API) DeleteReadReplica(req *DeleteReadReplicaRequest, opts ...scw.RequestOption) (*ReadReplica, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ReadReplicaID) == "" { return nil, errors.New("field ReadReplicaID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/read-replicas/" + fmt.Sprint(req.ReadReplicaID) + "", } var resp ReadReplica err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ResetReadReplica: When you resync a Read Replica, first it is reset, then its data is resynchronized from the primary node. Your Read Replica remains unavailable during the resync process. The duration of this process is proportional to the size of your Database Instance. // The configured endpoints do not change. func (s *API) ResetReadReplica(req *ResetReadReplicaRequest, opts ...scw.RequestOption) (*ReadReplica, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ReadReplicaID) == "" { return nil, errors.New("field ReadReplicaID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/read-replicas/" + fmt.Sprint(req.ReadReplicaID) + "/reset", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp ReadReplica err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // PromoteReadReplica: Promote a Read Replica to Database Instance automatically. func (s *API) PromoteReadReplica(req *PromoteReadReplicaRequest, opts ...scw.RequestOption) (*Instance, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ReadReplicaID) == "" { return nil, errors.New("field ReadReplicaID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/read-replicas/" + fmt.Sprint(req.ReadReplicaID) + "/promote", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Instance err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateReadReplicaEndpoint: Create a new endpoint for a Read Replica. Read Replicas can have at most one direct access and one Private Network endpoint. func (s *API) CreateReadReplicaEndpoint(req *CreateReadReplicaEndpointRequest, opts ...scw.RequestOption) (*ReadReplica, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ReadReplicaID) == "" { return nil, errors.New("field ReadReplicaID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/read-replicas/" + fmt.Sprint(req.ReadReplicaID) + "/endpoints", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp ReadReplica err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // PrepareInstanceLogs: Prepare your Database Instance logs. You can define the `start_date` and `end_date` parameters for your query. The download URL is returned in the response. Logs are recorded from 00h00 to 23h59 and then aggregated in a `.log` file once a day. Therefore, even if you specify a timeframe from which you want to get the logs, you will receive logs from the full 24 hours. func (s *API) PrepareInstanceLogs(req *PrepareInstanceLogsRequest, opts ...scw.RequestOption) (*PrepareInstanceLogsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/prepare-logs", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp PrepareInstanceLogsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListInstanceLogs: List the available logs of a Database Instance. By default, the logs returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. func (s *API) ListInstanceLogs(req *ListInstanceLogsRequest, opts ...scw.RequestOption) (*ListInstanceLogsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/logs", Query: query, } var resp ListInstanceLogsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetInstanceLog: Retrieve information about the logs of a Database Instance. Specify the `instance_log_id` and `region` in your request to get information such as `download_url`, `status`, `expires_at` and `created_at` about your logs in the response. func (s *API) GetInstanceLog(req *GetInstanceLogRequest, opts ...scw.RequestOption) (*InstanceLog, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceLogID) == "" { return nil, errors.New("field InstanceLogID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/logs/" + fmt.Sprint(req.InstanceLogID) + "", } var resp InstanceLog err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // PurgeInstanceLogs: Purge a given remote log from a Database Instance. You can specify the `log_name` of the log you wish to clean from your Database Instance. func (s *API) PurgeInstanceLogs(req *PurgeInstanceLogsRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/purge-logs", } err = scwReq.SetBody(req) if err != nil { return err } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListInstanceLogsDetails: List remote log details. By default, the details returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. func (s *API) ListInstanceLogsDetails(req *ListInstanceLogsDetailsRequest, opts ...scw.RequestOption) (*ListInstanceLogsDetailsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/logs-details", } var resp ListInstanceLogsDetailsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // AddInstanceSettings: Add an advanced setting to a Database Instance. You must set the `name` and the `value` of each setting. func (s *API) AddInstanceSettings(req *AddInstanceSettingsRequest, opts ...scw.RequestOption) (*AddInstanceSettingsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/settings", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp AddInstanceSettingsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteInstanceSettings: Delete an advanced setting in a Database Instance. You must specify the names of the settings you want to delete in the request. func (s *API) DeleteInstanceSettings(req *DeleteInstanceSettingsRequest, opts ...scw.RequestOption) (*DeleteInstanceSettingsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/settings", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp DeleteInstanceSettingsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SetInstanceSettings: Update an advanced setting for a Database Instance. Settings added upon database engine initalization can only be defined once, and cannot, therefore, be updated. func (s *API) SetInstanceSettings(req *SetInstanceSettingsRequest, opts ...scw.RequestOption) (*SetInstanceSettingsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/settings", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SetInstanceSettingsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListInstanceACLRules: List the ACL rules for a given Database Instance. The response is an array of ACL objects, each one representing an ACL that denies, allows or redirects traffic based on certain conditions. func (s *API) ListInstanceACLRules(req *ListInstanceACLRulesRequest, opts ...scw.RequestOption) (*ListInstanceACLRulesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/acls", Query: query, } var resp ListInstanceACLRulesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // AddInstanceACLRules: Add an additional ACL rule to a Database Instance. func (s *API) AddInstanceACLRules(req *AddInstanceACLRulesRequest, opts ...scw.RequestOption) (*AddInstanceACLRulesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/acls", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp AddInstanceACLRulesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SetInstanceACLRules: Replace all the ACL rules of a Database Instance. func (s *API) SetInstanceACLRules(req *SetInstanceACLRulesRequest, opts ...scw.RequestOption) (*SetInstanceACLRulesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/acls", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SetInstanceACLRulesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteInstanceACLRules: Delete one or more ACL rules of a Database Instance. func (s *API) DeleteInstanceACLRules(req *DeleteInstanceACLRulesRequest, opts ...scw.RequestOption) (*DeleteInstanceACLRulesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/acls", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp DeleteInstanceACLRulesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListUsers: List all users of a given Database Instance. By default, the users returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. func (s *API) ListUsers(req *ListUsersRequest, opts ...scw.RequestOption) (*ListUsersResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/users", Query: query, } var resp ListUsersResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateUser: Create a new user for a Database Instance. You must define the `name`, `password` and `is_admin` parameters. func (s *API) CreateUser(req *CreateUserRequest, opts ...scw.RequestOption) (*User, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/users", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp User err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateUser: Update the parameters of a user on a Database Instance. You can update the `password` and `is_admin` parameters, but you cannot change the name of the user. func (s *API) UpdateUser(req *UpdateUserRequest, opts ...scw.RequestOption) (*User, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } if fmt.Sprint(req.Name) == "" { return nil, errors.New("field Name cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/users/" + fmt.Sprint(req.Name) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp User err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteUser: Delete a given user on a Database Instance. You must specify, in the endpoint, the `region`, `instance_id` and `name` parameters of the user you want to delete. func (s *API) DeleteUser(req *DeleteUserRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return errors.New("field InstanceID cannot be empty in request") } if fmt.Sprint(req.Name) == "" { return errors.New("field Name cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/users/" + fmt.Sprint(req.Name) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListDatabases: List all databases of a given Database Instance. By default, the databases returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. You can define additional parameters for your query, such as `name`, `managed` and `owner`. func (s *API) ListDatabases(req *ListDatabasesRequest, opts ...scw.RequestOption) (*ListDatabasesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "managed", req.Managed) parameter.AddToQuery(query, "owner", req.Owner) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/databases", Query: query, } var resp ListDatabasesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateDatabase: Create a new database. You must define the `name` parameter in the request. func (s *API) CreateDatabase(req *CreateDatabaseRequest, opts ...scw.RequestOption) (*Database, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/databases", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Database err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteDatabase: Delete a given database on a Database Instance. You must specify, in the endpoint, the `region`, `instance_id` and `name` parameters of the database you want to delete. func (s *API) DeleteDatabase(req *DeleteDatabaseRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return errors.New("field InstanceID cannot be empty in request") } if fmt.Sprint(req.Name) == "" { return errors.New("field Name cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/databases/" + fmt.Sprint(req.Name) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListPrivileges: List privileges of a user on a database. By default, the details returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. You can define additional parameters for your query, such as `database_name` and `user_name`. func (s *API) ListPrivileges(req *ListPrivilegesRequest, opts ...scw.RequestOption) (*ListPrivilegesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "database_name", req.DatabaseName) parameter.AddToQuery(query, "user_name", req.UserName) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/privileges", Query: query, } var resp ListPrivilegesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SetPrivilege: Set the privileges of a user on a database. You must define `database_name`, `user_name` and `permission` in the request body. func (s *API) SetPrivilege(req *SetPrivilegeRequest, opts ...scw.RequestOption) (*Privilege, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/privileges", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Privilege err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListSnapshots: List snapshots. You can include the `instance_id` or `project_id` in your query to get the list of snapshots for specific Database Instances and/or Projects. By default, the details returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. func (s *API) ListSnapshots(req *ListSnapshotsRequest, opts ...scw.RequestOption) (*ListSnapshotsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "instance_id", req.InstanceID) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/snapshots", Query: query, } var resp ListSnapshotsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetSnapshot: Retrieve information about a given snapshot, specified by its `snapshot_id` and `region`. Full details about the snapshot, like size and expiration date, are returned in the response. func (s *API) GetSnapshot(req *GetSnapshotRequest, opts ...scw.RequestOption) (*Snapshot, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SnapshotID) == "" { return nil, errors.New("field SnapshotID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/snapshots/" + fmt.Sprint(req.SnapshotID) + "", } var resp Snapshot err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateSnapshot: Create a new snapshot of a Database Instance. You must define the `name` parameter in the request. func (s *API) CreateSnapshot(req *CreateSnapshotRequest, opts ...scw.RequestOption) (*Snapshot, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.Name == "" { req.Name = namegenerator.GetRandomName("snp") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/snapshots", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Snapshot err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateSnapshot: Update the parameters of a snapshot of a Database Instance. You can update the `name` and `expires_at` parameters. func (s *API) UpdateSnapshot(req *UpdateSnapshotRequest, opts ...scw.RequestOption) (*Snapshot, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SnapshotID) == "" { return nil, errors.New("field SnapshotID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/snapshots/" + fmt.Sprint(req.SnapshotID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Snapshot err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteSnapshot: Delete a given snapshot of a Database Instance. You must specify, in the endpoint, the `region` and `snapshot_id` parameters of the snapshot you want to delete. func (s *API) DeleteSnapshot(req *DeleteSnapshotRequest, opts ...scw.RequestOption) (*Snapshot, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SnapshotID) == "" { return nil, errors.New("field SnapshotID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/snapshots/" + fmt.Sprint(req.SnapshotID) + "", } var resp Snapshot err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateInstanceFromSnapshot: Restore a snapshot. When you restore a snapshot, a new Instance is created and billed to your account. Note that is possible to select a larger node type for your new Database Instance. However, the Block volume size will be the same as the size of the restored snapshot. All Instance settings will be restored if you chose a node type with the same or more memory size than the initial Instance. Settings will be reset to the default if your node type has less memory. func (s *API) CreateInstanceFromSnapshot(req *CreateInstanceFromSnapshotRequest, opts ...scw.RequestOption) (*Instance, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SnapshotID) == "" { return nil, errors.New("field SnapshotID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/snapshots/" + fmt.Sprint(req.SnapshotID) + "/create-instance", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Instance err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateEndpoint: Create a new endpoint for a Database Instance. You can add `load_balancer` and `private_network` specifications to the body of the request. func (s *API) CreateEndpoint(req *CreateEndpointRequest, opts ...scw.RequestOption) (*Endpoint, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.InstanceID) == "" { return nil, errors.New("field InstanceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/instances/" + fmt.Sprint(req.InstanceID) + "/endpoints", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Endpoint err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteEndpoint: Delete the endpoint of a Database Instance. You must specify the `region` and `endpoint_id` parameters of the endpoint you want to delete. Note that might need to update any environment configurations that point to the deleted endpoint. func (s *API) DeleteEndpoint(req *DeleteEndpointRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.EndpointID) == "" { return errors.New("field EndpointID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/endpoints/" + fmt.Sprint(req.EndpointID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // GetEndpoint: Retrieve information about a Database Instance endpoint. Full details about the endpoint, like `ip`, `port`, `private_network` and `load_balancer` specifications are returned in the response. func (s *API) GetEndpoint(req *GetEndpointRequest, opts ...scw.RequestOption) (*Endpoint, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.EndpointID) == "" { return nil, errors.New("field EndpointID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/endpoints/" + fmt.Sprint(req.EndpointID) + "", } var resp Endpoint err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // MigrateEndpoint: Migrate an existing instance endpoint to another instance. func (s *API) MigrateEndpoint(req *MigrateEndpointRequest, opts ...scw.RequestOption) (*Endpoint, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.EndpointID) == "" { return nil, errors.New("field EndpointID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/rdb/v1/regions/" + fmt.Sprint(req.Region) + "/endpoints/" + fmt.Sprint(req.EndpointID) + "/migrate", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Endpoint err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/rdb/v1/rdb_utils.go000066400000000000000000000133001456366605600264370ustar00rootroot00000000000000package rdb import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) const ( defaultRetryInterval = 15 * time.Second defaultTimeout = 15 * time.Minute ) // WaitForInstanceRequest is used by WaitForInstance method. type WaitForInstanceRequest struct { InstanceID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForInstance waits for the instance to be in a "terminal state" before returning. // This function can be used to wait for an instance to be ready for example. func (s *API) WaitForInstance(req *WaitForInstanceRequest, opts ...scw.RequestOption) (*Instance, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[InstanceStatus]struct{}{ InstanceStatusReady: {}, InstanceStatusDiskFull: {}, InstanceStatusError: {}, } instance, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetInstance(&GetInstanceRequest{ InstanceID: req.InstanceID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.Status] return res, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for instance failed") } return instance.(*Instance), nil } type WaitForDatabaseBackupRequest struct { DatabaseBackupID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForDatabaseBackup waits for the backup to be in a "terminal state" before returning. // This function can be used to wait for a backup to be ready for example. func (s *API) WaitForDatabaseBackup(req *WaitForDatabaseBackupRequest, opts ...scw.RequestOption) (*DatabaseBackup, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[DatabaseBackupStatus]struct{}{ DatabaseBackupStatusReady: {}, DatabaseBackupStatusError: {}, } backup, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetDatabaseBackup(&GetDatabaseBackupRequest{ DatabaseBackupID: req.DatabaseBackupID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.Status] return res, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for database backup failed") } return backup.(*DatabaseBackup), nil } type WaitForInstanceLogRequest struct { InstanceLogID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForInstanceLog waits for the instance logs to be in a "terminal state" before returning. // This function can be used to wait for an instance logs to be ready for example. func (s *API) WaitForInstanceLog(req *WaitForInstanceLogRequest, opts ...scw.RequestOption) (*InstanceLog, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[InstanceLogStatus]struct{}{ InstanceLogStatusReady: {}, InstanceLogStatusError: {}, } logs, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetInstanceLog(&GetInstanceLogRequest{ Region: req.Region, InstanceLogID: req.InstanceLogID, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.Status] return res, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for instance logs failed") } return logs.(*InstanceLog), nil } // WaitForReadReplicaRequest is used by WaitForReadReplica method. type WaitForReadReplicaRequest struct { ReadReplicaID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForReadReplica waits for the read replica to be in a "terminal state" before returning. // This function can be used to wait for a read replica to be ready for example. func (s *API) WaitForReadReplica(req *WaitForReadReplicaRequest, opts ...scw.RequestOption) (*ReadReplica, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[ReadReplicaStatus]struct{}{ ReadReplicaStatusReady: {}, ReadReplicaStatusError: {}, } readReplica, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetReadReplica(&GetReadReplicaRequest{ ReadReplicaID: req.ReadReplicaID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.Status] return res, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for read replica failed") } return readReplica.(*ReadReplica), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/redis/000077500000000000000000000000001456366605600241355ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/redis/v1/000077500000000000000000000000001456366605600244635ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/redis/v1/redis_sdk.go000066400000000000000000001465431456366605600267760ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package redis provides methods and message types of the redis v1 API. package redis import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type AvailableClusterSettingPropertyType string const ( AvailableClusterSettingPropertyTypeUNKNOWN = AvailableClusterSettingPropertyType("UNKNOWN") AvailableClusterSettingPropertyTypeBOOLEAN = AvailableClusterSettingPropertyType("BOOLEAN") AvailableClusterSettingPropertyTypeINT = AvailableClusterSettingPropertyType("INT") AvailableClusterSettingPropertyTypeSTRING = AvailableClusterSettingPropertyType("STRING") ) func (enum AvailableClusterSettingPropertyType) String() string { if enum == "" { // return default value if empty return "UNKNOWN" } return string(enum) } func (enum AvailableClusterSettingPropertyType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *AvailableClusterSettingPropertyType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = AvailableClusterSettingPropertyType(AvailableClusterSettingPropertyType(tmp).String()) return nil } type ClusterStatus string const ( ClusterStatusUnknown = ClusterStatus("unknown") ClusterStatusReady = ClusterStatus("ready") ClusterStatusProvisioning = ClusterStatus("provisioning") ClusterStatusConfiguring = ClusterStatus("configuring") ClusterStatusDeleting = ClusterStatus("deleting") ClusterStatusError = ClusterStatus("error") ClusterStatusAutohealing = ClusterStatus("autohealing") ClusterStatusLocked = ClusterStatus("locked") ClusterStatusSuspended = ClusterStatus("suspended") ClusterStatusInitializing = ClusterStatus("initializing") ) func (enum ClusterStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum ClusterStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ClusterStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ClusterStatus(ClusterStatus(tmp).String()) return nil } type ListClustersRequestOrderBy string const ( ListClustersRequestOrderByCreatedAtAsc = ListClustersRequestOrderBy("created_at_asc") ListClustersRequestOrderByCreatedAtDesc = ListClustersRequestOrderBy("created_at_desc") ListClustersRequestOrderByNameAsc = ListClustersRequestOrderBy("name_asc") ListClustersRequestOrderByNameDesc = ListClustersRequestOrderBy("name_desc") ) func (enum ListClustersRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListClustersRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListClustersRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListClustersRequestOrderBy(ListClustersRequestOrderBy(tmp).String()) return nil } type NodeTypeStock string const ( NodeTypeStockUnknown = NodeTypeStock("unknown") NodeTypeStockLowStock = NodeTypeStock("low_stock") NodeTypeStockOutOfStock = NodeTypeStock("out_of_stock") NodeTypeStockAvailable = NodeTypeStock("available") ) func (enum NodeTypeStock) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum NodeTypeStock) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *NodeTypeStock) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = NodeTypeStock(NodeTypeStock(tmp).String()) return nil } type PrivateNetworkProvisioningMode string const ( PrivateNetworkProvisioningModeStatic = PrivateNetworkProvisioningMode("static") PrivateNetworkProvisioningModeIpam = PrivateNetworkProvisioningMode("ipam") ) func (enum PrivateNetworkProvisioningMode) String() string { if enum == "" { // return default value if empty return "static" } return string(enum) } func (enum PrivateNetworkProvisioningMode) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *PrivateNetworkProvisioningMode) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = PrivateNetworkProvisioningMode(PrivateNetworkProvisioningMode(tmp).String()) return nil } // EndpointSpecPrivateNetworkSpecIpamConfig: endpoint spec private network spec ipam config. type EndpointSpecPrivateNetworkSpecIpamConfig struct { } // PrivateNetwork: private network. type PrivateNetwork struct { // ID: UUID of the Private Network. ID string `json:"id"` // ServiceIPs: list of IPv4 CIDR notation addresses of the endpoint. ServiceIPs []scw.IPNet `json:"service_ips"` // Zone: zone of the Private Network. Zone scw.Zone `json:"zone"` // ProvisioningMode: how your endpoint ips are provisioned. // Default value: static ProvisioningMode PrivateNetworkProvisioningMode `json:"provisioning_mode"` } // PublicNetwork: public network. type PublicNetwork struct { } // EndpointSpecPrivateNetworkSpec: endpoint spec private network spec. type EndpointSpecPrivateNetworkSpec struct { // ID: UUID of the Private Network to connect to the Database Instance. ID string `json:"id"` // ServiceIPs: endpoint IPv4 address with a CIDR notation. You must provide at least one IPv4 per node. ServiceIPs []scw.IPNet `json:"service_ips"` // IpamConfig: automated configuration of your Private Network endpoint with Scaleway IPAM service. IpamConfig *EndpointSpecPrivateNetworkSpecIpamConfig `json:"ipam_config"` } // EndpointSpecPublicNetworkSpec: endpoint spec public network spec. type EndpointSpecPublicNetworkSpec struct { } // AvailableClusterSetting: available cluster setting. type AvailableClusterSetting struct { // Name: name of the setting. Name string `json:"name"` // DefaultValue: default value of the setting. DefaultValue *string `json:"default_value"` // Type: type of setting. // Default value: UNKNOWN Type AvailableClusterSettingPropertyType `json:"type"` // Description: description of the setting. Description string `json:"description"` // MaxValue: optional maximum value of the setting. MaxValue *int64 `json:"max_value"` // MinValue: optional minimum value of the setting. MinValue *int64 `json:"min_value"` // Regex: optional validation rule of the setting. Regex *string `json:"regex"` // Deprecated: defines whether or not the setting is deprecated. Deprecated bool `json:"deprecated"` } // ACLRule: acl rule. type ACLRule struct { // ID: ID of the rule. ID string `json:"id"` // IPCidr: iPv4 network address of the rule. IPCidr *scw.IPNet `json:"ip_cidr"` // Description: description of the rule. Description *string `json:"description"` } // ClusterSetting: cluster setting. type ClusterSetting struct { // Value: value of the setting. Value string `json:"value"` // Name: name of the setting. Name string `json:"name"` } // Endpoint: endpoint. type Endpoint struct { // Port: TCP port of the endpoint. Port uint32 `json:"port"` // PrivateNetwork: private Network details. // Precisely one of PrivateNetwork, PublicNetwork must be set. PrivateNetwork *PrivateNetwork `json:"private_network,omitempty"` // PublicNetwork: public network details. // Precisely one of PrivateNetwork, PublicNetwork must be set. PublicNetwork *PublicNetwork `json:"public_network,omitempty"` // IPs: list of IPv4 addresses of the endpoint. IPs []net.IP `json:"ips"` // ID: UUID of the endpoint. ID string `json:"id"` } // ACLRuleSpec: acl rule spec. type ACLRuleSpec struct { // IPCidr: iPv4 network address of the rule. IPCidr scw.IPNet `json:"ip_cidr"` // Description: description of the rule. Description string `json:"description"` } // EndpointSpec: endpoint spec. type EndpointSpec struct { // PrivateNetwork: private Network specification details. // Precisely one of PrivateNetwork, PublicNetwork must be set. PrivateNetwork *EndpointSpecPrivateNetworkSpec `json:"private_network,omitempty"` // PublicNetwork: public network specification details. // Precisely one of PrivateNetwork, PublicNetwork must be set. PublicNetwork *EndpointSpecPublicNetworkSpec `json:"public_network,omitempty"` } // ClusterVersion: cluster version. type ClusterVersion struct { // Version: redis™ engine version. Version string `json:"version"` // EndOfLifeAt: date of End of Life. EndOfLifeAt *time.Time `json:"end_of_life_at"` // AvailableSettings: cluster settings available to be updated. AvailableSettings []*AvailableClusterSetting `json:"available_settings"` // LogoURL: redis™ logo url. LogoURL string `json:"logo_url"` // Zone: zone of the Redis™ Database Instance. Zone scw.Zone `json:"zone"` } // Cluster: cluster. type Cluster struct { // ID: UUID of the Database Instance. ID string `json:"id"` // Name: name of the Database Instance. Name string `json:"name"` // ProjectID: project ID the Database Instance belongs to. ProjectID string `json:"project_id"` // Status: status of the Database Instance. // Default value: unknown Status ClusterStatus `json:"status"` // Version: redis™ engine version of the Database Instance. Version string `json:"version"` // Endpoints: list of Database Instance endpoints. Endpoints []*Endpoint `json:"endpoints"` // Tags: list of tags applied to the Database Instance. Tags []string `json:"tags"` // NodeType: node type of the Database Instance. NodeType string `json:"node_type"` // CreatedAt: creation date (Format ISO 8601). CreatedAt *time.Time `json:"created_at"` // UpdatedAt: update date (Format ISO 8601). UpdatedAt *time.Time `json:"updated_at"` // TLSEnabled: defines whether or not TLS is enabled. TLSEnabled bool `json:"tls_enabled"` // ClusterSettings: list of Database Instance settings. ClusterSettings []*ClusterSetting `json:"cluster_settings"` // ACLRules: list of ACL rules. ACLRules []*ACLRule `json:"acl_rules"` // ClusterSize: number of nodes of the Database Instance cluster. ClusterSize uint32 `json:"cluster_size"` // Zone: zone of the Database Instance. Zone scw.Zone `json:"zone"` // UserName: name of the user associated to the cluster. UserName string `json:"user_name"` // UpgradableVersions: list of engine versions the Database Instance can upgrade to. UpgradableVersions []string `json:"upgradable_versions"` } // NodeType: node type. type NodeType struct { // Name: node type name. Name string `json:"name"` // StockStatus: current stock status of the node type. // Default value: unknown StockStatus NodeTypeStock `json:"stock_status"` // Description: current specifications of the offer. Description string `json:"description"` // Vcpus: number of virtual CPUs. Vcpus uint32 `json:"vcpus"` // Memory: quantity of RAM. Memory scw.Size `json:"memory"` // Disabled: defines whether node type is currently disabled or not. Disabled bool `json:"disabled"` // Beta: defines whether node type is currently in beta. Beta bool `json:"beta"` // Zone: zone of the node type. Zone scw.Zone `json:"zone"` } // AddACLRulesRequest: add acl rules request. type AddACLRulesRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ClusterID: UUID of the Database Instance you want to add ACL rules to. ClusterID string `json:"-"` // ACLRules: aCLs rules to add to the cluster. ACLRules []*ACLRuleSpec `json:"acl_rules"` } // AddACLRulesResponse: add acl rules response. type AddACLRulesResponse struct { // ACLRules: ACL Rules enabled for the Database Instance. ACLRules []*ACLRule `json:"acl_rules"` // TotalCount: total count of ACL rules of the Database Instance. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *AddACLRulesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *AddACLRulesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*AddACLRulesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.ACLRules = append(r.ACLRules, results.ACLRules...) r.TotalCount += uint32(len(results.ACLRules)) return uint32(len(results.ACLRules)), nil } // AddClusterSettingsRequest: add cluster settings request. type AddClusterSettingsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ClusterID: UUID of the Database Instance you want to add settings to. ClusterID string `json:"-"` // Settings: settings to add to the cluster. Settings []*ClusterSetting `json:"settings"` } // AddEndpointsRequest: add endpoints request. type AddEndpointsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ClusterID: UUID of the Database Instance you want to add endpoints to. ClusterID string `json:"-"` // Endpoints: endpoints to add to the Database Instance. Endpoints []*EndpointSpec `json:"endpoints"` } // AddEndpointsResponse: add endpoints response. type AddEndpointsResponse struct { // Endpoints: endpoints defined on the Database Instance. Endpoints []*Endpoint `json:"endpoints"` // TotalCount: total count of endpoints of the Database Instance. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *AddEndpointsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *AddEndpointsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*AddEndpointsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Endpoints = append(r.Endpoints, results.Endpoints...) r.TotalCount += uint32(len(results.Endpoints)) return uint32(len(results.Endpoints)), nil } // ClusterMetricsResponse: cluster metrics response. type ClusterMetricsResponse struct { // Timeseries: time series of metrics of a given cluster. Timeseries []*scw.TimeSeries `json:"timeseries"` } // ClusterSettingsResponse: cluster settings response. type ClusterSettingsResponse struct { // Settings: settings configured for a given Database Instance. Settings []*ClusterSetting `json:"settings"` } // CreateClusterRequest: create cluster request. type CreateClusterRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ProjectID: project ID in which to create the Database Instance. ProjectID string `json:"project_id"` // Name: name of the Database Instance. Name string `json:"name"` // Version: redis™ engine version of the Database Instance. Version string `json:"version"` // Tags: tags to apply to the Database Instance. Tags []string `json:"tags"` // NodeType: type of node to use for the Database Instance. NodeType string `json:"node_type"` // UserName: name of the user created upon Database Instance creation. UserName string `json:"user_name"` // Password: password of the user. Password string `json:"password"` // ClusterSize: number of nodes in the Redis™ cluster. ClusterSize *int32 `json:"cluster_size,omitempty"` // ACLRules: list of ACLRuleSpec used to secure your publicly exposed cluster. ACLRules []*ACLRuleSpec `json:"acl_rules"` // Endpoints: zero or multiple EndpointSpec used to expose your cluster publicly and inside private networks. If no EndpoindSpec is given the cluster will be publicly exposed by default. Endpoints []*EndpointSpec `json:"endpoints"` // TLSEnabled: defines whether or not TLS is enabled. TLSEnabled bool `json:"tls_enabled"` // ClusterSettings: list of advanced settings to be set upon Database Instance initialization. ClusterSettings []*ClusterSetting `json:"cluster_settings"` } // DeleteACLRuleRequest: delete acl rule request. type DeleteACLRuleRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ACLID: UUID of the ACL rule you want to delete. ACLID string `json:"-"` } // DeleteClusterRequest: delete cluster request. type DeleteClusterRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ClusterID: UUID of the Database Instance to delete. ClusterID string `json:"-"` } // DeleteClusterSettingRequest: delete cluster setting request. type DeleteClusterSettingRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ClusterID: UUID of the Database Instance where the settings must be set. ClusterID string `json:"-"` // SettingName: setting name to delete. SettingName string `json:"-"` } // DeleteEndpointRequest: delete endpoint request. type DeleteEndpointRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // EndpointID: UUID of the endpoint you want to delete. EndpointID string `json:"-"` } // GetACLRuleRequest: get acl rule request. type GetACLRuleRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ACLID: UUID of the ACL rule you want to get. ACLID string `json:"-"` } // GetClusterCertificateRequest: get cluster certificate request. type GetClusterCertificateRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ClusterID: UUID of the cluster. ClusterID string `json:"-"` } // GetClusterMetricsRequest: get cluster metrics request. type GetClusterMetricsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ClusterID: UUID of the cluster. ClusterID string `json:"-"` // StartAt: start date. StartAt *time.Time `json:"-"` // EndAt: end date. EndAt *time.Time `json:"-"` // MetricName: name of the metric to gather. MetricName *string `json:"-"` } // GetClusterRequest: get cluster request. type GetClusterRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ClusterID: UUID of the cluster. ClusterID string `json:"-"` } // GetEndpointRequest: get endpoint request. type GetEndpointRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // EndpointID: UUID of the endpoint you want to get. EndpointID string `json:"-"` } // ListClusterVersionsRequest: list cluster versions request. type ListClusterVersionsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // IncludeDisabled: defines whether or not to include disabled Redis™ engine versions. IncludeDisabled bool `json:"-"` // IncludeBeta: defines whether or not to include beta Redis™ engine versions. IncludeBeta bool `json:"-"` // IncludeDeprecated: defines whether or not to include deprecated Redis™ engine versions. IncludeDeprecated bool `json:"-"` // Version: list Redis™ engine versions that match a given name pattern. Version *string `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` } // ListClusterVersionsResponse: list cluster versions response. type ListClusterVersionsResponse struct { // Versions: list of available Redis™ engine versions. Versions []*ClusterVersion `json:"versions"` // TotalCount: total count of available Redis™ engine versions. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListClusterVersionsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListClusterVersionsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListClusterVersionsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Versions = append(r.Versions, results.Versions...) r.TotalCount += uint32(len(results.Versions)) return uint32(len(results.Versions)), nil } // ListClustersRequest: list clusters request. type ListClustersRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Tags: filter by Database Instance tags. Tags []string `json:"-"` // Name: filter by Database Instance names. Name *string `json:"-"` // OrderBy: criteria to use when ordering the list. // Default value: created_at_asc OrderBy ListClustersRequestOrderBy `json:"-"` // ProjectID: filter by Project ID. ProjectID *string `json:"-"` // OrganizationID: filter by Organization ID. OrganizationID *string `json:"-"` // Version: filter by Redis™ engine version. Version *string `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` } // ListClustersResponse: list clusters response. type ListClustersResponse struct { // Clusters: list all Database Instances. Clusters []*Cluster `json:"clusters"` // TotalCount: total count of Database Instances. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListClustersResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListClustersResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListClustersResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Clusters = append(r.Clusters, results.Clusters...) r.TotalCount += uint32(len(results.Clusters)) return uint32(len(results.Clusters)), nil } // ListNodeTypesRequest: list node types request. type ListNodeTypesRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // IncludeDisabledTypes: defines whether or not to include disabled types. IncludeDisabledTypes bool `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` } // ListNodeTypesResponse: list node types response. type ListNodeTypesResponse struct { // NodeTypes: types of node. NodeTypes []*NodeType `json:"node_types"` // TotalCount: total count of node types available. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListNodeTypesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListNodeTypesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListNodeTypesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.NodeTypes = append(r.NodeTypes, results.NodeTypes...) r.TotalCount += uint32(len(results.NodeTypes)) return uint32(len(results.NodeTypes)), nil } // MigrateClusterRequest: migrate cluster request. type MigrateClusterRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ClusterID: UUID of the Database Instance to update. ClusterID string `json:"-"` // Version: redis™ engine version of the Database Instance. // Precisely one of Version, NodeType, ClusterSize must be set. Version *string `json:"version,omitempty"` // NodeType: type of node to use for the Database Instance. // Precisely one of Version, NodeType, ClusterSize must be set. NodeType *string `json:"node_type,omitempty"` // ClusterSize: number of nodes for the Database Instance. // Precisely one of Version, NodeType, ClusterSize must be set. ClusterSize *uint32 `json:"cluster_size,omitempty"` } // RenewClusterCertificateRequest: renew cluster certificate request. type RenewClusterCertificateRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ClusterID: UUID of the cluster. ClusterID string `json:"-"` } // SetACLRulesRequest: set acl rules request. type SetACLRulesRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ClusterID: UUID of the Database Instance where the ACL rules have to be set. ClusterID string `json:"-"` // ACLRules: aCLs rules to define for the cluster. ACLRules []*ACLRuleSpec `json:"acl_rules"` } // SetACLRulesResponse: set acl rules response. type SetACLRulesResponse struct { // ACLRules: ACL Rules enabled for the Database Instance. ACLRules []*ACLRule `json:"acl_rules"` } // SetClusterSettingsRequest: set cluster settings request. type SetClusterSettingsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ClusterID: UUID of the Database Instance where the settings must be set. ClusterID string `json:"-"` // Settings: settings to define for the Database Instance. Settings []*ClusterSetting `json:"settings"` } // SetEndpointsRequest: set endpoints request. type SetEndpointsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ClusterID: UUID of the Database Instance where the endpoints have to be set. ClusterID string `json:"-"` // Endpoints: endpoints to define for the Database Instance. Endpoints []*EndpointSpec `json:"endpoints"` } // SetEndpointsResponse: set endpoints response. type SetEndpointsResponse struct { // Endpoints: endpoints defined on the Database Instance. Endpoints []*Endpoint `json:"endpoints"` } // UpdateClusterRequest: update cluster request. type UpdateClusterRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ClusterID: UUID of the Database Instance to update. ClusterID string `json:"-"` // Name: name of the Database Instance. Name *string `json:"name,omitempty"` // Tags: database Instance tags. Tags *[]string `json:"tags,omitempty"` // UserName: name of the Database Instance user. UserName *string `json:"user_name,omitempty"` // Password: password of the Database Instance user. Password *string `json:"password,omitempty"` } // UpdateEndpointRequest: update endpoint request. type UpdateEndpointRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // EndpointID: UUID of the endpoint you want to get. EndpointID string `json:"-"` // PrivateNetwork: private Network details. // Precisely one of PrivateNetwork, PublicNetwork must be set. PrivateNetwork *EndpointSpecPrivateNetworkSpec `json:"private_network,omitempty"` // PublicNetwork: public network details. // Precisely one of PrivateNetwork, PublicNetwork must be set. PublicNetwork *EndpointSpecPublicNetworkSpec `json:"public_network,omitempty"` } type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Zones() []scw.Zone { return []scw.Zone{scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZonePlWaw1, scw.ZonePlWaw2} } // CreateCluster: Create a new Redis™ Database Instance (Redis™ cluster). You must set the `zone`, `project_id`, `version`, `node_type`, `user_name` and `password` parameters. Optionally you can define `acl_rules`, `endpoints`, `tls_enabled` and `cluster_settings`. func (s *API) CreateCluster(req *CreateClusterRequest, opts ...scw.RequestOption) (*Cluster, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if req.Name == "" { req.Name = namegenerator.GetRandomName("ins") } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/redis/v1/zones/" + fmt.Sprint(req.Zone) + "/clusters", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Cluster err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateCluster: Update the parameters of a Redis™ Database Instance (Redis™ cluster), including `name`, `tags`, `user_name` and `password`. func (s *API) UpdateCluster(req *UpdateClusterRequest, opts ...scw.RequestOption) (*Cluster, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/redis/v1/zones/" + fmt.Sprint(req.Zone) + "/clusters/" + fmt.Sprint(req.ClusterID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Cluster err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetCluster: Retrieve information about a Redis™ Database Instance (Redis™ cluster). Specify the `cluster_id` and `region` in your request to get information such as `id`, `status`, `version`, `tls_enabled`, `cluster_settings`, `upgradable_versions` and `endpoints` about your cluster in the response. func (s *API) GetCluster(req *GetClusterRequest, opts ...scw.RequestOption) (*Cluster, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/redis/v1/zones/" + fmt.Sprint(req.Zone) + "/clusters/" + fmt.Sprint(req.ClusterID) + "", } var resp Cluster err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListClusters: List all Redis™ Database Instances (Redis™ cluster) in the specified zone. By default, the Database Instances returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. You can define additional parameters for your query, such as `tags`, `name`, `organization_id` and `version`. func (s *API) ListClusters(req *ListClustersRequest, opts ...scw.RequestOption) (*ListClustersResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "tags", req.Tags) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "version", req.Version) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/redis/v1/zones/" + fmt.Sprint(req.Zone) + "/clusters", Query: query, } var resp ListClustersResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // MigrateCluster: Upgrade your standalone Redis™ Database Instance node, either by upgrading to a bigger node type (vertical scaling) or by adding more nodes to your Database Instance to increase your number of endpoints and distribute cache (horizontal scaling). Note that scaling horizontally your Redis™ Database Instance will not renew its TLS certificate. In order to refresh the TLS certificate, you must use the Renew TLS certificate endpoint. func (s *API) MigrateCluster(req *MigrateClusterRequest, opts ...scw.RequestOption) (*Cluster, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/redis/v1/zones/" + fmt.Sprint(req.Zone) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/migrate", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Cluster err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteCluster: Delete a Redis™ Database Instance (Redis™ cluster), specified by the `region` and `cluster_id` parameters. Deleting a Database Instance is permanent, and cannot be undone. Note that upon deletion all your data will be lost. func (s *API) DeleteCluster(req *DeleteClusterRequest, opts ...scw.RequestOption) (*Cluster, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/redis/v1/zones/" + fmt.Sprint(req.Zone) + "/clusters/" + fmt.Sprint(req.ClusterID) + "", } var resp Cluster err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetClusterMetrics: Retrieve the metrics of a Redis™ Database Instance (Redis™ cluster). You can define the period from which to retrieve metrics by specifying the `start_date` and `end_date`. func (s *API) GetClusterMetrics(req *GetClusterMetricsRequest, opts ...scw.RequestOption) (*ClusterMetricsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } query := url.Values{} parameter.AddToQuery(query, "start_at", req.StartAt) parameter.AddToQuery(query, "end_at", req.EndAt) parameter.AddToQuery(query, "metric_name", req.MetricName) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/redis/v1/zones/" + fmt.Sprint(req.Zone) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/metrics", Query: query, } var resp ClusterMetricsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListNodeTypes: List all available node types. By default, the node types returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. func (s *API) ListNodeTypes(req *ListNodeTypesRequest, opts ...scw.RequestOption) (*ListNodeTypesResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "include_disabled_types", req.IncludeDisabledTypes) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/redis/v1/zones/" + fmt.Sprint(req.Zone) + "/node-types", Query: query, } var resp ListNodeTypesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListClusterVersions: List the Redis™ database engine versions available. You can define additional parameters for your query, such as `include_disabled`, `include_beta`, `include_deprecated` and `version`. func (s *API) ListClusterVersions(req *ListClusterVersionsRequest, opts ...scw.RequestOption) (*ListClusterVersionsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "include_disabled", req.IncludeDisabled) parameter.AddToQuery(query, "include_beta", req.IncludeBeta) parameter.AddToQuery(query, "include_deprecated", req.IncludeDeprecated) parameter.AddToQuery(query, "version", req.Version) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/redis/v1/zones/" + fmt.Sprint(req.Zone) + "/cluster-versions", Query: query, } var resp ListClusterVersionsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetClusterCertificate: Retrieve information about the TLS certificate of a Redis™ Database Instance (Redis™ cluster). Details like name and content are returned in the response. func (s *API) GetClusterCertificate(req *GetClusterCertificateRequest, opts ...scw.RequestOption) (*scw.File, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/redis/v1/zones/" + fmt.Sprint(req.Zone) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/certificate", } var resp scw.File err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // RenewClusterCertificate: Renew a TLS certificate for a Redis™ Database Instance (Redis™ cluster). Renewing a certificate means that you will not be able to connect to your Database Instance using the previous certificate. You will also need to download and update the new certificate for all database clients. func (s *API) RenewClusterCertificate(req *RenewClusterCertificateRequest, opts ...scw.RequestOption) (*Cluster, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/redis/v1/zones/" + fmt.Sprint(req.Zone) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/renew-certificate", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Cluster err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // AddClusterSettings: Add an advanced setting to a Redis™ Database Instance (Redis™ cluster). You must set the `name` and the `value` of each setting. func (s *API) AddClusterSettings(req *AddClusterSettingsRequest, opts ...scw.RequestOption) (*ClusterSettingsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/redis/v1/zones/" + fmt.Sprint(req.Zone) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/settings", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp ClusterSettingsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteClusterSetting: Delete an advanced setting in a Redis™ Database Instance (Redis™ cluster). You must specify the names of the settings you want to delete in the request body. func (s *API) DeleteClusterSetting(req *DeleteClusterSettingRequest, opts ...scw.RequestOption) (*Cluster, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } if fmt.Sprint(req.SettingName) == "" { return nil, errors.New("field SettingName cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/redis/v1/zones/" + fmt.Sprint(req.Zone) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/settings/" + fmt.Sprint(req.SettingName) + "", } var resp Cluster err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SetClusterSettings: Update an advanced setting for a Redis™ Database Instance (Redis™ cluster). Settings added upon database engine initalization can only be defined once, and cannot, therefore, be updated. func (s *API) SetClusterSettings(req *SetClusterSettingsRequest, opts ...scw.RequestOption) (*ClusterSettingsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/redis/v1/zones/" + fmt.Sprint(req.Zone) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/settings", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp ClusterSettingsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SetACLRules: Replace all the ACL rules of a Redis™ Database Instance (Redis™ cluster). func (s *API) SetACLRules(req *SetACLRulesRequest, opts ...scw.RequestOption) (*SetACLRulesResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/redis/v1/zones/" + fmt.Sprint(req.Zone) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/acls", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SetACLRulesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // AddACLRules: Add an additional ACL rule to a Redis™ Database Instance (Redis™ cluster). func (s *API) AddACLRules(req *AddACLRulesRequest, opts ...scw.RequestOption) (*AddACLRulesResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/redis/v1/zones/" + fmt.Sprint(req.Zone) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/acls", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp AddACLRulesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteACLRule: Delete an ACL rule of a Redis™ Database Instance (Redis™ cluster). You must specify the `acl_id` of the rule you want to delete in your request. func (s *API) DeleteACLRule(req *DeleteACLRuleRequest, opts ...scw.RequestOption) (*Cluster, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ACLID) == "" { return nil, errors.New("field ACLID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/redis/v1/zones/" + fmt.Sprint(req.Zone) + "/acls/" + fmt.Sprint(req.ACLID) + "", } var resp Cluster err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetACLRule: Retrieve information about an ACL rule of a Redis™ Database Instance (Redis™ cluster). You must specify the `acl_id` of the rule in your request. func (s *API) GetACLRule(req *GetACLRuleRequest, opts ...scw.RequestOption) (*ACLRule, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ACLID) == "" { return nil, errors.New("field ACLID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/redis/v1/zones/" + fmt.Sprint(req.Zone) + "/acls/" + fmt.Sprint(req.ACLID) + "", } var resp ACLRule err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SetEndpoints: Update an endpoint for a Redis™ Database Instance (Redis™ cluster). You must specify the `cluster_id` and the `endpoints` parameters in your request. func (s *API) SetEndpoints(req *SetEndpointsRequest, opts ...scw.RequestOption) (*SetEndpointsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/redis/v1/zones/" + fmt.Sprint(req.Zone) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/endpoints", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SetEndpointsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // AddEndpoints: Add a new endpoint for a Redis™ Database Instance (Redis™ cluster). You can add `private_network` or `public_network` specifications to the body of the request. func (s *API) AddEndpoints(req *AddEndpointsRequest, opts ...scw.RequestOption) (*AddEndpointsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.ClusterID) == "" { return nil, errors.New("field ClusterID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/redis/v1/zones/" + fmt.Sprint(req.Zone) + "/clusters/" + fmt.Sprint(req.ClusterID) + "/endpoints", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp AddEndpointsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteEndpoint: Delete the endpoint of a Redis™ Database Instance (Redis™ cluster). You must specify the `region` and `endpoint_id` parameters of the endpoint you want to delete. Note that might need to update any environment configurations that point to the deleted endpoint. func (s *API) DeleteEndpoint(req *DeleteEndpointRequest, opts ...scw.RequestOption) (*Cluster, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.EndpointID) == "" { return nil, errors.New("field EndpointID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/redis/v1/zones/" + fmt.Sprint(req.Zone) + "/endpoints/" + fmt.Sprint(req.EndpointID) + "", } var resp Cluster err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetEndpoint: Retrieve information about a Redis™ Database Instance (Redis™ cluster) endpoint. Full details about the endpoint, like `ips`, `port`, `private_network` and `public_network` specifications are returned in the response. func (s *API) GetEndpoint(req *GetEndpointRequest, opts ...scw.RequestOption) (*Endpoint, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.EndpointID) == "" { return nil, errors.New("field EndpointID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/redis/v1/zones/" + fmt.Sprint(req.Zone) + "/endpoints/" + fmt.Sprint(req.EndpointID) + "", } var resp Endpoint err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateEndpoint: Update information about a Redis™ Database Instance (Redis™ cluster) endpoint. Full details about the endpoint, like `ips`, `port`, `private_network` and `public_network` specifications are returned in the response. func (s *API) UpdateEndpoint(req *UpdateEndpointRequest, opts ...scw.RequestOption) (*Endpoint, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.EndpointID) == "" { return nil, errors.New("field EndpointID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/redis/v1/zones/" + fmt.Sprint(req.Zone) + "/endpoints/" + fmt.Sprint(req.EndpointID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Endpoint err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/redis/v1/redis_utils.go000066400000000000000000000032161456366605600273420ustar00rootroot00000000000000package redis import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) const ( defaultRetryInterval = 15 * time.Second defaultTimeout = 15 * time.Minute ) // WaitForClusterRequest is used by WaitForCluster method. type WaitForClusterRequest struct { ClusterID string Zone scw.Zone Timeout *time.Duration RetryInterval *time.Duration } // WaitForCluster waits for the cluster to be in a "terminal state" before returning. // This function can be used to wait for a cluster to be ready for example. func (s *API) WaitForCluster(req *WaitForClusterRequest, opts ...scw.RequestOption) (*Cluster, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[ClusterStatus]struct{}{ ClusterStatusReady: {}, ClusterStatusLocked: {}, ClusterStatusError: {}, ClusterStatusSuspended: {}, } cluster, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetCluster(&GetClusterRequest{ Zone: req.Zone, ClusterID: req.ClusterID, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.Status] return res, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for cluster failed") } return cluster.(*Cluster), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/registry/000077500000000000000000000000001456366605600246775ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/registry/v1/000077500000000000000000000000001456366605600252255ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/registry/v1/image_utils.go000066400000000000000000000030111456366605600300510ustar00rootroot00000000000000package registry import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) // WaitForNamespaceRequest is used by WaitForNamespace method type WaitForImageRequest struct { ImageID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForImage wait for the image to be in a "terminal state" before returning. // This function can be used to wait for an image to be ready for example. func (s *API) WaitForImage(req *WaitForImageRequest, opts ...scw.RequestOption) (*Image, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[ImageStatus]struct{}{ ImageStatusReady: {}, ImageStatusLocked: {}, ImageStatusError: {}, ImageStatusUnknown: {}, } image, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { img, err := s.GetImage(&GetImageRequest{ Region: req.Region, ImageID: req.ImageID, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[img.Status] return img, isTerminal, err }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for image failed") } return image.(*Image), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/registry/v1/registry_sdk.go000066400000000000000000000767731456366605600303110ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package registry provides methods and message types of the registry v1 API. package registry import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type ImageStatus string const ( ImageStatusUnknown = ImageStatus("unknown") ImageStatusReady = ImageStatus("ready") ImageStatusDeleting = ImageStatus("deleting") ImageStatusError = ImageStatus("error") ImageStatusLocked = ImageStatus("locked") ) func (enum ImageStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum ImageStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ImageStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ImageStatus(ImageStatus(tmp).String()) return nil } type ImageVisibility string const ( ImageVisibilityVisibilityUnknown = ImageVisibility("visibility_unknown") ImageVisibilityInherit = ImageVisibility("inherit") ImageVisibilityPublic = ImageVisibility("public") ImageVisibilityPrivate = ImageVisibility("private") ) func (enum ImageVisibility) String() string { if enum == "" { // return default value if empty return "visibility_unknown" } return string(enum) } func (enum ImageVisibility) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ImageVisibility) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ImageVisibility(ImageVisibility(tmp).String()) return nil } type ListImagesRequestOrderBy string const ( ListImagesRequestOrderByCreatedAtAsc = ListImagesRequestOrderBy("created_at_asc") ListImagesRequestOrderByCreatedAtDesc = ListImagesRequestOrderBy("created_at_desc") ListImagesRequestOrderByNameAsc = ListImagesRequestOrderBy("name_asc") ListImagesRequestOrderByNameDesc = ListImagesRequestOrderBy("name_desc") ) func (enum ListImagesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListImagesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListImagesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListImagesRequestOrderBy(ListImagesRequestOrderBy(tmp).String()) return nil } type ListNamespacesRequestOrderBy string const ( ListNamespacesRequestOrderByCreatedAtAsc = ListNamespacesRequestOrderBy("created_at_asc") ListNamespacesRequestOrderByCreatedAtDesc = ListNamespacesRequestOrderBy("created_at_desc") ListNamespacesRequestOrderByDescriptionAsc = ListNamespacesRequestOrderBy("description_asc") ListNamespacesRequestOrderByDescriptionDesc = ListNamespacesRequestOrderBy("description_desc") ListNamespacesRequestOrderByNameAsc = ListNamespacesRequestOrderBy("name_asc") ListNamespacesRequestOrderByNameDesc = ListNamespacesRequestOrderBy("name_desc") ) func (enum ListNamespacesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListNamespacesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListNamespacesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListNamespacesRequestOrderBy(ListNamespacesRequestOrderBy(tmp).String()) return nil } type ListTagsRequestOrderBy string const ( ListTagsRequestOrderByCreatedAtAsc = ListTagsRequestOrderBy("created_at_asc") ListTagsRequestOrderByCreatedAtDesc = ListTagsRequestOrderBy("created_at_desc") ListTagsRequestOrderByNameAsc = ListTagsRequestOrderBy("name_asc") ListTagsRequestOrderByNameDesc = ListTagsRequestOrderBy("name_desc") ) func (enum ListTagsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListTagsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListTagsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListTagsRequestOrderBy(ListTagsRequestOrderBy(tmp).String()) return nil } type NamespaceStatus string const ( NamespaceStatusUnknown = NamespaceStatus("unknown") NamespaceStatusReady = NamespaceStatus("ready") NamespaceStatusDeleting = NamespaceStatus("deleting") NamespaceStatusError = NamespaceStatus("error") NamespaceStatusLocked = NamespaceStatus("locked") ) func (enum NamespaceStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum NamespaceStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *NamespaceStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = NamespaceStatus(NamespaceStatus(tmp).String()) return nil } type TagStatus string const ( TagStatusUnknown = TagStatus("unknown") TagStatusReady = TagStatus("ready") TagStatusDeleting = TagStatus("deleting") TagStatusError = TagStatus("error") TagStatusLocked = TagStatus("locked") ) func (enum TagStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum TagStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *TagStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = TagStatus(TagStatus(tmp).String()) return nil } // Image: image. type Image struct { // ID: UUID of the image. ID string `json:"id"` // Name: name of the image, it must be unique within the namespace. Name string `json:"name"` // NamespaceID: UUID of the namespace the image belongs to. NamespaceID string `json:"namespace_id"` // Status: status of the image. // Default value: unknown Status ImageStatus `json:"status"` // StatusMessage: details of the image status. StatusMessage *string `json:"status_message"` // Visibility: set to `public` to allow the image to be pulled without authentication. Else, set to `private`. Set to `inherit` to keep the same visibility configuration as the namespace. // Default value: visibility_unknown Visibility ImageVisibility `json:"visibility"` // Size: image size in bytes, calculated from the size of image layers. One layer used in two tags of the same image is counted once but one layer used in two images is counted twice. Size scw.Size `json:"size"` // CreatedAt: date and time of image creation. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date and time of last update. UpdatedAt *time.Time `json:"updated_at"` // Tags: list of docker tags of the image. Tags []string `json:"tags"` } // Namespace: namespace. type Namespace struct { // ID: UUID of the namespace. ID string `json:"id"` // Name: name of the namespace, unique in a region accross all organizations. Name string `json:"name"` // Description: description of the namespace. Description string `json:"description"` // OrganizationID: owner of the namespace. OrganizationID string `json:"organization_id"` // ProjectID: project of the namespace. ProjectID string `json:"project_id"` // Status: namespace status. // Default value: unknown Status NamespaceStatus `json:"status"` // StatusMessage: namespace status details. StatusMessage string `json:"status_message"` // Endpoint: endpoint reachable by docker. Endpoint string `json:"endpoint"` // IsPublic: defines whether or not namespace is public. IsPublic bool `json:"is_public"` // Size: total size of the namespace, calculated as the sum of the size of all images in the namespace. Size scw.Size `json:"size"` // CreatedAt: date and time of creation. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date and time of last update. UpdatedAt *time.Time `json:"updated_at"` // ImageCount: number of images in the namespace. ImageCount uint32 `json:"image_count"` // Region: region the namespace belongs to. Region scw.Region `json:"region"` } // Tag: tag. type Tag struct { // ID: UUID of the tag. ID string `json:"id"` // Name: tag name, unique to an image. Name string `json:"name"` // ImageID: image ID the of the image the tag belongs to. ImageID string `json:"image_id"` // Status: tag status. // Default value: unknown Status TagStatus `json:"status"` // Digest: hash of the tag content. Several tags of a same image may have the same digest. Digest string `json:"digest"` // CreatedAt: date and time of creation. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date and time of last update. UpdatedAt *time.Time `json:"updated_at"` } // CreateNamespaceRequest: create namespace request. type CreateNamespaceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Name: name of the namespace. Name string `json:"name"` // Description: description of the namespace. Description string `json:"description"` // Deprecated: OrganizationID: namespace owner (deprecated). // Precisely one of ProjectID, OrganizationID must be set. OrganizationID *string `json:"organization_id,omitempty"` // ProjectID: project ID on which the namespace will be created. // Precisely one of ProjectID, OrganizationID must be set. ProjectID *string `json:"project_id,omitempty"` // IsPublic: defines whether or not namespace is public. IsPublic bool `json:"is_public"` } // DeleteImageRequest: delete image request. type DeleteImageRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ImageID: UUID of the image. ImageID string `json:"-"` } // DeleteNamespaceRequest: delete namespace request. type DeleteNamespaceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NamespaceID: UUID of the namespace. NamespaceID string `json:"-"` } // DeleteTagRequest: delete tag request. type DeleteTagRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // TagID: UUID of the tag. TagID string `json:"-"` // Deprecated: Force: if two tags share the same digest the deletion will fail unless this parameter is set to true (deprecated). Force *bool `json:"force,omitempty"` } // GetImageRequest: get image request. type GetImageRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ImageID: UUID of the image. ImageID string `json:"-"` } // GetNamespaceRequest: get namespace request. type GetNamespaceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NamespaceID: UUID of the namespace. NamespaceID string `json:"-"` } // GetTagRequest: get tag request. type GetTagRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // TagID: UUID of the tag. TagID string `json:"-"` } // ListImagesRequest: list images request. type ListImagesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: a positive integer to choose the page to display. Page *int32 `json:"-"` // PageSize: a positive integer lower or equal to 100 to select the number of items to display. PageSize *uint32 `json:"-"` // OrderBy: criteria to use when ordering image listings. Possible values are `created_at_asc`, `created_at_desc`, `name_asc`, `name_desc`, `region`, `status_asc` and `status_desc`. The default value is `created_at_asc`. // Default value: created_at_asc OrderBy ListImagesRequestOrderBy `json:"-"` // NamespaceID: filter by the namespace ID. NamespaceID *string `json:"-"` // Name: filter by the image name (exact match). Name *string `json:"-"` // OrganizationID: filter by Organization ID. OrganizationID *string `json:"-"` // ProjectID: filter by Project ID. ProjectID *string `json:"-"` } // ListImagesResponse: list images response. type ListImagesResponse struct { // Images: paginated list of images that match the selected filters. Images []*Image `json:"images"` // TotalCount: total number of images that match the selected filters. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListImagesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListImagesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListImagesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Images = append(r.Images, results.Images...) r.TotalCount += uint32(len(results.Images)) return uint32(len(results.Images)), nil } // ListNamespacesRequest: list namespaces request. type ListNamespacesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: a positive integer to choose the page to display. Page *int32 `json:"-"` // PageSize: a positive integer lower or equal to 100 to select the number of items to display. PageSize *uint32 `json:"-"` // OrderBy: criteria to use when ordering namespace listings. Possible values are `created_at_asc`, `created_at_desc`, `name_asc`, `name_desc`, `region`, `status_asc` and `status_desc`. The default value is `created_at_asc`. // Default value: created_at_asc OrderBy ListNamespacesRequestOrderBy `json:"-"` // OrganizationID: filter by Organization ID. OrganizationID *string `json:"-"` // ProjectID: filter by Project ID. ProjectID *string `json:"-"` // Name: filter by the namespace name (exact match). Name *string `json:"-"` } // ListNamespacesResponse: list namespaces response. type ListNamespacesResponse struct { // Namespaces: paginated list of namespaces that match the selected filters. Namespaces []*Namespace `json:"namespaces"` // TotalCount: total number of namespaces that match the selected filters. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListNamespacesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListNamespacesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListNamespacesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Namespaces = append(r.Namespaces, results.Namespaces...) r.TotalCount += uint32(len(results.Namespaces)) return uint32(len(results.Namespaces)), nil } // ListTagsRequest: list tags request. type ListTagsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ImageID: UUID of the image. ImageID string `json:"-"` // Page: a positive integer to choose the page to display. Page *int32 `json:"-"` // PageSize: a positive integer lower or equal to 100 to select the number of items to display. PageSize *uint32 `json:"-"` // OrderBy: criteria to use when ordering tag listings. Possible values are `created_at_asc`, `created_at_desc`, `name_asc`, `name_desc`, `region`, `status_asc` and `status_desc`. The default value is `created_at_asc`. // Default value: created_at_asc OrderBy ListTagsRequestOrderBy `json:"-"` // Name: filter by the tag name (exact match). Name *string `json:"-"` } // ListTagsResponse: list tags response. type ListTagsResponse struct { // Tags: paginated list of tags that match the selected filters. Tags []*Tag `json:"tags"` // TotalCount: total number of tags that match the selected filters. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListTagsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListTagsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListTagsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Tags = append(r.Tags, results.Tags...) r.TotalCount += uint32(len(results.Tags)) return uint32(len(results.Tags)), nil } // UpdateImageRequest: update image request. type UpdateImageRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ImageID: ID of the image to update. ImageID string `json:"-"` // Visibility: set to `public` to allow the image to be pulled without authentication. Else, set to `private`. Set to `inherit` to keep the same visibility configuration as the namespace. // Default value: visibility_unknown Visibility ImageVisibility `json:"visibility"` } // UpdateNamespaceRequest: update namespace request. type UpdateNamespaceRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // NamespaceID: ID of the namespace to update. NamespaceID string `json:"-"` // Description: namespace description. Description *string `json:"description,omitempty"` // IsPublic: defines whether or not the namespace is public. IsPublic *bool `json:"is_public,omitempty"` } // Container Registry API. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Regions() []scw.Region { return []scw.Region{scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw} } // ListNamespaces: List all namespaces in a specified region. By default, the namespaces listed are ordered by creation date in ascending order. This can be modified via the order_by field. You can also define additional parameters for your query, such as the `instance_id` and `project_id` parameters. func (s *API) ListNamespaces(req *ListNamespacesRequest, opts ...scw.RequestOption) (*ListNamespacesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "name", req.Name) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/registry/v1/regions/" + fmt.Sprint(req.Region) + "/namespaces", Query: query, } var resp ListNamespacesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetNamespace: Retrieve information about a given namespace, specified by its `namespace_id` and region. Full details about the namespace, such as `description`, `project_id`, `status`, `endpoint`, `is_public`, `size`, and `image_count` are returned in the response. func (s *API) GetNamespace(req *GetNamespaceRequest, opts ...scw.RequestOption) (*Namespace, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NamespaceID) == "" { return nil, errors.New("field NamespaceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/registry/v1/regions/" + fmt.Sprint(req.Region) + "/namespaces/" + fmt.Sprint(req.NamespaceID) + "", } var resp Namespace err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateNamespace: Create a new Container Registry namespace. You must specify the namespace name and region in which you want it to be created. Optionally, you can specify the `project_id` and `is_public` in the request payload. func (s *API) CreateNamespace(req *CreateNamespaceRequest, opts ...scw.RequestOption) (*Namespace, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultProjectID, exist := s.client.GetDefaultProjectID() if exist && req.ProjectID == nil && req.OrganizationID == nil { req.ProjectID = &defaultProjectID } defaultOrganizationID, exist := s.client.GetDefaultOrganizationID() if exist && req.ProjectID == nil && req.OrganizationID == nil { req.OrganizationID = &defaultOrganizationID } if req.Name == "" { req.Name = namegenerator.GetRandomName("ns") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/registry/v1/regions/" + fmt.Sprint(req.Region) + "/namespaces", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Namespace err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateNamespace: Update the parameters of a given namespace, specified by its `namespace_id` and `region`. You can update the `description` and `is_public` parameters. func (s *API) UpdateNamespace(req *UpdateNamespaceRequest, opts ...scw.RequestOption) (*Namespace, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NamespaceID) == "" { return nil, errors.New("field NamespaceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/registry/v1/regions/" + fmt.Sprint(req.Region) + "/namespaces/" + fmt.Sprint(req.NamespaceID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Namespace err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteNamespace: Delete a given namespace. You must specify, in the endpoint, the `region` and `namespace_id` parameters of the namespace you want to delete. func (s *API) DeleteNamespace(req *DeleteNamespaceRequest, opts ...scw.RequestOption) (*Namespace, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.NamespaceID) == "" { return nil, errors.New("field NamespaceID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/registry/v1/regions/" + fmt.Sprint(req.Region) + "/namespaces/" + fmt.Sprint(req.NamespaceID) + "", } var resp Namespace err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListImages: List all images in a specified region. By default, the images listed are ordered by creation date in ascending order. This can be modified via the order_by field. You can also define additional parameters for your query, such as the `namespace_id` and `project_id` parameters. func (s *API) ListImages(req *ListImagesRequest, opts ...scw.RequestOption) (*ListImagesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "namespace_id", req.NamespaceID) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/registry/v1/regions/" + fmt.Sprint(req.Region) + "/images", Query: query, } var resp ListImagesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetImage: Retrieve information about a given container image, specified by its `image_id` and region. Full details about the image, such as `name`, `namespace_id`, `status`, `visibility`, and `size` are returned in the response. func (s *API) GetImage(req *GetImageRequest, opts ...scw.RequestOption) (*Image, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ImageID) == "" { return nil, errors.New("field ImageID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/registry/v1/regions/" + fmt.Sprint(req.Region) + "/images/" + fmt.Sprint(req.ImageID) + "", } var resp Image err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateImage: Update the parameters of a given image, specified by its `image_id` and `region`. You can update the `visibility` parameter. func (s *API) UpdateImage(req *UpdateImageRequest, opts ...scw.RequestOption) (*Image, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ImageID) == "" { return nil, errors.New("field ImageID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/registry/v1/regions/" + fmt.Sprint(req.Region) + "/images/" + fmt.Sprint(req.ImageID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Image err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteImage: Delete a given image. You must specify, in the endpoint, the `region` and `image_id` parameters of the image you want to delete. func (s *API) DeleteImage(req *DeleteImageRequest, opts ...scw.RequestOption) (*Image, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ImageID) == "" { return nil, errors.New("field ImageID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/registry/v1/regions/" + fmt.Sprint(req.Region) + "/images/" + fmt.Sprint(req.ImageID) + "", } var resp Image err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListTags: List all tags for a given image, specified by region. By default, the tags listed are ordered by creation date in ascending order. This can be modified via the order_by field. You can also define additional parameters for your query, such as the `name`. func (s *API) ListTags(req *ListTagsRequest, opts ...scw.RequestOption) (*ListTagsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "name", req.Name) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.ImageID) == "" { return nil, errors.New("field ImageID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/registry/v1/regions/" + fmt.Sprint(req.Region) + "/images/" + fmt.Sprint(req.ImageID) + "/tags", Query: query, } var resp ListTagsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetTag: Retrieve information about a given image tag, specified by its `tag_id` and region. Full details about the tag, such as `name`, `image_id`, `status`, and `digest` are returned in the response. func (s *API) GetTag(req *GetTagRequest, opts ...scw.RequestOption) (*Tag, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.TagID) == "" { return nil, errors.New("field TagID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/registry/v1/regions/" + fmt.Sprint(req.Region) + "/tags/" + fmt.Sprint(req.TagID) + "", } var resp Tag err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteTag: Delete a given image tag. You must specify, in the endpoint, the `region` and `tag_id` parameters of the tag you want to delete. func (s *API) DeleteTag(req *DeleteTagRequest, opts ...scw.RequestOption) (*Tag, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } query := url.Values{} parameter.AddToQuery(query, "force", req.Force) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.TagID) == "" { return nil, errors.New("field TagID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/registry/v1/regions/" + fmt.Sprint(req.Region) + "/tags/" + fmt.Sprint(req.TagID) + "", Query: query, } var resp Tag err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/registry/v1/registry_utils.go000066400000000000000000000032651456366605600306520ustar00rootroot00000000000000package registry import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) const ( defaultTimeout = 5 * time.Minute defaultRetryInterval = 15 * time.Second ) // WaitForNamespaceRequest is used by WaitForNamespace method type WaitForNamespaceRequest struct { NamespaceID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForNamespace wait for the namespace to be in a "terminal state" before returning. // This function can be used to wait for a namespace to be ready for example. func (s *API) WaitForNamespace(req *WaitForNamespaceRequest, opts ...scw.RequestOption) (*Namespace, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[NamespaceStatus]struct{}{ NamespaceStatusReady: {}, NamespaceStatusLocked: {}, NamespaceStatusError: {}, NamespaceStatusUnknown: {}, } namespace, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { ns, err := s.GetNamespace(&GetNamespaceRequest{ Region: req.Region, NamespaceID: req.NamespaceID, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[ns.Status] return ns, isTerminal, err }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for namespace failed") } return namespace.(*Namespace), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/registry/v1/tag_utils.go000066400000000000000000000027161456366605600275550ustar00rootroot00000000000000package registry import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) // WaitForTagRequest is used by WaitForTag method type WaitForTagRequest struct { TagID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForTag wait for the tag to be in a "terminal state" before returning. // This function can be used to wait for a tag to be ready for example. func (s *API) WaitForTag(req *WaitForTagRequest, opts ...scw.RequestOption) (*Tag, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[TagStatus]struct{}{ TagStatusReady: {}, TagStatusLocked: {}, TagStatusError: {}, TagStatusUnknown: {}, } tag, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { t, err := s.GetTag(&GetTagRequest{ Region: req.Region, TagID: req.TagID, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[t.Status] return t, isTerminal, err }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for tag failed") } return tag.(*Tag), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/secret/000077500000000000000000000000001456366605600243145ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/secret/v1alpha1/000077500000000000000000000000001456366605600257315ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/secret/v1alpha1/secret_sdk.go000066400000000000000000001620431456366605600304140ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package secret provides methods and message types of the secret v1alpha1 API. package secret import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type EphemeralPolicyAction string const ( EphemeralPolicyActionUnknownAction = EphemeralPolicyAction("unknown_action") // The version is deleted once it expires. EphemeralPolicyActionDelete = EphemeralPolicyAction("delete") // The version is disabled once it expires. EphemeralPolicyActionDisable = EphemeralPolicyAction("disable") ) func (enum EphemeralPolicyAction) String() string { if enum == "" { // return default value if empty return "unknown_action" } return string(enum) } func (enum EphemeralPolicyAction) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *EphemeralPolicyAction) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = EphemeralPolicyAction(EphemeralPolicyAction(tmp).String()) return nil } type ListFoldersRequestOrderBy string const ( ListFoldersRequestOrderByCreatedAtAsc = ListFoldersRequestOrderBy("created_at_asc") ListFoldersRequestOrderByCreatedAtDesc = ListFoldersRequestOrderBy("created_at_desc") ListFoldersRequestOrderByNameAsc = ListFoldersRequestOrderBy("name_asc") ListFoldersRequestOrderByNameDesc = ListFoldersRequestOrderBy("name_desc") ) func (enum ListFoldersRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListFoldersRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListFoldersRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListFoldersRequestOrderBy(ListFoldersRequestOrderBy(tmp).String()) return nil } type ListSecretsRequestOrderBy string const ( ListSecretsRequestOrderByNameAsc = ListSecretsRequestOrderBy("name_asc") ListSecretsRequestOrderByNameDesc = ListSecretsRequestOrderBy("name_desc") ListSecretsRequestOrderByCreatedAtAsc = ListSecretsRequestOrderBy("created_at_asc") ListSecretsRequestOrderByCreatedAtDesc = ListSecretsRequestOrderBy("created_at_desc") ListSecretsRequestOrderByUpdatedAtAsc = ListSecretsRequestOrderBy("updated_at_asc") ListSecretsRequestOrderByUpdatedAtDesc = ListSecretsRequestOrderBy("updated_at_desc") ) func (enum ListSecretsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "name_asc" } return string(enum) } func (enum ListSecretsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListSecretsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListSecretsRequestOrderBy(ListSecretsRequestOrderBy(tmp).String()) return nil } type Product string const ( ProductUnknown = Product("unknown") ProductEdgeServices = Product("edge_services") ) func (enum Product) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum Product) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *Product) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = Product(Product(tmp).String()) return nil } type SecretStatus string const ( SecretStatusReady = SecretStatus("ready") SecretStatusLocked = SecretStatus("locked") ) func (enum SecretStatus) String() string { if enum == "" { // return default value if empty return "ready" } return string(enum) } func (enum SecretStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *SecretStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = SecretStatus(SecretStatus(tmp).String()) return nil } type SecretType string const ( SecretTypeUnknownSecretType = SecretType("unknown_secret_type") // Default type. SecretTypeOpaque = SecretType("opaque") // List of concatenated PEM blocks. They can contain certificates, private keys or any other PEM block types. SecretTypeCertificate = SecretType("certificate") // Flat JSON that allows you to set any number of first level key and a scalar type as a value (string, numeric, boolean). SecretTypeKeyValue = SecretType("key_value") ) func (enum SecretType) String() string { if enum == "" { // return default value if empty return "unknown_secret_type" } return string(enum) } func (enum SecretType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *SecretType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = SecretType(SecretType(tmp).String()) return nil } type SecretVersionStatus string const ( SecretVersionStatusUnknown = SecretVersionStatus("unknown") SecretVersionStatusEnabled = SecretVersionStatus("enabled") SecretVersionStatusDisabled = SecretVersionStatus("disabled") SecretVersionStatusDestroyed = SecretVersionStatus("destroyed") ) func (enum SecretVersionStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum SecretVersionStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *SecretVersionStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = SecretVersionStatus(SecretVersionStatus(tmp).String()) return nil } // EphemeralProperties: ephemeral properties. type EphemeralProperties struct { // ExpiresAt: (Optional.) If not specified, the version does not have an expiration date. ExpiresAt *time.Time `json:"expires_at"` // ExpiresOnceAccessed: (Optional.) If not specified, the version can be accessed an unlimited amount of times. ExpiresOnceAccessed *bool `json:"expires_once_accessed"` // Action: see `EphemeralPolicy.Action` enum for a description of values. // Default value: unknown_action Action EphemeralPolicyAction `json:"action"` } // EphemeralPolicy: ephemeral policy. type EphemeralPolicy struct { // TimeToLive: time frame, from one second and up to one year, during which the secret's versions are valid. TimeToLive *scw.Duration `json:"time_to_live"` // ExpiresOnceAccessed: returns `true` if the version expires after a single user access. ExpiresOnceAccessed *bool `json:"expires_once_accessed"` // Action: see the `EphemeralPolicy.Action` enum for a description of values. // Default value: unknown_action Action EphemeralPolicyAction `json:"action"` } // PasswordGenerationParams: password generation params. type PasswordGenerationParams struct { // Length: length of the password to generate (between 1 and 1024). Length uint32 `json:"length"` // NoLowercaseLetters: do not include lower case letters by default in the alphabet. NoLowercaseLetters bool `json:"no_lowercase_letters"` // NoUppercaseLetters: do not include upper case letters by default in the alphabet. NoUppercaseLetters bool `json:"no_uppercase_letters"` // NoDigits: do not include digits by default in the alphabet. NoDigits bool `json:"no_digits"` // AdditionalChars: additional ascii characters to be included in the alphabet. AdditionalChars string `json:"additional_chars"` } // Folder: folder. type Folder struct { // ID: ID of the folder. ID string `json:"id"` // ProjectID: ID of the Project containing the folder. ProjectID string `json:"project_id"` // Name: name of the folder. Name string `json:"name"` // Path: location of the folder in the directory structure. Path string `json:"path"` // CreatedAt: date and time of the folder's creation. CreatedAt *time.Time `json:"created_at"` // Region: region of the folder. Region scw.Region `json:"region"` } // SecretVersion: secret version. type SecretVersion struct { // Revision: the first version of the secret is numbered 1, and all subsequent revisions augment by 1. Revision uint32 `json:"revision"` // SecretID: ID of the secret. SecretID string `json:"secret_id"` // Status: * `unknown`: the version is in an invalid state. // * `enabled`: the version is accessible. // * `disabled`: the version is not accessible but can be enabled. // * `destroyed`: the version is permanently deleted. It is not possible to recover it. // Default value: unknown Status SecretVersionStatus `json:"status"` // CreatedAt: date and time of the version's creation. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: last update of the version. UpdatedAt *time.Time `json:"updated_at"` // Description: description of the version. Description *string `json:"description"` // IsLatest: returns `true` if the version is the latest. IsLatest bool `json:"is_latest"` // EphemeralProperties: returns the version's expiration date, whether it expires after being accessed once, and the action to perform (disable or delete) once the version expires. EphemeralProperties *EphemeralProperties `json:"ephemeral_properties"` } // Secret: secret. type Secret struct { // ID: ID of the secret. ID string `json:"id"` // ProjectID: ID of the Project containing the secret. ProjectID string `json:"project_id"` // Name: name of the secret. Name string `json:"name"` // Status: * `ready`: the secret can be read, modified and deleted. // * `locked`: no action can be performed on the secret. This status can only be applied and removed by Scaleway. // Default value: ready Status SecretStatus `json:"status"` // CreatedAt: date and time of the secret's creation. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: last update of the secret. UpdatedAt *time.Time `json:"updated_at"` // Tags: list of the secret's tags. Tags []string `json:"tags"` // VersionCount: number of versions for this secret. VersionCount uint32 `json:"version_count"` // Description: updated description of the secret. Description *string `json:"description"` // IsManaged: returns `true` for secrets that are managed by another product. IsManaged bool `json:"is_managed"` // IsProtected: returns `true` for protected secrets that cannot be deleted. IsProtected bool `json:"is_protected"` // Type: see `Secret.Type` enum for description of values. // Default value: unknown_secret_type Type SecretType `json:"type"` // Path: location of the secret in the directory structure. Path string `json:"path"` // EphemeralPolicy: (Optional.) Policy that defines whether/when a secret's versions expire. By default, the policy is applied to all the secret's versions. EphemeralPolicy *EphemeralPolicy `json:"ephemeral_policy"` // Region: region of the secret. Region scw.Region `json:"region"` } // AccessSecretVersionByNameRequest: access secret version by name request. type AccessSecretVersionByNameRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretName: name of the secret. SecretName string `json:"-"` // Revision: the first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be either: // - a number (the revision number) // - "latest" (the latest revision) // - "latest_enabled" (the latest enabled revision). Revision string `json:"-"` // ProjectID: (Optional.) If not specified, Secret Manager will look for the secret version in all Projects. ProjectID *string `json:"project_id,omitempty"` } // AccessSecretVersionRequest: access secret version request. type AccessSecretVersionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` // Revision: the first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be either: // - a number (the revision number) // - "latest" (the latest revision) // - "latest_enabled" (the latest enabled revision). Revision string `json:"-"` } // AccessSecretVersionResponse: access secret version response. type AccessSecretVersionResponse struct { // SecretID: ID of the secret. SecretID string `json:"secret_id"` // Revision: the first version of the secret is numbered 1, and all subsequent revisions augment by 1. Revision uint32 `json:"revision"` // Data: the base64-encoded secret payload of the version. Data []byte `json:"data"` // DataCrc32: this field is only available if a CRC32 was supplied during the creation of the version. DataCrc32 *uint32 `json:"data_crc32"` } // AddSecretOwnerRequest: add secret owner request. type AddSecretOwnerRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` // Deprecated: ProductName: (Deprecated: use `product` field) Name of the product to add. ProductName *string `json:"product_name,omitempty"` // Product: see `Product` enum for description of values. // Default value: unknown Product Product `json:"product"` } // CreateFolderRequest: create folder request. type CreateFolderRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: ID of the Project containing the folder. ProjectID string `json:"project_id"` // Name: name of the folder. Name string `json:"name"` // Path: (Optional.) Location of the folder in the directory structure. If not specified, the path is `/`. Path *string `json:"path,omitempty"` } // CreateSecretRequest: create secret request. type CreateSecretRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: ID of the Project containing the secret. ProjectID string `json:"project_id"` // Name: name of the secret. Name string `json:"name"` // Tags: list of the secret's tags. Tags []string `json:"tags"` // Description: description of the secret. Description *string `json:"description,omitempty"` // Type: (Optional.) See `Secret.Type` enum for description of values. If not specified, the type is `Opaque`. // Default value: unknown_secret_type Type SecretType `json:"type"` // Path: (Optional.) Location of the secret in the directory structure. If not specified, the path is `/`. Path *string `json:"path,omitempty"` // EphemeralPolicy: (Optional.) Policy that defines whether/when a secret's versions expire. By default, the policy is applied to all the secret's versions. EphemeralPolicy *EphemeralPolicy `json:"ephemeral_policy,omitempty"` // IsProtected: a protected secret cannot be deleted. IsProtected bool `json:"is_protected"` } // CreateSecretVersionRequest: create secret version request. type CreateSecretVersionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` // Data: the base64-encoded secret payload of the version. Data []byte `json:"data"` // Description: description of the version. Description *string `json:"description,omitempty"` // DisablePrevious: (Optional.) If there is no previous version or if the previous version was already disabled, does nothing. DisablePrevious *bool `json:"disable_previous,omitempty"` // Deprecated: PasswordGeneration: (Optional.) If specified, a random password will be generated. The `data` and `data_crc32` fields must be empty. By default, the generator will use upper and lower case letters, and digits. This behavior can be tuned using the generation parameters. PasswordGeneration *PasswordGenerationParams `json:"password_generation,omitempty"` // DataCrc32: if specified, Secret Manager will verify the integrity of the data received against the given CRC32 checksum. An error is returned if the CRC32 does not match. If, however, the CRC32 matches, it will be stored and returned along with the SecretVersion on future access requests. DataCrc32 *uint32 `json:"data_crc32,omitempty"` } // DeleteFolderRequest: delete folder request. type DeleteFolderRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // FolderID: ID of the folder. FolderID string `json:"-"` } // DeleteSecretRequest: delete secret request. type DeleteSecretRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` } // DestroySecretVersionRequest: destroy secret version request. type DestroySecretVersionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` // Revision: the first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be either: // - a number (the revision number) // - "latest" (the latest revision) // - "latest_enabled" (the latest enabled revision). Revision string `json:"-"` } // DisableSecretVersionRequest: disable secret version request. type DisableSecretVersionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` // Revision: the first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be either: // - a number (the revision number) // - "latest" (the latest revision) // - "latest_enabled" (the latest enabled revision). Revision string `json:"-"` } // EnableSecretVersionRequest: enable secret version request. type EnableSecretVersionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` // Revision: the first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be either: // - a number (the revision number) // - "latest" (the latest revision) // - "latest_enabled" (the latest enabled revision). Revision string `json:"-"` } // GeneratePasswordRequest: generate password request. type GeneratePasswordRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` // Description: description of the version. Description *string `json:"description,omitempty"` // DisablePrevious: this has no effect if there is no previous version or if the previous version was already disabled. DisablePrevious *bool `json:"disable_previous,omitempty"` // Length: length of the password to generate (between 1 and 1024 characters). Length uint32 `json:"length"` // NoLowercaseLetters: (Optional.) Exclude lower case letters by default in the password character set. NoLowercaseLetters *bool `json:"no_lowercase_letters,omitempty"` // NoUppercaseLetters: (Optional.) Exclude upper case letters by default in the password character set. NoUppercaseLetters *bool `json:"no_uppercase_letters,omitempty"` // NoDigits: (Optional.) Exclude digits by default in the password character set. NoDigits *bool `json:"no_digits,omitempty"` // AdditionalChars: (Optional.) Additional ASCII characters to be included in the password character set. AdditionalChars *string `json:"additional_chars,omitempty"` } // GetSecretByNameRequest: get secret by name request. type GetSecretByNameRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretName: name of the secret. SecretName string `json:"-"` // ProjectID: (Optional.) If not specified, Secret Manager will look for the secret in all Projects. ProjectID *string `json:"project_id,omitempty"` } // GetSecretRequest: get secret request. type GetSecretRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` } // GetSecretVersionByNameRequest: get secret version by name request. type GetSecretVersionByNameRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretName: name of the secret. SecretName string `json:"-"` // Revision: the first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be either: // - a number (the revision number) // - "latest" (the latest revision) // - "latest_enabled" (the latest enabled revision). Revision string `json:"-"` // ProjectID: (Optional.) If not specified, Secret Manager will look for the secret version in all Projects. ProjectID *string `json:"project_id,omitempty"` } // GetSecretVersionRequest: get secret version request. type GetSecretVersionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` // Revision: the first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be either: // - a number (the revision number) // - "latest" (the latest revision) // - "latest_enabled" (the latest enabled revision). Revision string `json:"-"` } // ListFoldersRequest: list folders request. type ListFoldersRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: filter by Project ID (optional). ProjectID *string `json:"-"` // Path: filter by path (optional). Path *string `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` // OrderBy: default value: created_at_asc OrderBy ListFoldersRequestOrderBy `json:"-"` } // ListFoldersResponse: list folders response. type ListFoldersResponse struct { // Folders: list of folders. Folders []*Folder `json:"folders"` // TotalCount: count of all folders matching the requested criteria. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListFoldersResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListFoldersResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListFoldersResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Folders = append(r.Folders, results.Folders...) r.TotalCount += uint32(len(results.Folders)) return uint32(len(results.Folders)), nil } // ListSecretVersionsByNameRequest: list secret versions by name request. type ListSecretVersionsByNameRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretName: name of the secret. SecretName string `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` // Status: filter results by status. Status []SecretVersionStatus `json:"-"` // ProjectID: (Optional.) If not specified, Secret Manager will look for the secret in all Projects. ProjectID *string `json:"-"` } // ListSecretVersionsRequest: list secret versions request. type ListSecretVersionsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` // Status: filter results by status. Status []SecretVersionStatus `json:"-"` } // ListSecretVersionsResponse: list secret versions response. type ListSecretVersionsResponse struct { // Versions: single page of versions. Versions []*SecretVersion `json:"versions"` // TotalCount: number of versions. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListSecretVersionsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListSecretVersionsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListSecretVersionsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Versions = append(r.Versions, results.Versions...) r.TotalCount += uint32(len(results.Versions)) return uint32(len(results.Versions)), nil } // ListSecretsRequest: list secrets request. type ListSecretsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // OrganizationID: filter by Organization ID (optional). OrganizationID *string `json:"-"` // ProjectID: filter by Project ID (optional). ProjectID *string `json:"-"` // OrderBy: default value: name_asc OrderBy ListSecretsRequestOrderBy `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` // Tags: list of tags to filter on (optional). Tags []string `json:"-"` // Name: filter by secret name (optional). Name *string `json:"-"` // IsManaged: filter by managed / not managed (optional). IsManaged *bool `json:"-"` // Path: filter by path (optional). Path *string `json:"-"` // IsEphemeral: filter by ephemeral / not ephemeral (optional). IsEphemeral *bool `json:"-"` } // ListSecretsResponse: list secrets response. type ListSecretsResponse struct { // Secrets: single page of secrets matching the requested criteria. Secrets []*Secret `json:"secrets"` // TotalCount: count of all secrets matching the requested criteria. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListSecretsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListSecretsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListSecretsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Secrets = append(r.Secrets, results.Secrets...) r.TotalCount += uint32(len(results.Secrets)) return uint32(len(results.Secrets)), nil } // ListTagsRequest: list tags request. type ListTagsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: (Optional.) If not specified, Secret Manager will look for tags in all Projects. ProjectID *string `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` } // ListTagsResponse: list tags response. type ListTagsResponse struct { // Tags: list of tags. Tags []string `json:"tags"` // TotalCount: count of all tags matching the requested criteria. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListTagsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListTagsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListTagsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Tags = append(r.Tags, results.Tags...) r.TotalCount += uint32(len(results.Tags)) return uint32(len(results.Tags)), nil } // ProtectSecretRequest: protect secret request. type ProtectSecretRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret to protect. SecretID string `json:"-"` } // UnprotectSecretRequest: unprotect secret request. type UnprotectSecretRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret to unprotect. SecretID string `json:"-"` } // UpdateSecretRequest: update secret request. type UpdateSecretRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` // Name: secret's updated name (optional). Name *string `json:"name,omitempty"` // Tags: secret's updated list of tags (optional). Tags *[]string `json:"tags,omitempty"` // Description: description of the secret. Description *string `json:"description,omitempty"` // Path: (Optional.) Location of the folder in the directory structure. If not specified, the path is `/`. Path *string `json:"path,omitempty"` // EphemeralPolicy: (Optional.) Policy that defines whether/when a secret's versions expire. EphemeralPolicy *EphemeralPolicy `json:"ephemeral_policy,omitempty"` } // UpdateSecretVersionRequest: update secret version request. type UpdateSecretVersionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` // Revision: the first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be either: // - a number (the revision number) // - "latest" (the latest revision) // - "latest_enabled" (the latest enabled revision). Revision string `json:"-"` // Description: description of the version. Description *string `json:"description,omitempty"` // EphemeralProperties: (Optional.) Properties that defines the version's expiration date, whether it expires after being accessed once, and the action to perform (disable or delete) once the version expires. EphemeralProperties *EphemeralProperties `json:"ephemeral_properties,omitempty"` } // This API allows you to conveniently store, access and share sensitive data. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Regions() []scw.Region { return []scw.Region{scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw} } // CreateSecret: You must specify the `region` to create a secret. func (s *API) CreateSecret(req *CreateSecretRequest, opts ...scw.RequestOption) (*Secret, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/secrets", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Secret err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateFolder: Create folder. func (s *API) CreateFolder(req *CreateFolderRequest, opts ...scw.RequestOption) (*Folder, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/folders", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Folder err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetSecret: Retrieve the metadata of a secret specified by the `region` and `secret_id` parameters. func (s *API) GetSecret(req *GetSecretRequest, opts ...scw.RequestOption) (*Secret, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "", } var resp Secret err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // Deprecated: GetSecretByName: Retrieve the metadata of a secret specified by the `region` and `secret_name` parameters. // // GetSecretByName usage is now deprecated. // // Scaleway recommends that you use the `ListSecrets` request with the `name` filter. func (s *API) GetSecretByName(req *GetSecretByNameRequest, opts ...scw.RequestOption) (*Secret, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } query := url.Values{} parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretName) == "" { return nil, errors.New("field SecretName cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/secrets-by-name/" + fmt.Sprint(req.SecretName) + "", Query: query, } var resp Secret err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateSecret: Edit a secret's metadata such as name, tag(s), description and ephemeral policy. The secret to update is specified by the `secret_id` and `region` parameters. func (s *API) UpdateSecret(req *UpdateSecretRequest, opts ...scw.RequestOption) (*Secret, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Secret err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListSecrets: Retrieve the list of secrets created within an Organization and/or Project. You must specify either the `organization_id` or the `project_id` and the `region`. func (s *API) ListSecrets(req *ListSecretsRequest, opts ...scw.RequestOption) (*ListSecretsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "tags", req.Tags) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "is_managed", req.IsManaged) parameter.AddToQuery(query, "path", req.Path) parameter.AddToQuery(query, "is_ephemeral", req.IsEphemeral) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/secrets", Query: query, } var resp ListSecretsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListFolders: Retrieve the list of folders created within a Project. func (s *API) ListFolders(req *ListFoldersRequest, opts ...scw.RequestOption) (*ListFoldersResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "path", req.Path) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/folders", Query: query, } var resp ListFoldersResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteSecret: Delete a given secret specified by the `region` and `secret_id` parameters. func (s *API) DeleteSecret(req *DeleteSecretRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return errors.New("field SecretID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // DeleteFolder: Delete a given folder specified by the `region` and `folder_id` parameters. func (s *API) DeleteFolder(req *DeleteFolderRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.FolderID) == "" { return errors.New("field FolderID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/folders/" + fmt.Sprint(req.FolderID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ProtectSecret: Protect a given secret specified by the `secret_id` parameter. A protected secret can be read and modified but cannot be deleted. func (s *API) ProtectSecret(req *ProtectSecretRequest, opts ...scw.RequestOption) (*Secret, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "/protect", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Secret err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UnprotectSecret: Unprotect a given secret specified by the `secret_id` parameter. An unprotected secret can be read, modified and deleted. func (s *API) UnprotectSecret(req *UnprotectSecretRequest, opts ...scw.RequestOption) (*Secret, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "/unprotect", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Secret err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // AddSecretOwner: Allow a product to use the secret. func (s *API) AddSecretOwner(req *AddSecretOwnerRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return errors.New("field SecretID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "/add-owner", } err = scwReq.SetBody(req) if err != nil { return err } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // CreateSecretVersion: Create a version of a given secret specified by the `region` and `secret_id` parameters. func (s *API) CreateSecretVersion(req *CreateSecretVersionRequest, opts ...scw.RequestOption) (*SecretVersion, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "/versions", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SecretVersion err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GeneratePassword: Generate a password for the given secret specified by the `region` and `secret_id` parameters. This will also create a new version of the secret that will store the password. func (s *API) GeneratePassword(req *GeneratePasswordRequest, opts ...scw.RequestOption) (*SecretVersion, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "/generate-password", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SecretVersion err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetSecretVersion: Retrieve the metadata of a secret's given version specified by the `region`, `secret_id` and `revision` parameters. func (s *API) GetSecretVersion(req *GetSecretVersionRequest, opts ...scw.RequestOption) (*SecretVersion, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } if fmt.Sprint(req.Revision) == "" { return nil, errors.New("field Revision cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "/versions/" + fmt.Sprint(req.Revision) + "", } var resp SecretVersion err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // Deprecated: GetSecretVersionByName: Retrieve the metadata of a secret's given version specified by the `region`, `secret_name`, `revision` and `project_id` parameters. // // This method is deprecated. // // Scaleway recommends that you use the `ListSecrets` request with the `name` filter to specify the secret version desired, then use the `GetSecretVersion` request. func (s *API) GetSecretVersionByName(req *GetSecretVersionByNameRequest, opts ...scw.RequestOption) (*SecretVersion, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } query := url.Values{} parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretName) == "" { return nil, errors.New("field SecretName cannot be empty in request") } if fmt.Sprint(req.Revision) == "" { return nil, errors.New("field Revision cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/secrets-by-name/" + fmt.Sprint(req.SecretName) + "/versions/" + fmt.Sprint(req.Revision) + "", Query: query, } var resp SecretVersion err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateSecretVersion: Edit the metadata of a secret's given version, specified by the `region`, `secret_id` and `revision` parameters. func (s *API) UpdateSecretVersion(req *UpdateSecretVersionRequest, opts ...scw.RequestOption) (*SecretVersion, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } if fmt.Sprint(req.Revision) == "" { return nil, errors.New("field Revision cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "/versions/" + fmt.Sprint(req.Revision) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SecretVersion err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListSecretVersions: Retrieve the list of a given secret's versions specified by the `secret_id` and `region` parameters. func (s *API) ListSecretVersions(req *ListSecretVersionsRequest, opts ...scw.RequestOption) (*ListSecretVersionsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "status", req.Status) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "/versions", Query: query, } var resp ListSecretVersionsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // Deprecated: ListSecretVersionsByName: Retrieve the list of a given secret's versions specified by the `secret_name`,`region` and `project_id` parameters. // // This method is deprecated. // // Scaleway recommends that you use the `ListSecrets` request with the `name` filter to specify the secret version desired, then use the `ListSecretVersions` request. func (s *API) ListSecretVersionsByName(req *ListSecretVersionsByNameRequest, opts ...scw.RequestOption) (*ListSecretVersionsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "status", req.Status) parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretName) == "" { return nil, errors.New("field SecretName cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/secrets-by-name/" + fmt.Sprint(req.SecretName) + "/versions", Query: query, } var resp ListSecretVersionsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // EnableSecretVersion: Make a specific version accessible. You must specify the `region`, `secret_id` and `revision` parameters. func (s *API) EnableSecretVersion(req *EnableSecretVersionRequest, opts ...scw.RequestOption) (*SecretVersion, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } if fmt.Sprint(req.Revision) == "" { return nil, errors.New("field Revision cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "/versions/" + fmt.Sprint(req.Revision) + "/enable", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SecretVersion err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DisableSecretVersion: Make a specific version inaccessible. You must specify the `region`, `secret_id` and `revision` parameters. func (s *API) DisableSecretVersion(req *DisableSecretVersionRequest, opts ...scw.RequestOption) (*SecretVersion, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } if fmt.Sprint(req.Revision) == "" { return nil, errors.New("field Revision cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "/versions/" + fmt.Sprint(req.Revision) + "/disable", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SecretVersion err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // AccessSecretVersion: Access sensitive data in a secret's version specified by the `region`, `secret_id` and `revision` parameters. func (s *API) AccessSecretVersion(req *AccessSecretVersionRequest, opts ...scw.RequestOption) (*AccessSecretVersionResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } if fmt.Sprint(req.Revision) == "" { return nil, errors.New("field Revision cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "/versions/" + fmt.Sprint(req.Revision) + "/access", } var resp AccessSecretVersionResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // Deprecated: AccessSecretVersionByName: Access sensitive data in a secret's version specified by the `region`, `secret_name`, `revision` and `project_id` parameters. // // This method is deprecated. // // Scaleway recommends that you use the `ListSecrets` request with the `name` filter to specify the secret version desired, then use the `AccessSecretVersion` request. func (s *API) AccessSecretVersionByName(req *AccessSecretVersionByNameRequest, opts ...scw.RequestOption) (*AccessSecretVersionResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } query := url.Values{} parameter.AddToQuery(query, "project_id", req.ProjectID) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretName) == "" { return nil, errors.New("field SecretName cannot be empty in request") } if fmt.Sprint(req.Revision) == "" { return nil, errors.New("field Revision cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/secrets-by-name/" + fmt.Sprint(req.SecretName) + "/versions/" + fmt.Sprint(req.Revision) + "/access", Query: query, } var resp AccessSecretVersionResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DestroySecretVersion: Delete a secret's version and the sensitive data contained in it. Deleting a version is permanent and cannot be undone. func (s *API) DestroySecretVersion(req *DestroySecretVersionRequest, opts ...scw.RequestOption) (*SecretVersion, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } if fmt.Sprint(req.Revision) == "" { return nil, errors.New("field Revision cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "/versions/" + fmt.Sprint(req.Revision) + "/destroy", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SecretVersion err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListTags: List all tags associated with secrets within a given Project. func (s *API) ListTags(req *ListTagsRequest, opts ...scw.RequestOption) (*ListTagsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/secret-manager/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/tags", Query: query, } var resp ListTagsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/secret/v1beta1/000077500000000000000000000000001456366605600255575ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/secret/v1beta1/secret_sdk.go000066400000000000000000001242741456366605600302460ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package secret provides methods and message types of the secret v1beta1 API. package secret import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type BrowseSecretsRequestOrderBy string const ( BrowseSecretsRequestOrderByNameAsc = BrowseSecretsRequestOrderBy("name_asc") BrowseSecretsRequestOrderByNameDesc = BrowseSecretsRequestOrderBy("name_desc") BrowseSecretsRequestOrderByCreatedAtAsc = BrowseSecretsRequestOrderBy("created_at_asc") BrowseSecretsRequestOrderByCreatedAtDesc = BrowseSecretsRequestOrderBy("created_at_desc") BrowseSecretsRequestOrderByUpdatedAtAsc = BrowseSecretsRequestOrderBy("updated_at_asc") BrowseSecretsRequestOrderByUpdatedAtDesc = BrowseSecretsRequestOrderBy("updated_at_desc") ) func (enum BrowseSecretsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "name_asc" } return string(enum) } func (enum BrowseSecretsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *BrowseSecretsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = BrowseSecretsRequestOrderBy(BrowseSecretsRequestOrderBy(tmp).String()) return nil } type EphemeralPolicyAction string const ( EphemeralPolicyActionUnknownAction = EphemeralPolicyAction("unknown_action") // The version is deleted once it expires. EphemeralPolicyActionDelete = EphemeralPolicyAction("delete") // The version is disabled once it expires. EphemeralPolicyActionDisable = EphemeralPolicyAction("disable") ) func (enum EphemeralPolicyAction) String() string { if enum == "" { // return default value if empty return "unknown_action" } return string(enum) } func (enum EphemeralPolicyAction) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *EphemeralPolicyAction) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = EphemeralPolicyAction(EphemeralPolicyAction(tmp).String()) return nil } type ListSecretsRequestOrderBy string const ( ListSecretsRequestOrderByNameAsc = ListSecretsRequestOrderBy("name_asc") ListSecretsRequestOrderByNameDesc = ListSecretsRequestOrderBy("name_desc") ListSecretsRequestOrderByCreatedAtAsc = ListSecretsRequestOrderBy("created_at_asc") ListSecretsRequestOrderByCreatedAtDesc = ListSecretsRequestOrderBy("created_at_desc") ListSecretsRequestOrderByUpdatedAtAsc = ListSecretsRequestOrderBy("updated_at_asc") ListSecretsRequestOrderByUpdatedAtDesc = ListSecretsRequestOrderBy("updated_at_desc") ) func (enum ListSecretsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "name_asc" } return string(enum) } func (enum ListSecretsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListSecretsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListSecretsRequestOrderBy(ListSecretsRequestOrderBy(tmp).String()) return nil } type Product string const ( ProductUnknownProduct = Product("unknown_product") ProductEdgeServices = Product("edge_services") ) func (enum Product) String() string { if enum == "" { // return default value if empty return "unknown_product" } return string(enum) } func (enum Product) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *Product) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = Product(Product(tmp).String()) return nil } type SecretStatus string const ( SecretStatusUnknownStatus = SecretStatus("unknown_status") SecretStatusReady = SecretStatus("ready") SecretStatusLocked = SecretStatus("locked") ) func (enum SecretStatus) String() string { if enum == "" { // return default value if empty return "unknown_status" } return string(enum) } func (enum SecretStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *SecretStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = SecretStatus(SecretStatus(tmp).String()) return nil } type SecretType string const ( SecretTypeUnknownType = SecretType("unknown_type") // Default type. SecretTypeOpaque = SecretType("opaque") // List of concatenated PEM blocks. They can contain certificates, private keys or any other PEM block types. SecretTypeCertificate = SecretType("certificate") // Flat JSON that allows you to set any number of first level key and a scalar type as a value (string, numeric, boolean). SecretTypeKeyValue = SecretType("key_value") ) func (enum SecretType) String() string { if enum == "" { // return default value if empty return "unknown_type" } return string(enum) } func (enum SecretType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *SecretType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = SecretType(SecretType(tmp).String()) return nil } type SecretVersionStatus string const ( SecretVersionStatusUnknownStatus = SecretVersionStatus("unknown_status") SecretVersionStatusEnabled = SecretVersionStatus("enabled") SecretVersionStatusDisabled = SecretVersionStatus("disabled") SecretVersionStatusDeleted = SecretVersionStatus("deleted") ) func (enum SecretVersionStatus) String() string { if enum == "" { // return default value if empty return "unknown_status" } return string(enum) } func (enum SecretVersionStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *SecretVersionStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = SecretVersionStatus(SecretVersionStatus(tmp).String()) return nil } // EphemeralPolicy: ephemeral policy. type EphemeralPolicy struct { // TimeToLive: time frame, from one second and up to one year, during which the secret's versions are valid. TimeToLive *scw.Duration `json:"time_to_live"` // ExpiresOnceAccessed: returns `true` if the version expires after a single user access. ExpiresOnceAccessed *bool `json:"expires_once_accessed"` // Action: see the `EphemeralPolicy.Action` enum for a description of values. // Default value: unknown_action Action EphemeralPolicyAction `json:"action"` } // BrowseSecretsResponseItemFolderDetails: browse secrets response item folder details. type BrowseSecretsResponseItemFolderDetails struct { } // BrowseSecretsResponseItemSecretDetails: browse secrets response item secret details. type BrowseSecretsResponseItemSecretDetails struct { ID string `json:"id"` Tags []string `json:"tags"` VersionCount uint32 `json:"version_count"` Protected bool `json:"protected"` EphemeralPolicy *EphemeralPolicy `json:"ephemeral_policy"` } // EphemeralProperties: ephemeral properties. type EphemeralProperties struct { // ExpiresAt: (Optional.) If not specified, the version does not have an expiration date. ExpiresAt *time.Time `json:"expires_at"` // ExpiresOnceAccessed: (Optional.) If not specified, the version can be accessed an unlimited amount of times. ExpiresOnceAccessed *bool `json:"expires_once_accessed"` // Action: see `EphemeralPolicy.Action` enum for a description of values. // Default value: unknown_action Action EphemeralPolicyAction `json:"action"` } // BrowseSecretsResponseItem: browse secrets response item. type BrowseSecretsResponseItem struct { Name string `json:"name"` CreatedAt *time.Time `json:"created_at"` UpdatedAt *time.Time `json:"updated_at"` // Precisely one of Secret, Folder must be set. Secret *BrowseSecretsResponseItemSecretDetails `json:"secret,omitempty"` // Precisely one of Secret, Folder must be set. Folder *BrowseSecretsResponseItemFolderDetails `json:"folder,omitempty"` } // SecretVersion: secret version. type SecretVersion struct { // Revision: the first version of the secret is numbered 1, and all subsequent revisions augment by 1. Revision uint32 `json:"revision"` // SecretID: ID of the secret. SecretID string `json:"secret_id"` // Status: * `unknown`: the version is in an invalid state. // * `enabled`: the version is accessible. // * `disabled`: the version is not accessible but can be enabled. // * `deleted`: the version is permanently deleted. It is not possible to recover it. // Default value: unknown_status Status SecretVersionStatus `json:"status"` // CreatedAt: date and time of the version's creation. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: last update of the version. UpdatedAt *time.Time `json:"updated_at"` // Description: description of the version. Description *string `json:"description"` // Latest: returns `true` if the version is the latest. Latest bool `json:"latest"` // EphemeralProperties: returns the version's expiration date, whether it expires after being accessed once, and the action to perform (disable or delete) once the version expires. EphemeralProperties *EphemeralProperties `json:"ephemeral_properties"` } // Secret: secret. type Secret struct { // ID: ID of the secret. ID string `json:"id"` // ProjectID: ID of the Project containing the secret. ProjectID string `json:"project_id"` // Name: name of the secret. Name string `json:"name"` // Status: * `ready`: the secret can be read, modified and deleted. // * `locked`: no action can be performed on the secret. This status can only be applied and removed by Scaleway. // Default value: unknown_status Status SecretStatus `json:"status"` // CreatedAt: date and time of the secret's creation. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: last update of the secret. UpdatedAt *time.Time `json:"updated_at"` // Tags: list of the secret's tags. Tags []string `json:"tags"` // VersionCount: number of versions for this secret. VersionCount uint32 `json:"version_count"` // Description: updated description of the secret. Description *string `json:"description"` // Managed: returns `true` for secrets that are managed by another product. Managed bool `json:"managed"` // Protected: returns `true` for protected secrets that cannot be deleted. Protected bool `json:"protected"` // Type: see `Secret.Type` enum for description of values. // Default value: unknown_type Type SecretType `json:"type"` // Path: location of the secret in the directory structure. Path string `json:"path"` // EphemeralPolicy: (Optional.) Policy that defines whether/when a secret's versions expire. By default, the policy is applied to all the secret's versions. EphemeralPolicy *EphemeralPolicy `json:"ephemeral_policy"` // Region: region of the secret. Region scw.Region `json:"region"` } // AccessSecretVersionRequest: access secret version request. type AccessSecretVersionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` // Revision: the first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be either: // - a number (the revision number) // - "latest" (the latest revision) // - "latest_enabled" (the latest enabled revision). Revision string `json:"-"` } // AccessSecretVersionResponse: access secret version response. type AccessSecretVersionResponse struct { // SecretID: ID of the secret. SecretID string `json:"secret_id"` // Revision: the first version of the secret is numbered 1, and all subsequent revisions augment by 1. Revision uint32 `json:"revision"` // Data: the base64-encoded secret payload of the version. Data []byte `json:"data"` // DataCrc32: this field is only available if a CRC32 was supplied during the creation of the version. DataCrc32 *uint32 `json:"data_crc32"` } // AddSecretOwnerRequest: add secret owner request. type AddSecretOwnerRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` // Product: see `Product` enum for description of values. // Default value: unknown_product Product Product `json:"product"` } // BrowseSecretsRequest: browse secrets request. type BrowseSecretsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: filter by Project ID (optional). ProjectID *string `json:"-"` // OrderBy: default value: name_asc OrderBy BrowseSecretsRequestOrderBy `json:"-"` // Prefix: filter secrets and folders for a given prefix (default /). Prefix string `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` } // BrowseSecretsResponse: browse secrets response. type BrowseSecretsResponse struct { // Items: repeated item of type secret or folder, sorted by the request parameter. Items []*BrowseSecretsResponseItem `json:"items"` // CurrentPath: current path for the given prefix. CurrentPath string `json:"current_path"` // TotalCount: count of all secrets and folders matching the requested criteria. TotalCount uint64 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *BrowseSecretsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *BrowseSecretsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*BrowseSecretsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Items = append(r.Items, results.Items...) r.TotalCount += uint64(len(results.Items)) return uint64(len(results.Items)), nil } // CreateSecretRequest: create secret request. type CreateSecretRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: ID of the Project containing the secret. ProjectID string `json:"project_id"` // Name: name of the secret. Name string `json:"name"` // Tags: list of the secret's tags. Tags []string `json:"tags"` // Description: description of the secret. Description *string `json:"description,omitempty"` // Type: (Optional.) See `Secret.Type` enum for description of values. If not specified, the type is `Opaque`. // Default value: unknown_type Type SecretType `json:"type"` // Path: (Optional.) Location of the secret in the directory structure. If not specified, the path is `/`. Path *string `json:"path,omitempty"` // EphemeralPolicy: (Optional.) Policy that defines whether/when a secret's versions expire. By default, the policy is applied to all the secret's versions. EphemeralPolicy *EphemeralPolicy `json:"ephemeral_policy,omitempty"` // Protected: a protected secret cannot be deleted. Protected bool `json:"protected"` } // CreateSecretVersionRequest: create secret version request. type CreateSecretVersionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` // Data: the base64-encoded secret payload of the version. Data []byte `json:"data"` // Description: description of the version. Description *string `json:"description,omitempty"` // DisablePrevious: (Optional.) If there is no previous version or if the previous version was already disabled, does nothing. DisablePrevious *bool `json:"disable_previous,omitempty"` // DataCrc32: if specified, Secret Manager will verify the integrity of the data received against the given CRC32 checksum. An error is returned if the CRC32 does not match. If, however, the CRC32 matches, it will be stored and returned along with the SecretVersion on future access requests. DataCrc32 *uint32 `json:"data_crc32,omitempty"` } // DeleteSecretRequest: delete secret request. type DeleteSecretRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` } // DeleteSecretVersionRequest: delete secret version request. type DeleteSecretVersionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` // Revision: the first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be either: // - a number (the revision number) // - "latest" (the latest revision) // - "latest_enabled" (the latest enabled revision). Revision string `json:"-"` } // DisableSecretVersionRequest: disable secret version request. type DisableSecretVersionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` // Revision: the first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be either: // - a number (the revision number) // - "latest" (the latest revision) // - "latest_enabled" (the latest enabled revision). Revision string `json:"-"` } // EnableSecretVersionRequest: enable secret version request. type EnableSecretVersionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` // Revision: the first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be either: // - a number (the revision number) // - "latest" (the latest revision) // - "latest_enabled" (the latest enabled revision). Revision string `json:"-"` } // GetSecretRequest: get secret request. type GetSecretRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` } // GetSecretVersionRequest: get secret version request. type GetSecretVersionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` // Revision: the first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be either: // - a number (the revision number) // - "latest" (the latest revision) // - "latest_enabled" (the latest enabled revision). Revision string `json:"-"` } // ListSecretVersionsRequest: list secret versions request. type ListSecretVersionsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` // Status: filter results by status. Status []SecretVersionStatus `json:"-"` } // ListSecretVersionsResponse: list secret versions response. type ListSecretVersionsResponse struct { // Versions: single page of versions. Versions []*SecretVersion `json:"versions"` // TotalCount: number of versions. TotalCount uint64 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListSecretVersionsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListSecretVersionsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListSecretVersionsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Versions = append(r.Versions, results.Versions...) r.TotalCount += uint64(len(results.Versions)) return uint64(len(results.Versions)), nil } // ListSecretsRequest: list secrets request. type ListSecretsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // OrganizationID: filter by Organization ID (optional). OrganizationID *string `json:"-"` // ProjectID: filter by Project ID (optional). ProjectID *string `json:"-"` // OrderBy: default value: name_asc OrderBy ListSecretsRequestOrderBy `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` // Tags: list of tags to filter on (optional). Tags []string `json:"-"` // Name: filter by secret name (optional). Name *string `json:"-"` // Path: filter by exact path (optional). Path *string `json:"-"` // Ephemeral: filter by ephemeral / not ephemeral (optional). Ephemeral *bool `json:"-"` } // ListSecretsResponse: list secrets response. type ListSecretsResponse struct { // Secrets: single page of secrets matching the requested criteria. Secrets []*Secret `json:"secrets"` // TotalCount: count of all secrets matching the requested criteria. TotalCount uint64 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListSecretsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListSecretsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListSecretsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Secrets = append(r.Secrets, results.Secrets...) r.TotalCount += uint64(len(results.Secrets)) return uint64(len(results.Secrets)), nil } // ProtectSecretRequest: protect secret request. type ProtectSecretRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret to enable secret protection for. SecretID string `json:"-"` } // UnprotectSecretRequest: unprotect secret request. type UnprotectSecretRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret to disable secret protection for. SecretID string `json:"-"` } // UpdateSecretRequest: update secret request. type UpdateSecretRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` // Name: secret's updated name (optional). Name *string `json:"name,omitempty"` // Tags: secret's updated list of tags (optional). Tags *[]string `json:"tags,omitempty"` // Description: description of the secret. Description *string `json:"description,omitempty"` // Path: (Optional.) Location of the folder in the directory structure. If not specified, the path is `/`. Path *string `json:"path,omitempty"` // EphemeralPolicy: (Optional.) Policy that defines whether/when a secret's versions expire. EphemeralPolicy *EphemeralPolicy `json:"ephemeral_policy,omitempty"` } // UpdateSecretVersionRequest: update secret version request. type UpdateSecretVersionRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // SecretID: ID of the secret. SecretID string `json:"-"` // Revision: the first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be either: // - a number (the revision number) // - "latest" (the latest revision) // - "latest_enabled" (the latest enabled revision). Revision string `json:"-"` // Description: description of the version. Description *string `json:"description,omitempty"` // EphemeralProperties: (Optional.) Properties that defines the version's expiration date, whether it expires after being accessed once, and the action to perform (disable or delete) once the version expires. EphemeralProperties *EphemeralProperties `json:"ephemeral_properties,omitempty"` } // This API allows you to conveniently store, access and share sensitive data such as passwords, API keys and certificates. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Regions() []scw.Region { return []scw.Region{scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw} } // CreateSecret: You must specify the `region` to create a secret. func (s *API) CreateSecret(req *CreateSecretRequest, opts ...scw.RequestOption) (*Secret, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/secret-manager/v1beta1/regions/" + fmt.Sprint(req.Region) + "/secrets", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Secret err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetSecret: Retrieve the metadata of a secret specified by the `region` and `secret_id` parameters. func (s *API) GetSecret(req *GetSecretRequest, opts ...scw.RequestOption) (*Secret, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/secret-manager/v1beta1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "", } var resp Secret err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateSecret: Edit a secret's metadata such as name, tag(s), description and ephemeral policy. The secret to update is specified by the `secret_id` and `region` parameters. func (s *API) UpdateSecret(req *UpdateSecretRequest, opts ...scw.RequestOption) (*Secret, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/secret-manager/v1beta1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Secret err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteSecret: Delete a given secret specified by the `region` and `secret_id` parameters. func (s *API) DeleteSecret(req *DeleteSecretRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return errors.New("field SecretID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/secret-manager/v1beta1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListSecrets: Retrieve the list of secrets created within an Organization and/or Project. You must specify either the `organization_id` or the `project_id` and the `region`. func (s *API) ListSecrets(req *ListSecretsRequest, opts ...scw.RequestOption) (*ListSecretsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "tags", req.Tags) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "path", req.Path) parameter.AddToQuery(query, "ephemeral", req.Ephemeral) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/secret-manager/v1beta1/regions/" + fmt.Sprint(req.Region) + "/secrets", Query: query, } var resp ListSecretsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // BrowseSecrets: Retrieve the list of secrets and folders for the given prefix. You must specify either the `organization_id` or the `project_id` and the `region`. func (s *API) BrowseSecrets(req *BrowseSecretsRequest, opts ...scw.RequestOption) (*BrowseSecretsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "prefix", req.Prefix) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/secret-manager/v1beta1/regions/" + fmt.Sprint(req.Region) + "/secrets/browse", Query: query, } var resp BrowseSecretsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ProtectSecret: Enable secret protection for a given secret specified by the `secret_id` parameter. Enabling secret protection means that your secret can be read and modified, but it cannot be deleted. func (s *API) ProtectSecret(req *ProtectSecretRequest, opts ...scw.RequestOption) (*Secret, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/secret-manager/v1beta1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "/protect", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Secret err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UnprotectSecret: Disable secret protection for a given secret specified by the `secret_id` parameter. Disabling secret protection means that your secret can be read, modified and deleted. func (s *API) UnprotectSecret(req *UnprotectSecretRequest, opts ...scw.RequestOption) (*Secret, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/secret-manager/v1beta1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "/unprotect", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Secret err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // AddSecretOwner: Allow a product to use the secret. func (s *API) AddSecretOwner(req *AddSecretOwnerRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return errors.New("field SecretID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/secret-manager/v1beta1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "/add-owner", } err = scwReq.SetBody(req) if err != nil { return err } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // CreateSecretVersion: Create a version of a given secret specified by the `region` and `secret_id` parameters. func (s *API) CreateSecretVersion(req *CreateSecretVersionRequest, opts ...scw.RequestOption) (*SecretVersion, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/secret-manager/v1beta1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "/versions", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SecretVersion err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetSecretVersion: Retrieve the metadata of a secret's given version specified by the `region`, `secret_id` and `revision` parameters. func (s *API) GetSecretVersion(req *GetSecretVersionRequest, opts ...scw.RequestOption) (*SecretVersion, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } if fmt.Sprint(req.Revision) == "" { return nil, errors.New("field Revision cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/secret-manager/v1beta1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "/versions/" + fmt.Sprint(req.Revision) + "", } var resp SecretVersion err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateSecretVersion: Edit the metadata of a secret's given version, specified by the `region`, `secret_id` and `revision` parameters. func (s *API) UpdateSecretVersion(req *UpdateSecretVersionRequest, opts ...scw.RequestOption) (*SecretVersion, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } if fmt.Sprint(req.Revision) == "" { return nil, errors.New("field Revision cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/secret-manager/v1beta1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "/versions/" + fmt.Sprint(req.Revision) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SecretVersion err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteSecretVersion: Delete a secret's version and the sensitive data contained in it. Deleting a version is permanent and cannot be undone. func (s *API) DeleteSecretVersion(req *DeleteSecretVersionRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return errors.New("field SecretID cannot be empty in request") } if fmt.Sprint(req.Revision) == "" { return errors.New("field Revision cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/secret-manager/v1beta1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "/versions/" + fmt.Sprint(req.Revision) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListSecretVersions: Retrieve the list of a given secret's versions specified by the `secret_id` and `region` parameters. func (s *API) ListSecretVersions(req *ListSecretVersionsRequest, opts ...scw.RequestOption) (*ListSecretVersionsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "status", req.Status) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/secret-manager/v1beta1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "/versions", Query: query, } var resp ListSecretVersionsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // AccessSecretVersion: Access sensitive data in a secret's version specified by the `region`, `secret_id` and `revision` parameters. func (s *API) AccessSecretVersion(req *AccessSecretVersionRequest, opts ...scw.RequestOption) (*AccessSecretVersionResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } if fmt.Sprint(req.Revision) == "" { return nil, errors.New("field Revision cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/secret-manager/v1beta1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "/versions/" + fmt.Sprint(req.Revision) + "/access", } var resp AccessSecretVersionResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // EnableSecretVersion: Make a specific version accessible. You must specify the `region`, `secret_id` and `revision` parameters. func (s *API) EnableSecretVersion(req *EnableSecretVersionRequest, opts ...scw.RequestOption) (*SecretVersion, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } if fmt.Sprint(req.Revision) == "" { return nil, errors.New("field Revision cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/secret-manager/v1beta1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "/versions/" + fmt.Sprint(req.Revision) + "/enable", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SecretVersion err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DisableSecretVersion: Make a specific version inaccessible. You must specify the `region`, `secret_id` and `revision` parameters. func (s *API) DisableSecretVersion(req *DisableSecretVersionRequest, opts ...scw.RequestOption) (*SecretVersion, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.SecretID) == "" { return nil, errors.New("field SecretID cannot be empty in request") } if fmt.Sprint(req.Revision) == "" { return nil, errors.New("field Revision cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/secret-manager/v1beta1/regions/" + fmt.Sprint(req.Region) + "/secrets/" + fmt.Sprint(req.SecretID) + "/versions/" + fmt.Sprint(req.Revision) + "/disable", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SecretVersion err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/serverless_sqldb/000077500000000000000000000000001456366605600264115ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/serverless_sqldb/v1alpha1/000077500000000000000000000000001456366605600300265ustar00rootroot00000000000000serverless_sqldb_sdk.go000066400000000000000000000551411456366605600345270ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/serverless_sqldb/v1alpha1// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package serverless_sqldb provides methods and message types of the serverless_sqldb v1alpha1 API. package serverless_sqldb import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type DatabaseBackupStatus string const ( DatabaseBackupStatusUnknownStatus = DatabaseBackupStatus("unknown_status") DatabaseBackupStatusError = DatabaseBackupStatus("error") DatabaseBackupStatusReady = DatabaseBackupStatus("ready") DatabaseBackupStatusLocked = DatabaseBackupStatus("locked") ) func (enum DatabaseBackupStatus) String() string { if enum == "" { // return default value if empty return "unknown_status" } return string(enum) } func (enum DatabaseBackupStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DatabaseBackupStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DatabaseBackupStatus(DatabaseBackupStatus(tmp).String()) return nil } type DatabaseStatus string const ( DatabaseStatusUnknownStatus = DatabaseStatus("unknown_status") DatabaseStatusError = DatabaseStatus("error") DatabaseStatusCreating = DatabaseStatus("creating") DatabaseStatusReady = DatabaseStatus("ready") DatabaseStatusDeleting = DatabaseStatus("deleting") DatabaseStatusRestoring = DatabaseStatus("restoring") DatabaseStatusLocked = DatabaseStatus("locked") ) func (enum DatabaseStatus) String() string { if enum == "" { // return default value if empty return "unknown_status" } return string(enum) } func (enum DatabaseStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DatabaseStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DatabaseStatus(DatabaseStatus(tmp).String()) return nil } type ListDatabaseBackupsRequestOrderBy string const ( ListDatabaseBackupsRequestOrderByCreatedAtAsc = ListDatabaseBackupsRequestOrderBy("created_at_asc") ListDatabaseBackupsRequestOrderByCreatedAtDesc = ListDatabaseBackupsRequestOrderBy("created_at_desc") ) func (enum ListDatabaseBackupsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListDatabaseBackupsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListDatabaseBackupsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListDatabaseBackupsRequestOrderBy(ListDatabaseBackupsRequestOrderBy(tmp).String()) return nil } type ListDatabasesRequestOrderBy string const ( ListDatabasesRequestOrderByCreatedAtAsc = ListDatabasesRequestOrderBy("created_at_asc") ListDatabasesRequestOrderByCreatedAtDesc = ListDatabasesRequestOrderBy("created_at_desc") ListDatabasesRequestOrderByNameAsc = ListDatabasesRequestOrderBy("name_asc") ListDatabasesRequestOrderByNameDesc = ListDatabasesRequestOrderBy("name_desc") ) func (enum ListDatabasesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListDatabasesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListDatabasesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListDatabasesRequestOrderBy(ListDatabasesRequestOrderBy(tmp).String()) return nil } // DatabaseBackup: database backup. type DatabaseBackup struct { // ID: UUID that uniquely identifies a Serverless SQL Database backup. ID string `json:"id"` // Status: status of the Serverless SQL Database backup. One of `unknown_status` | `error` | `ready` | `locked`. // Default value: unknown_status Status DatabaseBackupStatus `json:"status"` // OrganizationID: the ID of your Scaleway organization. OrganizationID string `json:"organization_id"` // ProjectID: UUID of the Scaleway project. ProjectID string `json:"project_id"` // DatabaseID: UUID of the source Serverless SQL Database the backup is created from. DatabaseID string `json:"database_id"` // CreatedAt: creation date. CreatedAt *time.Time `json:"created_at"` // ExpiresAt: expiration date. ExpiresAt *time.Time `json:"expires_at"` // Size: size of the database backup. Size *scw.Size `json:"size"` // DownloadURL: download URL of the exported database backup. DownloadURL *string `json:"download_url"` // DownloadURLExpiresAt: expiration date of the download URL. DownloadURLExpiresAt *time.Time `json:"download_url_expires_at"` // Region: region of the database backup. Region scw.Region `json:"region"` } // Database: database. type Database struct { // ID: UUID that uniquely identifies your Serverless SQL DB Database. ID string `json:"id"` // Name: name of the database. Name string `json:"name"` // Status: status of the Serverless SQL Ddatabase. One of `unknown_status` | `ready` | `creating` | `deleting` | `error` | `restoring` | `locked`. // Default value: unknown_status Status DatabaseStatus `json:"status"` // Endpoint: endpoint of the database. Endpoint string `json:"endpoint"` // OrganizationID: the ID of your Scaleway organization. OrganizationID string `json:"organization_id"` // ProjectID: project ID the database belongs to. ProjectID string `json:"project_id"` // Region: region of the database. Region scw.Region `json:"region"` // CreatedAt: creation date. CreatedAt *time.Time `json:"created_at"` // CPUMin: the minimum number of CPU units for your Serverless SQL Database. CPUMin uint32 `json:"cpu_min"` // CPUMax: the maximum number of CPU units for your Serverless SQL Database. CPUMax uint32 `json:"cpu_max"` // CPUCurrent: the current number of CPU units allocated to your Serverless SQL Database. CPUCurrent uint32 `json:"cpu_current"` // Started: whether your Serverless SQL Database is running or not. Started bool `json:"started"` // EngineMajorVersion: the major version of the underlying database engine. EngineMajorVersion uint32 `json:"engine_major_version"` } // CreateDatabaseRequest: create database request. type CreateDatabaseRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: the ID of your Scaleway project. ProjectID string `json:"project_id"` // Name: the name of the Serverless SQL Database to be created. Name string `json:"name"` // CPUMin: the minimum number of CPU units for your Serverless SQL Database. CPUMin uint32 `json:"cpu_min"` // CPUMax: the maximum number of CPU units for your Serverless SQL Database. CPUMax uint32 `json:"cpu_max"` // FromBackupID: the ID of the backup to create the database from. FromBackupID *string `json:"from_backup_id,omitempty"` } // DeleteDatabaseRequest: delete database request. type DeleteDatabaseRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DatabaseID: UUID of the Serverless SQL Database. DatabaseID string `json:"-"` } // ExportDatabaseBackupRequest: export database backup request. type ExportDatabaseBackupRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // BackupID: UUID of the Serverless SQL Database backup. BackupID string `json:"-"` } // GetDatabaseBackupRequest: get database backup request. type GetDatabaseBackupRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // BackupID: UUID of the Serverless SQL Database backup. BackupID string `json:"-"` } // GetDatabaseRequest: get database request. type GetDatabaseRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DatabaseID: UUID of the Serverless SQL DB database. DatabaseID string `json:"-"` } // ListDatabaseBackupsRequest: list database backups request. type ListDatabaseBackupsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // OrganizationID: filter by the UUID of the Scaleway organization. OrganizationID *string `json:"-"` // ProjectID: filter by the UUID of the Scaleway project. ProjectID *string `json:"-"` // DatabaseID: filter by the UUID of the Serverless SQL Database. DatabaseID string `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: page size. PageSize *uint32 `json:"-"` // OrderBy: sorting criteria. One of `created_at_asc`, `created_at_desc`. // Default value: created_at_asc OrderBy ListDatabaseBackupsRequestOrderBy `json:"-"` } // ListDatabaseBackupsResponse: list database backups response. type ListDatabaseBackupsResponse struct { // Backups: list of the backups. Backups []*DatabaseBackup `json:"backups"` // TotalCount: length of the backups list. TotalCount uint64 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListDatabaseBackupsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListDatabaseBackupsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListDatabaseBackupsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Backups = append(r.Backups, results.Backups...) r.TotalCount += uint64(len(results.Backups)) return uint64(len(results.Backups)), nil } // ListDatabasesRequest: list databases request. type ListDatabasesRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // OrganizationID: filter by the UUID of the Scaleway organization. OrganizationID *string `json:"-"` // ProjectID: UUID of the Scaleway project. ProjectID string `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: page size. PageSize *uint32 `json:"-"` // Name: filter by the name of the database. Name *string `json:"-"` // OrderBy: sorting criteria. One of `created_at_asc`, `created_at_desc`, `name_asc`, `name_desc`. // Default value: created_at_asc OrderBy ListDatabasesRequestOrderBy `json:"-"` } // ListDatabasesResponse: list databases response. type ListDatabasesResponse struct { // Databases: list of the databases. Databases []*Database `json:"databases"` // TotalCount: total count of Serverless SQL Databases. TotalCount uint64 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListDatabasesResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListDatabasesResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListDatabasesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Databases = append(r.Databases, results.Databases...) r.TotalCount += uint64(len(results.Databases)) return uint64(len(results.Databases)), nil } // RestoreDatabaseFromBackupRequest: restore database from backup request. type RestoreDatabaseFromBackupRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DatabaseID: UUID of the Serverless SQL Database. DatabaseID string `json:"-"` // BackupID: UUID of the Serverless SQL Database backup to restore. BackupID string `json:"backup_id"` } // UpdateDatabaseRequest: update database request. type UpdateDatabaseRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DatabaseID: UUID of the Serverless SQL Database. DatabaseID string `json:"-"` // CPUMin: the minimum number of CPU units for your Serverless SQL Database. CPUMin *uint32 `json:"cpu_min,omitempty"` // CPUMax: the maximum number of CPU units for your Serverless SQL Database. CPUMax *uint32 `json:"cpu_max,omitempty"` } // This API allows you to manage your Serverless SQL DB databases. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Regions() []scw.Region { return []scw.Region{scw.RegionFrPar} } // CreateDatabase: You must provide the following parameters: `organization_id`, `project_id`, `name`, `cpu_min`, `cpu_max`. You can also provide `from_backup_id` to create a database from a backup. func (s *API) CreateDatabase(req *CreateDatabaseRequest, opts ...scw.RequestOption) (*Database, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/serverless-sqldb/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/databases", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Database err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetDatabase: Retrieve information about your Serverless SQL Database. You must provide the `database_id` parameter. func (s *API) GetDatabase(req *GetDatabaseRequest, opts ...scw.RequestOption) (*Database, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DatabaseID) == "" { return nil, errors.New("field DatabaseID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/serverless-sqldb/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/databases/" + fmt.Sprint(req.DatabaseID) + "", } var resp Database err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteDatabase: Deletes a database. You must provide the `database_id` parameter. All data stored in the database will be permanently deleted. func (s *API) DeleteDatabase(req *DeleteDatabaseRequest, opts ...scw.RequestOption) (*Database, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DatabaseID) == "" { return nil, errors.New("field DatabaseID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/serverless-sqldb/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/databases/" + fmt.Sprint(req.DatabaseID) + "", } var resp Database err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListDatabases: List all Serverless SQL Databases for a given Scaleway Organization or Scaleway Project. By default, the databases returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. For the `name` parameter, the value you include will be checked against the whole name string to see if it includes the string you put in the parameter. func (s *API) ListDatabases(req *ListDatabasesRequest, opts ...scw.RequestOption) (*ListDatabasesResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "order_by", req.OrderBy) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/serverless-sqldb/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/databases", Query: query, } var resp ListDatabasesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateDatabase: Update CPU limits of your Serverless SQL Database. You must provide the `database_id` parameter. func (s *API) UpdateDatabase(req *UpdateDatabaseRequest, opts ...scw.RequestOption) (*Database, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DatabaseID) == "" { return nil, errors.New("field DatabaseID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/serverless-sqldb/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/databases/" + fmt.Sprint(req.DatabaseID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Database err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // RestoreDatabaseFromBackup: Restore a database from a backup. You must provide the `backup_id` parameter. func (s *API) RestoreDatabaseFromBackup(req *RestoreDatabaseFromBackupRequest, opts ...scw.RequestOption) (*Database, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DatabaseID) == "" { return nil, errors.New("field DatabaseID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/serverless-sqldb/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/databases/" + fmt.Sprint(req.DatabaseID) + "/restore", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Database err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetDatabaseBackup: Retrieve information about your Serverless SQL Database backup. You must provide the `backup_id` parameter. func (s *API) GetDatabaseBackup(req *GetDatabaseBackupRequest, opts ...scw.RequestOption) (*DatabaseBackup, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.BackupID) == "" { return nil, errors.New("field BackupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/serverless-sqldb/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/backups/" + fmt.Sprint(req.BackupID) + "", } var resp DatabaseBackup err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListDatabaseBackups: List all Serverless SQL Database backups for a given Scaleway Project or Database. By default, the backups returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. func (s *API) ListDatabaseBackups(req *ListDatabaseBackupsRequest, opts ...scw.RequestOption) (*ListDatabaseBackupsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "database_id", req.DatabaseID) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/serverless-sqldb/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/backups", Query: query, } var resp ListDatabaseBackupsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ExportDatabaseBackup: Export a database backup providing a download link once the export process is completed. You must provide the `backup_id` parameter. func (s *API) ExportDatabaseBackup(req *ExportDatabaseBackupRequest, opts ...scw.RequestOption) (*DatabaseBackup, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.BackupID) == "" { return nil, errors.New("field BackupID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/serverless-sqldb/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/backups/" + fmt.Sprint(req.BackupID) + "/export", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp DatabaseBackup err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } serverless_sqldb_utils.go000066400000000000000000000060721456366605600351050ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/serverless_sqldb/v1alpha1package serverless_sqldb import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) const ( defaultRetryInterval = 15 * time.Second defaultTimeout = 15 * time.Minute ) // WaitForDatabaseRequest is used by WaitForDatabase method. type WaitForDatabaseRequest struct { DatabaseID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForDatabase waits for the database to be in a "terminal state" before returning. // This function can be used to wait for a database to be ready for example. func (s *API) WaitForDatabase(req *WaitForDatabaseRequest, opts ...scw.RequestOption) (*Database, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[DatabaseStatus]struct{}{ DatabaseStatusReady: {}, DatabaseStatusError: {}, DatabaseStatusLocked: {}, } database, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetDatabase(&GetDatabaseRequest{ DatabaseID: req.DatabaseID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.Status] return res, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for database failed") } return database.(*Database), nil } // WaitForDatabaseBackupRequest is used by WaitForDatabase method. type WaitForDatabaseBackupRequest struct { BackupID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForDatabaseBackup waits for the backup to be in a "terminal state" before returning. // This function can be used to wait for a backup to be ready for example. func (s *API) WaitForDatabaseBackup(req *WaitForDatabaseBackupRequest, opts ...scw.RequestOption) (*DatabaseBackup, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[DatabaseBackupStatus]struct{}{ DatabaseBackupStatusReady: {}, DatabaseBackupStatusError: {}, DatabaseBackupStatusLocked: {}, } backup, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { res, err := s.GetDatabaseBackup(&GetDatabaseBackupRequest{ BackupID: req.BackupID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[res.Status] return res, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for backup backup failed") } return backup.(*DatabaseBackup), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/std/000077500000000000000000000000001456366605600236215ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/std/std_sdk.go000066400000000000000000000030051456366605600256010ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package std provides methods and message types of the std API. package std import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type LanguageCode string const ( LanguageCodeUnknownLanguageCode = LanguageCode("unknown_language_code") LanguageCodeEnUS = LanguageCode("en_US") LanguageCodeFrFR = LanguageCode("fr_FR") LanguageCodeDeDE = LanguageCode("de_DE") ) func (enum LanguageCode) String() string { if enum == "" { // return default value if empty return "unknown_language_code" } return string(enum) } func (enum LanguageCode) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *LanguageCode) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = LanguageCode(LanguageCode(tmp).String()) return nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/tem/000077500000000000000000000000001456366605600236145ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/tem/v1alpha1/000077500000000000000000000000001456366605600252315ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/tem/v1alpha1/tem_sdk.go000066400000000000000000001124601456366605600272120ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package tem provides methods and message types of the tem v1alpha1 API. package tem import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type DomainLastStatusRecordStatus string const ( // If unspecified, the status of the domain's record is unknown by default. DomainLastStatusRecordStatusUnknownRecordStatus = DomainLastStatusRecordStatus("unknown_record_status") // The record is valid. DomainLastStatusRecordStatusValid = DomainLastStatusRecordStatus("valid") // The record is invalid. DomainLastStatusRecordStatusInvalid = DomainLastStatusRecordStatus("invalid") // The record was not found. DomainLastStatusRecordStatusNotFound = DomainLastStatusRecordStatus("not_found") ) func (enum DomainLastStatusRecordStatus) String() string { if enum == "" { // return default value if empty return "unknown_record_status" } return string(enum) } func (enum DomainLastStatusRecordStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DomainLastStatusRecordStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DomainLastStatusRecordStatus(DomainLastStatusRecordStatus(tmp).String()) return nil } type DomainReputationStatus string const ( // If unspecified, the status of the domain's reputation is unknown by default. DomainReputationStatusUnknownStatus = DomainReputationStatus("unknown_status") // The domain has an excellent reputation. DomainReputationStatusExcellent = DomainReputationStatus("excellent") // The domain has a good reputation. DomainReputationStatusGood = DomainReputationStatus("good") // The domain has an average reputation. DomainReputationStatusAverage = DomainReputationStatus("average") // The domain has a bad reputation. DomainReputationStatusBad = DomainReputationStatus("bad") ) func (enum DomainReputationStatus) String() string { if enum == "" { // return default value if empty return "unknown_status" } return string(enum) } func (enum DomainReputationStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DomainReputationStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DomainReputationStatus(DomainReputationStatus(tmp).String()) return nil } type DomainStatus string const ( // If unspecified, the status of the domain is unknown by default. DomainStatusUnknown = DomainStatus("unknown") // The domain is checked. DomainStatusChecked = DomainStatus("checked") // The domain is unchecked. DomainStatusUnchecked = DomainStatus("unchecked") // The domain is invalid. DomainStatusInvalid = DomainStatus("invalid") // The domain is locked. DomainStatusLocked = DomainStatus("locked") // The domain is revoked. DomainStatusRevoked = DomainStatus("revoked") // The domain is pending, waiting to be checked. DomainStatusPending = DomainStatus("pending") ) func (enum DomainStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum DomainStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DomainStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DomainStatus(DomainStatus(tmp).String()) return nil } type EmailFlag string const ( // If unspecified, the flag type is unknown by default. EmailFlagUnknownFlag = EmailFlag("unknown_flag") // Refers to a non critical error received while sending the email(s). Soft bounced emails are retried. EmailFlagSoftBounce = EmailFlag("soft_bounce") // Refers to a critical error that happened while sending the email(s). EmailFlagHardBounce = EmailFlag("hard_bounce") // Refers to an email considered as spam. EmailFlagSpam = EmailFlag("spam") // Refers to an undelivered email because the recipient mailbox is full. EmailFlagMailboxFull = EmailFlag("mailbox_full") // Refers to an undelivered email because the recipient mailbox does not exist. EmailFlagMailboxNotFound = EmailFlag("mailbox_not_found") // Refers to an email slightly delayed by the recipient to ensure that Scaleway is not sending spam. EmailFlagGreylisted = EmailFlag("greylisted") // Refers to an email with a `send-before` tag to indicate the maximum time limit for the email to be sent. EmailFlagSendBeforeExpiration = EmailFlag("send_before_expiration") ) func (enum EmailFlag) String() string { if enum == "" { // return default value if empty return "unknown_flag" } return string(enum) } func (enum EmailFlag) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *EmailFlag) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = EmailFlag(EmailFlag(tmp).String()) return nil } type EmailRcptType string const ( // If unspecified, the recipient type is unknown by default. EmailRcptTypeUnknownRcptType = EmailRcptType("unknown_rcpt_type") // Primary recipient. EmailRcptTypeTo = EmailRcptType("to") // Carbon copy recipient. EmailRcptTypeCc = EmailRcptType("cc") // Blind carbon copy recipient. EmailRcptTypeBcc = EmailRcptType("bcc") ) func (enum EmailRcptType) String() string { if enum == "" { // return default value if empty return "unknown_rcpt_type" } return string(enum) } func (enum EmailRcptType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *EmailRcptType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = EmailRcptType(EmailRcptType(tmp).String()) return nil } type EmailStatus string const ( // If unspecified, the status of the email is unknown by default. EmailStatusUnknown = EmailStatus("unknown") // The email is new. EmailStatusNew = EmailStatus("new") // The email is in the process of being sent. EmailStatusSending = EmailStatus("sending") // The email was sent. EmailStatusSent = EmailStatus("sent") // The sending of the email failed. EmailStatusFailed = EmailStatus("failed") // The sending of the email was canceled. EmailStatusCanceled = EmailStatus("canceled") ) func (enum EmailStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum EmailStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *EmailStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = EmailStatus(EmailStatus(tmp).String()) return nil } type ListEmailsRequestOrderBy string const ( // Order by creation date (descending chronological order). ListEmailsRequestOrderByCreatedAtDesc = ListEmailsRequestOrderBy("created_at_desc") // Order by creation date (ascending chronological order). ListEmailsRequestOrderByCreatedAtAsc = ListEmailsRequestOrderBy("created_at_asc") // Order by last update date (descending chronological order). ListEmailsRequestOrderByUpdatedAtDesc = ListEmailsRequestOrderBy("updated_at_desc") // Order by last update date (ascending chronological order). ListEmailsRequestOrderByUpdatedAtAsc = ListEmailsRequestOrderBy("updated_at_asc") // Order by status (descending alphabetical order). ListEmailsRequestOrderByStatusDesc = ListEmailsRequestOrderBy("status_desc") // Order by status (ascending alphabetical order). ListEmailsRequestOrderByStatusAsc = ListEmailsRequestOrderBy("status_asc") // Order by mail_from (descending alphabetical order). ListEmailsRequestOrderByMailFromDesc = ListEmailsRequestOrderBy("mail_from_desc") // Order by mail_from (ascending alphabetical order). ListEmailsRequestOrderByMailFromAsc = ListEmailsRequestOrderBy("mail_from_asc") // Order by mail recipient (descending alphabetical order). ListEmailsRequestOrderByMailRcptDesc = ListEmailsRequestOrderBy("mail_rcpt_desc") // Order by mail recipient (ascending alphabetical order). ListEmailsRequestOrderByMailRcptAsc = ListEmailsRequestOrderBy("mail_rcpt_asc") // Order by subject (descending alphabetical order). ListEmailsRequestOrderBySubjectDesc = ListEmailsRequestOrderBy("subject_desc") // Order by subject (ascending alphabetical order). ListEmailsRequestOrderBySubjectAsc = ListEmailsRequestOrderBy("subject_asc") ) func (enum ListEmailsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_desc" } return string(enum) } func (enum ListEmailsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListEmailsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListEmailsRequestOrderBy(ListEmailsRequestOrderBy(tmp).String()) return nil } // EmailTry: email try. type EmailTry struct { // Rank: rank number of this attempt to send the email. Rank uint32 `json:"rank"` // TriedAt: date of the attempt to send the email. TriedAt *time.Time `json:"tried_at"` // Code: the SMTP status code received after the attempt. 0 if the attempt did not reach an SMTP server. Code int32 `json:"code"` // Message: the SMTP message received. If the attempt did not reach an SMTP server, the message returned explains what happened. Message string `json:"message"` } // DomainReputation: domain reputation. type DomainReputation struct { // Status: status of your domain's reputation. // Default value: unknown_status Status DomainReputationStatus `json:"status"` // Score: a range from 0 to 100 that determines your domain's reputation score. A score of `0` means a bad domain reputation and a score of `100` means an excellent domain reputation. Score uint32 `json:"score"` // ScoredAt: time and date the score was calculated. ScoredAt *time.Time `json:"scored_at"` // PreviousScore: the previously-calculated domain's reputation score. PreviousScore *uint32 `json:"previous_score"` // PreviousScoredAt: time and date the previous reputation score was calculated. PreviousScoredAt *time.Time `json:"previous_scored_at"` } // DomainStatistics: domain statistics. type DomainStatistics struct { TotalCount uint32 `json:"total_count"` SentCount uint32 `json:"sent_count"` FailedCount uint32 `json:"failed_count"` CanceledCount uint32 `json:"canceled_count"` } // CreateEmailRequestAddress: create email request address. type CreateEmailRequestAddress struct { // Email: email address. Email string `json:"email"` // Name: (Optional) Name displayed. Name *string `json:"name"` } // CreateEmailRequestAttachment: create email request attachment. type CreateEmailRequestAttachment struct { // Name: filename of the attachment. Name string `json:"name"` // Type: mIME type of the attachment. Type string `json:"type"` // Content: content of the attachment encoded in base64. Content []byte `json:"content"` } // CreateEmailRequestHeader: create email request header. type CreateEmailRequestHeader struct { // Key: email header key. Key string `json:"key"` // Value: email header value. Value string `json:"value"` } // Email: email. type Email struct { // ID: technical ID of the email. ID string `json:"id"` // MessageID: message ID of the email. MessageID string `json:"message_id"` // ProjectID: ID of the Project to which the email belongs. ProjectID string `json:"project_id"` // MailFrom: email address of the sender. MailFrom string `json:"mail_from"` // Deprecated: RcptTo: email address of the recipient. RcptTo *string `json:"rcpt_to,omitempty"` // MailRcpt: email address of the recipient. MailRcpt string `json:"mail_rcpt"` // RcptType: type of recipient. // Default value: unknown_rcpt_type RcptType EmailRcptType `json:"rcpt_type"` // Subject: subject of the email. Subject string `json:"subject"` // CreatedAt: creation date of the email object. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: last update of the email object. UpdatedAt *time.Time `json:"updated_at"` // Status: status of the email. // Default value: unknown Status EmailStatus `json:"status"` // StatusDetails: additional status information. StatusDetails *string `json:"status_details"` // TryCount: number of attempts to send the email. TryCount uint32 `json:"try_count"` // LastTries: information about the last three attempts to send the email. LastTries []*EmailTry `json:"last_tries"` // Flags: flags categorize emails. They allow you to obtain more information about recurring errors, for example. Flags []EmailFlag `json:"flags"` } // DomainLastStatusDkimRecord: domain last status dkim record. type DomainLastStatusDkimRecord struct { // Status: status of the DKIM record's configuration. // Default value: unknown_record_status Status DomainLastStatusRecordStatus `json:"status"` // LastValidAt: time and date the DKIM record was last valid. LastValidAt *time.Time `json:"last_valid_at"` // Error: an error text displays in case the record is not valid. Error *string `json:"error"` } // DomainLastStatusDmarcRecord: domain last status dmarc record. type DomainLastStatusDmarcRecord struct { // Status: status of the DMARC record's configuration. // Default value: unknown_record_status Status DomainLastStatusRecordStatus `json:"status"` // LastValidAt: time and date the DMARC record was last valid. LastValidAt *time.Time `json:"last_valid_at"` // Error: an error text displays in case the record is not valid. Error *string `json:"error"` } // DomainLastStatusSpfRecord: domain last status spf record. type DomainLastStatusSpfRecord struct { // Status: status of the SPF record's configuration. // Default value: unknown_record_status Status DomainLastStatusRecordStatus `json:"status"` // LastValidAt: time and date the SPF record was last valid. LastValidAt *time.Time `json:"last_valid_at"` // Error: an error text displays in case the record is not valid. Error *string `json:"error"` } // Domain: domain. type Domain struct { // ID: ID of the domain. ID string `json:"id"` // OrganizationID: ID of the domain's Organization. OrganizationID string `json:"organization_id"` // ProjectID: ID of the domain's Project. ProjectID string `json:"project_id"` // Name: domain name (example.com). Name string `json:"name"` // Status: status of the domain. // Default value: unknown Status DomainStatus `json:"status"` // CreatedAt: date and time of domain creation. CreatedAt *time.Time `json:"created_at"` // NextCheckAt: date and time of the next scheduled check. NextCheckAt *time.Time `json:"next_check_at"` // LastValidAt: date and time the domain was last valid. LastValidAt *time.Time `json:"last_valid_at"` // RevokedAt: date and time of the domain's deletion. RevokedAt *time.Time `json:"revoked_at"` // Deprecated: LastError: error message returned if the last check failed. LastError *string `json:"last_error,omitempty"` // SpfConfig: snippet of the SPF record to register in the DNS zone. SpfConfig string `json:"spf_config"` // DkimConfig: dKIM public key to record in the DNS zone. DkimConfig string `json:"dkim_config"` // Statistics: domain's statistics. Statistics *DomainStatistics `json:"statistics"` // Reputation: the domain's reputation is available when your domain is checked and has sent enough emails. Reputation *DomainReputation `json:"reputation"` // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"region"` } // CancelEmailRequest: cancel email request. type CancelEmailRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // EmailID: ID of the email to cancel. EmailID string `json:"-"` } // CheckDomainRequest: check domain request. type CheckDomainRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DomainID: ID of the domain to check. DomainID string `json:"-"` } // CreateDomainRequest: create domain request. type CreateDomainRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: ID of the project to which the domain belongs. ProjectID string `json:"project_id"` // DomainName: fully qualified domain dame. DomainName string `json:"domain_name"` // AcceptTos: accept Scaleway's Terms of Service. AcceptTos bool `json:"accept_tos"` } // CreateEmailRequest: create email request. type CreateEmailRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // From: sender information. Must be from a checked domain declared in the Project. From *CreateEmailRequestAddress `json:"from,omitempty"` // To: an array of the primary recipient's information. To []*CreateEmailRequestAddress `json:"to"` // Cc: an array of the carbon copy recipient's information. Cc []*CreateEmailRequestAddress `json:"cc"` // Bcc: an array of the blind carbon copy recipient's information. Bcc []*CreateEmailRequestAddress `json:"bcc"` // Subject: subject of the email. Subject string `json:"subject"` // Text: text content. Text string `json:"text"` // HTML: HTML content. HTML string `json:"html"` // ProjectID: ID of the Project in which to create the email. ProjectID string `json:"project_id"` // Attachments: array of attachments. Attachments []*CreateEmailRequestAttachment `json:"attachments"` // SendBefore: maximum date to deliver the email. SendBefore *time.Time `json:"send_before,omitempty"` // AdditionalHeaders: array of additional headers as key-value. AdditionalHeaders []*CreateEmailRequestHeader `json:"additional_headers"` } // CreateEmailResponse: create email response. type CreateEmailResponse struct { // Emails: single page of emails matching the requested criteria. Emails []*Email `json:"emails"` } // DomainLastStatus: domain last status. type DomainLastStatus struct { // DomainID: the ID of the domain. DomainID string `json:"domain_id"` // DomainName: the domain name (example.com). DomainName string `json:"domain_name"` // SpfRecord: the SPF record verification data. SpfRecord *DomainLastStatusSpfRecord `json:"spf_record"` // DkimRecord: the DKIM record verification data. DkimRecord *DomainLastStatusDkimRecord `json:"dkim_record"` // DmarcRecord: the DMARC record verification data. DmarcRecord *DomainLastStatusDmarcRecord `json:"dmarc_record"` } // GetDomainLastStatusRequest: get domain last status request. type GetDomainLastStatusRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DomainID: ID of the domain to delete. DomainID string `json:"-"` } // GetDomainRequest: get domain request. type GetDomainRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DomainID: ID of the domain. DomainID string `json:"-"` } // GetEmailRequest: get email request. type GetEmailRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // EmailID: ID of the email to retrieve. EmailID string `json:"-"` } // GetStatisticsRequest: get statistics request. type GetStatisticsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // ProjectID: (Optional) Number of emails for this Project. ProjectID *string `json:"-"` // DomainID: (Optional) Number of emails sent from this domain (must be coherent with the `project_id` and the `organization_id`). DomainID *string `json:"-"` // Since: (Optional) Number of emails created after this date. Since *time.Time `json:"-"` // Until: (Optional) Number of emails created before this date. Until *time.Time `json:"-"` // MailFrom: (Optional) Number of emails sent with this sender's email address. MailFrom *string `json:"-"` } // ListDomainsRequest: list domains request. type ListDomainsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: requested page number. Value must be greater or equal to 1. Page *int32 `json:"-"` // PageSize: page size. PageSize *uint32 `json:"-"` ProjectID *string `json:"-"` Status []DomainStatus `json:"-"` OrganizationID *string `json:"-"` Name *string `json:"-"` } // ListDomainsResponse: list domains response. type ListDomainsResponse struct { // TotalCount: number of domains that match the request (without pagination). TotalCount uint32 `json:"total_count"` Domains []*Domain `json:"domains"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListDomainsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListDomainsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListDomainsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Domains = append(r.Domains, results.Domains...) r.TotalCount += uint32(len(results.Domains)) return uint32(len(results.Domains)), nil } // ListEmailsRequest: list emails request. type ListEmailsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` Page *int32 `json:"-"` PageSize *uint32 `json:"-"` // ProjectID: (Optional) ID of the Project in which to list the emails. ProjectID *string `json:"-"` // DomainID: (Optional) ID of the domain for which to list the emails. DomainID *string `json:"-"` // MessageID: (Optional) ID of the message for which to list the emails. MessageID *string `json:"-"` // Since: (Optional) List emails created after this date. Since *time.Time `json:"-"` // Until: (Optional) List emails created before this date. Until *time.Time `json:"-"` // MailFrom: (Optional) List emails sent with this sender's email address. MailFrom *string `json:"-"` // Deprecated: MailTo: list emails sent to this recipient's email address. MailTo *string `json:"-"` // MailRcpt: (Optional) List emails sent to this recipient's email address. MailRcpt *string `json:"-"` // Statuses: (Optional) List emails with any of these statuses. Statuses []EmailStatus `json:"-"` // Subject: (Optional) List emails with this subject. Subject *string `json:"-"` // Search: (Optional) List emails by searching to all fields. Search *string `json:"-"` // OrderBy: (Optional) List emails corresponding to specific criteria. // Default value: created_at_desc OrderBy ListEmailsRequestOrderBy `json:"-"` // Flags: (Optional) List emails containing only specific flags. Flags []EmailFlag `json:"-"` } // ListEmailsResponse: list emails response. type ListEmailsResponse struct { // TotalCount: number of emails matching the requested criteria. TotalCount uint32 `json:"total_count"` // Emails: single page of emails matching the requested criteria. Emails []*Email `json:"emails"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListEmailsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListEmailsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListEmailsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Emails = append(r.Emails, results.Emails...) r.TotalCount += uint32(len(results.Emails)) return uint32(len(results.Emails)), nil } // RevokeDomainRequest: revoke domain request. type RevokeDomainRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // DomainID: ID of the domain to delete. DomainID string `json:"-"` } // Statistics: statistics. type Statistics struct { // TotalCount: total number of emails matching the requested criteria. TotalCount uint32 `json:"total_count"` // NewCount: number of emails still in the `new` transient state. This means emails received from the API but not yet processed. NewCount uint32 `json:"new_count"` // SendingCount: number of emails still in the `sending` transient state. This means emails received from the API but not yet in their final status. SendingCount uint32 `json:"sending_count"` // SentCount: number of emails in the final `sent` state. This means emails that have been delivered to the target mail system. SentCount uint32 `json:"sent_count"` // FailedCount: number of emails in the final `failed` state. This means emails that have been refused by the target mail system with a final error status. FailedCount uint32 `json:"failed_count"` // CanceledCount: number of emails in the final `canceled` state. This means emails that have been canceled upon request. CanceledCount uint32 `json:"canceled_count"` } type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Regions() []scw.Region { return []scw.Region{scw.RegionFrPar} } // CreateEmail: You must specify the `region`, the sender and the recipient's information and the `project_id` to send an email from a checked domain. The subject of the email must contain at least 6 characters. func (s *API) CreateEmail(req *CreateEmailRequest, opts ...scw.RequestOption) (*CreateEmailResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/transactional-email/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/emails", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp CreateEmailResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetEmail: Retrieve information about a specific email using the `email_id` and `region` parameters. func (s *API) GetEmail(req *GetEmailRequest, opts ...scw.RequestOption) (*Email, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.EmailID) == "" { return nil, errors.New("field EmailID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/transactional-email/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/emails/" + fmt.Sprint(req.EmailID) + "", } var resp Email err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListEmails: Retrieve the list of emails sent from a specific domain or for a specific Project or Organization. You must specify the `region`. func (s *API) ListEmails(req *ListEmailsRequest, opts ...scw.RequestOption) (*ListEmailsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "domain_id", req.DomainID) parameter.AddToQuery(query, "message_id", req.MessageID) parameter.AddToQuery(query, "since", req.Since) parameter.AddToQuery(query, "until", req.Until) parameter.AddToQuery(query, "mail_from", req.MailFrom) parameter.AddToQuery(query, "mail_to", req.MailTo) parameter.AddToQuery(query, "mail_rcpt", req.MailRcpt) parameter.AddToQuery(query, "statuses", req.Statuses) parameter.AddToQuery(query, "subject", req.Subject) parameter.AddToQuery(query, "search", req.Search) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "flags", req.Flags) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/transactional-email/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/emails", Query: query, } var resp ListEmailsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetStatistics: Get information on your emails' statuses. func (s *API) GetStatistics(req *GetStatisticsRequest, opts ...scw.RequestOption) (*Statistics, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } query := url.Values{} parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "domain_id", req.DomainID) parameter.AddToQuery(query, "since", req.Since) parameter.AddToQuery(query, "until", req.Until) parameter.AddToQuery(query, "mail_from", req.MailFrom) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/transactional-email/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/statistics", Query: query, } var resp Statistics err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CancelEmail: You can cancel the sending of an email if it has not been sent yet. You must specify the `region` and the `email_id` of the email you want to cancel. func (s *API) CancelEmail(req *CancelEmailRequest, opts ...scw.RequestOption) (*Email, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.EmailID) == "" { return nil, errors.New("field EmailID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/transactional-email/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/emails/" + fmt.Sprint(req.EmailID) + "/cancel", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Email err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateDomain: You must specify the `region`, `project_id` and `domain_name` to register a domain in a specific Project. func (s *API) CreateDomain(req *CreateDomainRequest, opts ...scw.RequestOption) (*Domain, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/transactional-email/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/domains", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Domain err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetDomain: Retrieve information about a specific domain using the `region` and `domain_id` parameters. Monitor your domain's reputation and improve **average** and **bad** reputation statuses, using your domain's **Email activity** tab on the [Scaleway console](https://console.scaleway.com/transactional-email/domains) to get a more detailed report. Check out our [dedicated documentation](https://www.scaleway.com/en/docs/managed-services/transactional-email/reference-content/understanding-tem-reputation-score/) to improve your domain's reputation. func (s *API) GetDomain(req *GetDomainRequest, opts ...scw.RequestOption) (*Domain, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DomainID) == "" { return nil, errors.New("field DomainID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/transactional-email/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/domains/" + fmt.Sprint(req.DomainID) + "", } var resp Domain err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListDomains: Retrieve domains in a specific Project or in a specific Organization using the `region` parameter. func (s *API) ListDomains(req *ListDomainsRequest, opts ...scw.RequestOption) (*ListDomainsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "status", req.Status) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "name", req.Name) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/transactional-email/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/domains", Query: query, } var resp ListDomainsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // RevokeDomain: You must specify the domain you want to delete by the `region` and `domain_id`. Deleting a domain is permanent and cannot be undone. func (s *API) RevokeDomain(req *RevokeDomainRequest, opts ...scw.RequestOption) (*Domain, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DomainID) == "" { return nil, errors.New("field DomainID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/transactional-email/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/domains/" + fmt.Sprint(req.DomainID) + "/revoke", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Domain err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CheckDomain: Perform an immediate DNS check of a domain using the `region` and `domain_id` parameters. func (s *API) CheckDomain(req *CheckDomainRequest, opts ...scw.RequestOption) (*Domain, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DomainID) == "" { return nil, errors.New("field DomainID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/transactional-email/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/domains/" + fmt.Sprint(req.DomainID) + "/check", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Domain err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetDomainLastStatus: Display SPF and DKIM records status and potential errors, including the found records to make debugging easier. func (s *API) GetDomainLastStatus(req *GetDomainLastStatusRequest, opts ...scw.RequestOption) (*DomainLastStatus, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.DomainID) == "" { return nil, errors.New("field DomainID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/transactional-email/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/domains/" + fmt.Sprint(req.DomainID) + "/verification", } var resp DomainLastStatus err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/tem/v1alpha1/tem_utils.go000066400000000000000000000036301456366605600275670ustar00rootroot00000000000000package tem import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) const ( defaultTimeout = 5 * time.Minute defaultRetryInterval = 15 * time.Second SMTPHost = "smtp.tem.scw.cloud" SMTPPortUnsecure = 25 SMTPPort = 587 SMTPPortAlternative = 2587 SMTPSPort = 465 SMTPSPortAlternative = 2465 MXBlackhole = "blackhole.scw-tem.cloud." ) // WaitForDomainRequest is used by WaitForDomain method type WaitForDomainRequest struct { DomainID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForDomain wait for the domain to be in a "terminal state" before returning. // This function can be used to wait for a domain to be checked for example. func (s *API) WaitForDomain(req *WaitForDomainRequest, opts ...scw.RequestOption) (*Domain, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[DomainStatus]struct{}{ DomainStatusChecked: {}, DomainStatusUnchecked: {}, DomainStatusInvalid: {}, DomainStatusLocked: {}, DomainStatusRevoked: {}, DomainStatusUnknown: {}, } domain, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { img, err := s.GetDomain(&GetDomainRequest{ Region: req.Region, DomainID: req.DomainID, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[img.Status] return img, isTerminal, err }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for domain failed") } return domain.(*Domain), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/test/000077500000000000000000000000001456366605600240065ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/test/v1/000077500000000000000000000000001456366605600243345ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/test/v1/test_sdk.go000066400000000000000000000322041456366605600265040ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package test provides methods and message types of the test v1 API. package test import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type EyeColors string const ( // Unknown color. EyeColorsUnknown = EyeColors("unknown") // Rare and striking shade that typically features a golden or yellowish-brown hue. EyeColorsAmber = EyeColors("amber") // Relatively rare, with the highest frequency found in eastern Europe. EyeColorsBlue = EyeColors("blue") // Most common eye color in the world caused by a high concentration of melanin in the iris. EyeColorsBrown = EyeColors("brown") // Relatively rare color which can change depending on the lighting conditions. EyeColorsGray = EyeColors("gray") // Rare and unique color characterized by a combination of yellow, brown, and blue pigments. EyeColorsGreen = EyeColors("green") // Brownish-yellow or greenish-brown with a hint of gold. EyeColorsHazel = EyeColors("hazel") // Rare mutation that results in a reddish-pink hue. EyeColorsRed = EyeColors("red") // Rare and striking shade that appears to be a mix of blue and purple. EyeColorsViolet = EyeColors("violet") ) func (enum EyeColors) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum EyeColors) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *EyeColors) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = EyeColors(EyeColors(tmp).String()) return nil } type HumanStatus string const ( // Unknown status. HumanStatusUnknown = HumanStatus("unknown") // The human is stopped. HumanStatusStopped = HumanStatus("stopped") // The human is running. HumanStatusRunning = HumanStatus("running") ) func (enum HumanStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum HumanStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *HumanStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = HumanStatus(HumanStatus(tmp).String()) return nil } type ListHumansRequestOrderBy string const ( // Ascending creation date. ListHumansRequestOrderByCreatedAtAsc = ListHumansRequestOrderBy("created_at_asc") // Descending creation date. ListHumansRequestOrderByCreatedAtDesc = ListHumansRequestOrderBy("created_at_desc") // Ascending update date. ListHumansRequestOrderByUpdatedAtAsc = ListHumansRequestOrderBy("updated_at_asc") // Descending update date. ListHumansRequestOrderByUpdatedAtDesc = ListHumansRequestOrderBy("updated_at_desc") // Ascending height. ListHumansRequestOrderByHeightAsc = ListHumansRequestOrderBy("height_asc") // Descending height. ListHumansRequestOrderByHeightDesc = ListHumansRequestOrderBy("height_desc") ) func (enum ListHumansRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListHumansRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListHumansRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListHumansRequestOrderBy(ListHumansRequestOrderBy(tmp).String()) return nil } // Human: human. type Human struct { ID string `json:"id"` OrganizationID string `json:"organization_id"` CreatedAt *time.Time `json:"created_at"` UpdatedAt *time.Time `json:"updated_at"` Height float64 `json:"height"` ShoeSize float32 `json:"shoe_size"` AltitudeInMeter int32 `json:"altitude_in_meter"` AltitudeInMillimeter int64 `json:"altitude_in_millimeter"` FingersCount uint32 `json:"fingers_count"` HairCount uint64 `json:"hair_count"` IsHappy bool `json:"is_happy"` // EyesColor: default value: unknown EyesColor EyeColors `json:"eyes_color"` // Status: default value: unknown Status HumanStatus `json:"status"` Name string `json:"name"` ProjectID string `json:"project_id"` } // CreateHumanRequest: create human request. type CreateHumanRequest struct { Height float64 `json:"height"` ShoeSize float32 `json:"shoe_size"` AltitudeInMeter int32 `json:"altitude_in_meter"` AltitudeInMillimeter int64 `json:"altitude_in_millimeter"` FingersCount uint32 `json:"fingers_count"` HairCount uint64 `json:"hair_count"` IsHappy bool `json:"is_happy"` // EyesColor: default value: unknown EyesColor EyeColors `json:"eyes_color"` // Deprecated // Precisely one of ProjectID, OrganizationID must be set. OrganizationID *string `json:"organization_id,omitempty"` Name string `json:"name"` // Precisely one of ProjectID, OrganizationID must be set. ProjectID *string `json:"project_id,omitempty"` } // DeleteHumanRequest: delete human request. type DeleteHumanRequest struct { // HumanID: UUID of the human you want to delete. HumanID string `json:"-"` } // GetHumanRequest: get human request. type GetHumanRequest struct { // HumanID: UUID of the human you want to get. HumanID string `json:"-"` } // ListHumansRequest: list humans request. type ListHumansRequest struct { Page *int32 `json:"-"` PageSize *uint32 `json:"-"` // OrderBy: default value: created_at_asc OrderBy ListHumansRequestOrderBy `json:"-"` OrganizationID *string `json:"-"` ProjectID *string `json:"-"` } // ListHumansResponse: list humans response. type ListHumansResponse struct { TotalCount uint32 `json:"total_count"` Humans []*Human `json:"humans"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListHumansResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListHumansResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListHumansResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Humans = append(r.Humans, results.Humans...) r.TotalCount += uint32(len(results.Humans)) return uint32(len(results.Humans)), nil } // RegisterRequest: register request. type RegisterRequest struct { Username string `json:"username"` } // RegisterResponse: register response. type RegisterResponse struct { SecretKey string `json:"secret_key"` AccessKey string `json:"access_key"` } // RunHumanRequest: run human request. type RunHumanRequest struct { // HumanID: UUID of the human you want to make run. HumanID string `json:"-"` } // SmokeHumanRequest: smoke human request. type SmokeHumanRequest struct { // Deprecated: HumanID: UUID of the human you want to make smoking. HumanID string `json:"-"` } // UpdateHumanRequest: update human request. type UpdateHumanRequest struct { // HumanID: UUID of the human you want to update. HumanID string `json:"-"` // Height: height of the human in meters. Height *float64 `json:"height,omitempty"` ShoeSize *float32 `json:"shoe_size,omitempty"` AltitudeInMeter *int32 `json:"altitude_in_meter,omitempty"` AltitudeInMillimeter *int64 `json:"altitude_in_millimeter,omitempty"` FingersCount *uint32 `json:"fingers_count,omitempty"` HairCount *uint64 `json:"hair_count,omitempty"` IsHappy *bool `json:"is_happy,omitempty"` // EyesColor: default value: unknown EyesColor EyeColors `json:"eyes_color"` Name *string `json:"name,omitempty"` } // No Auth Service for end-to-end testing. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } // Register: Register a human and return a access-key and a secret-key that must be used in all other commands. // // Hint: you can use other test commands by setting the SCW_SECRET_KEY env variable. func (s *API) Register(req *RegisterRequest, opts ...scw.RequestOption) (*RegisterResponse, error) { var err error scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/test/v1/register", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp RegisterResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListHumans: List all your humans. func (s *API) ListHumans(req *ListHumansRequest, opts ...scw.RequestOption) (*ListHumansResponse, error) { var err error defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/test/v1/humans", Query: query, } var resp ListHumansResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetHuman: Get the human details associated with the given id. func (s *API) GetHuman(req *GetHumanRequest, opts ...scw.RequestOption) (*Human, error) { var err error if fmt.Sprint(req.HumanID) == "" { return nil, errors.New("field HumanID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/test/v1/humans/" + fmt.Sprint(req.HumanID) + "", } var resp Human err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateHuman: Create a new human. func (s *API) CreateHuman(req *CreateHumanRequest, opts ...scw.RequestOption) (*Human, error) { var err error defaultProjectID, exist := s.client.GetDefaultProjectID() if exist && req.ProjectID == nil && req.OrganizationID == nil { req.ProjectID = &defaultProjectID } defaultOrganizationID, exist := s.client.GetDefaultOrganizationID() if exist && req.ProjectID == nil && req.OrganizationID == nil { req.OrganizationID = &defaultOrganizationID } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/test/v1/humans", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Human err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateHuman: Update the human associated with the given id. func (s *API) UpdateHuman(req *UpdateHumanRequest, opts ...scw.RequestOption) (*Human, error) { var err error if fmt.Sprint(req.HumanID) == "" { return nil, errors.New("field HumanID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/test/v1/humans/" + fmt.Sprint(req.HumanID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Human err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteHuman: Delete the human associated with the given id. func (s *API) DeleteHuman(req *DeleteHumanRequest, opts ...scw.RequestOption) (*Human, error) { var err error if fmt.Sprint(req.HumanID) == "" { return nil, errors.New("field HumanID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/test/v1/humans/" + fmt.Sprint(req.HumanID) + "", } var resp Human err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // RunHuman: Start a one hour running for the given human. func (s *API) RunHuman(req *RunHumanRequest, opts ...scw.RequestOption) (*Human, error) { var err error if fmt.Sprint(req.HumanID) == "" { return nil, errors.New("field HumanID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/test/v1/humans/" + fmt.Sprint(req.HumanID) + "/run", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Human err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // Deprecated: SmokeHuman: Make a human smoke. func (s *API) SmokeHuman(req *SmokeHumanRequest, opts ...scw.RequestOption) (*Human, error) { var err error if fmt.Sprint(req.HumanID) == "" { return nil, errors.New("field HumanID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/test/v1/humans/" + fmt.Sprint(req.HumanID) + "/smoke", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Human err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/vpc/000077500000000000000000000000001456366605600236175ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/vpc/v1/000077500000000000000000000000001456366605600241455ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/vpc/v1/vpc_sdk.go000066400000000000000000000300401456366605600261220ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package vpc provides methods and message types of the vpc v1 API. package vpc import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type ListPrivateNetworksRequestOrderBy string const ( ListPrivateNetworksRequestOrderByCreatedAtAsc = ListPrivateNetworksRequestOrderBy("created_at_asc") ListPrivateNetworksRequestOrderByCreatedAtDesc = ListPrivateNetworksRequestOrderBy("created_at_desc") ListPrivateNetworksRequestOrderByNameAsc = ListPrivateNetworksRequestOrderBy("name_asc") ListPrivateNetworksRequestOrderByNameDesc = ListPrivateNetworksRequestOrderBy("name_desc") ) func (enum ListPrivateNetworksRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListPrivateNetworksRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListPrivateNetworksRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListPrivateNetworksRequestOrderBy(ListPrivateNetworksRequestOrderBy(tmp).String()) return nil } // PrivateNetwork: private network. type PrivateNetwork struct { // ID: private Network ID. ID string `json:"id"` // Name: private Network name. Name string `json:"name"` // OrganizationID: scaleway Organization the Private Network belongs to. OrganizationID string `json:"organization_id"` // ProjectID: scaleway Project the Private Network belongs to. ProjectID string `json:"project_id"` // Zone: availability Zone in which the Private Network is available. Zone scw.Zone `json:"zone"` // Tags: tags of the Private Network. Tags []string `json:"tags"` // CreatedAt: date the Private Network was created. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date the Private Network was last modified. UpdatedAt *time.Time `json:"updated_at"` // Subnets: private Network subnets CIDR. Subnets []scw.IPNet `json:"subnets"` } // CreatePrivateNetworkRequest: create private network request. type CreatePrivateNetworkRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // Name: name for the Private Network. Name string `json:"name"` // ProjectID: scaleway Project in which to create the Private Network. ProjectID string `json:"project_id"` // Tags: tags for the Private Network. Tags []string `json:"tags"` // Subnets: private Network subnets CIDR. Subnets []scw.IPNet `json:"subnets"` } // DeletePrivateNetworkRequest: delete private network request. type DeletePrivateNetworkRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // PrivateNetworkID: private Network ID. PrivateNetworkID string `json:"-"` } // GetPrivateNetworkRequest: get private network request. type GetPrivateNetworkRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // PrivateNetworkID: private Network ID. PrivateNetworkID string `json:"-"` } // ListPrivateNetworksRequest: list private networks request. type ListPrivateNetworksRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // OrderBy: sort order of the returned Private Networks. // Default value: created_at_asc OrderBy ListPrivateNetworksRequestOrderBy `json:"-"` // Page: page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: maximum number of Private Networks to return per page. PageSize *uint32 `json:"-"` // Name: name to filter for. Only Private Networks with names containing this string will be returned. Name *string `json:"-"` // Tags: tags to filter for. Only Private Networks with one or more matching tags will be returned. Tags []string `json:"-"` // OrganizationID: organization ID to filter for. Only Private Networks belonging to this Organization will be returned. OrganizationID *string `json:"-"` // ProjectID: project ID to filter for. Only Private Networks belonging to this Project will be returned. ProjectID *string `json:"-"` // PrivateNetworkIDs: private Network IDs to filter for. Only Private Networks with one of these IDs will be returned. PrivateNetworkIDs []string `json:"-"` // IncludeRegional: defines whether to include regional Private Networks in the response. IncludeRegional *bool `json:"-"` } // ListPrivateNetworksResponse: list private networks response. type ListPrivateNetworksResponse struct { PrivateNetworks []*PrivateNetwork `json:"private_networks"` TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListPrivateNetworksResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListPrivateNetworksResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListPrivateNetworksResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.PrivateNetworks = append(r.PrivateNetworks, results.PrivateNetworks...) r.TotalCount += uint32(len(results.PrivateNetworks)) return uint32(len(results.PrivateNetworks)), nil } // UpdatePrivateNetworkRequest: update private network request. type UpdatePrivateNetworkRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // PrivateNetworkID: private Network ID. PrivateNetworkID string `json:"-"` // Name: name of the private network. Name *string `json:"name,omitempty"` // Tags: tags for the Private Network. Tags *[]string `json:"tags,omitempty"` // Deprecated: Subnets: private Network subnets CIDR (deprecated). Subnets *[]string `json:"subnets,omitempty"` } // VPC API. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Zones() []scw.Zone { return []scw.Zone{scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneFrPar3, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2} } // ListPrivateNetworks: List existing Private Networks in a specified Availability Zone. By default, the Private Networks returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. func (s *API) ListPrivateNetworks(req *ListPrivateNetworksRequest, opts ...scw.RequestOption) (*ListPrivateNetworksResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "tags", req.Tags) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "private_network_ids", req.PrivateNetworkIDs) parameter.AddToQuery(query, "include_regional", req.IncludeRegional) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/vpc/v1/zones/" + fmt.Sprint(req.Zone) + "/private-networks", Query: query, } var resp ListPrivateNetworksResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreatePrivateNetwork: Create a new Private Network. Once created, you can attach Scaleway resources in the same Availability Zone. func (s *API) CreatePrivateNetwork(req *CreatePrivateNetworkRequest, opts ...scw.RequestOption) (*PrivateNetwork, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if req.Name == "" { req.Name = namegenerator.GetRandomName("pn") } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/vpc/v1/zones/" + fmt.Sprint(req.Zone) + "/private-networks", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp PrivateNetwork err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetPrivateNetwork: Retrieve information about an existing Private Network, specified by its Private Network ID. Its full details are returned in the response object. func (s *API) GetPrivateNetwork(req *GetPrivateNetworkRequest, opts ...scw.RequestOption) (*PrivateNetwork, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.PrivateNetworkID) == "" { return nil, errors.New("field PrivateNetworkID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/vpc/v1/zones/" + fmt.Sprint(req.Zone) + "/private-networks/" + fmt.Sprint(req.PrivateNetworkID) + "", } var resp PrivateNetwork err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdatePrivateNetwork: Update parameters (such as name or tags) of an existing Private Network, specified by its Private Network ID. func (s *API) UpdatePrivateNetwork(req *UpdatePrivateNetworkRequest, opts ...scw.RequestOption) (*PrivateNetwork, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.PrivateNetworkID) == "" { return nil, errors.New("field PrivateNetworkID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/vpc/v1/zones/" + fmt.Sprint(req.Zone) + "/private-networks/" + fmt.Sprint(req.PrivateNetworkID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp PrivateNetwork err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeletePrivateNetwork: Delete an existing Private Network. Note that you must first detach all resources from the network, in order to delete it. func (s *API) DeletePrivateNetwork(req *DeletePrivateNetworkRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.PrivateNetworkID) == "" { return errors.New("field PrivateNetworkID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/vpc/v1/zones/" + fmt.Sprint(req.Zone) + "/private-networks/" + fmt.Sprint(req.PrivateNetworkID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/vpc/v2/000077500000000000000000000000001456366605600241465ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/vpc/v2/vpc_sdk.go000066400000000000000000000725111456366605600261340ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package vpc provides methods and message types of the vpc v2 API. package vpc import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type ListPrivateNetworksRequestOrderBy string const ( ListPrivateNetworksRequestOrderByCreatedAtAsc = ListPrivateNetworksRequestOrderBy("created_at_asc") ListPrivateNetworksRequestOrderByCreatedAtDesc = ListPrivateNetworksRequestOrderBy("created_at_desc") ListPrivateNetworksRequestOrderByNameAsc = ListPrivateNetworksRequestOrderBy("name_asc") ListPrivateNetworksRequestOrderByNameDesc = ListPrivateNetworksRequestOrderBy("name_desc") ) func (enum ListPrivateNetworksRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListPrivateNetworksRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListPrivateNetworksRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListPrivateNetworksRequestOrderBy(ListPrivateNetworksRequestOrderBy(tmp).String()) return nil } type ListVPCsRequestOrderBy string const ( ListVPCsRequestOrderByCreatedAtAsc = ListVPCsRequestOrderBy("created_at_asc") ListVPCsRequestOrderByCreatedAtDesc = ListVPCsRequestOrderBy("created_at_desc") ListVPCsRequestOrderByNameAsc = ListVPCsRequestOrderBy("name_asc") ListVPCsRequestOrderByNameDesc = ListVPCsRequestOrderBy("name_desc") ) func (enum ListVPCsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListVPCsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListVPCsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListVPCsRequestOrderBy(ListVPCsRequestOrderBy(tmp).String()) return nil } // Subnet: subnet. type Subnet struct { // ID: ID of the subnet. ID string `json:"id"` // CreatedAt: subnet creation date. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: subnet last modification date. UpdatedAt *time.Time `json:"updated_at"` // Subnet: subnet CIDR. Subnet scw.IPNet `json:"subnet"` } // PrivateNetwork: private network. type PrivateNetwork struct { // ID: private Network ID. ID string `json:"id"` // Name: private Network name. Name string `json:"name"` // OrganizationID: scaleway Organization the Private Network belongs to. OrganizationID string `json:"organization_id"` // ProjectID: scaleway Project the Private Network belongs to. ProjectID string `json:"project_id"` // Region: region in which the Private Network is available. Region scw.Region `json:"region"` // Tags: tags of the Private Network. Tags []string `json:"tags"` // CreatedAt: date the Private Network was created. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date the Private Network was last modified. UpdatedAt *time.Time `json:"updated_at"` // Subnets: private Network subnets. Subnets []*Subnet `json:"subnets"` // VpcID: vPC the Private Network belongs to. VpcID string `json:"vpc_id"` // DHCPEnabled: defines whether managed DHCP is enabled for this Private Network. DHCPEnabled bool `json:"dhcp_enabled"` } // VPC: vpc. type VPC struct { // ID: vPC ID. ID string `json:"id"` // Name: vPC name. Name string `json:"name"` // OrganizationID: scaleway Organization the VPC belongs to. OrganizationID string `json:"organization_id"` // ProjectID: scaleway Project the VPC belongs to. ProjectID string `json:"project_id"` // Region: region of the VPC. Region scw.Region `json:"region"` // Tags: tags for the VPC. Tags []string `json:"tags"` // IsDefault: defines whether the VPC is the default one for its Project. IsDefault bool `json:"is_default"` // CreatedAt: date the VPC was created. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: date the VPC was last modified. UpdatedAt *time.Time `json:"updated_at"` // PrivateNetworkCount: number of Private Networks within this VPC. PrivateNetworkCount uint32 `json:"private_network_count"` } // AddSubnetsRequest: add subnets request. type AddSubnetsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // PrivateNetworkID: private Network ID. PrivateNetworkID string `json:"-"` // Subnets: private Network subnets CIDR. Subnets []scw.IPNet `json:"subnets"` } // AddSubnetsResponse: add subnets response. type AddSubnetsResponse struct { Subnets []scw.IPNet `json:"subnets"` } // CreatePrivateNetworkRequest: create private network request. type CreatePrivateNetworkRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Name: name for the Private Network. Name string `json:"name"` // ProjectID: scaleway Project in which to create the Private Network. ProjectID string `json:"project_id"` // Tags: tags for the Private Network. Tags []string `json:"tags"` // Subnets: private Network subnets CIDR. Subnets []scw.IPNet `json:"subnets"` // VpcID: vPC in which to create the Private Network. VpcID *string `json:"vpc_id,omitempty"` } // CreateVPCRequest: create vpc request. type CreateVPCRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Name: name for the VPC. Name string `json:"name"` // ProjectID: scaleway Project in which to create the VPC. ProjectID string `json:"project_id"` // Tags: tags for the VPC. Tags []string `json:"tags"` } // DeletePrivateNetworkRequest: delete private network request. type DeletePrivateNetworkRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // PrivateNetworkID: private Network ID. PrivateNetworkID string `json:"-"` } // DeleteSubnetsRequest: delete subnets request. type DeleteSubnetsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // PrivateNetworkID: private Network ID. PrivateNetworkID string `json:"-"` // Subnets: private Network subnets CIDR. Subnets []scw.IPNet `json:"subnets"` } // DeleteSubnetsResponse: delete subnets response. type DeleteSubnetsResponse struct { Subnets []scw.IPNet `json:"subnets"` } // DeleteVPCRequest: delete vpc request. type DeleteVPCRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // VpcID: vPC ID. VpcID string `json:"-"` } // EnableDHCPRequest: enable dhcp request. type EnableDHCPRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // PrivateNetworkID: private Network ID. PrivateNetworkID string `json:"-"` } // GetPrivateNetworkRequest: get private network request. type GetPrivateNetworkRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // PrivateNetworkID: private Network ID. PrivateNetworkID string `json:"-"` } // GetVPCRequest: get vpc request. type GetVPCRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // VpcID: vPC ID. VpcID string `json:"-"` } // ListPrivateNetworksRequest: list private networks request. type ListPrivateNetworksRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // OrderBy: sort order of the returned Private Networks. // Default value: created_at_asc OrderBy ListPrivateNetworksRequestOrderBy `json:"-"` // Page: page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: maximum number of Private Networks to return per page. PageSize *uint32 `json:"-"` // Name: name to filter for. Only Private Networks with names containing this string will be returned. Name *string `json:"-"` // Tags: tags to filter for. Only Private Networks with one or more matching tags will be returned. Tags []string `json:"-"` // OrganizationID: organization ID to filter for. Only Private Networks belonging to this Organization will be returned. OrganizationID *string `json:"-"` // ProjectID: project ID to filter for. Only Private Networks belonging to this Project will be returned. ProjectID *string `json:"-"` // PrivateNetworkIDs: private Network IDs to filter for. Only Private Networks with one of these IDs will be returned. PrivateNetworkIDs []string `json:"-"` // VpcID: vPC ID to filter for. Only Private Networks belonging to this VPC will be returned. VpcID *string `json:"-"` // DHCPEnabled: DHCP status to filter for. When true, only Private Networks with managed DHCP enabled will be returned. DHCPEnabled *bool `json:"-"` } // ListPrivateNetworksResponse: list private networks response. type ListPrivateNetworksResponse struct { PrivateNetworks []*PrivateNetwork `json:"private_networks"` TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListPrivateNetworksResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListPrivateNetworksResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListPrivateNetworksResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.PrivateNetworks = append(r.PrivateNetworks, results.PrivateNetworks...) r.TotalCount += uint32(len(results.PrivateNetworks)) return uint32(len(results.PrivateNetworks)), nil } // ListVPCsRequest: list vp cs request. type ListVPCsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // OrderBy: sort order of the returned VPCs. // Default value: created_at_asc OrderBy ListVPCsRequestOrderBy `json:"-"` // Page: page number to return, from the paginated results. Page *int32 `json:"-"` // PageSize: maximum number of VPCs to return per page. PageSize *uint32 `json:"-"` // Name: name to filter for. Only VPCs with names containing this string will be returned. Name *string `json:"-"` // Tags: tags to filter for. Only VPCs with one more more matching tags will be returned. Tags []string `json:"-"` // OrganizationID: organization ID to filter for. Only VPCs belonging to this Organization will be returned. OrganizationID *string `json:"-"` // ProjectID: project ID to filter for. Only VPCs belonging to this Project will be returned. ProjectID *string `json:"-"` // IsDefault: defines whether to filter only for VPCs which are the default one for their Project. IsDefault *bool `json:"-"` } // ListVPCsResponse: list vp cs response. type ListVPCsResponse struct { Vpcs []*VPC `json:"vpcs"` TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListVPCsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListVPCsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListVPCsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Vpcs = append(r.Vpcs, results.Vpcs...) r.TotalCount += uint32(len(results.Vpcs)) return uint32(len(results.Vpcs)), nil } // MigrateZonalPrivateNetworksRequest: migrate zonal private networks request. type MigrateZonalPrivateNetworksRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // OrganizationID: organization ID to target. The specified zoned Private Networks within this Organization will be migrated to regional. // Precisely one of OrganizationID, ProjectID must be set. OrganizationID *string `json:"organization_id,omitempty"` // ProjectID: project to target. The specified zoned Private Networks within this Project will be migrated to regional. // Precisely one of OrganizationID, ProjectID must be set. ProjectID *string `json:"project_id,omitempty"` // PrivateNetworkIDs: iDs of the Private Networks to migrate. PrivateNetworkIDs []string `json:"private_network_ids"` } // SetSubnetsRequest: set subnets request. type SetSubnetsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // PrivateNetworkID: private Network ID. PrivateNetworkID string `json:"-"` // Subnets: private Network subnets CIDR. Subnets []scw.IPNet `json:"subnets"` } // SetSubnetsResponse: set subnets response. type SetSubnetsResponse struct { Subnets []scw.IPNet `json:"subnets"` } // UpdatePrivateNetworkRequest: update private network request. type UpdatePrivateNetworkRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // PrivateNetworkID: private Network ID. PrivateNetworkID string `json:"-"` // Name: name for the Private Network. Name *string `json:"name,omitempty"` // Tags: tags for the Private Network. Tags *[]string `json:"tags,omitempty"` } // UpdateVPCRequest: update vpc request. type UpdateVPCRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // VpcID: vPC ID. VpcID string `json:"-"` // Name: name for the VPC. Name *string `json:"name,omitempty"` // Tags: tags for the VPC. Tags *[]string `json:"tags,omitempty"` } // VPC API. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Regions() []scw.Region { return []scw.Region{scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw} } // ListVPCs: List existing VPCs in the specified region. func (s *API) ListVPCs(req *ListVPCsRequest, opts ...scw.RequestOption) (*ListVPCsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "tags", req.Tags) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "is_default", req.IsDefault) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/vpc/v2/regions/" + fmt.Sprint(req.Region) + "/vpcs", Query: query, } var resp ListVPCsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateVPC: Create a new VPC in the specified region. func (s *API) CreateVPC(req *CreateVPCRequest, opts ...scw.RequestOption) (*VPC, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if req.Name == "" { req.Name = namegenerator.GetRandomName("vpc") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/vpc/v2/regions/" + fmt.Sprint(req.Region) + "/vpcs", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp VPC err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetVPC: Retrieve details of an existing VPC, specified by its VPC ID. func (s *API) GetVPC(req *GetVPCRequest, opts ...scw.RequestOption) (*VPC, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.VpcID) == "" { return nil, errors.New("field VpcID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/vpc/v2/regions/" + fmt.Sprint(req.Region) + "/vpcs/" + fmt.Sprint(req.VpcID) + "", } var resp VPC err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateVPC: Update parameters including name and tags of the specified VPC. func (s *API) UpdateVPC(req *UpdateVPCRequest, opts ...scw.RequestOption) (*VPC, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.VpcID) == "" { return nil, errors.New("field VpcID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/vpc/v2/regions/" + fmt.Sprint(req.Region) + "/vpcs/" + fmt.Sprint(req.VpcID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp VPC err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteVPC: Delete a VPC specified by its VPC ID. func (s *API) DeleteVPC(req *DeleteVPCRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.VpcID) == "" { return errors.New("field VpcID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/vpc/v2/regions/" + fmt.Sprint(req.Region) + "/vpcs/" + fmt.Sprint(req.VpcID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListPrivateNetworks: List existing Private Networks in the specified region. By default, the Private Networks returned in the list are ordered by creation date in ascending order, though this can be modified via the order_by field. func (s *API) ListPrivateNetworks(req *ListPrivateNetworksRequest, opts ...scw.RequestOption) (*ListPrivateNetworksResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "tags", req.Tags) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "private_network_ids", req.PrivateNetworkIDs) parameter.AddToQuery(query, "vpc_id", req.VpcID) parameter.AddToQuery(query, "dhcp_enabled", req.DHCPEnabled) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/vpc/v2/regions/" + fmt.Sprint(req.Region) + "/private-networks", Query: query, } var resp ListPrivateNetworksResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreatePrivateNetwork: Create a new Private Network. Once created, you can attach Scaleway resources which are in the same region. func (s *API) CreatePrivateNetwork(req *CreatePrivateNetworkRequest, opts ...scw.RequestOption) (*PrivateNetwork, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if req.Name == "" { req.Name = namegenerator.GetRandomName("pn") } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/vpc/v2/regions/" + fmt.Sprint(req.Region) + "/private-networks", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp PrivateNetwork err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetPrivateNetwork: Retrieve information about an existing Private Network, specified by its Private Network ID. Its full details are returned in the response object. func (s *API) GetPrivateNetwork(req *GetPrivateNetworkRequest, opts ...scw.RequestOption) (*PrivateNetwork, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.PrivateNetworkID) == "" { return nil, errors.New("field PrivateNetworkID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/vpc/v2/regions/" + fmt.Sprint(req.Region) + "/private-networks/" + fmt.Sprint(req.PrivateNetworkID) + "", } var resp PrivateNetwork err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdatePrivateNetwork: Update parameters (such as name or tags) of an existing Private Network, specified by its Private Network ID. func (s *API) UpdatePrivateNetwork(req *UpdatePrivateNetworkRequest, opts ...scw.RequestOption) (*PrivateNetwork, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.PrivateNetworkID) == "" { return nil, errors.New("field PrivateNetworkID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/vpc/v2/regions/" + fmt.Sprint(req.Region) + "/private-networks/" + fmt.Sprint(req.PrivateNetworkID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp PrivateNetwork err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeletePrivateNetwork: Delete an existing Private Network. Note that you must first detach all resources from the network, in order to delete it. func (s *API) DeletePrivateNetwork(req *DeletePrivateNetworkRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.PrivateNetworkID) == "" { return errors.New("field PrivateNetworkID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/vpc/v2/regions/" + fmt.Sprint(req.Region) + "/private-networks/" + fmt.Sprint(req.PrivateNetworkID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // MigrateZonalPrivateNetworks: Transform multiple existing zoned Private Networks (scoped to a single Availability Zone) into regional Private Networks, scoped to an entire region. You can transform one or many Private Networks (specified by their Private Network IDs) within a single Scaleway Organization or Project, with the same call. func (s *API) MigrateZonalPrivateNetworks(req *MigrateZonalPrivateNetworksRequest, opts ...scw.RequestOption) error { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultOrganizationID, exist := s.client.GetDefaultOrganizationID() if exist && req.OrganizationID == nil && req.ProjectID == nil { req.OrganizationID = &defaultOrganizationID } defaultProjectID, exist := s.client.GetDefaultProjectID() if exist && req.OrganizationID == nil && req.ProjectID == nil { req.ProjectID = &defaultProjectID } if fmt.Sprint(req.Region) == "" { return errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/vpc/v2/regions/" + fmt.Sprint(req.Region) + "/private-networks/migrate-zonal", } err = scwReq.SetBody(req) if err != nil { return err } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // EnableDHCP: Enable DHCP managed on an existing Private Network. Note that you will not be able to deactivate it afterwards. func (s *API) EnableDHCP(req *EnableDHCPRequest, opts ...scw.RequestOption) (*PrivateNetwork, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.PrivateNetworkID) == "" { return nil, errors.New("field PrivateNetworkID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/vpc/v2/regions/" + fmt.Sprint(req.Region) + "/private-networks/" + fmt.Sprint(req.PrivateNetworkID) + "/enable-dhcp", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp PrivateNetwork err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SetSubnets: Set subnets for an existing Private Network. Note that the method is PUT and not PATCH. Any existing subnets will be removed in favor of the new specified set of subnets. func (s *API) SetSubnets(req *SetSubnetsRequest, opts ...scw.RequestOption) (*SetSubnetsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.PrivateNetworkID) == "" { return nil, errors.New("field PrivateNetworkID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/vpc/v2/regions/" + fmt.Sprint(req.Region) + "/private-networks/" + fmt.Sprint(req.PrivateNetworkID) + "/subnets", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SetSubnetsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // AddSubnets: Add new subnets to an existing Private Network. func (s *API) AddSubnets(req *AddSubnetsRequest, opts ...scw.RequestOption) (*AddSubnetsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.PrivateNetworkID) == "" { return nil, errors.New("field PrivateNetworkID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/vpc/v2/regions/" + fmt.Sprint(req.Region) + "/private-networks/" + fmt.Sprint(req.PrivateNetworkID) + "/subnets", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp AddSubnetsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteSubnets: Delete the specified subnets from a Private Network. func (s *API) DeleteSubnets(req *DeleteSubnetsRequest, opts ...scw.RequestOption) (*DeleteSubnetsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.PrivateNetworkID) == "" { return nil, errors.New("field PrivateNetworkID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/vpc/v2/regions/" + fmt.Sprint(req.Region) + "/private-networks/" + fmt.Sprint(req.PrivateNetworkID) + "/subnets", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp DeleteSubnetsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/vpcgw/000077500000000000000000000000001456366605600241555ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/vpcgw/v1/000077500000000000000000000000001456366605600245035ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/vpcgw/v1/vpcgw_sdk.go000066400000000000000000002564241456366605600270360ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package vpcgw provides methods and message types of the vpcgw v1 API. package vpcgw import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type DHCPEntryType string const ( DHCPEntryTypeUnknown = DHCPEntryType("unknown") DHCPEntryTypeReservation = DHCPEntryType("reservation") DHCPEntryTypeLease = DHCPEntryType("lease") ) func (enum DHCPEntryType) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum DHCPEntryType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DHCPEntryType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DHCPEntryType(DHCPEntryType(tmp).String()) return nil } type GatewayNetworkStatus string const ( GatewayNetworkStatusUnknown = GatewayNetworkStatus("unknown") GatewayNetworkStatusCreated = GatewayNetworkStatus("created") GatewayNetworkStatusAttaching = GatewayNetworkStatus("attaching") GatewayNetworkStatusConfiguring = GatewayNetworkStatus("configuring") GatewayNetworkStatusReady = GatewayNetworkStatus("ready") GatewayNetworkStatusDetaching = GatewayNetworkStatus("detaching") GatewayNetworkStatusDeleted = GatewayNetworkStatus("deleted") ) func (enum GatewayNetworkStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum GatewayNetworkStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *GatewayNetworkStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = GatewayNetworkStatus(GatewayNetworkStatus(tmp).String()) return nil } type GatewayStatus string const ( GatewayStatusUnknown = GatewayStatus("unknown") GatewayStatusStopped = GatewayStatus("stopped") GatewayStatusAllocating = GatewayStatus("allocating") GatewayStatusConfiguring = GatewayStatus("configuring") GatewayStatusRunning = GatewayStatus("running") GatewayStatusStopping = GatewayStatus("stopping") GatewayStatusFailed = GatewayStatus("failed") GatewayStatusDeleting = GatewayStatus("deleting") GatewayStatusDeleted = GatewayStatus("deleted") GatewayStatusLocked = GatewayStatus("locked") ) func (enum GatewayStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum GatewayStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *GatewayStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = GatewayStatus(GatewayStatus(tmp).String()) return nil } type ListDHCPEntriesRequestOrderBy string const ( ListDHCPEntriesRequestOrderByCreatedAtAsc = ListDHCPEntriesRequestOrderBy("created_at_asc") ListDHCPEntriesRequestOrderByCreatedAtDesc = ListDHCPEntriesRequestOrderBy("created_at_desc") ListDHCPEntriesRequestOrderByIPAddressAsc = ListDHCPEntriesRequestOrderBy("ip_address_asc") ListDHCPEntriesRequestOrderByIPAddressDesc = ListDHCPEntriesRequestOrderBy("ip_address_desc") ListDHCPEntriesRequestOrderByHostnameAsc = ListDHCPEntriesRequestOrderBy("hostname_asc") ListDHCPEntriesRequestOrderByHostnameDesc = ListDHCPEntriesRequestOrderBy("hostname_desc") ) func (enum ListDHCPEntriesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListDHCPEntriesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListDHCPEntriesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListDHCPEntriesRequestOrderBy(ListDHCPEntriesRequestOrderBy(tmp).String()) return nil } type ListDHCPsRequestOrderBy string const ( ListDHCPsRequestOrderByCreatedAtAsc = ListDHCPsRequestOrderBy("created_at_asc") ListDHCPsRequestOrderByCreatedAtDesc = ListDHCPsRequestOrderBy("created_at_desc") ListDHCPsRequestOrderBySubnetAsc = ListDHCPsRequestOrderBy("subnet_asc") ListDHCPsRequestOrderBySubnetDesc = ListDHCPsRequestOrderBy("subnet_desc") ) func (enum ListDHCPsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListDHCPsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListDHCPsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListDHCPsRequestOrderBy(ListDHCPsRequestOrderBy(tmp).String()) return nil } type ListGatewayNetworksRequestOrderBy string const ( ListGatewayNetworksRequestOrderByCreatedAtAsc = ListGatewayNetworksRequestOrderBy("created_at_asc") ListGatewayNetworksRequestOrderByCreatedAtDesc = ListGatewayNetworksRequestOrderBy("created_at_desc") ListGatewayNetworksRequestOrderByStatusAsc = ListGatewayNetworksRequestOrderBy("status_asc") ListGatewayNetworksRequestOrderByStatusDesc = ListGatewayNetworksRequestOrderBy("status_desc") ) func (enum ListGatewayNetworksRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListGatewayNetworksRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListGatewayNetworksRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListGatewayNetworksRequestOrderBy(ListGatewayNetworksRequestOrderBy(tmp).String()) return nil } type ListGatewaysRequestOrderBy string const ( ListGatewaysRequestOrderByCreatedAtAsc = ListGatewaysRequestOrderBy("created_at_asc") ListGatewaysRequestOrderByCreatedAtDesc = ListGatewaysRequestOrderBy("created_at_desc") ListGatewaysRequestOrderByNameAsc = ListGatewaysRequestOrderBy("name_asc") ListGatewaysRequestOrderByNameDesc = ListGatewaysRequestOrderBy("name_desc") ListGatewaysRequestOrderByTypeAsc = ListGatewaysRequestOrderBy("type_asc") ListGatewaysRequestOrderByTypeDesc = ListGatewaysRequestOrderBy("type_desc") ListGatewaysRequestOrderByStatusAsc = ListGatewaysRequestOrderBy("status_asc") ListGatewaysRequestOrderByStatusDesc = ListGatewaysRequestOrderBy("status_desc") ) func (enum ListGatewaysRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListGatewaysRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListGatewaysRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListGatewaysRequestOrderBy(ListGatewaysRequestOrderBy(tmp).String()) return nil } type ListIPsRequestOrderBy string const ( ListIPsRequestOrderByCreatedAtAsc = ListIPsRequestOrderBy("created_at_asc") ListIPsRequestOrderByCreatedAtDesc = ListIPsRequestOrderBy("created_at_desc") ListIPsRequestOrderByIPAsc = ListIPsRequestOrderBy("ip_asc") ListIPsRequestOrderByIPDesc = ListIPsRequestOrderBy("ip_desc") ListIPsRequestOrderByReverseAsc = ListIPsRequestOrderBy("reverse_asc") ListIPsRequestOrderByReverseDesc = ListIPsRequestOrderBy("reverse_desc") ) func (enum ListIPsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListIPsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListIPsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListIPsRequestOrderBy(ListIPsRequestOrderBy(tmp).String()) return nil } type ListPATRulesRequestOrderBy string const ( ListPATRulesRequestOrderByCreatedAtAsc = ListPATRulesRequestOrderBy("created_at_asc") ListPATRulesRequestOrderByCreatedAtDesc = ListPATRulesRequestOrderBy("created_at_desc") ListPATRulesRequestOrderByPublicPortAsc = ListPATRulesRequestOrderBy("public_port_asc") ListPATRulesRequestOrderByPublicPortDesc = ListPATRulesRequestOrderBy("public_port_desc") ) func (enum ListPATRulesRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListPATRulesRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListPATRulesRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListPATRulesRequestOrderBy(ListPATRulesRequestOrderBy(tmp).String()) return nil } type PATRuleProtocol string const ( PATRuleProtocolUnknown = PATRuleProtocol("unknown") PATRuleProtocolBoth = PATRuleProtocol("both") PATRuleProtocolTCP = PATRuleProtocol("tcp") PATRuleProtocolUDP = PATRuleProtocol("udp") ) func (enum PATRuleProtocol) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum PATRuleProtocol) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *PATRuleProtocol) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = PATRuleProtocol(PATRuleProtocol(tmp).String()) return nil } // DHCP: dhcp. type DHCP struct { // ID: ID of the DHCP config. ID string `json:"id"` // OrganizationID: owning Organization. OrganizationID string `json:"organization_id"` // ProjectID: owning Project. ProjectID string `json:"project_id"` // CreatedAt: date the DHCP configuration was created. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: configuration last modification date. UpdatedAt *time.Time `json:"updated_at"` // Subnet: subnet for the DHCP server. Subnet scw.IPNet `json:"subnet"` // Address: IP address of the DHCP server. This will be the Public Gateway's address in the Private Network. It must be part of config's subnet. Address net.IP `json:"address"` // PoolLow: low IP (inclusive) of the dynamic address pool. Must be in the config's subnet. PoolLow net.IP `json:"pool_low"` // PoolHigh: high IP (inclusive) of the dynamic address pool. Must be in the config's subnet. PoolHigh net.IP `json:"pool_high"` // EnableDynamic: defines whether to enable dynamic pooling of IPs. When false, only pre-existing DHCP reservations will be handed out. EnableDynamic bool `json:"enable_dynamic"` // ValidLifetime: how long DHCP entries will be valid for. ValidLifetime *scw.Duration `json:"valid_lifetime"` // RenewTimer: after how long a renew will be attempted. Must be 30s lower than `rebind_timer`. RenewTimer *scw.Duration `json:"renew_timer"` // RebindTimer: after how long a DHCP client will query for a new lease if previous renews fail. Must be 30s lower than `valid_lifetime`. RebindTimer *scw.Duration `json:"rebind_timer"` // PushDefaultRoute: defines whether the gateway should push a default route to DHCP clients, or only hand out IPs. PushDefaultRoute bool `json:"push_default_route"` // PushDNSServer: defines whether the gateway should push custom DNS servers to clients. This allows for instance hostname -> IP resolution. PushDNSServer bool `json:"push_dns_server"` // DNSServersOverride: array of DNS server IP addresses used to override the DNS server list pushed to DHCP clients, instead of the gateway itself. DNSServersOverride []string `json:"dns_servers_override"` // DNSSearch: array of search paths in addition to the pushed DNS configuration. DNSSearch []string `json:"dns_search"` // DNSLocalName: tLD given to hostnames in the Private Networks. If an Instance with hostname `foo` gets a lease, and this is set to `bar`, `foo.bar` will resolve. DNSLocalName string `json:"dns_local_name"` // Zone: zone of this DHCP configuration. Zone scw.Zone `json:"zone"` } // IpamConfig: ipam config. type IpamConfig struct { // PushDefaultRoute: defines whether the default route is enabled on that Gateway Network. PushDefaultRoute bool `json:"push_default_route"` // IpamIPID: iPAM-booked IP ID as the Gateway's IP in this Private Network. IpamIPID string `json:"ipam_ip_id"` } // GatewayNetwork: gateway network. type GatewayNetwork struct { // ID: ID of the Public Gateway-Private Network connection. ID string `json:"id"` // CreatedAt: connection creation date. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: connection last modification date. UpdatedAt *time.Time `json:"updated_at"` // GatewayID: ID of the connected Public Gateway. GatewayID string `json:"gateway_id"` // PrivateNetworkID: ID of the connected Private Network. PrivateNetworkID string `json:"private_network_id"` // MacAddress: mAC address of the gateway in the Private Network (if the gateway is up and running). MacAddress *string `json:"mac_address"` // EnableMasquerade: defines whether the gateway masquerades traffic for this Private Network (Dynamic NAT). EnableMasquerade bool `json:"enable_masquerade"` // Status: current status of the Public Gateway's connection to the Private Network. // Default value: unknown Status GatewayNetworkStatus `json:"status"` // DHCP: DHCP configuration for the connected Private Network. DHCP *DHCP `json:"dhcp"` // EnableDHCP: defines whether DHCP is enabled on the connected Private Network. EnableDHCP bool `json:"enable_dhcp"` // Address: address of the Gateway (in CIDR form) to use when DHCP is not used. Address *scw.IPNet `json:"address"` // IpamConfig: iPAM IP configuration used. IpamConfig *IpamConfig `json:"ipam_config"` // Zone: zone of the GatewayNetwork connection. Zone scw.Zone `json:"zone"` } // GatewayType: gateway type. type GatewayType struct { // Name: public Gateway type name. Name string `json:"name"` // Bandwidth: bandwidth, in bps, of the Public Gateway. This is the public bandwidth to the outer Internet, and the internal bandwidth to each connected Private Networks. Bandwidth uint64 `json:"bandwidth"` // Zone: zone the Public Gateway type is available in. Zone scw.Zone `json:"zone"` } // IP: ip. type IP struct { // ID: IP address ID. ID string `json:"id"` // OrganizationID: owning Organization. OrganizationID string `json:"organization_id"` // ProjectID: owning Project. ProjectID string `json:"project_id"` // CreatedAt: IP address creation date. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: IP address last modification date. UpdatedAt *time.Time `json:"updated_at"` // Tags: tags associated with the IP address. Tags []string `json:"tags"` // Address: the IP address itself. Address net.IP `json:"address"` // Reverse: reverse domain name for the IP address. Reverse *string `json:"reverse"` // GatewayID: public Gateway associated with the IP address. GatewayID *string `json:"gateway_id"` // Zone: zone of the IP address. Zone scw.Zone `json:"zone"` } // CreateDHCPRequest: create dhcp request. type CreateDHCPRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ProjectID: project to create the DHCP configuration in. ProjectID string `json:"project_id"` // Subnet: subnet for the DHCP server. Subnet scw.IPNet `json:"subnet"` // Address: IP address of the DHCP server. This will be the gateway's address in the Private Network. Defaults to the first address of the subnet. Address *net.IP `json:"address,omitempty"` // PoolLow: low IP (inclusive) of the dynamic address pool. Must be in the config's subnet. Defaults to the second address of the subnet. PoolLow *net.IP `json:"pool_low,omitempty"` // PoolHigh: high IP (inclusive) of the dynamic address pool. Must be in the config's subnet. Defaults to the last address of the subnet. PoolHigh *net.IP `json:"pool_high,omitempty"` // EnableDynamic: defines whether to enable dynamic pooling of IPs. When false, only pre-existing DHCP reservations will be handed out. Defaults to true. EnableDynamic *bool `json:"enable_dynamic,omitempty"` // ValidLifetime: how long DHCP entries will be valid for. Defaults to 1h (3600s). ValidLifetime *scw.Duration `json:"valid_lifetime,omitempty"` // RenewTimer: after how long a renew will be attempted. Must be 30s lower than `rebind_timer`. Defaults to 50m (3000s). RenewTimer *scw.Duration `json:"renew_timer,omitempty"` // RebindTimer: after how long a DHCP client will query for a new lease if previous renews fail. Must be 30s lower than `valid_lifetime`. Defaults to 51m (3060s). RebindTimer *scw.Duration `json:"rebind_timer,omitempty"` // PushDefaultRoute: defines whether the gateway should push a default route to DHCP clients or only hand out IPs. Defaults to true. PushDefaultRoute *bool `json:"push_default_route,omitempty"` // PushDNSServer: defines whether the gateway should push custom DNS servers to clients. This allows for Instance hostname -> IP resolution. Defaults to true. PushDNSServer *bool `json:"push_dns_server,omitempty"` // DNSServersOverride: array of DNS server IP addresses used to override the DNS server list pushed to DHCP clients, instead of the gateway itself. DNSServersOverride *[]string `json:"dns_servers_override,omitempty"` // DNSSearch: array of search paths in addition to the pushed DNS configuration. DNSSearch *[]string `json:"dns_search,omitempty"` // DNSLocalName: tLD given to hostnames in the Private Network. Allowed characters are `a-z0-9-.`. Defaults to the slugified Private Network name if created along a GatewayNetwork, or else to `priv`. DNSLocalName *string `json:"dns_local_name,omitempty"` } // CreateGatewayNetworkRequestIpamConfig: create gateway network request ipam config. type CreateGatewayNetworkRequestIpamConfig struct { // PushDefaultRoute: enabling the default route also enables masquerading. PushDefaultRoute bool `json:"push_default_route"` // IpamIPID: use this IPAM-booked IP ID as the Gateway's IP in this Private Network. IpamIPID *string `json:"ipam_ip_id"` } // DHCPEntry: dhcp entry. type DHCPEntry struct { // ID: DHCP entry ID. ID string `json:"id"` // CreatedAt: DHCP entry creation date. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: DHCP entry last modification date. UpdatedAt *time.Time `json:"updated_at"` // GatewayNetworkID: owning GatewayNetwork. GatewayNetworkID string `json:"gateway_network_id"` // MacAddress: mAC address of the client device. MacAddress string `json:"mac_address"` // IPAddress: assigned IP address. IPAddress net.IP `json:"ip_address"` // Hostname: hostname of the client device. Hostname string `json:"hostname"` // Type: entry type, either static (DHCP reservation) or dynamic (DHCP lease). // Default value: unknown Type DHCPEntryType `json:"type"` // Zone: zone of this DHCP entry. Zone scw.Zone `json:"zone"` } // Gateway: gateway. type Gateway struct { // ID: ID of the gateway. ID string `json:"id"` // OrganizationID: owning Organization. OrganizationID string `json:"organization_id"` // ProjectID: owning Project. ProjectID string `json:"project_id"` // CreatedAt: gateway creation date. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: gateway last modification date. UpdatedAt *time.Time `json:"updated_at"` // Type: gateway type (commercial offer). Type *GatewayType `json:"type"` // Status: current status of the gateway. // Default value: unknown Status GatewayStatus `json:"status"` // Name: name of the gateway. Name string `json:"name"` // Tags: tags associated with the gateway. Tags []string `json:"tags"` // IP: public IP address of the gateway. IP *IP `json:"ip"` // GatewayNetworks: gatewayNetwork objects attached to the gateway (each one represents a connection to a Private Network). GatewayNetworks []*GatewayNetwork `json:"gateway_networks"` // UpstreamDNSServers: array of DNS server IP addresses to override the gateway's default recursive DNS servers. UpstreamDNSServers []string `json:"upstream_dns_servers"` // Version: version of the running gateway software. Version *string `json:"version"` // CanUpgradeTo: newly available gateway software version that can be updated to. CanUpgradeTo *string `json:"can_upgrade_to"` // BastionEnabled: defines whether SSH bastion is enabled on the gateway. BastionEnabled bool `json:"bastion_enabled"` // BastionPort: port of the SSH bastion. BastionPort uint32 `json:"bastion_port"` // SMTPEnabled: defines whether SMTP traffic is allowed to pass through the gateway. SMTPEnabled bool `json:"smtp_enabled"` // IsLegacy: defines whether the gateway uses non-IPAM IP configurations. IsLegacy bool `json:"is_legacy"` // IPMobilityEnabled: defines whether the gateway uses routed IPs (IP mobility) instead of NAT IPs. IPMobilityEnabled bool `json:"ip_mobility_enabled"` // Zone: zone of the gateway. Zone scw.Zone `json:"zone"` } // PATRule: pat rule. type PATRule struct { // ID: pAT rule ID. ID string `json:"id"` // GatewayID: gateway the PAT rule applies to. GatewayID string `json:"gateway_id"` // CreatedAt: pAT rule creation date. CreatedAt *time.Time `json:"created_at"` // UpdatedAt: pAT rule last modification date. UpdatedAt *time.Time `json:"updated_at"` // PublicPort: public port to listen on. PublicPort uint32 `json:"public_port"` // PrivateIP: private IP address to forward data to. PrivateIP net.IP `json:"private_ip"` // PrivatePort: private port to translate to. PrivatePort uint32 `json:"private_port"` // Protocol: protocol the rule applies to. // Default value: unknown Protocol PATRuleProtocol `json:"protocol"` // Zone: zone of the PAT rule. Zone scw.Zone `json:"zone"` } // SetDHCPEntriesRequestEntry: set dhcp entries request entry. type SetDHCPEntriesRequestEntry struct { // MacAddress: mAC address to give a static entry to. A matching entry will be upgraded to a reservation, and a matching reservation will be updated. MacAddress string `json:"mac_address"` // IPAddress: IP address to give to the device. IPAddress net.IP `json:"ip_address"` } // SetPATRulesRequestRule: set pat rules request rule. type SetPATRulesRequestRule struct { // PublicPort: public port to listen on. Uniquely identifies the rule, and a matching rule will be updated with the new parameters. PublicPort uint32 `json:"public_port"` // PrivateIP: private IP to forward data to. PrivateIP net.IP `json:"private_ip"` // PrivatePort: private port to translate to. PrivatePort uint32 `json:"private_port"` // Protocol: protocol the rule should apply to. // Default value: unknown Protocol PATRuleProtocol `json:"protocol"` } // UpdateGatewayNetworkRequestIpamConfig: update gateway network request ipam config. type UpdateGatewayNetworkRequestIpamConfig struct { // PushDefaultRoute: enabling the default route also enables masquerading. PushDefaultRoute *bool `json:"push_default_route"` // IpamIPID: use this IPAM-booked IP ID as the Gateway's IP in this Private Network. IpamIPID *string `json:"ipam_ip_id"` } // CreateDHCPEntryRequest: create dhcp entry request. type CreateDHCPEntryRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // GatewayNetworkID: gatewayNetwork on which to create a DHCP reservation. GatewayNetworkID string `json:"gateway_network_id"` // MacAddress: mAC address to give a static entry to. MacAddress string `json:"mac_address"` // IPAddress: IP address to give to the device. IPAddress net.IP `json:"ip_address"` } // CreateGatewayNetworkRequest: create gateway network request. type CreateGatewayNetworkRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // GatewayID: public Gateway to connect. GatewayID string `json:"gateway_id"` // PrivateNetworkID: private Network to connect. PrivateNetworkID string `json:"private_network_id"` // EnableMasquerade: note: this setting is ignored when passing `ipam_config`. EnableMasquerade bool `json:"enable_masquerade"` // EnableDHCP: defaults to `true` if either `dhcp_id` or `dhcp` are present. If set to `true`, either `dhcp_id` or `dhcp` must be present. // Note: this setting is ignored when passing `ipam_config`. EnableDHCP *bool `json:"enable_dhcp,omitempty"` // DHCPID: ID of an existing DHCP configuration object to use for this GatewayNetwork. // Precisely one of DHCPID, DHCP, Address, IpamConfig must be set. DHCPID *string `json:"dhcp_id,omitempty"` // DHCP: new DHCP configuration object to use for this GatewayNetwork. // Precisely one of DHCPID, DHCP, Address, IpamConfig must be set. DHCP *CreateDHCPRequest `json:"dhcp,omitempty"` // Address: static IP address in CIDR format to to use without DHCP. // Precisely one of DHCPID, DHCP, Address, IpamConfig must be set. Address *scw.IPNet `json:"address,omitempty"` // IpamConfig: note: all or none of the GatewayNetworks for a single gateway can use the IPAM. DHCP and IPAM configurations cannot be mixed. Some products may require that the Public Gateway uses the IPAM, to ensure correct functionality. // Precisely one of DHCPID, DHCP, Address, IpamConfig must be set. IpamConfig *CreateGatewayNetworkRequestIpamConfig `json:"ipam_config,omitempty"` } // CreateGatewayRequest: create gateway request. type CreateGatewayRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ProjectID: scaleway Project to create the gateway in. ProjectID string `json:"project_id"` // Name: name for the gateway. Name string `json:"name"` // Tags: tags for the gateway. Tags []string `json:"tags"` // Type: gateway type (commercial offer type). Type string `json:"type"` // UpstreamDNSServers: array of DNS server IP addresses to override the gateway's default recursive DNS servers. UpstreamDNSServers []string `json:"upstream_dns_servers"` // IPID: existing IP address to attach to the gateway. IPID *string `json:"ip_id,omitempty"` // EnableSMTP: defines whether SMTP traffic should be allowed pass through the gateway. EnableSMTP bool `json:"enable_smtp"` // EnableBastion: defines whether SSH bastion should be enabled the gateway. EnableBastion bool `json:"enable_bastion"` // BastionPort: port of the SSH bastion. BastionPort *uint32 `json:"bastion_port,omitempty"` } // CreateIPRequest: create ip request. type CreateIPRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // ProjectID: project to create the IP address in. ProjectID string `json:"project_id"` // Tags: tags to give to the IP address. Tags []string `json:"tags"` } // CreatePATRuleRequest: create pat rule request. type CreatePATRuleRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // GatewayID: ID of the Gateway on which to create the rule. GatewayID string `json:"gateway_id"` // PublicPort: public port to listen on. PublicPort uint32 `json:"public_port"` // PrivateIP: private IP to forward data to. PrivateIP net.IP `json:"private_ip"` // PrivatePort: private port to translate to. PrivatePort uint32 `json:"private_port"` // Protocol: protocol the rule should apply to. // Default value: unknown Protocol PATRuleProtocol `json:"protocol"` } // DeleteDHCPEntryRequest: delete dhcp entry request. type DeleteDHCPEntryRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // DHCPEntryID: ID of the DHCP entry to delete. DHCPEntryID string `json:"-"` } // DeleteDHCPRequest: delete dhcp request. type DeleteDHCPRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // DHCPID: DHCP configuration ID to delete. DHCPID string `json:"-"` } // DeleteGatewayNetworkRequest: delete gateway network request. type DeleteGatewayNetworkRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // GatewayNetworkID: ID of the GatewayNetwork to delete. GatewayNetworkID string `json:"-"` // CleanupDHCP: defines whether to clean up attached DHCP configurations (if any, and if not attached to another Gateway Network). CleanupDHCP bool `json:"cleanup_dhcp"` } // DeleteGatewayRequest: delete gateway request. type DeleteGatewayRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // GatewayID: ID of the gateway to delete. GatewayID string `json:"-"` // CleanupDHCP: defines whether to clean up attached DHCP configurations (if any, and if not attached to another Gateway Network). CleanupDHCP bool `json:"cleanup_dhcp"` } // DeleteIPRequest: delete ip request. type DeleteIPRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // IPID: ID of the IP address to delete. IPID string `json:"-"` } // DeletePATRuleRequest: delete pat rule request. type DeletePATRuleRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // PatRuleID: ID of the PAT rule to delete. PatRuleID string `json:"-"` } // EnableIPMobilityRequest: enable ip mobility request. type EnableIPMobilityRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // GatewayID: ID of the gateway to upgrade to IP mobility. GatewayID string `json:"-"` } // GetDHCPEntryRequest: get dhcp entry request. type GetDHCPEntryRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // DHCPEntryID: ID of the DHCP entry to fetch. DHCPEntryID string `json:"-"` } // GetDHCPRequest: get dhcp request. type GetDHCPRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // DHCPID: ID of the DHCP configuration to fetch. DHCPID string `json:"-"` } // GetGatewayNetworkRequest: get gateway network request. type GetGatewayNetworkRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // GatewayNetworkID: ID of the GatewayNetwork to fetch. GatewayNetworkID string `json:"-"` } // GetGatewayRequest: get gateway request. type GetGatewayRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // GatewayID: ID of the gateway to fetch. GatewayID string `json:"-"` } // GetIPRequest: get ip request. type GetIPRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // IPID: ID of the IP address to get. IPID string `json:"-"` } // GetPATRuleRequest: get pat rule request. type GetPATRuleRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // PatRuleID: ID of the PAT rule to get. PatRuleID string `json:"-"` } // ListDHCPEntriesRequest: list dhcp entries request. type ListDHCPEntriesRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // OrderBy: order in which to return results. // Default value: created_at_asc OrderBy ListDHCPEntriesRequestOrderBy `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: DHCP entries per page. PageSize *uint32 `json:"-"` // GatewayNetworkID: filter for entries on this GatewayNetwork. GatewayNetworkID *string `json:"-"` // MacAddress: filter for entries with this MAC address. MacAddress *string `json:"-"` // IPAddress: filter for entries with this IP address. IPAddress *net.IP `json:"-"` // Hostname: filter for entries with this hostname substring. Hostname *string `json:"-"` // Type: filter for entries of this type. // Default value: unknown Type DHCPEntryType `json:"-"` } // ListDHCPEntriesResponse: list dhcp entries response. type ListDHCPEntriesResponse struct { // DHCPEntries: DHCP entries in this page. DHCPEntries []*DHCPEntry `json:"dhcp_entries"` // TotalCount: total count of DHCP entries matching the filter. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListDHCPEntriesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListDHCPEntriesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListDHCPEntriesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.DHCPEntries = append(r.DHCPEntries, results.DHCPEntries...) r.TotalCount += uint32(len(results.DHCPEntries)) return uint32(len(results.DHCPEntries)), nil } // ListDHCPsRequest: list dhc ps request. type ListDHCPsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // OrderBy: order in which to return results. // Default value: created_at_asc OrderBy ListDHCPsRequestOrderBy `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: DHCP configurations per page. PageSize *uint32 `json:"-"` // OrganizationID: include only DHCP configuration objects in this Organization. OrganizationID *string `json:"-"` // ProjectID: include only DHCP configuration objects in this Project. ProjectID *string `json:"-"` // Address: filter for DHCP configuration objects with this DHCP server IP address (the gateway's address in the Private Network). Address *net.IP `json:"-"` // HasAddress: filter for DHCP configuration objects with subnets containing this IP address. HasAddress *net.IP `json:"-"` } // ListDHCPsResponse: list dhc ps response. type ListDHCPsResponse struct { // Dhcps: first page of DHCP configuration objects. Dhcps []*DHCP `json:"dhcps"` // TotalCount: total count of DHCP configuration objects matching the filter. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListDHCPsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListDHCPsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListDHCPsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Dhcps = append(r.Dhcps, results.Dhcps...) r.TotalCount += uint32(len(results.Dhcps)) return uint32(len(results.Dhcps)), nil } // ListGatewayNetworksRequest: list gateway networks request. type ListGatewayNetworksRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // OrderBy: order in which to return results. // Default value: created_at_asc OrderBy ListGatewayNetworksRequestOrderBy `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: gatewayNetworks per page. PageSize *uint32 `json:"-"` // GatewayID: filter for GatewayNetworks connected to this gateway. GatewayID *string `json:"-"` // PrivateNetworkID: filter for GatewayNetworks connected to this Private Network. PrivateNetworkID *string `json:"-"` // EnableMasquerade: filter for GatewayNetworks with this `enable_masquerade` setting. EnableMasquerade *bool `json:"-"` // DHCPID: filter for GatewayNetworks using this DHCP configuration. DHCPID *string `json:"-"` // Status: filter for GatewayNetworks with this current status this status. Use `unknown` to include all statuses. // Default value: unknown Status GatewayNetworkStatus `json:"-"` } // ListGatewayNetworksResponse: list gateway networks response. type ListGatewayNetworksResponse struct { // GatewayNetworks: gatewayNetworks on this page. GatewayNetworks []*GatewayNetwork `json:"gateway_networks"` // TotalCount: total GatewayNetworks count matching the filter. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListGatewayNetworksResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListGatewayNetworksResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListGatewayNetworksResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.GatewayNetworks = append(r.GatewayNetworks, results.GatewayNetworks...) r.TotalCount += uint32(len(results.GatewayNetworks)) return uint32(len(results.GatewayNetworks)), nil } // ListGatewayTypesRequest: list gateway types request. type ListGatewayTypesRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` } // ListGatewayTypesResponse: list gateway types response. type ListGatewayTypesResponse struct { // Types: available types of Public Gateway. Types []*GatewayType `json:"types"` } // ListGatewaysRequest: list gateways request. type ListGatewaysRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // OrderBy: order in which to return results. // Default value: created_at_asc OrderBy ListGatewaysRequestOrderBy `json:"-"` // Page: page number to return. Page *int32 `json:"-"` // PageSize: gateways per page. PageSize *uint32 `json:"-"` // OrganizationID: include only gateways in this Organization. OrganizationID *string `json:"-"` // ProjectID: include only gateways in this Project. ProjectID *string `json:"-"` // Name: filter for gateways which have this search term in their name. Name *string `json:"-"` // Tags: filter for gateways with these tags. Tags []string `json:"-"` // Type: filter for gateways of this type. Type *string `json:"-"` // Status: filter for gateways with this current status. Use `unknown` to include all statuses. // Default value: unknown Status GatewayStatus `json:"-"` // PrivateNetworkID: filter for gateways attached to this Private nNetwork. PrivateNetworkID *string `json:"-"` } // ListGatewaysResponse: list gateways response. type ListGatewaysResponse struct { // Gateways: gateways on this page. Gateways []*Gateway `json:"gateways"` // TotalCount: total count of gateways matching the filter. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListGatewaysResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListGatewaysResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListGatewaysResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Gateways = append(r.Gateways, results.Gateways...) r.TotalCount += uint32(len(results.Gateways)) return uint32(len(results.Gateways)), nil } // ListIPsRequest: list i ps request. type ListIPsRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // OrderBy: order in which to return results. // Default value: created_at_asc OrderBy ListIPsRequestOrderBy `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: IP addresses per page. PageSize *uint32 `json:"-"` // OrganizationID: filter for IP addresses in this Organization. OrganizationID *string `json:"-"` // ProjectID: filter for IP addresses in this Project. ProjectID *string `json:"-"` // Tags: filter for IP addresses with these tags. Tags []string `json:"-"` // Reverse: filter for IP addresses that have a reverse containing this string. Reverse *string `json:"-"` // IsFree: filter based on whether the IP is attached to a gateway or not. IsFree *bool `json:"-"` } // ListIPsResponse: list i ps response. type ListIPsResponse struct { // IPs: IP addresses on this page. IPs []*IP `json:"ips"` // TotalCount: total count of IP addresses matching the filter. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListIPsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListIPsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListIPsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.IPs = append(r.IPs, results.IPs...) r.TotalCount += uint32(len(results.IPs)) return uint32(len(results.IPs)), nil } // ListPATRulesRequest: list pat rules request. type ListPATRulesRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // OrderBy: order in which to return results. // Default value: created_at_asc OrderBy ListPATRulesRequestOrderBy `json:"-"` // Page: page number. Page *int32 `json:"-"` // PageSize: pAT rules per page. PageSize *uint32 `json:"-"` // GatewayID: filter for PAT rules on this Gateway. GatewayID *string `json:"-"` // PrivateIP: filter for PAT rules targeting this private ip. PrivateIP *net.IP `json:"-"` // Protocol: filter for PAT rules with this protocol. // Default value: unknown Protocol PATRuleProtocol `json:"-"` } // ListPATRulesResponse: list pat rules response. type ListPATRulesResponse struct { // PatRules: array of PAT rules matching the filter. PatRules []*PATRule `json:"pat_rules"` // TotalCount: total count of PAT rules matching the filter. TotalCount uint32 `json:"total_count"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListPATRulesResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListPATRulesResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListPATRulesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.PatRules = append(r.PatRules, results.PatRules...) r.TotalCount += uint32(len(results.PatRules)) return uint32(len(results.PatRules)), nil } // RefreshSSHKeysRequest: refresh ssh keys request. type RefreshSSHKeysRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // GatewayID: ID of the gateway to refresh SSH keys on. GatewayID string `json:"-"` } // SetDHCPEntriesRequest: set dhcp entries request. type SetDHCPEntriesRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // GatewayNetworkID: ID of the Gateway Network on which to set DHCP reservation list. GatewayNetworkID string `json:"gateway_network_id"` // DHCPEntries: new list of DHCP reservations. DHCPEntries []*SetDHCPEntriesRequestEntry `json:"dhcp_entries"` } // SetDHCPEntriesResponse: set dhcp entries response. type SetDHCPEntriesResponse struct { // DHCPEntries: list of DHCP entries. DHCPEntries []*DHCPEntry `json:"dhcp_entries"` } // SetPATRulesRequest: set pat rules request. type SetPATRulesRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // GatewayID: ID of the gateway on which to set the PAT rules. GatewayID string `json:"gateway_id"` // PatRules: new list of PAT rules. PatRules []*SetPATRulesRequestRule `json:"pat_rules"` } // SetPATRulesResponse: set pat rules response. type SetPATRulesResponse struct { // PatRules: list of PAT rules. PatRules []*PATRule `json:"pat_rules"` } // UpdateDHCPEntryRequest: update dhcp entry request. type UpdateDHCPEntryRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // DHCPEntryID: ID of the DHCP entry to update. DHCPEntryID string `json:"-"` // IPAddress: new IP address to give to the device. IPAddress *net.IP `json:"ip_address,omitempty"` } // UpdateDHCPRequest: update dhcp request. type UpdateDHCPRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // DHCPID: DHCP configuration to update. DHCPID string `json:"-"` // Subnet: subnet for the DHCP server. Subnet *scw.IPNet `json:"subnet,omitempty"` // Address: IP address of the DHCP server. This will be the Public Gateway's address in the Private Network. It must be part of config's subnet. Address *net.IP `json:"address,omitempty"` // PoolLow: low IP (inclusive) of the dynamic address pool. Must be in the config's subnet. PoolLow *net.IP `json:"pool_low,omitempty"` // PoolHigh: high IP (inclusive) of the dynamic address pool. Must be in the config's subnet. PoolHigh *net.IP `json:"pool_high,omitempty"` // EnableDynamic: defines whether to enable dynamic pooling of IPs. When false, only pre-existing DHCP reservations will be handed out. Defaults to true. EnableDynamic *bool `json:"enable_dynamic,omitempty"` // ValidLifetime: how long DHCP entries will be valid for. ValidLifetime *scw.Duration `json:"valid_lifetime,omitempty"` // RenewTimer: after how long a renew will be attempted. Must be 30s lower than `rebind_timer`. RenewTimer *scw.Duration `json:"renew_timer,omitempty"` // RebindTimer: after how long a DHCP client will query for a new lease if previous renews fail. Must be 30s lower than `valid_lifetime`. RebindTimer *scw.Duration `json:"rebind_timer,omitempty"` // PushDefaultRoute: defines whether the gateway should push a default route to DHCP clients, or only hand out IPs. PushDefaultRoute *bool `json:"push_default_route,omitempty"` // PushDNSServer: defines whether the gateway should push custom DNS servers to clients. This allows for instance hostname -> IP resolution. PushDNSServer *bool `json:"push_dns_server,omitempty"` // DNSServersOverride: array of DNS server IP addresses used to override the DNS server list pushed to DHCP clients, instead of the gateway itself. DNSServersOverride *[]string `json:"dns_servers_override,omitempty"` // DNSSearch: array of search paths in addition to the pushed DNS configuration. DNSSearch *[]string `json:"dns_search,omitempty"` // DNSLocalName: tLD given to hostnames in the Private Networks. If an instance with hostname `foo` gets a lease, and this is set to `bar`, `foo.bar` will resolve. Allowed characters are `a-z0-9-.`. DNSLocalName *string `json:"dns_local_name,omitempty"` } // UpdateGatewayNetworkRequest: update gateway network request. type UpdateGatewayNetworkRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // GatewayNetworkID: ID of the GatewayNetwork to update. GatewayNetworkID string `json:"-"` // EnableMasquerade: note: this setting is ignored when passing `ipam_config`. EnableMasquerade *bool `json:"enable_masquerade,omitempty"` // EnableDHCP: defaults to `true` if `dhcp_id` is present. If set to `true`, `dhcp_id` must be present. // Note: this setting is ignored when passing `ipam_config`. EnableDHCP *bool `json:"enable_dhcp,omitempty"` // DHCPID: ID of the new DHCP configuration object to use with this GatewayNetwork. // Precisely one of DHCPID, Address, IpamConfig must be set. DHCPID *string `json:"dhcp_id,omitempty"` // Address: new static IP address. // Precisely one of DHCPID, Address, IpamConfig must be set. Address *scw.IPNet `json:"address,omitempty"` // IpamConfig: note: all or none of the GatewayNetworks for a single gateway can use the IPAM. DHCP and IPAM configurations cannot be mixed. Some products may require that the Public Gateway uses the IPAM, to ensure correct functionality. // Precisely one of DHCPID, Address, IpamConfig must be set. IpamConfig *UpdateGatewayNetworkRequestIpamConfig `json:"ipam_config,omitempty"` } // UpdateGatewayRequest: update gateway request. type UpdateGatewayRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // GatewayID: ID of the gateway to update. GatewayID string `json:"-"` // Name: name for the gateway. Name *string `json:"name,omitempty"` // Tags: tags for the gateway. Tags *[]string `json:"tags,omitempty"` // UpstreamDNSServers: array of DNS server IP addresses to override the gateway's default recursive DNS servers. UpstreamDNSServers *[]string `json:"upstream_dns_servers,omitempty"` // EnableBastion: defines whether SSH bastion should be enabled the gateway. EnableBastion *bool `json:"enable_bastion,omitempty"` // BastionPort: port of the SSH bastion. BastionPort *uint32 `json:"bastion_port,omitempty"` // EnableSMTP: defines whether SMTP traffic should be allowed to pass through the gateway. EnableSMTP *bool `json:"enable_smtp,omitempty"` } // UpdateIPRequest: update ip request. type UpdateIPRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // IPID: ID of the IP address to update. IPID string `json:"-"` // Tags: tags to give to the IP address. Tags *[]string `json:"tags,omitempty"` // Reverse: reverse to set on the address. Empty string to unset. Reverse *string `json:"reverse,omitempty"` // GatewayID: gateway to attach the IP address to. Empty string to detach. GatewayID *string `json:"gateway_id,omitempty"` } // UpdatePATRuleRequest: update pat rule request. type UpdatePATRuleRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // PatRuleID: ID of the PAT rule to update. PatRuleID string `json:"-"` // PublicPort: public port to listen on. PublicPort *uint32 `json:"public_port,omitempty"` // PrivateIP: private IP to forward data to. PrivateIP *net.IP `json:"private_ip,omitempty"` // PrivatePort: private port to translate to. PrivatePort *uint32 `json:"private_port,omitempty"` // Protocol: protocol the rule should apply to. // Default value: unknown Protocol PATRuleProtocol `json:"protocol"` } // UpgradeGatewayRequest: upgrade gateway request. type UpgradeGatewayRequest struct { // Zone: zone to target. If none is passed will use default zone from the config. Zone scw.Zone `json:"-"` // GatewayID: ID of the gateway to upgrade. GatewayID string `json:"-"` } // Public Gateways API. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Zones() []scw.Zone { return []scw.Zone{scw.ZoneFrPar1, scw.ZoneFrPar2, scw.ZoneNlAms1, scw.ZoneNlAms2, scw.ZoneNlAms3, scw.ZonePlWaw1, scw.ZonePlWaw2, scw.ZonePlWaw3} } // ListGateways: List Public Gateways in a given Scaleway Organization or Project. By default, results are displayed in ascending order of creation date. func (s *API) ListGateways(req *ListGatewaysRequest, opts ...scw.RequestOption) (*ListGatewaysResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "name", req.Name) parameter.AddToQuery(query, "tags", req.Tags) parameter.AddToQuery(query, "type", req.Type) parameter.AddToQuery(query, "status", req.Status) parameter.AddToQuery(query, "private_network_id", req.PrivateNetworkID) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/gateways", Query: query, } var resp ListGatewaysResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetGateway: Get details of a Public Gateway, specified by its gateway ID. The response object contains full details of the gateway, including its **name**, **type**, **status** and more. func (s *API) GetGateway(req *GetGatewayRequest, opts ...scw.RequestOption) (*Gateway, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.GatewayID) == "" { return nil, errors.New("field GatewayID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/gateways/" + fmt.Sprint(req.GatewayID) + "", } var resp Gateway err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateGateway: Create a new Public Gateway in the specified Scaleway Project, defining its **name**, **type** and other configuration details such as whether to enable SSH bastion. func (s *API) CreateGateway(req *CreateGatewayRequest, opts ...scw.RequestOption) (*Gateway, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if req.Name == "" { req.Name = namegenerator.GetRandomName("gw") } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/gateways", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Gateway err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateGateway: Update the parameters of an existing Public Gateway, for example, its **name**, **tags**, **SSH bastion configuration**, and **DNS servers**. func (s *API) UpdateGateway(req *UpdateGatewayRequest, opts ...scw.RequestOption) (*Gateway, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.GatewayID) == "" { return nil, errors.New("field GatewayID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/gateways/" + fmt.Sprint(req.GatewayID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Gateway err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteGateway: Delete an existing Public Gateway, specified by its gateway ID. This action is irreversible. func (s *API) DeleteGateway(req *DeleteGatewayRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } query := url.Values{} parameter.AddToQuery(query, "cleanup_dhcp", req.CleanupDHCP) if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.GatewayID) == "" { return errors.New("field GatewayID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/gateways/" + fmt.Sprint(req.GatewayID) + "", Query: query, } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // UpgradeGateway: Upgrade a given Public Gateway to the newest software version. This applies the latest bugfixes and features to your Public Gateway, but its service will be interrupted during the update. func (s *API) UpgradeGateway(req *UpgradeGatewayRequest, opts ...scw.RequestOption) (*Gateway, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.GatewayID) == "" { return nil, errors.New("field GatewayID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/gateways/" + fmt.Sprint(req.GatewayID) + "/upgrade", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Gateway err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // EnableIPMobility: Upgrade a Public Gateway to IP mobility (move from NAT IP to routed IP). This is idempotent: repeated calls after the first will return no error but have no effect. func (s *API) EnableIPMobility(req *EnableIPMobilityRequest, opts ...scw.RequestOption) (*Gateway, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.GatewayID) == "" { return nil, errors.New("field GatewayID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/gateways/" + fmt.Sprint(req.GatewayID) + "/enable-ip-mobility", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Gateway err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListGatewayNetworks: List the connections between Public Gateways and Private Networks (a connection = a GatewayNetwork). You can choose to filter by `gateway-id` to list all Private Networks attached to the specified Public Gateway, or by `private_network_id` to list all Public Gateways attached to the specified Private Network. Other query parameters are also available. The result is an array of GatewayNetwork objects, each giving details of the connection between a given Public Gateway and a given Private Network. func (s *API) ListGatewayNetworks(req *ListGatewayNetworksRequest, opts ...scw.RequestOption) (*ListGatewayNetworksResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "gateway_id", req.GatewayID) parameter.AddToQuery(query, "private_network_id", req.PrivateNetworkID) parameter.AddToQuery(query, "enable_masquerade", req.EnableMasquerade) parameter.AddToQuery(query, "dhcp_id", req.DHCPID) parameter.AddToQuery(query, "status", req.Status) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/gateway-networks", Query: query, } var resp ListGatewayNetworksResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetGatewayNetwork: Get details of a given connection between a Public Gateway and a Private Network (this connection = a GatewayNetwork), specified by its `gateway_network_id`. The response object contains details of the connection including the IDs of the Public Gateway and Private Network, the dates the connection was created/updated and its configuration settings. func (s *API) GetGatewayNetwork(req *GetGatewayNetworkRequest, opts ...scw.RequestOption) (*GatewayNetwork, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.GatewayNetworkID) == "" { return nil, errors.New("field GatewayNetworkID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/gateway-networks/" + fmt.Sprint(req.GatewayNetworkID) + "", } var resp GatewayNetwork err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateGatewayNetwork: Attach a specific Public Gateway to a specific Private Network (create a GatewayNetwork). You can configure parameters for the connection including DHCP settings, whether to enable masquerade (dynamic NAT), and more. func (s *API) CreateGatewayNetwork(req *CreateGatewayNetworkRequest, opts ...scw.RequestOption) (*GatewayNetwork, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/gateway-networks", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp GatewayNetwork err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateGatewayNetwork: Update the configuration parameters of a connection between a given Public Gateway and Private Network (the connection = a GatewayNetwork). Updatable parameters include DHCP settings and whether to enable traffic masquerade (dynamic NAT). func (s *API) UpdateGatewayNetwork(req *UpdateGatewayNetworkRequest, opts ...scw.RequestOption) (*GatewayNetwork, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.GatewayNetworkID) == "" { return nil, errors.New("field GatewayNetworkID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/gateway-networks/" + fmt.Sprint(req.GatewayNetworkID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp GatewayNetwork err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteGatewayNetwork: Detach a given Public Gateway from a given Private Network, i.e. delete a GatewayNetwork specified by a gateway_network_id. func (s *API) DeleteGatewayNetwork(req *DeleteGatewayNetworkRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } query := url.Values{} parameter.AddToQuery(query, "cleanup_dhcp", req.CleanupDHCP) if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.GatewayNetworkID) == "" { return errors.New("field GatewayNetworkID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/gateway-networks/" + fmt.Sprint(req.GatewayNetworkID) + "", Query: query, } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListDHCPs: List DHCP configurations, optionally filtering by Organization, Project, Public Gateway IP address or more. The response is an array of DHCP configuration objects, each identified by a DHCP ID and containing configuration settings for the assignment of IP addresses to devices on a Private Network attached to a Public Gateway. Note that the response does not contain the IDs of any Private Network / Public Gateway the configuration is attached to. Use the `List Public Gateway connections to Private Networks` method for that purpose, filtering on DHCP ID. func (s *API) ListDHCPs(req *ListDHCPsRequest, opts ...scw.RequestOption) (*ListDHCPsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "address", req.Address) parameter.AddToQuery(query, "has_address", req.HasAddress) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/dhcps", Query: query, } var resp ListDHCPsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetDHCP: Get a DHCP configuration object, identified by its DHCP ID. The response object contains configuration settings for the assignment of IP addresses to devices on a Private Network attached to a Public Gateway. Note that the response does not contain the IDs of any Private Network / Public Gateway the configuration is attached to. Use the `List Public Gateway connections to Private Networks` method for that purpose, filtering on DHCP ID. func (s *API) GetDHCP(req *GetDHCPRequest, opts ...scw.RequestOption) (*DHCP, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.DHCPID) == "" { return nil, errors.New("field DHCPID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/dhcps/" + fmt.Sprint(req.DHCPID) + "", } var resp DHCP err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateDHCP: Create a new DHCP configuration object, containing settings for the assignment of IP addresses to devices on a Private Network attached to a Public Gateway. The response object includes the ID of the DHCP configuration object. You can use this ID as part of a call to `Create a Public Gateway connection to a Private Network` or `Update a Public Gateway connection to a Private Network` to directly apply this DHCP configuration. func (s *API) CreateDHCP(req *CreateDHCPRequest, opts ...scw.RequestOption) (*DHCP, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/dhcps", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp DHCP err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateDHCP: Update a DHCP configuration object, identified by its DHCP ID. func (s *API) UpdateDHCP(req *UpdateDHCPRequest, opts ...scw.RequestOption) (*DHCP, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.DHCPID) == "" { return nil, errors.New("field DHCPID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/dhcps/" + fmt.Sprint(req.DHCPID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp DHCP err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteDHCP: Delete a DHCP configuration object, identified by its DHCP ID. Note that you cannot delete a DHCP configuration object that is currently being used by a Gateway Network. func (s *API) DeleteDHCP(req *DeleteDHCPRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.DHCPID) == "" { return errors.New("field DHCPID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/dhcps/" + fmt.Sprint(req.DHCPID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListDHCPEntries: List DHCP entries, whether dynamically assigned and/or statically reserved. DHCP entries can be filtered by the Gateway Network they are on, their MAC address, IP address, type or hostname. func (s *API) ListDHCPEntries(req *ListDHCPEntriesRequest, opts ...scw.RequestOption) (*ListDHCPEntriesResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "gateway_network_id", req.GatewayNetworkID) parameter.AddToQuery(query, "mac_address", req.MacAddress) parameter.AddToQuery(query, "ip_address", req.IPAddress) parameter.AddToQuery(query, "hostname", req.Hostname) parameter.AddToQuery(query, "type", req.Type) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/dhcp-entries", Query: query, } var resp ListDHCPEntriesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetDHCPEntry: Get a DHCP entry, specified by its DHCP entry ID. func (s *API) GetDHCPEntry(req *GetDHCPEntryRequest, opts ...scw.RequestOption) (*DHCPEntry, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.DHCPEntryID) == "" { return nil, errors.New("field DHCPEntryID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/dhcp-entries/" + fmt.Sprint(req.DHCPEntryID) + "", } var resp DHCPEntry err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateDHCPEntry: Create a static DHCP reservation, specifying the Gateway Network for the reservation, the MAC address of the target device and the IP address to assign this device. The response is a DHCP entry object, confirming the ID and configuration details of the static DHCP reservation. func (s *API) CreateDHCPEntry(req *CreateDHCPEntryRequest, opts ...scw.RequestOption) (*DHCPEntry, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/dhcp-entries", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp DHCPEntry err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateDHCPEntry: Update the IP address for a DHCP entry, specified by its DHCP entry ID. You can update an existing DHCP entry of any type (`reservation` (static), `lease` (dynamic) or `unknown`), but in manually updating the IP address the entry will necessarily be of type `reservation` after the update. func (s *API) UpdateDHCPEntry(req *UpdateDHCPEntryRequest, opts ...scw.RequestOption) (*DHCPEntry, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.DHCPEntryID) == "" { return nil, errors.New("field DHCPEntryID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/dhcp-entries/" + fmt.Sprint(req.DHCPEntryID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp DHCPEntry err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SetDHCPEntries: Set the list of DHCP reservations attached to a Gateway Network. Reservations are identified by their MAC address, and will sync the current DHCP entry list to the given list, creating, updating or deleting DHCP entries accordingly. func (s *API) SetDHCPEntries(req *SetDHCPEntriesRequest, opts ...scw.RequestOption) (*SetDHCPEntriesResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/dhcp-entries", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SetDHCPEntriesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteDHCPEntry: Delete a static DHCP reservation, identified by its DHCP entry ID. Note that you cannot delete DHCP entries of type `lease`, these are deleted automatically when their time-to-live expires. func (s *API) DeleteDHCPEntry(req *DeleteDHCPEntryRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.DHCPEntryID) == "" { return errors.New("field DHCPEntryID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/dhcp-entries/" + fmt.Sprint(req.DHCPEntryID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListPATRules: List PAT rules. You can filter by gateway ID to list all PAT rules for a particular gateway, or filter for PAT rules targeting a specific IP address or using a specific protocol. func (s *API) ListPATRules(req *ListPATRulesRequest, opts ...scw.RequestOption) (*ListPATRulesResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "gateway_id", req.GatewayID) parameter.AddToQuery(query, "private_ip", req.PrivateIP) parameter.AddToQuery(query, "protocol", req.Protocol) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/pat-rules", Query: query, } var resp ListPATRulesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetPATRule: Get a PAT rule, specified by its PAT rule ID. The response object gives full details of the PAT rule, including the Public Gateway it belongs to and the configuration settings in terms of public / private ports, private IP and protocol. func (s *API) GetPATRule(req *GetPATRuleRequest, opts ...scw.RequestOption) (*PATRule, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.PatRuleID) == "" { return nil, errors.New("field PatRuleID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/pat-rules/" + fmt.Sprint(req.PatRuleID) + "", } var resp PATRule err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreatePATRule: Create a new PAT rule on a specified Public Gateway, defining the protocol to use, public port to listen on, and private port / IP address to map to. func (s *API) CreatePATRule(req *CreatePATRuleRequest, opts ...scw.RequestOption) (*PATRule, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/pat-rules", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp PATRule err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdatePATRule: Update a PAT rule, specified by its PAT rule ID. Configuration settings including private/public port, private IP address and protocol can all be updated. func (s *API) UpdatePATRule(req *UpdatePATRuleRequest, opts ...scw.RequestOption) (*PATRule, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.PatRuleID) == "" { return nil, errors.New("field PatRuleID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/pat-rules/" + fmt.Sprint(req.PatRuleID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp PATRule err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // SetPATRules: Set a definitive list of PAT rules attached to a Public Gateway. Each rule is identified by its public port and protocol. This will sync the current PAT rule list on the gateway with the new list, creating, updating or deleting PAT rules accordingly. func (s *API) SetPATRules(req *SetPATRulesRequest, opts ...scw.RequestOption) (*SetPATRulesResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PUT", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/pat-rules", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp SetPATRulesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeletePATRule: Delete a PAT rule, identified by its PAT rule ID. This action is irreversible. func (s *API) DeletePATRule(req *DeletePATRuleRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.PatRuleID) == "" { return errors.New("field PatRuleID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/pat-rules/" + fmt.Sprint(req.PatRuleID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // ListGatewayTypes: List the different Public Gateway commercial offer types available at Scaleway. The response is an array of objects describing the name and technical details of each available gateway type. func (s *API) ListGatewayTypes(req *ListGatewayTypesRequest, opts ...scw.RequestOption) (*ListGatewayTypesResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/gateway-types", } var resp ListGatewayTypesResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListIPs: List Public Gateway flexible IP addresses. A number of filter options are available for limiting results in the response. func (s *API) ListIPs(req *ListIPsRequest, opts ...scw.RequestOption) (*ListIPsResponse, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "tags", req.Tags) parameter.AddToQuery(query, "reverse", req.Reverse) parameter.AddToQuery(query, "is_free", req.IsFree) if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/ips", Query: query, } var resp ListIPsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetIP: Get details of a Public Gateway flexible IP address, identified by its IP ID. The response object contains information including which (if any) Public Gateway using this IP address, the reverse and various other metadata. func (s *API) GetIP(req *GetIPRequest, opts ...scw.RequestOption) (*IP, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.IPID) == "" { return nil, errors.New("field IPID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/ips/" + fmt.Sprint(req.IPID) + "", } var resp IP err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // CreateIP: Create (reserve) a new flexible IP address that can be used for a Public Gateway in a specified Scaleway Project. func (s *API) CreateIP(req *CreateIPRequest, opts ...scw.RequestOption) (*IP, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/ips", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp IP err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateIP: Update details of an existing flexible IP address, including its tags, reverse and the Public Gateway it is assigned to. func (s *API) UpdateIP(req *UpdateIPRequest, opts ...scw.RequestOption) (*IP, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.IPID) == "" { return nil, errors.New("field IPID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/ips/" + fmt.Sprint(req.IPID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp IP err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteIP: Delete a flexible IP address from your account. This action is irreversible. func (s *API) DeleteIP(req *DeleteIPRequest, opts ...scw.RequestOption) error { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.IPID) == "" { return errors.New("field IPID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/ips/" + fmt.Sprint(req.IPID) + "", } err = s.client.Do(scwReq, nil, opts...) if err != nil { return err } return nil } // RefreshSSHKeys: Refresh the SSH keys of a given Public Gateway, specified by its gateway ID. This adds any new SSH keys in the gateway's Scaleway Project to the gateway itself. func (s *API) RefreshSSHKeys(req *RefreshSSHKeysRequest, opts ...scw.RequestOption) (*Gateway, error) { var err error if req.Zone == "" { defaultZone, _ := s.client.GetDefaultZone() req.Zone = defaultZone } if fmt.Sprint(req.Zone) == "" { return nil, errors.New("field Zone cannot be empty in request") } if fmt.Sprint(req.GatewayID) == "" { return nil, errors.New("field GatewayID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/vpc-gw/v1/zones/" + fmt.Sprint(req.Zone) + "/gateways/" + fmt.Sprint(req.GatewayID) + "/refresh-ssh-keys", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Gateway err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/vpcgw/v1/vpcgw_utils.go000066400000000000000000000112521456366605600274010ustar00rootroot00000000000000package vpcgw import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) const ( defaultTimeout = 5 * time.Minute defaultRetryInterval = 15 * time.Second ) // WaitForGatewayRequest is used by WaitForGateway method type WaitForGatewayRequest struct { GatewayID string Zone scw.Zone Timeout *time.Duration RetryInterval *time.Duration } // WaitForGateway waits for the gateway to be in a "terminal state" before returning. // This function can be used to wait for a gateway to be ready for example. func (s *API) WaitForGateway(req *WaitForGatewayRequest, opts ...scw.RequestOption) (*Gateway, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[GatewayStatus]struct{}{ GatewayStatusUnknown: {}, GatewayStatusStopped: {}, GatewayStatusRunning: {}, GatewayStatusFailed: {}, GatewayStatusDeleted: {}, GatewayStatusLocked: {}, } gateway, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { ns, err := s.GetGateway(&GetGatewayRequest{ Zone: req.Zone, GatewayID: req.GatewayID, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[ns.Status] return ns, isTerminal, err }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for gateway failed") } return gateway.(*Gateway), nil } // WaitForGatewayNetworkRequest is used by WaitForGatewayNetwork method type WaitForGatewayNetworkRequest struct { GatewayNetworkID string Zone scw.Zone Timeout *time.Duration RetryInterval *time.Duration } // WaitForGatewayNetwork waits for the gateway network to be in a "terminal state" before returning. // This function can be used to wait for a gateway network to be ready for example. func (s *API) WaitForGatewayNetwork(req *WaitForGatewayNetworkRequest, opts ...scw.RequestOption) (*GatewayNetwork, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[GatewayNetworkStatus]struct{}{ GatewayNetworkStatusReady: {}, GatewayNetworkStatusUnknown: {}, GatewayNetworkStatusDeleted: {}, } gatewayNetwork, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { ns, err := s.GetGatewayNetwork(&GetGatewayNetworkRequest{ Zone: req.Zone, GatewayNetworkID: req.GatewayNetworkID, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[ns.Status] return ns, isTerminal, err }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for gateway network failed") } return gatewayNetwork.(*GatewayNetwork), nil } // WaitForDHCPEntriesRequest is used by WaitForDHCPEntries method type WaitForDHCPEntriesRequest struct { GatewayNetworkID *string MacAddress string Zone scw.Zone Timeout *time.Duration RetryInterval *time.Duration } // WaitForDHCPEntries waits for at least one dhcp entry with the correct mac address. // This function can be used to wait for an instance to use dhcp func (s *API) WaitForDHCPEntries(req *WaitForDHCPEntriesRequest, opts ...scw.RequestOption) (*ListDHCPEntriesResponse, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } dhcpEntries, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { entries, err := s.ListDHCPEntries(&ListDHCPEntriesRequest{ Zone: req.Zone, GatewayNetworkID: req.GatewayNetworkID, MacAddress: &req.MacAddress, }, opts...) if err != nil { return nil, false, err } containsMacAddress := false for _, entry := range entries.DHCPEntries { if entry.MacAddress == req.MacAddress { containsMacAddress = true break } } return entries, containsMacAddress, err }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for gateway network failed") } return dhcpEntries.(*ListDHCPEntriesResponse), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/webhosting/000077500000000000000000000000001456366605600252005ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/webhosting/v1alpha1/000077500000000000000000000000001456366605600266155ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/webhosting/v1alpha1/webhosting_sdk.go000066400000000000000000000741011456366605600321610ustar00rootroot00000000000000// This file was automatically generated. DO NOT EDIT. // If you have any remark or suggestion do not hesitate to open an issue. // Package webhosting provides methods and message types of the webhosting v1alpha1 API. package webhosting import ( "bytes" "encoding/json" "fmt" "net" "net/http" "net/url" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/marshaler" "github.com/scaleway/scaleway-sdk-go/internal/parameter" "github.com/scaleway/scaleway-sdk-go/namegenerator" "github.com/scaleway/scaleway-sdk-go/scw" std "github.com/scaleway/scaleway-sdk-go/api/std" ) // always import dependencies var ( _ fmt.Stringer _ json.Unmarshaler _ url.URL _ net.IP _ http.Header _ bytes.Reader _ time.Time _ = strings.Join _ scw.ScalewayRequest _ marshaler.Duration _ scw.File _ = parameter.AddToQuery _ = namegenerator.GetRandomName ) type DNSRecordStatus string const ( DNSRecordStatusUnknownStatus = DNSRecordStatus("unknown_status") DNSRecordStatusValid = DNSRecordStatus("valid") DNSRecordStatusInvalid = DNSRecordStatus("invalid") ) func (enum DNSRecordStatus) String() string { if enum == "" { // return default value if empty return "unknown_status" } return string(enum) } func (enum DNSRecordStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DNSRecordStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DNSRecordStatus(DNSRecordStatus(tmp).String()) return nil } type DNSRecordType string const ( DNSRecordTypeUnknownType = DNSRecordType("unknown_type") DNSRecordTypeA = DNSRecordType("a") DNSRecordTypeCname = DNSRecordType("cname") DNSRecordTypeMx = DNSRecordType("mx") DNSRecordTypeTxt = DNSRecordType("txt") DNSRecordTypeNs = DNSRecordType("ns") DNSRecordTypeAaaa = DNSRecordType("aaaa") ) func (enum DNSRecordType) String() string { if enum == "" { // return default value if empty return "unknown_type" } return string(enum) } func (enum DNSRecordType) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DNSRecordType) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DNSRecordType(DNSRecordType(tmp).String()) return nil } type DNSRecordsStatus string const ( DNSRecordsStatusUnknown = DNSRecordsStatus("unknown") DNSRecordsStatusValid = DNSRecordsStatus("valid") DNSRecordsStatusInvalid = DNSRecordsStatus("invalid") ) func (enum DNSRecordsStatus) String() string { if enum == "" { // return default value if empty return "unknown" } return string(enum) } func (enum DNSRecordsStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *DNSRecordsStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = DNSRecordsStatus(DNSRecordsStatus(tmp).String()) return nil } type HostingDNSStatus string const ( HostingDNSStatusUnknownDNSStatus = HostingDNSStatus("unknown_dns_status") HostingDNSStatusValid = HostingDNSStatus("valid") HostingDNSStatusInvalid = HostingDNSStatus("invalid") ) func (enum HostingDNSStatus) String() string { if enum == "" { // return default value if empty return "unknown_dns_status" } return string(enum) } func (enum HostingDNSStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *HostingDNSStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = HostingDNSStatus(HostingDNSStatus(tmp).String()) return nil } type HostingStatus string const ( HostingStatusUnknownStatus = HostingStatus("unknown_status") HostingStatusDelivering = HostingStatus("delivering") HostingStatusReady = HostingStatus("ready") HostingStatusDeleting = HostingStatus("deleting") HostingStatusError = HostingStatus("error") HostingStatusLocked = HostingStatus("locked") HostingStatusMigrating = HostingStatus("migrating") ) func (enum HostingStatus) String() string { if enum == "" { // return default value if empty return "unknown_status" } return string(enum) } func (enum HostingStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *HostingStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = HostingStatus(HostingStatus(tmp).String()) return nil } type ListHostingsRequestOrderBy string const ( ListHostingsRequestOrderByCreatedAtAsc = ListHostingsRequestOrderBy("created_at_asc") ListHostingsRequestOrderByCreatedAtDesc = ListHostingsRequestOrderBy("created_at_desc") ) func (enum ListHostingsRequestOrderBy) String() string { if enum == "" { // return default value if empty return "created_at_asc" } return string(enum) } func (enum ListHostingsRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListHostingsRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListHostingsRequestOrderBy(ListHostingsRequestOrderBy(tmp).String()) return nil } type ListOffersRequestOrderBy string const ( ListOffersRequestOrderByPriceAsc = ListOffersRequestOrderBy("price_asc") ) func (enum ListOffersRequestOrderBy) String() string { if enum == "" { // return default value if empty return "price_asc" } return string(enum) } func (enum ListOffersRequestOrderBy) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *ListOffersRequestOrderBy) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = ListOffersRequestOrderBy(ListOffersRequestOrderBy(tmp).String()) return nil } type NameserverStatus string const ( NameserverStatusUnknownStatus = NameserverStatus("unknown_status") NameserverStatusValid = NameserverStatus("valid") NameserverStatusInvalid = NameserverStatus("invalid") ) func (enum NameserverStatus) String() string { if enum == "" { // return default value if empty return "unknown_status" } return string(enum) } func (enum NameserverStatus) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *NameserverStatus) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = NameserverStatus(NameserverStatus(tmp).String()) return nil } type OfferQuotaWarning string const ( OfferQuotaWarningUnknownQuotaWarning = OfferQuotaWarning("unknown_quota_warning") OfferQuotaWarningEmailCountExceeded = OfferQuotaWarning("email_count_exceeded") OfferQuotaWarningDatabaseCountExceeded = OfferQuotaWarning("database_count_exceeded") OfferQuotaWarningDiskUsageExceeded = OfferQuotaWarning("disk_usage_exceeded") ) func (enum OfferQuotaWarning) String() string { if enum == "" { // return default value if empty return "unknown_quota_warning" } return string(enum) } func (enum OfferQuotaWarning) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, enum)), nil } func (enum *OfferQuotaWarning) UnmarshalJSON(data []byte) error { tmp := "" if err := json.Unmarshal(data, &tmp); err != nil { return err } *enum = OfferQuotaWarning(OfferQuotaWarning(tmp).String()) return nil } // HostingCpanelURLs: hosting cpanel ur ls. type HostingCpanelURLs struct { Dashboard string `json:"dashboard"` Webmail string `json:"webmail"` } // HostingOption: hosting option. type HostingOption struct { // ID: option ID. ID string `json:"id"` // Name: option name. Name string `json:"name"` } // OfferProduct: offer product. type OfferProduct struct { // Name: product name. Name string `json:"name"` // Option: product option. Option bool `json:"option"` // EmailAccountsQuota: limit number of email accounts. EmailAccountsQuota int32 `json:"email_accounts_quota"` // EmailStorageQuota: limit quantity of email storage in gigabytes. EmailStorageQuota int32 `json:"email_storage_quota"` // DatabasesQuota: limit number of databases. DatabasesQuota int32 `json:"databases_quota"` // HostingStorageQuota: limit quantity of hosting storage in gigabytes. HostingStorageQuota uint32 `json:"hosting_storage_quota"` // SupportIncluded: whether or not support is included. SupportIncluded bool `json:"support_included"` // VCPU: limit number of virtual CPU. VCPU uint32 `json:"v_cpu"` // RAM: limit quantity of memory in gigabytes. RAM uint32 `json:"ram"` // MaxAddonDomains: limit number of add-on domains. MaxAddonDomains int32 `json:"max_addon_domains"` } // DNSRecord: dns record. type DNSRecord struct { // Name: record name. Name string `json:"name"` // Type: record type. // Default value: unknown_type Type DNSRecordType `json:"type"` // TTL: record time-to-live. TTL uint32 `json:"ttl"` // Value: record value. Value string `json:"value"` // Priority: record priority level. Priority *uint32 `json:"priority"` // Status: record status. // Default value: unknown_status Status DNSRecordStatus `json:"status"` } // Nameserver: nameserver. type Nameserver struct { // Hostname: hostname of the nameserver. Hostname string `json:"hostname"` // Status: status of the nameserver. // Default value: unknown_status Status NameserverStatus `json:"status"` // IsDefault: defines whether the nameserver is the default one. IsDefault bool `json:"is_default"` } // ControlPanel: control panel. type ControlPanel struct { // Name: control panel name. Name string `json:"name"` // Available: define if the control panel type is available to order. Available bool `json:"available"` // LogoURL: URL of this control panel's logo. LogoURL string `json:"logo_url"` } // Hosting: hosting. type Hosting struct { // ID: ID of the Web Hosting plan. ID string `json:"id"` // OrganizationID: ID of the Scaleway Organization the Web Hosting plan belongs to. OrganizationID string `json:"organization_id"` // ProjectID: ID of the Scaleway Project the Web Hosting plan belongs to. ProjectID string `json:"project_id"` // UpdatedAt: date on which the Web Hosting plan was last updated. UpdatedAt *time.Time `json:"updated_at"` // CreatedAt: date on which the Web Hosting plan was created. CreatedAt *time.Time `json:"created_at"` // Status: status of the Web Hosting plan. // Default value: unknown_status Status HostingStatus `json:"status"` // PlatformHostname: hostname of the host platform. PlatformHostname string `json:"platform_hostname"` // PlatformNumber: number of the host platform. PlatformNumber *int32 `json:"platform_number"` // OfferID: ID of the active offer for the Web Hosting plan. OfferID string `json:"offer_id"` // OfferName: name of the active offer for the Web Hosting plan. OfferName string `json:"offer_name"` // Domain: main domain associated with the Web Hosting plan. Domain string `json:"domain"` // Tags: list of tags associated with the Web Hosting plan. Tags []string `json:"tags"` // Options: array of any options activated for the Web Hosting plan. Options []*HostingOption `json:"options"` // DNSStatus: DNS status of the Web Hosting plan. // Default value: unknown_dns_status DNSStatus HostingDNSStatus `json:"dns_status"` // CpanelURLs: URL to connect to cPanel dashboard and to Webmail interface. CpanelURLs *HostingCpanelURLs `json:"cpanel_urls"` // Username: main Web Hosting cPanel username. Username string `json:"username"` // OfferEndOfLife: indicates if the hosting offer has reached its end of life. OfferEndOfLife bool `json:"offer_end_of_life"` // ControlPanelName: name of the control panel. ControlPanelName string `json:"control_panel_name"` // PlatformGroup: group of the hosting's host server/platform. PlatformGroup string `json:"platform_group"` // IPv4: iPv4 address of the hosting's host server. IPv4 string `json:"ipv4"` // IPv6: iPv6 address of the hosting's host server. IPv6 string `json:"ipv6"` // Region: region where the Web Hosting plan is hosted. Region scw.Region `json:"region"` } // Offer: offer. type Offer struct { // ID: offer ID. ID string `json:"id"` // BillingOperationPath: unique identifier used for billing. BillingOperationPath string `json:"billing_operation_path"` // Product: product constituting this offer. Product *OfferProduct `json:"product"` // Price: price of this offer. Price *scw.Money `json:"price"` // Available: if a hosting_id was specified in the call, defines whether this offer is available for that Web Hosting plan to migrate (update) to. Available bool `json:"available"` // QuotaWarnings: quota warnings, if the offer is not available for the specified hosting_id. QuotaWarnings []OfferQuotaWarning `json:"quota_warnings"` // EndOfLife: indicates if the offer has reached its end of life. EndOfLife bool `json:"end_of_life"` // ControlPanelName: name of the control panel. ControlPanelName string `json:"control_panel_name"` } // CreateHostingRequest: create hosting request. type CreateHostingRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // OfferID: ID of the selected offer for the Web Hosting plan. OfferID string `json:"offer_id"` // ProjectID: ID of the Scaleway Project in which to create the Web Hosting plan. ProjectID string `json:"project_id"` // Email: contact email for the Web Hosting client. Email *string `json:"email,omitempty"` // Tags: list of tags for the Web Hosting plan. Tags []string `json:"tags"` // Domain: domain name to link to the Web Hosting plan. You must already own this domain name, and have completed the DNS validation process beforehand. Domain string `json:"domain"` // OptionIDs: iDs of any selected additional options for the Web Hosting plan. OptionIDs []string `json:"option_ids"` // Language: default language for the control panel interface. // Default value: unknown_language_code Language std.LanguageCode `json:"language"` } // DNSRecords: dns records. type DNSRecords struct { // Records: list of DNS records. Records []*DNSRecord `json:"records"` // NameServers: list of nameservers. NameServers []*Nameserver `json:"name_servers"` // Status: status of the records. // Default value: unknown Status DNSRecordsStatus `json:"status"` } // DeleteHostingRequest: delete hosting request. type DeleteHostingRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // HostingID: hosting ID. HostingID string `json:"-"` } // GetDomainDNSRecordsRequest: get domain dns records request. type GetDomainDNSRecordsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Domain: domain associated with the DNS records. Domain string `json:"-"` } // GetHostingRequest: get hosting request. type GetHostingRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // HostingID: hosting ID. HostingID string `json:"-"` } // ListControlPanelsRequest: list control panels request. type ListControlPanelsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: page number to return, from the paginated results (must be a positive integer). Page *int32 `json:"-"` // PageSize: number of control panels to return (must be a positive integer lower or equal to 100). PageSize *uint32 `json:"-"` } // ListControlPanelsResponse: list control panels response. type ListControlPanelsResponse struct { // TotalCount: number of control panels returned. TotalCount uint64 `json:"total_count"` // ControlPanels: list of control panels. ControlPanels []*ControlPanel `json:"control_panels"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListControlPanelsResponse) UnsafeGetTotalCount() uint64 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListControlPanelsResponse) UnsafeAppend(res interface{}) (uint64, error) { results, ok := res.(*ListControlPanelsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.ControlPanels = append(r.ControlPanels, results.ControlPanels...) r.TotalCount += uint64(len(results.ControlPanels)) return uint64(len(results.ControlPanels)), nil } // ListHostingsRequest: list hostings request. type ListHostingsRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // Page: page number to return, from the paginated results (must be a positive integer). Page *int32 `json:"-"` // PageSize: number of Web Hosting plans to return (must be a positive integer lower or equal to 100). PageSize *uint32 `json:"-"` // OrderBy: sort order for Web Hosting plans in the response. // Default value: created_at_asc OrderBy ListHostingsRequestOrderBy `json:"-"` // Tags: tags to filter for, only Web Hosting plans with matching tags will be returned. Tags []string `json:"-"` // Statuses: statuses to filter for, only Web Hosting plans with matching statuses will be returned. Statuses []HostingStatus `json:"-"` // Domain: domain to filter for, only Web Hosting plans associated with this domain will be returned. Domain *string `json:"-"` // ProjectID: project ID to filter for, only Web Hosting plans from this Project will be returned. ProjectID *string `json:"-"` // OrganizationID: organization ID to filter for, only Web Hosting plans from this Organization will be returned. OrganizationID *string `json:"-"` // ControlPanels: name of the control panel to filter for, only Web Hosting plans from this control panel will be returned. ControlPanels []string `json:"-"` } // ListHostingsResponse: list hostings response. type ListHostingsResponse struct { // TotalCount: number of Web Hosting plans returned. TotalCount uint32 `json:"total_count"` // Hostings: list of Web Hosting plans. Hostings []*Hosting `json:"hostings"` } // UnsafeGetTotalCount should not be used // Internal usage only func (r *ListHostingsResponse) UnsafeGetTotalCount() uint32 { return r.TotalCount } // UnsafeAppend should not be used // Internal usage only func (r *ListHostingsResponse) UnsafeAppend(res interface{}) (uint32, error) { results, ok := res.(*ListHostingsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) } r.Hostings = append(r.Hostings, results.Hostings...) r.TotalCount += uint32(len(results.Hostings)) return uint32(len(results.Hostings)), nil } // ListOffersRequest: list offers request. type ListOffersRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // OrderBy: sort order of offers in the response. // Default value: price_asc OrderBy ListOffersRequestOrderBy `json:"-"` // WithoutOptions: defines whether the response should consist of offers only, without options. WithoutOptions bool `json:"-"` // OnlyOptions: defines whether the response should consist of options only, without offers. OnlyOptions bool `json:"-"` // HostingID: ID of a Web Hosting plan, to check compatibility with returned offers (in case of wanting to update the plan). HostingID *string `json:"-"` // ControlPanels: name of the control panel to filter for. ControlPanels []string `json:"-"` } // ListOffersResponse: list offers response. type ListOffersResponse struct { // Offers: list of offers. Offers []*Offer `json:"offers"` } // RestoreHostingRequest: restore hosting request. type RestoreHostingRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // HostingID: hosting ID. HostingID string `json:"-"` } // UpdateHostingRequest: update hosting request. type UpdateHostingRequest struct { // Region: region to target. If none is passed will use default region from the config. Region scw.Region `json:"-"` // HostingID: hosting ID. HostingID string `json:"-"` // Email: new contact email for the Web Hosting plan. Email *string `json:"email,omitempty"` // Tags: new tags for the Web Hosting plan. Tags *[]string `json:"tags,omitempty"` // OptionIDs: iDs of the new options for the Web Hosting plan. OptionIDs *[]string `json:"option_ids,omitempty"` // OfferID: ID of the new offer for the Web Hosting plan. OfferID *string `json:"offer_id,omitempty"` } // Web Hosting API. type API struct { client *scw.Client } // NewAPI returns a API object from a Scaleway client. func NewAPI(client *scw.Client) *API { return &API{ client: client, } } func (s *API) Regions() []scw.Region { return []scw.Region{scw.RegionFrPar, scw.RegionNlAms} } // CreateHosting: Order a Web Hosting plan, specifying the offer type required via the `offer_id` parameter. func (s *API) CreateHosting(req *CreateHostingRequest, opts ...scw.RequestOption) (*Hosting, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if req.ProjectID == "" { defaultProjectID, _ := s.client.GetDefaultProjectID() req.ProjectID = defaultProjectID } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/webhosting/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/hostings", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Hosting err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListHostings: List all of your existing Web Hosting plans. Various filters are available to limit the results, including filtering by domain, status, tag and Project ID. func (s *API) ListHostings(req *ListHostingsRequest, opts ...scw.RequestOption) (*ListHostingsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "tags", req.Tags) parameter.AddToQuery(query, "statuses", req.Statuses) parameter.AddToQuery(query, "domain", req.Domain) parameter.AddToQuery(query, "project_id", req.ProjectID) parameter.AddToQuery(query, "organization_id", req.OrganizationID) parameter.AddToQuery(query, "control_panels", req.ControlPanels) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/webhosting/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/hostings", Query: query, } var resp ListHostingsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetHosting: Get the details of one of your existing Web Hosting plans, specified by its `hosting_id`. func (s *API) GetHosting(req *GetHostingRequest, opts ...scw.RequestOption) (*Hosting, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.HostingID) == "" { return nil, errors.New("field HostingID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/webhosting/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/hostings/" + fmt.Sprint(req.HostingID) + "", } var resp Hosting err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // UpdateHosting: Update the details of one of your existing Web Hosting plans, specified by its `hosting_id`. You can update parameters including the contact email address, tags, options and offer. func (s *API) UpdateHosting(req *UpdateHostingRequest, opts ...scw.RequestOption) (*Hosting, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.HostingID) == "" { return nil, errors.New("field HostingID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "PATCH", Path: "/webhosting/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/hostings/" + fmt.Sprint(req.HostingID) + "", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Hosting err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // DeleteHosting: Delete a Web Hosting plan, specified by its `hosting_id`. Note that deletion is not immediate: it will take place at the end of the calendar month, after which time your Web Hosting plan and all its data (files and emails) will be irreversibly lost. func (s *API) DeleteHosting(req *DeleteHostingRequest, opts ...scw.RequestOption) (*Hosting, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.HostingID) == "" { return nil, errors.New("field HostingID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "DELETE", Path: "/webhosting/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/hostings/" + fmt.Sprint(req.HostingID) + "", } var resp Hosting err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // RestoreHosting: When you [delete a Web Hosting plan](#path-hostings-delete-a-hosting), definitive deletion does not take place until the end of the calendar month. In the time between initiating the deletion, and definitive deletion at the end of the month, you can choose to **restore** the Web Hosting plan, using this endpoint and specifying its `hosting_id`. func (s *API) RestoreHosting(req *RestoreHostingRequest, opts ...scw.RequestOption) (*Hosting, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.HostingID) == "" { return nil, errors.New("field HostingID cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "POST", Path: "/webhosting/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/hostings/" + fmt.Sprint(req.HostingID) + "/restore", } err = scwReq.SetBody(req) if err != nil { return nil, err } var resp Hosting err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // GetDomainDNSRecords: Get the set of DNS records of a specified domain associated with a Web Hosting plan. func (s *API) GetDomainDNSRecords(req *GetDomainDNSRecordsRequest, opts ...scw.RequestOption) (*DNSRecords, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } if fmt.Sprint(req.Domain) == "" { return nil, errors.New("field Domain cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/webhosting/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/domains/" + fmt.Sprint(req.Domain) + "/dns-records", } var resp DNSRecords err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListOffers: List the different Web Hosting offers, and their options, available to order from Scaleway. func (s *API) ListOffers(req *ListOffersRequest, opts ...scw.RequestOption) (*ListOffersResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } query := url.Values{} parameter.AddToQuery(query, "order_by", req.OrderBy) parameter.AddToQuery(query, "without_options", req.WithoutOptions) parameter.AddToQuery(query, "only_options", req.OnlyOptions) parameter.AddToQuery(query, "hosting_id", req.HostingID) parameter.AddToQuery(query, "control_panels", req.ControlPanels) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/webhosting/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/offers", Query: query, } var resp ListOffersResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } // ListControlPanels: List the control panels type: cpanel or plesk. func (s *API) ListControlPanels(req *ListControlPanelsRequest, opts ...scw.RequestOption) (*ListControlPanelsResponse, error) { var err error if req.Region == "" { defaultRegion, _ := s.client.GetDefaultRegion() req.Region = defaultRegion } defaultPageSize, exist := s.client.GetDefaultPageSize() if (req.PageSize == nil || *req.PageSize == 0) && exist { req.PageSize = &defaultPageSize } query := url.Values{} parameter.AddToQuery(query, "page", req.Page) parameter.AddToQuery(query, "page_size", req.PageSize) if fmt.Sprint(req.Region) == "" { return nil, errors.New("field Region cannot be empty in request") } scwReq := &scw.ScalewayRequest{ Method: "GET", Path: "/webhosting/v1alpha1/regions/" + fmt.Sprint(req.Region) + "/control-panels", Query: query, } var resp ListControlPanelsResponse err = s.client.Do(scwReq, &resp, opts...) if err != nil { return nil, err } return &resp, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/api/webhosting/v1alpha1/webhosting_utils.go000066400000000000000000000031321456366605600325340ustar00rootroot00000000000000package webhosting import ( "time" "github.com/scaleway/scaleway-sdk-go/internal/async" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) const ( defaultRetryInterval = 5 * time.Second defaultTimeout = 5 * time.Minute ) // WaitForHostingRequest is used by WaitForHosting method. type WaitForHostingRequest struct { HostingID string Region scw.Region Timeout *time.Duration RetryInterval *time.Duration } // WaitForHosting wait for a hosting to be in a "terminal state" before returning. func (s *API) WaitForHosting(req *WaitForHostingRequest, opts ...scw.RequestOption) (*Hosting, error) { timeout := defaultTimeout if req.Timeout != nil { timeout = *req.Timeout } retryInterval := defaultRetryInterval if req.RetryInterval != nil { retryInterval = *req.RetryInterval } terminalStatus := map[HostingStatus]struct{}{ HostingStatusReady: {}, HostingStatusError: {}, HostingStatusUnknownStatus: {}, HostingStatusLocked: {}, } res, err := async.WaitSync(&async.WaitSyncConfig{ Get: func() (interface{}, bool, error) { hosting, err := s.GetHosting(&GetHostingRequest{ HostingID: req.HostingID, Region: req.Region, }, opts...) if err != nil { return nil, false, err } _, isTerminal := terminalStatus[hosting.Status] return hosting, isTerminal, nil }, Timeout: timeout, IntervalStrategy: async.LinearIntervalStrategy(retryInterval), }) if err != nil { return nil, errors.Wrap(err, "waiting for hosting failed") } return res.(*Hosting), nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/doc.go000066400000000000000000000005711456366605600233550ustar00rootroot00000000000000// Package scalewaysdkgo is the Scaleway API SDK for Go. // // In order to use the available APIs, create a `Client`. Once created, it can be used to instantiate an API. // To use the `instance` API, for example, instantiate it (with the client object) `instance.NewApi(client)`. // On this instance API, all the available API functions can be called. // package scalewaysdkgo golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/docs/000077500000000000000000000000001456366605600232065ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/docs/CONTINUOUS_CODE_DEPLOYMENT.md000066400000000000000000000016321456366605600275720ustar00rootroot00000000000000# Continuous code deployment Part of this repo is automatically generated from our [protocol buffer](https://en.wikipedia.org/wiki/Protocol_Buffers) monorepo. This enables us to keep Scaleway toolings up to date with the latest version of our APIs ([developer website](http://developers.scaleway.com), soon-to-be CLI, ...). ## Generated files Generated files and folders are located in [scaleway-sdk-go/api](../api). They always start with the following line: ```c // This file was automatically generated. DO NOT EDIT. ``` ## Continuous deployment process TODO: explains the continuous deployment process. ## Synchronization frequency The continuous code deployment process can occur at anytime of the day, sometime many times a day. Expect it to happen regularly. ## Any question? If you have any question or request about the continuous code deployment process feel free to [reach us](../README.md#reach-us). golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/docs/static_files/000077500000000000000000000000001456366605600256575ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/docs/static_files/sdk-artwork.png000066400000000000000000003047011456366605600306420ustar00rootroot00000000000000PNG  IHDR)2gAMA a cHRMz&u0`:pQ<eXIfMM*JR(iZHH)jq} pHYs  hiTXtXML:com.adobe.xmp 1 2 1 929 929 $@IDATxy}{N}N$@Q )d2Cdu*qb gW9N^#/~yI ql'(b~HJD@$ fs}ܙK/t6kx>|N1@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@`>"O@L>I:)3,LSщ[}99!υ3w@@@T$:J-DdK 8l ㎫_-U*Y+g|a # @ki8ə8ZAuRZ/&Nn)3aR3Pf}@@""%%"И&{: \Iٌ9V`{նmn΍z}{bNMTd!e~]_KnFM/3^C@I1k mB V]+ &c 5XEj4Yۖ+ JTGX`TQkX// FvxK@@@`PR </m:V%- TB蕔f/sbJRfR ̱eE(-$n JXv5#ݏkbI# &Y!rgRHE*-Uέ9Ys,71/@@%%%^=js_lO_Wx%^G)iTkWgwsIaɟyaˀ   PR2XW Y"lGq#u^xed|N1+"lJ@@ $yw [dɬq:M'U W=7 ůOOR )+2<@@+F5f;eܚMKIG1!kIY =byL0rN@,ĂMȝ I;\ˊrVf~T    H/]zՄMՄ$ҕ;퓵Xr_gr˗@@@<M\g9gOM)Ƅ'}/Ƥ L_?Jw (ֳM5Ȍ,x. ɝfFzc,&Hoee]j>x&@.`G|;2 Y{F   P9Ҥ-.o*&Rmy;Ւ)we*MťS Ue| y0Ee ހ6PRQHr҉5VLBG*,dqŪL>- q*޹%!%%5I('T~c᫑V SaVdvMT(ǒAy+bs+[ϯf7Z[ q\*ȝlPNJr0*n.˺`zIRRuB¢)"kGɗ ;^nRii,im4$jߡTҋ(΁@xJ#pbnfZMEOj"KKFSX;[KTTH^w0)/4ꍞN=9WT]LsB eoV Re]!'r"X):dHʘw*FRء?/tRd   PRҲ)_=i; {ĥf\(5"k󒴖rBJJ4).Z*k0=d4~?P:*S}4WoJE  efB| @I} @?&vTCwU?|s"emy#KG WA@@()\sd.v"VALnrY1i._; Z$ Ŭ3^oxV]U,S:iI4&no+L!Kf;Tj,[h %ET YO yx{P˾ F-TFTJj+P?p6޴ڻeckD" gOʰPCJ%'vb"toYM:yTPf[oJeԄ$-@4~x+Vh WIJPr}qpl̗.i   (PRӿoYs_"1)(\ODLybAI?ty]0|W`U MA@b#%%6fN,}rx?:$)(YO(KWPGEoN4k`!A@ e?{=&7Ylo@I" J7 UQ^I  =\S3rd'3@ɗF{gő$IrrHT+v)SC@YauU(  @IQ2U#IdJZN2.R mo_cBƢyȸ'#q1`+'RZ{RE8x촌UW2(!3e?)g/j.VHi,/c: ^J    S3t傶CATN-#JG{ = N4ܿ4s  C @I( \׮\<ŝt J7 oU+$u ܿt   XÛE < ˦+(GqA9ƟkWE>[cCI\1)c>ߜ;u@!2@J _<rk_jkdDwQ乜|v#>%<}`S`p -A@1lgb^B\fՕ^~Oz +`L=qNtJ@TmP1*Ҙ@@.iAX(qB]q=`ZOz, Ojzz?:33_d 7Y_ݴȂ}&*(Z|z%i=<EZOYtn©K(+r !JEB4a,@|wߵs4nUI5.^#AG&Ap&dKAnv{(1p?ݚ{\Sa @*(%t⬿No9X{ TさDxQݓ{#yq0/Lxlf pu!8@@8^\oeϤOK>W&/J1 eT~ {^q1`(؟ &KJh{"y)`Ů2C1@8R 'JAaҽK0|!yy~J8" c՚s3SQMy@@C_.0$A =i-v둻y%LAM^쉧;Ql.5)" S G""@@%KJ n׽=((ɩJ a š\]e3V((}g5zA}h Y'h9IM3`X b]MK YP-v/2DyPĠ##($P1 dܽ ~׽+;8{LBkWkl)t J3^ADvAmpM}E@bK8((B!7+'HAI Ec*HIzL  )#%Ű u3wu/˭R{1Wn,F"ݻ6P:*/_݈M MY{(*Pb 0()mB}L^NA%*yOTGadGu rraM 0tw(*b8()Oi_nʛɋ)(?5 F֔p"E%̘@RJ ާ)rYn|>Q ~E댲+#B8gڻZZ>#@z j&hV?|O,Ƭ,eǩ % h [F@`Q #@@II螻}wBBzD͋#bdE JǸtS؝*3 !Ee \EJ. If|7P^ZQL=֖VX۶#ȇ1kNJ#vPTb |rVƟൽ _{uioH9G"vi ʑL{(((?k2W>. B@L2/ @@ ;$h]OUPF[[Z&J4~GmlŪ\vqW[ߺYfk9f[y(*f@Iy*(nEyE,O;W5Ɗ6:ve;H1đ E%)@=1( D` ʉchE~Ewʓ21*1VPTTs.+fH*()1[ơ|7p$tUYMmݵ塠!>=- (*3}*(0")h"?K5y((wE U6g#$H"L4bZiɊ;S>Q1DN&B8 ݵ5Ȍq1İw'ϲYNVW9eVC|Cz!E~mzpv9I=cT@Ix,^B<v4yEaE1(qġRB󰷹11*$4.M3yEkmEz(Y!CČ k88[lPi^S   PR"U 7((yx!z(&c8kGtO: \s?֚{|¥x   @I _œate趢LP0:y6' /;k 8dłL8O>  "%E~ pL#婲n+ yMq5'dx(0v .^ zQ\  ,PR4)F `J:Bu[QܼF4n힡kDhDq@ @IѴ)SPtrj[Qֺ(?Ԉ ~4 OV%7.cAJ})C Uç͋X-Bg*X:x(g3~bD%x8{\z<o@@2AJmv3񘪡Ɋ"7T 8TYYD4ÏJ%[P9iG [*sTׇW\ .D46S@ %EL^ f|0UBHɏBtehM)H Hg$ )͹Sg# JJ* 3yuo>aʺɩ&hߠTQ~JIR~3|^ Lb*̡`>) b(H(() 6FrYB!vU&썾M3`^LP)H&7+:&HK,dfL0-b]W0%oZ"Iavq-cT bn+n_&o d 3蒮8wΔTWdC 4d+ݎmoY!-;A@?()"}rF^B:%z1 fK:ȊuI-2h0`܂[rȴܣ@@ EL }v<-:SNaBUrPRTk}E>PR-Xtš(i"`RBKn[ Cl5mgj]Iڲ0T^c Y!ݷu Υ#ܼKZQF[Q*8RN`y Zh*X}!W*v7)p 8ਭBVrVeJJ8x V8Cn_l E@Wej<HC"Q@ x(ܼH zߌ]ZQn?P\EsG]#,.!r"13_Yp%]P+%]IUaE  -PRw.w^g6pu]XQ΀Q;ќ;u(!,PRv-;W\aEW@zs3,gA@  "q~eEkUh լՕN^?iuyXQn11[CP1b MA@<xIr8Ӣ|8TzQl \\EI:MP/pNQ#@3q%-8"|iyᆎ+PDh@r @I7wNWZ,Iɫ3vq+WRhp5Hb   @IuD,ߙZGi%~o#8^+)pnGyAMJ?3f8AtC7kꔔ7Š}@ zbf60r+3X)oE(mVƫ0} <Ojs7~Xd,tiQRT.L+;}% &cs[*@R@I 'gcQoLZQ QڕE V*E6&RSOPR$07尬N쓝iGi(G2`.ch&`94πA@By ފ*"dGe(+-TH1@! c(hnAP `B!oZQD,Y_ v}8 (MAL'y%ŵ6Fv5iϩ*jDYa!(0  Pф] 'i%%N+ wiG(QkQ̈́y VWLjBHbCzo2jEq"K n2U;:棏U&#SCl=հ<H @b Y%%nͫDebMÔ%;pJD!)QP  @&wNZ,)kb< e'Ȥ"(Eq P<\v1gt#kJ@3rOĹiI=j oXwDp 19 cdz+F020!fS7-NUzwPp)SF*jLAKbaMIbM Ȕ"7g=~pAV.Gs"Ww~"/$R.-vV  Џ@4|~6){'^;’*/u+2fMfOs.A4l))qo쾭拣h}W/x\$ ֔$md2()qoҐ~mW(n4ޯiL`um][Ա.  Ȍ¸5IS[^Qד!i$mM'.ks7 z% % gⱰO{>#RT{$eLl)R%ɱ9%a2|.[[$*,)S$ȒAS\5<A@Ȇi}}8'̑/ɩB!E 1  v#?/ /HJ%H/Ĉea"_#gGvL  z%E2N%BGAa1}EaEPqG{Q(RȀDTړ4<袢mC5|dK#>mHjÚp i&j%=KAv__- n02WwD:L4  @VRdz 'F"U@o^} ^iVM釣:%'0A &gJJ72@&Č|.+h쑾>-+J 7p \.6["q8\X-@<ҥ0g7{wQĜ+a 9Fq^^ʛFF]_l.LnpJbu  .%oaErkd\B\4^v AI,| p-A@H"}r7XQ|# ᶻ a{/m0lTVGJN:d@I 5Jܾ[8v-Ѯ蕬.v,H35}dtv-kȱŨ  ȶ2Ȓ:c~J\^?^% IY- @ %Ғu~ tB^<˶{Bs 4̀ *xap+\`ZsPOYC0,K3wL!7G4f|OAQ͓i#p$ dmeMH2OLeА8ngX>ҕR r;)!쟖޾6ۑp[_"ҭ)d+ᗥC?HF/A„#KW?"$ŠBph< '`JI},qKL{t̳ӼF-2#RFNlU`OY-]eE {c1cd %FsX󤼴XR̗/ ?J/߀'}@:,)iɇ~xl".iI"#dcߑD֞N sf'ʎĺP^p[b Z[\%F>͑֗cRcHyɳT^YaܹQ\dy~f~Hxv$|Qdy OEcIQ.84@C`r!xLgcD}@*TH.QH#~XKP4h.2G4?IU~a]yC4ł a 1{7ٱ'gtw M ̧N3r=DZ=NVX7z/QH5OX>QZ72 F|%"y?G(4~FL01)Qr\_˱q2sCi^hme3&g[() G_gN[&Hwv̶eK+Qז ԝZ^!(7G)'e8uVEFf1-5L-fPXÅ>VRpYZӃ\>Z~CΎђB 6]^8@ *HEiH8ΆhE{=!S!c=s뇅̰uG|:*RIBY}q%Yrpjo{SVH$ie6?-- }JF+)z?(8mj3P8|ƥ%\2/&Cm'\$;''-ۋs6,Z?kwˀsJiyaC&HU9e.|4f$Ra ޴Tbx  pFhJJa5HA<E[+#8/-8@> HM<2ouo+'A\)u<&S❲)tm'w;+SSe*N=i1ح̝,gl%%H<rw~Wp7`48Q(c>,Y1sO߬ teYJS1^:r!jݸshL{}mU?f] J2tUÝwJwIx+Ls2SޅM9VRV==W_ _ʲ8Ւx[hԈbU:&r6޼3H} xkv:ex~čSi*e.!.j͝:gYdi@wsݽ(cX!G㡽'c9O4B0KuQl!y XMI_TB|rVZN;VXBE.k]A2>p=-mƓbd6~[ g9I%s-)A2{r )0'>!!蠊1}v1۟Մ\0 ?LDvͩ~p8NQiUQU^\Ģy}OwaǔQ(TøQ1&MXQ4pŐ! cHӿ[AV< jlGYv{.`2mCTYUeƊRE/ޜ{x>TRdPT bR8+:@Fs`‚`Bnt1ykh,GNMܐ5XV~l龷zE!"@^gTR88]&ϚLKtmfijX|4Ĥ -eS9e@.?fЉX'?ĊZU(VEUb= K,ye~{CzL%xƂ(D 47~6=H/Zgةd7^FYTh1UE+,]Jܿb*ҁ%}61)?es23_ URZRܣDH-(k?r#$_3[>X,I1+;s>yQƝI DzK"=+'EŪV"L/]MܾXJW `Av_]u3RNC^EQY>|70^}tCSX#RYmȿwvUʹՑܾ{ɛ"(B]^@#8g kN"zs5QBDX pBG4GD=ir\`=`mRT@#1z[X`'$y 墁J ]_ $EX:kP x Z݄2ؓyĞ^PBz$=ۨNIL5*HQ韞[M#^&*)LʌD dpJ@6o8p랸E0{aVi_r.ͥ#zLAۼjRy Aپ[|SSQ~0&UWo풪1NOAL=IH1pJfhii\vp<=9T>h J4>ŵ(LILA}4 |ã)NJ7A=RR\r|9@*XzjF d3'Y mwŒ/-}dE@5Ld }cVRc;)4xmxHƩܾܜ{hQJ sB=jɁPSTL E+}! ِ#$x擳lӽKmĭ %Vz4pS2ٚBR\_~TB=\ԝ0KI ;aG՟GB3xc6/\GlluW)Ed{@IDATOiMXK8RI l-TdvYS2sޫ=MM6HrɇdpSQAm JdKIk RTCSbn!jio}fe.k +BIJ/|Ig|m?1|E)ՙHݱ)tWE)>h酀YJp{Y6׾J_  n4 1y?n]ܠ%=CѓWl_2ӗ,,tbShOW=(cTf RRu<~]:cv}0T?ʲ3\@J7Lp@Y]/\OLL[w_ :S(ۗUV@+WgM˻f/(*zj^RRT\_= * xD7V ^) p\_BP9QB̗/'J&¸1TI.yr8hJbz8ES4_x~s5ƧxMK5.!fOI!`7%?ܴUgr{9v3 (e4]#b(cYPӋg<P3뭠 D+g?tWnD._~ݾr{,O KJzRf΀#.8<>pfbn`r؝dK5vXukpc 8^+}W^vJOaҊm9{rtJ ::,Y<8ok]F7bpO@yqI`lQ0k[BBA1i \Bzp*K,YomEjb6B9s2=7vԯVGh@}mk!A$k0k3.^q7i&¬iMYS)6eƚBRjb"|ZoLX,~<@ U^Ye?4'$a+ެ%aے:qdzEI` _aǎXa)RQG %%bo31] A E$|\"P?^YYw?x5ռaA0 Bsڻ~d:,)@v ֚59_`c()Xe.2-!rR4a}=,'w|CB߈g?uuP9iKƥM LEk;6d\[S\<%. sPR2Ϗxi6R1\N/:C2yZeΎAR/ZΨTP~[ǽ􍫍x擳rO5?&qUqPEm+HEħl()蹢!{*lkcC+41@Y4 {|Y*(+Xg-.,]NO@ ⋿xYBd $`}j#EsŽu()4ˠŽ)62>e&8)JJě ; EK31@m +."g]Yޫ^ͥwκP3lRL]x{kMw[.#Bh5~ydp*bS[9}Ŧf;, $ L= /YlRZ[...e>Eqao灂݁lA P.Pw,6KxɳL N `a{eݪT.{fC=MFf)))#^Jf^tTMxյKRPADơ0qΓhQ–^3iC/<TEXSH͔bNJ'҉ f2HC`"&XM.G<3=DK|2"e 8Pq#\וIk\ _^ꥐj](#1{")}쾋L}{0f,?e 2' +]TPO$p{ Rb_dBۻ+It>yNreE4]7(А:b~^x\"YOIm%ev>C2v>~m5NC~ӛ*dj{H"LӇ>`pXβg7kcLhE叞n ȖSQ͇y@/~oaĥ0MS %o._w)[s8VR߿sɪ0Kƚ^+͛XTHPP;-r͵Wʯu>zmR $@[}ܩqͺ2|EO4tZ9OiJʼ=(M3[qQ<3>Qu Y=2toW׼ƚ_]5}8p]K<_RHy%~,w'+\~{ICL}㸱) t>Ӕ@뫓N% Knת@007iH)i/1.IkJq5љ@}trSZkH[* ʂzU Q+fk ߄Ѓ4QJrܽh#wͽYvvԓ#DY_zUR˝MVO,w>w6}y"O9gRIܘ6;ܣ˗Z)Wlg[I_y EE53)=T}}]|mmB$xfb#,7D= c,ì>|OG{\Q bM#bRzi FV &I@z5%&+C#xēnQQSsD%R>|y5S*][kMz$D6Y7j/@A1k mIeG\#_#@dE!sƥ~bW)Qzф^G _^sfaz;R~Y(},GMeF4P=8͚i^dI@"Yi1y׽c=5rGQ[N֔}_5sM=L'#p8~W/ZhGsx-H貦HsYIGl2_|YVWtxMg0獀T"S CA:RNs~Y}OcRo{jх>m+E2)&wj5h =A<%;JGx;[l}myUgnD2KJ1\j~E>g~̅WE?f O~R;?5>pRcEH+J۹BŠb1 kP\Hu۾)}||~?ﱢ_hq@tm$ը mŋɴL1OIyW"7isKիUb1UV"7AB&?[k )mߚTľGAL1n:wVO$ "T/RNjw:)Ojh8I5żJ}QP4JF%_RſrMc1Jy?` CIxaK|U(6%Ǚywbm6li.V,Q:ؖbsv2o1Z'O`ˊbC8JC\՗m4._YR,I)?iTR,WF}K@mPy'n tJͪ((%[OR< ׳x<^d-5a&ƎB\3c?(( A'x^838%QM w]ӧĵ][n $*ؘG)Fd)`SR(.Eg'`'Ȯ(TN*~dNf /^I i;=yW#ΝwLR N4ݨfCft4ﰍ&OhYKLT:$w{W㷋[Q3%-!aݦegGmrSY]^>$-1N)['RL%E;7J CrY/b筋XQ$ť{W{%}/tL'*־ڈ}~]tƥDSl)ۄ-E_ʈ&v( E{Ԭ{G]gih"~YLt;ۜ\q߮N]4u{Ww*B\c?)ZG}-\tCE'Ny)DƝ(?HQ% =CDsq$+2ձgԒ j5#2Wiu"D`Iu|Q.w f#@q'%j_׮_Ep4kaCh^Ne.MŨPbi$ 6 o"V>ӼLEft^;Ln%/@74:asR!(X,*c#iae.,KŝUedAIQiI5 -O2^Mqּ]L)9+AV9( ҕ/X9"li%sEߦۍ8 ^4Ғ"Ywx'՚fKJ)}`C4cY2I%rFkwN*(+XRpR)CK]^k,o+\dX+[پ1̦ 3zM]̪Ԫ5Ȍ2J65eDޤwUNnp˲8˾Aտ^Zyӷԙ9˷8uE4A$k,[\&d+ [F.F@8qJ>.Q{mI"eb<7M i֔4zusWzYpƎrY%p@ \YI!{qXcn%u\q)KV^B'>ӪY;Oo\}ťAWp@{md Tu>rf"'ITRvI5%Ra;.%h8>e/ǧ\4/gB$w{~؆}dǪFy؇8\D5އBd&~^ҳt)Cݔ^:4/ʨYRg\ƥp6wp־QK%EW=)_0k_cv !ef r{Ξ?+WIГⷧs~":=]_Wg^sztr19{N987w,xIbĎᝈZY'^7PkB?ܐʠcqc.f?ulǬk3^4ƥڻ^αlN 3ȴ׫CQWvv lUs]ڍZVCm*4}#UdBkcL4/#/3aIGʼn1;7v*9 WƟP11wK &nucbS7,qȢ8#PcsV_{yK총 ^")K`*)aIqQ {ҩ﷾ǣtnI-:6eJ(IZf)f.Ğ职QRN̺oX|"Eܸگ|OmOoP.lơ~Q:8w [}ÛWvBL|ߐ jraW3VIUXR :t;KG%$m=Գ: ci]n3RJ'%ǵf[4k=4ihO:+3%X4F7Ѳ0ulg?Ț#6C=?㣭~շX?.Idgb6qԒX%EI^{u%.sP,v#W2X{"('㓃klt=ʼn4xjzGg0U&VRhliMQjfֿXWݔ^}Ͻ"@X/rj¤8A X!ߘggt)SfЕ᫺p9=tZk|e%V)=xPN:$*޿#S Ŧ"R+U'PI_)LaͬYΊw^[/:GfsW_O ܶۑR>ć)3=No}Gn&Zp %Xݨ2mzM.{QvI z>䷿_}tz~O$g>YNCJTI Z@ư9wVsݾ/wʷ?v}Vw%@ ڋNviRTXK{歹wߨD5?Hn}ZX`o@Ekًõ+=tM8r7g%_XƂ&#/0?"di /NԔ7?V "zj>uM׻Τ4Dn (n\u~-2B,(?n+'7ng@8rwW\ pP*X*h=W (=zO7M5šҼmf(źeq\R%U;bAIF3q|XM,D~BnbSWwx#G8OKzbRU6qD2v]_ d/?ӏj W=ť\}]x)eOpO},Y"~+~sbk xf9Ԡ2WxaBZU+O|47Wv_=:(%Pc+rGZ7LT=NJJJ̗..rO=O;V e8NXvS[oQ('Y/qRNV5C*)/SntGo|[o(~t'{_YzIKb)&?X6,\| ? **UT{&W0v\/LN8Xw@|3%×rsq[cV{;>HGs]N}5{J`sRV:aXODG: WI:_Xd7 ^JGHkIGX).7Se4 `Yb#=fRP;ì> gaА--6U$t ,K3x bT.Քۺu : cKqlƜT/õ+9Z%xr[_+@RUⵣ<ؑ.AQKFʡl@Y+ߒ-i k{=M?((;%OKE6|*CJm4hל{8\0ۗ&2#,e|"(FWuHI|^-Tq)B8ti2өƝdkx ׎ 7ԯ7ُyH|Ԧ5RR~EWU{yJ:{naGQM/-*ܟ/ Ok{HQ7v0_0 .EE.O bl~ &87aFKKx m^-PDtƤ7`c?x5iܔޒAfmp $@.]O*%E%5]ektͪRcL"o|_Afj^nKQ9- :DC`dŜTZ svxx { iFӋ+:2Ǘ׬-,W47 0 kEѯ Gl??ƛ\#Z\To rS+*<y=?~3ZGQYsD R!N`S 1˷Q}i5X>=ܪ5_I)LO&ih|[AUotkZ/IK7s$z*&P[^go`sTsEĎ˗7E_O8s *RY~L.@8GjP)jHXQ< ez$)nAI 1+)L65UӸ1PLk嫾_>jaO=4h6[_Ze._e7s{HL$E%q16:QAY:WYtHJ8nPuإAa &teZt^9U|uʕ#?9bPZP8c;uqNWebiUy/^twNHK׮rjM 3!0ks&VR!non70M|ud Z^7b+(&Z0cЀHYstdWRhV~}fU!KRAZ,d.V6Lj?{oYgmV"%! iJH@ K`.](` ^ӆBh$%8  I(,8lْ%ْeF<r9[o4sH4{yw>$)ٻ7"'wBofg{+;cٗܗ[KViWA֦(#p0qzgSDz{V2mkG\DL$8(=@Ұ ꖥ7vYɩ~ge  =Bw3I쟐L:yCEDb6%sx[O{?.>s\^!'\sbhR֢a"fiaE'tt74 ?5H"@Il4$Ґ!!";dIKMvN-w$hW!:MTBAO}jHX7p; dgކ!g#ga:]/>څHy6*Oole>D0b QHob2 ,[lJec '9hrs5^ d%a-ie^=6%IPCJ JĄ^LcaD5%undFq'`r5m;dCq\Yr8JSHzfUHp٦iFDŽ %30z50Py re3tz2ՑPIhD&š9XkD]i\/mz JG$HHPdǙBIp/=:Z:!nHJ50|NN'( &{;}\۷[{*lukQ2D-)i@>Yѿ2aHX|#UO9RfD?,@0Кwvȴo@EU) $HI‰J.d5C9r /e=P0vP[9"̰q499h2KV̼'GJyS$hu4+ΜE1!3Ž0䑺TWr5a.9.p'IzeN;N( %:s6)}=j\ɜ_. 9!6Jl . +b{-+oj)WC}sQ_\c%/4ڝ랓Iz6=GXH;p2)^lbBXf\!P,8R|ShE}R Qe]G, m(bE}T,ªYbSiVs؇J+W¨]';az'㪶-*94+UMQ8ym8rs=9o`[RHt8?Tᛴ理|X=(d2 SPgcR:yXTtVBvFIvuI,E?X MX@Y( ".5 pN0\BMs9gWssEVKHR>[6㻩MKVѾ& ϲ3"?eF.EC( ˖C5Fr誻eP @w뉔TGZ5,HME#vVy,jap1cl0H)iNRmPJ֚"&4E"%c'@d<gڑhluxꎩo(_âL{=p$tpLL MH9@mI`8o_M>}}׆D?SPd:jҌ$ -(y `@!.pI,(NGTi8(TBr`hb\8 21As.2"BB&4=^?Y+ d.@Ae Gm-RYMD%6IvՇ-)T Vf m$&IC\fcpB IbH񓸛c d#& bHcWty}jpҗ8݃_Da/k죡v9:ϛMRht1$*TτtZ 'MAވ;]K)FI |L)6o|MB|e(U1-jeBb&JÉ bXA.?!y/+"*F!l Gi>dlm|9y+d/??!)mF@f_K&F `txbBP A!bDknv@oT>L |kc#54?'*je<@iشnryFא%b|[XJFB\"`E(b1>vݜКQbhRF:ɷ+O8g+{%q{ZXxh傲"XE!$Dӱ+.jXK\8%@g4xT%^ d寽 |ntfV:m??`lp1a@ûLgOړc2G n2gc'pPkV, R?ԆBBFS.#G$H&lI%mpy6+bS$qzMmWs*,q[  ELf ϙb6&0>_E=+'|{ #z~͋9Sw='0E\7"*Ӳfyxb+"{ڢry6GW-YBY"aTȘ\R )ᒋޥ< G)dAԹj/a/UQ/ [Ꮲuzd9񖈬bJL/EJDg3M9W:L0u9l7E3$׀!t'M z/weќgc0=|`Ioj/3+ܡm!j4AR*O]n)^#`+ry)$V$ڴBC4 `**gE_ڹ6zMJ*j1*Ug7sz@͚ t' K!_?RROG<~M%v?蟛s33#PW*r]0|a8"/pj~w$ |Ri޶O5)&d JȤNt]YJ8-!wtgDBd.E}Ͳs|$иf#6"Hh^G 92]`b>|y][(Ci"$mIN]D(%y:sa$4Mh Flkjh1З M !)wE[Ŧ$ukΣ ")_ k,:X S&o%A!QI3iSNx;/#_ԈQ(Eh6A#Ѣ,Pn3FfV'qt'$%{wd Eʯƾ /IL1BRShpT& mljGXeReR2.MMC;6 @V J$)*D(b4g85182 T$&+S'ƖmZI1۰9\wڑtpyP63Ck `ť7p3$f7_~zdSiD3L9Reڒei{YJ-Mp̪[kZsjrSR kQ,?mҙ.hl?kB.#@ ǐ7e"邕Z3#[n]3x/s44Hdͧ 3|ON^[IJ>Il _ϋ@Lo9]-5L;7:z12/65H՞#*EYX7-02~t(jsͼ(q&%I%1rtZiftWFuwbR(DNV0UӇ@vBYiOjV'',hN t/>WlC8yVjS>*M3lXQ$bYV ijyQsp8A\(")YޒPs-s`TL-9QĘ9=ft8*Pj<Hr.G\##wl<^cĜ5F_l&bȌQi*Nb5gJ2&udj%j+`¨dNФbE 4zӥ{]ee~,aD4Yޡ$W*25=2ؐФfw5)E1zȡ>($LDj):I16IjRtQ|U;'c':ԢeXV(__Q|"wf e$z0CW^6Z(""rr]}1WzʕsiW9#8Z е'e￯ ˂ݵ=J'mpKy-')L&, ;FQ6kO c.0cdܼ,dEhHa1R^'/ioE@jav1K֢֎H0N7&Ũ3Ճ7+؜l>e&D(o+sqsʜ(btP~~kfݩN -95=ny_GE!,PJ!E_YiS,V,N0b$%M87k ;#D.'W:χ8_iG ip/Q>Li؈sՇ[RL73xK&+P$S,T*qM2rL|OR@l!T0>,Ȅ%a%x̥M+iFMr͚HɅ$# )Z4\M3Wa W{k{XIm؎'=:+_/+2N[jgoh^h̬U$.36ڜ4[֐xHj24d7iI u#/K wPB_֦p N4ZJHv9ϑ sŤm- %v|uo7\qTO -T`%kN3CɚނS-_JeL#m?(F8p01GPTZW.BV~ _ee9L\PqaqS$!>iS1%Ò摻r|\)L~=cTS'>USatj(AQ{)ZHZhEPa蘕P[_X7q6z90C3|(_ab U&%-C95,Y뙛_ >ʦa̵,%"GB?k"kQ4eDg(jVGP1)*2܁43r7''[zd|8'۬T7TAu}?jF 1qt7+S2 zZ(^K^8qRu#v+47J䍪SPZP!a0fXS,3<%kJ8GVy9+"G$ e!4wџ;+01?DL׶b%itIsQy㓵Lޚy/NAL4W2OCx&10>~휲.z4iRLamʁyD}yo[P=9s106nv0GZ/Ҩ :kz#@nɊ\P@3$2&- x!G-9Q{L$0":i*Kvspcykq#`E.Uxj <ܧM;7k4JǯLj\ðU9 1SyyQtծ\*TXS}PaBoǯ}{K6E1 }BY6KZd,+5eCKN)yr~NRl^Hۼf{E~'/y`&_@;ZCd+"N=y~)AL̷Dns%=ʭ&Vn~Ω~|`Dh&j( ,vODE~l\[>Z,Y賂f`¬WFrͦ I g)|OSNHhZ<)j9}$8R(;!bRXx1⼬A(fWmtGH=J73̗KZƛ1|,#ҤUYv)~E|ARLEH>1rЇr|KV"yrL-YQF0gF~.pҢ6' 95' eGr ' 0:[Hly̍siw CclCA?l-Zzet 06kIU*t?5"$̴*_RJNNJ[ XQCOǼyyiȉ"dB9 ]BRY5ϋr4#`9!^^y+$ffլF m5ԋZӪI)$ =?E"ј Dh .m\:Xf kUE)T5ԨKdelz=dEw^ w~-LDΉ( *Kcp:\7A⡇s(YdV=PXy36I:䠋4v ֟jF@]YБiaU!fH8UQm\BѼ"S*{79T] U.@#BT YQziFY31׎x 3sSͼ1 C ^en?Z/giہXUcE=ŧ#+u!03d6D.'2ЪPP䯫oT*lY!+ !3~=Lix X:B(i|vHNeM<;|0G!-')s!GV#'/NwRd9oL9a1bJJ$$c G:OifGwy_$_^YU>W" N}Nr' +t(֭(FFXY~ &fg 0>Rb^RU5bhΗ\#,*4ʂNPzf:琟eLL\6 WR(d?yeN`̲x/H{+[㈱0$Ez- I{H270 d|FsBQ;1Gыz0Qt;+=jԳ∏ۘ 0+ _ѪP^!3VE?./؇2jD p$T $Fs5ШiGGZ򝘗LL֬XFoIyZeKI ~+qטP$'S-G)hea^ɔCIrs{`2NGn*r|Lp*+a,a 51 kJ&Y! 5NԼwv9'J@]kхf^wR(yeo-5[bC;GfdEYММȤkh*~XќAz30ߗƚ儜e+_VZ\LF G!ʐF&2A팴8SC#dE!NHd S 5+z띃z9 9棏O.x6=W^SNH?.as:M!@0 2³^+ހ!LDN_lIcSь-b}#L. Yr䃴PVB&_{]w־M [FRO`^d9~Ϧn9V!`59!'ɉ6)g+uCiOaEI7̗IRZXT+ưO)hBR:hJ05ą^lٽdeRW&Z8CsE~.D`RDZ0KESNy),wfae|QMϻtXFR˻S[YSK@֢g'1y֊_vvDRb25J$=+LjXsa"Fc^XZFݖ𷾀3 J68#,DX09VKõC*k.FѼXvhFZJB)0 *":@`bI!4$Qj`62R**KNb!.BjrD"h\~7ch^kOe.:C3n2@#ᓵQKVODHXXYՓ򙜽xY#'mtQN-4>ɷ5]ZƲ(wU6b'1BjrBts.5 K8Ź? 1CBù|գ:?jNkQɡj2(yA +aUX&`e/!"ǁHI"}2D%ۼgAl6u2ٷIQ؊ڔ=VIUHN?":mNa#s(x(E'gTǢEYPoK H}P[\܀X)&F3?_} u,|x#{}щ,8=,[-a74ʖGP*Dڔݏo[yTEbW KAL"X(<:fOߔq iO$'^'eŸ5KR( ,Jm)Pˣ^UepUд8o[8q]A<^ p" 쳲t TUQ)d>vuPzvߒveN8{fIٮξCbÐ֔0BG\ޗBRmK@Lb"AW.p@(íNbrakV'`T*5rBN%#hQIG(Wh0 Iv)|5"Ԥ%-]@Pw,MXh:9>)WNG_ jH /5B7&`&Kv*#BU="4zQ{DW*u>jg1_4@ ׊vd_m$TVDfٗY )Maei:n '1f!o~VGRfDNzV8{rdдd&kDbl#z'ʖwhUt"$C]rfd)z5Y4l돭\2R.9,q1 h͟"F"5W4%ŧ%DRqhL+f_۝be$4<6> D-)mOnm O$r\'ڑ=1;G9Lh u|p;~.p?["Hp;Ӽ(lKK 9|s{EMߚʐ;5qQa7|pi^:BJ?Db2{nj,WҴ"-)LYdey6I1/m/\ϤQ) @[G2Jv$/@@j2Ҹ O]2" :ъ'(ZAX~4yBBulOќpz:t`; ҦdkFwti\H~/"0NMf*z$$6uI4&ޒIp7"`Qi$,BS$i\cLiZih[|kR'v^ ]6**xr"~I$&xSn3nppn2#%OFRq |dU!8> IJuC%|K{Мpz|-gVSLźB1xs1,fLYVɜ(IU5xĀd&)p浵-&ޥ;KۮIQ` @- h( '}yZ}AsutH&]?''>kДA[w2Pr4B}]i>a+:,-sZ- P uttȍ655e}MH iX:N#id}OG<**Jzrg_ T^,m.5MYQd3Y 52aԷ#'8J8FB f_싐pxDBdId|p99);jQACBJxT#zQ(-S_ #qw}QĶh 7R}OOl۶ }ymll6޼N}j ~sQ_M\O}J({}&+d&o~4A`d\=90,q ƹj$$&ur=X `hM$ck/R첱3-0f:+Ve˵ʩw'1nժS=֨Hg;v쀭[B8?Ɇ `׮]PWWWtb5a C q^> N*Z7_rF%+h&\JAhm<8B"IXlGɇ׹,69@b֚(sr QHHJ ]ww5gDh F3˗MBH3y랐Ay{F m\`t --- ,7nr^dR9LkzoOyNV WI 9Yɻ޻ыQ73rI?gŜT¤1hX>@õ1*#CJ.1eX189)<|&DNЕ''و;A|ra@JJN1Y591d [Ŀe;&blILP=\Ml޼|RepraEajwgǫ0rɴGۮ;Es{IͦEʜdzgNUy o\9 ^l۷oW]Ψ.Z iW&t-վ+5u}SP+EQ%aOA8 R .NbAo}L$GVl>;<{" kV!Afՠ|]>)?xUf@ {TE{}üEH^Q4$FC+6MWQ=ءSJ(p&4m,˼1;cQ8q"g|uLAw[O_/PHdmw3a?䀯V]"'12pjS݋sbf_Fo %W[ YYR? u!XRUQXt|cƆ!65 "89 ]ъ|gguSw~I6]j-Q?wjNs,HԤ*Oʝwީ)<|{8YmH߼aK(p]LVţ$" ԀMJ* B*;7 ٜ)A5"g0Խt4I M[yQHaI&f_ԡ[uC<DHGk8Y'z(<:"{IBf泠 ==5s,)biTLҐ$E''Y\ ;T,86Fѧ4,,Lt`NbX.\ڔV9NRLZ f_}oO"Qy"S](ESS\7 :3 !͆BA0''S]1XSo$w* % ?-Ϗá5E|kУUն}3 B&E!+*JG")2Jr?ױNcerY/W٦^y;ftc\I5e ayyȠpE9S8I1De6EdE_VG?{|ϕF?RIJdĠӿSdx`Rқ7@k t4(ڕOeBs"PMtl 02(kB-Ws}|yFO |'?-XjOJב}ЫiU>Ԝ60Je0<>h'(89 %ya0'p*?޼(TWsT/ hJԃ5Zڧ:kAܞUEaXː<Ǧ?&ߕͱ2y -^aтR D!!1]µܬfn)I+Devs'ȑ?}N!{k/?po19_V&6 O-׎Mbil;kLEq`p3> ]W`Z &Kd|WUN1ܑ$ -v LÈ\x[jl0EbvnkHL5/) T$XYH1˙IE1HT: ,3ۑ? nʅhfWBe`D}f &OD=;؊?Z@E^,a2a2UM /Z}=&ߪ7$:-;spGnșcjXjQ:&1Ҽq=:r9$~Ԧlu.bFI6tFR{e?xhk6!? LLN%2+a?RnMp3/[(O30,OUA,oly YBL NeE۲JRt E K)Y8MqT>7lHM$1 $ed}op"򇭫L3+!0j[1f^`qfeFyeZ/{vޮj> Gê Iro'[RM$n8EbtD^ !7B G{i9b0p?^X U2ҳGM;B\혪i7WC2}LuH^>"y *egyf^ƋzߞQIQ8d-%ߔ$aݣ[(Yܧ(Hçsë}CHZ+?{=[DodɆ@@UT#HجOZDFFwt9ê9P4Bde  qι u;lxDg|bvQ |-;gΌd1 N; cq'<ȣiX[DfHs\r _pIOUZ>GbĀ'rpc;$z}Qį{o;'2/",^U/h'd'$#0||t5LQN;X?/θauF|3ꖶ-nmNs;:֝HPN!QJkp~}zĪLGB-J(&: a|=_\# /Y_ǿqytq 6㕐4c+5/r0QɜFfakuUuPU5-,2=/Ҙta BP2:[(%CJ=*Z EI%//Ԣ(+n/1iZJ+U0O~qp֥aDk422{aifȭker {?ZkvY ͋ _e#ߐ0-`~5WN[;If}ppMENJY 8qBc Ic6 GzmLMpRh')Zc\?L[X5 29.}|`J_~~(>v/no[\kh230éq AAM#ݦQyZZ^;cc||n*# DD^LA/P㒀X50*s: h6uAmSWkHTv`ͺ*ĉYPȴ닏\$G)Yx~(0pf'AaBS=O$鮛ۃݶz7ȋw`<ͅ, @S/OD/ᇽ]|6#wH+S 1ɶrFB|Wt&o)_iX A%ѣe9hHbLe$*Lmiן$(8>>x5+fe"3X3; ʅͫ复F HNFע6x1kԁ pCu>$h Ϳ bp,E]= =~f^fMU۩$D0jWȜ%8~V+[L$uhrARCzVC*eB&^_|ʂNFp& @Z|k'AaKIP(eUNTE^gy'u$QY_v L~"brכݞ$(')ʇW|if&4c י`J_`ewn#Qi^;VlTM_PN,ܭPGVI;sGܟ =W&(u|ְ<_3Ǥ8^3r'n2 iPvD,xv2ґl2,+YwM\__XקvtN6\ :N5 MB\2&\cJ,h=W?nIV Bak7ҨS}YF:<X\%RX>$(4;w|U᩾^ ͤm|xۉʃlf(Iroo:Rz X4_HRTzRAؗ"1]2sw5O'zs$U{Y2>,BVqjMףOjɇҼ :r{pe?$*xeJIK [)HTb!$ZF?g ):r&ѳTmvFU"(ͼLPDbDTn%*/&FK,ݏ.L8"LO "$hL&&FʬOף)S/oؑ3o߯Z ?<{Z6E)gQ!1S虞1xli!`oܔ_ykW'P.W&IyaHTpK)E ,aSV)NPT, cɾL* 1o4/Ԯ|'=Ԡ+n<ăy)zEh pZwgaq<{G UCkpM`#6$*TQ!J%EQd*z\tF\߸UM9>'(ƗD12Pb6KB~({W ‡sҨlï;:V483?19TVRCZH%7 ӈ$%(4E7ЌjP<v瓔,PWG+ii,O[!J&i74?˜ VC-"{,e9f4b希Հ ]-熘C?'(ĉJf0{ײ]dI ͝?z^X* keԋJ4AQnZȤ+V/wK󣣪Qp۶m2!AyC[[B{.я^ȵpgE\?mHe?w؁}rb 0tu5ANN~ҒdVX;y.[?\s9l\ *Ey/@9 ;UNR6 Ff&QYsLƄ k.6U}MןaBI '(WG 1L3`MP~Y #+2S5_B4_#% }ԪAy Wў<ϽZOYF0 a}/Q<g )t߿W9S}v "RHP-/Fo<~{;cyl m1ut1F3g&G vnH#~b,O>_a?n9ii fì&pyݟmb+W*K=Y%ldֵG[ ,p=+&TiW+|"4T~a|U.\h< >9jޖ{sKk0S+"IL Rw7t 5~c_ʼt"*Lߵ\*AGg:<1 σe4jEcQi."HpMJWyy["YdU|`|Ͱ t1ك34' }I9EkOdJs$:Y6wvv_nݪ|!!&'H} Ʀ<љn4:Lj4f6K3~_?pRRBf ?xHJC01/UJrLeWfMPf&a5(&(i:뷣T+lfwQ <%(dE5*A_rٮ WK}8n8s7!sӄ6YKiOJh}UwL3\zoOjjK( `˰D B\#b(_7&}<8Pt-s#1ubX0pj(:YjAWy:> ?'o7懩L‚(^]=rgˮO^>LԆDZhWH{Œw5$9]qj׾*uS_o._&Ԁ3R;|(g%+k}HRąލ˗x||oꬍJ tx|s[d#0Ù&JT@n#BSQ%}u2Jt[G/l^m:AM (l(EP$0r؄("XIZ!r cG= EjwqC]WXvr9*O$='LPc0O`{!ߣ|)f ' EEBy>W~f(+e͵60԰:W3 u,XG IYz9NK^b0 O41.2RylEvFlh}Pnŵx [ȫl@j2!\ֲб`=!x9C,Ƨ2ǘ&DDՏI҄s$41 zW@&^B.W_??s ж6*y;qACPb~z  5R+dž~+>J ؏8-GBJnr$N2z;'=zY#x釱֭A}O&Gͅ-V$i1yxdyp aj 2By6>0)!w;5$ZpC:wHGsV!.Ҙ(ByN,[nP_0>z Y!B,ķe6τ4*f82ٶV MOો~lכ_6)JIVJN3Et!2Us89> :e}:QOufu2kZHPnnncډݍuK4;#P.$L%JB B3%+݋|9IPԮ\R6lKAy%) f3X/͑I?寶*KIWLYB9@,NҦ<5 ܜ"UhZ7ұ U~%`tm?^,iJ :ȣIT]6O}ǥm~3y"*E{ VM ?o~R &|)S]ve'D(IQQʁ޺$=R:rF҂S ^c*=|щ)7~{#g/ɾ=*5X2LJã;E{BR/noeBK#QDT#xr1tDeWzеm VoՕEgL1x_6LVzO@X(o|گ!4^')Y #AҌv9Q!?}4qjIbg1$t_~VSNm: 0X(C~mY]KfF;6ZnSƅ#"șaKS&z5>"S߃&V&fdկYy7YCP.Y,`՞$m+qHTJk8pD (w q.U0x32g}LOWGF jURGŷ TgL5;1ٮUпd/LX[$sI Fu`#[$4iʝ`L .^Fp~-m<)~5PB' PWm1M#'m'!ԠE*Tbؠ3<m)910-נL4)f5,CpWo|oͳ"ldޏjT(Ly:G Zq$1%Tj_kFLW,7MͶeGߓ'x.rO3ALp6 iO~%̝N9TA]e`S{fp9 k ߵAULv~͵@<|O>('gGŚHD@xe8 qΦ)ͽܻvFnf/Бob8Q? nʅЀL!3G"w 96JȴwalH{b9Sy'behD KvivSJY;~؁@$mp*xY &+!BҊ [pkU9brGvcfgޯFRmPY`}|!WL}Q8IQ(ӝ)n[m)Nvٴ(L LJlxgY1w\ w)u䑽r¯ypK l+^ֹh<PîF8|U]/H_B#]µ')ͼWlzB9Ua*ڻf|P(3Y `j$ENE]`x'\h 8ӄIԃ9nD@πoϫMp٢S!y"*;."w4adkB(`UyYNfx9P&} z62bG~B  4F,PB2G1kLQ %A5EykEڪĀ淎&si 'uF"rX#s؇O5v&%7z9*pd8rYԬ.4z'mó?8~쑓cFTci6+w-5/9ȿxJ&rWQ)V a&t"w[ w͟yXIXA 9^$&]rH eq(c$E-E4ޒwZ$;kix&~*;+E#J-BÃc?ͺt|$HN6^ړVSM*?9O?+yJ 'ww'gV(ܟEPK9?6OUеA?+"QZU d%fz+̿(r0'͊S۹>sbS3võ};P.2bzf@: _靹NRܶb|H%?||^^ WH0egtMךH%X˙şg1G1W')^[QF5ځͭgdf8MX<':1v"9!v|dU:gZx*T whUJyRZ풘+y\ {yy^kEnא\$Lټfvaz')x"aHb&>.;v0C=E6#Y!E ݢ0p㪒4#_/d,nRLѺ|ic`"pdHPBY)G#a伧er';&/gD/t|U]6V'Q69rJ&UoR5)D؅/ӿQ(Ͽ}B͘N?ps.M'(l VXȸC· BD |#=F^i@[u5S",aY?0pH^-05&Ah4M9+ $PnCr UZo6ԋK66T|a0ܟ;+ߟ+o7NPDx" Y!|U!_= XTՕ'-dUQ%@t2!>cM"K۵kpb"w@NhJAP8(<׈PkRI0-DXk#ߊ!0COzY7`_ 55(m\}lDyQԪ`{'pP&+eVVC95!p% nq?5 )ad%V@Prm"'{6$'=4.$E#`իxS+1W,7k~hIV阈XE+i}`Uވde~/*<$E;f,Z25i{6^`!vl˲dKJl+-r$ͳ-9yN}/ܦk4L5k">g5$M&1eI/dZXfs  037;w9? 09(yI<,FT)!DH{O$D !I;BiH$ aE˙tb)Z-1 53J@EYqv٫k"ԸQ]tWXZbuQǐ\{+a}-HP`6+d`$eӪh7KghV̚cj;iKjMh&#9\9 rj5>.\F.vp fBi>\2d!SEܕʹ,FRAIBJ3VVeSE*hV dUR^ ӂk1nd$WsE"ܗ0?C Q'Zbdzf\؊hȩsUdrrJ=Ǿϖrf_0Rw5kBBU%#+f!<?8<q@C:i$7پ{DN5F OadX"G /p_Ef)QR uuFD]I(=1;lLHbK"+8 >r~1Ą".oB>'e.1;އ|gN\iE+[~.80ajSvu9U18ƴ}HLFuR.QxԶ~cH^Hqȇ  A>#EJUrk Қ1پk\e%Ot9颜HY)p1Y&+j5kV·p~"֩0r 0 $+-8"iVL3W@d+Ǟ핫@\3oYyr."'&t"0r"#a֞^0."&YwT7t;Ac,]+g|p1;X؆ psVʡ(+gͷҔ$Cp}̬+OIL6TjL` L'+d >/bbHf >i"kK0<6d\&J!RBۻUlF)k|GX:"d kTzo{c~6f(op8"C!+|sI'''R5)fkedE Z0욓[i;Ҷ/~r_3 6rė )!@ji!q0 =?vUYA0blXȗ6l]]cZ쇟; / xJJ-"3G%B;MŋB :3isbtM ߷_}BZwWeBį}m;;-k˲ͧCGkj M+%T[( +pwnY̼9n|FR`CJ3ފ[^ ۏCn߄) Kˡ (F)`BdYA(q`Fd 1!x摳7#;qkKx~,ۼ*Ց/W3lUo#c~t|ϙS=~;vl~ԢT3EF HV6 {p˛X<%TCyE)ءl"!!$f`$6'"11\:M$Y> uMNp9K{Ԧ@o 1Zfw߼}~ vd^$Vx1J}ðU %Pնq_Rp6ZLM0>D >+qVҮq&^VO!D~c~C8N>HPScSpWS{̡roMu0sb;&Zە|"y)= ڐ6.[')/["7]i%,,\k#+q.N`dS5c9 q %yJRz G!osC˖̟:wFZFVA؁nNVA8ZEڗm|DÍ a'F#Ѓ^MFOOF@nr;V sY[TF[ =@l-F嵎3q95@UhD DH-Au(ʻ_mZA>-#Sl|T>5W=m-4+ + pاM, M)xzѓFP}hQIюgDV6Y'}A$,g"IYvEbr %JD6:u}&j̼:aCEx>1Y]ΊxNQ6)jP4 5M,zXla!L6ȌdB],HVQ҅ i4 ){%@Ɂ',0Rjqfظ3;|엯NOi&*GENd;+Zj\H 9o'W(å sxbUN|>%. ʲpc5WYź#L0 /|، ؁d-s%ߔC9md"F-:$1Kz) וK8K7 5!'x"(JZnk[T]oGgL3اyǢ~52☦~M4&(h 09Br QnIKd?.Zqv Cg"1\hy2;]33#{[iEIZm7[pۅe id/$i[օȋd:Vb񄄈UMⱖׄL(J.moOWnX ePv͕/5 Gml]3ˣ5VO!pa/lB-f!&|̯DbR(d;!.43]H`r ƆE"g%. J`^yMl$HVp|",{pvR]d EM>^37V^R5!myם77϶|"~um,3<4Ym(aa[ن߽nw9'^P#-="+Ǧ+ZR)$Y<-I `ve fܷmj%yHmZDe0Td2# /kesyO)H>D@no^:&S-{ݖPZZЮON(rr׺X^Pį #Gj4ʰ$k>DYaXL@՛Ǯ(Gb+yS;=PuԷL q_0q\`PXU"0gFt$a)޻cd?c1I rb4cxy44=ّEQiRqɱV&E tYm.V^cBiE73Rx$PLâQxmzAֿ```o]FɔA0ȓ7] >T}irA0V;II!i;o#J$-eCJn"%հc/QX\`^4hF\0pOڕf އװN\zr2|Йg5q޲f柢pxZ; ĄGh XGk3aQIt#+Y0n#(Y_7FRÒT$͸",m*edujKfZGIU4OAx+ۇb|\1 S: 4"pgɴmr@^8>Oaf+At!A԰TZ4mL˂@䣌NI&\Vі1~r' 1AFE.?%R.$Բ[$x#Gs%*mԒ]rz:92'W=y +hQDqGteXY0bl@If\Hs KvzUl#I Ɇop"W~ K̾0#)q`wHyJ~!߀l$Cx#}ʿ2&`Ur8|5>iK,ɽSLTbz8+XŇuiGG҄m3yM! 7AwYd\ԯT/FdaJa9#@;2yf6@6܁TaGW e,a36եu 3 !`1#0 1H = Yi13C I){7fyχOI<efkvn싃]m|;;7ދ~[}70+@H>x`VEhҞό VA%rS5vUљUGIwIR6bFI1CO4Mȹ̴H3BdD&&/P5؝vм^@/s h_ac4"mn @؋57D̻_9R&/H$EK\ڊ1#~0l$@JtE˃o]r;jv ꖻ V iC}y2b5')$3}Քe+݃C80@`?%KԈ٘"`&Q!\M?PdMQVM5eSpMJ!tOS~6bEõ>eBmV]Ur|UHpeӍi?l%ELg$S-bq> ّ<ڹ;E؁^ۋ~yZ(_yMѦ_Y;*T n^pe'dyE@'.M(4JKPh5(z+-LޫY(0rOjZZ5עsk\!br-C8T-3&_Jr2x<^8~a44=)ڗO_n;E{FIF?m?$_\l52&BC2DJj;;Z5|;+ن fRfe8jxI=Ԏ!6dD/IMI5^ uNհV!9?Tr-B +Mk w5M0B'ߙ0%;#|6A,UX850Lt ")f2X~сS)|؈ZV IjlŅEڄEӯ+/$"QAAMFڔRg9T{)JFwy2?@R̻T%h$-J/t9Y]8o.+VA9[N09t3^dt& =FOƏCV{ G!)7YQ4xp5*Z$~>+KWBuK+9KYIL,mz"'-g1{d"2xI-un?LR,Ӽh>ӤaWt3&&Zڱc3*D#ٻCwl/ ˮCg4u9nOKt~( nAO\7"NݶI`$E\ӘL8.s@W#BK{5mUa>֍=yHH252id]Bv‡K&Q&?=7ŢӦ0b'rqOvK>LÈ5Cu9Q,y0pŏڱu5>20b$ٍHJvYn9oG!'_ Z~d^"Ё0H( M!~K=)Eb%?lfSsȫo>rBAA-"FR~E _]HV4,faC/%iʯ4~jf@/_IP⻚"Mh??;/]g/0"==7uWe'29>ox 3%c(1ڭ}.K{ =]5FH!;6hvYiY:/p]հ|Si0azEFvkW˾Z>5tHf58#)YfNjB0$L]|Y3UX3bpt:6Jbbl+J8w6 L8CBҰ<7"7~xh*$Xc>CX+ k­~t6%䌤d]V ,vҴDJ@-&13=f7 3?15I}Iݎ6szAf a־σM+RIVnFcE}ʦvRe[6s+BDOJ2\PCP⇐9BǑPDj&bB$Z9r4achoO˗6;Йg5 ]FRrX& @>o^԰Ç%~A92|?Fš-1jOF^4'?.>UIԔ=#)iFR4eR/'e|Od26ǭrs]N!5!1$)8:%|) 1$?Jo>`w 5-pӽb:#yi]TZ Jq2FnG y$:Bj8#f,u/ 6hJˀt&IٚyMӠf|n),,Q”V5q<_%J&僠$݊W0[vUHAb:u-q 8Em5j p4Z+iQK뢨Y%٬'~ˈqfظs 3opOsN{w9~o0jy8,qmÖ3/Ek^=yM`D@ %TkK?rތ/ %wq&"DTEH`1 i/RlSWi_1tNWƍ&*nJ$-dG.i=H^ZsiPԠ]b)S 'zk7@^J<;5 C!OĒz?rWbvz?XOr_ܷ խpאsZII u/RD/QIBԎP.קtXQW2җ~ܱhof^8.|=>P԰J2r)EB۴td\F"݀宦}@Y“S0r]DZiW&UYJT6dT Ifdevմ٥@IDATIŴ`FR3FǗ0eB #Ҷ _~Ls <۳%[ ¤}jtu^ эǿ Dl%-J qcEIE9}bKD&+DTp^.9C="gaŘ{l+$ݑHD%2(*Mk$y[ ,!Y'u.pKN&԰lc=s8A59>5qf㜍W'ټH>w>3'Eq"oZ_b;v[=^Dd*dF2y0#&;ynڈ`)b|xyKkc k9 ); c9=e΄59 *+j.8?֌1_ѧ^wd@_5͇&-ءH iӾk@sd~bC!リX Kae9c($"iXHA\c(!iEDd*DDq,"?=B ئP}\ph금@)Ix4W0(UȽnkG7DƇ|钇W-(]H%; c[Aʪ*^g톥M+$`T|;P2HR6'jVjF]|> y4; $(DJf$R|YR!RR6GNlNOZοrF2/\nsL[>i2pC3ǖ*;y)$#Iz,3I9pdʟ4`i[8=tn$E x"Y͑]IlܧǠh7i0E-~z1?Uy`u6ѢSkC9e|lx |$=|au 7߷Cz;L_jJJRG D`$TRBR[mL#mJZ͖$A}? mS#^I,W)3$J?Tr<>yD,Rf}S4}\1a7 ٖG @$Bp7T(O%lklI1qlodE-IK6Yf`\]~E>Q[×RYr !QDE/4=Q԰$,7Oh$$eHā9M&7).9ۃ%y)HZk6waH2XZ E1]%OB+Sq kؤqȁC{1Xzl+ VQLTY Pģ\$-!gOqL$~cJ$ HEnF?t-7="U2 RL7_L<φTٗDtX1Wq!,+72.i :.%pD{ehx}ChO' TZbI'tu `TƒZKCS}liV_ɗzX# OC]W_%]eeHR CoIo +aôE`IHE9̐BQr!QԋL*S  l1GNVF"PIR\J6e,g!\}3G.3a昈űeͦp2ظ}V:=靂nz&|8{dYHc33Q1WXIF`uZIJQ|q8$#j k( "()ٗxL&\kΨԈ+eQ-cjK=M}ݩڰz`$<5Ԣ(FH$)6 pLWȏ"zpe=HqLL^?VPrdDT"gI2e+%_)Wj!,e_FC͛/G3/=#x- (m|Y7%IHvWM*] hۀQw|_=r^|Q1iZLVeiliLCVA)5~CEKT$"KgE/Kŀoypc%04OMžtM^jCo+hOԄLy`u *u+o^/PQV/+t)Rzjhk4kJ4yrIX߸a~{4wzaQy㯶mHbKJ( W+iIL'%F|ڍum|}B3_C- H6U|s*Lx+^?Ҝ E05 ɧJ*9 erzTWկ+[U[4* M@PvbHdoq HLj\KW>xͩ.RJf}/ozc/@ØdYoeRrQ9^lͼ&F&VgOPے+U/4 9ȿ)#("qZq\Sψ 1מPJ.[wN _koE?eH$_,q-"BJN_ ekC`ui|TF1#ZQ4 ( croDwyA )Q)7ƴ JXy0b֪fzrot7>|?D>a+68 ErR0ęzd(92of8=|5LĆQY[jVHfs`׭׮]yכVf=~[K"פ&t3e\(("ANDRF~b)hq2b͂3ʲz-x'x3[R]V/WZ7 _^uq<|浔D MٍIQmI1,? Mee.:1[I(+3yI.k+6V֧7cr[mp26<_kltW\L|`.i&ҴՖn*ba>tvS񫏾5][&xe,C 3iP~D: b`"+ou;ָ~A}I&B T{DQ|q4KY@u3,tOq3y%)hS GJoxfسGM侬F/I If5j6W_~n112&V-~,y)P`/f4"Ϋ FHi{PY:ߜ M nYͯFt7ok?#IiPA>UGa SGek3|PρU&*v}bbL,=٣"!cSE[B͊(oRS @Q9Xa jSC+_ Lp^nQ+Y2 `یFR2cdZ qj s(+Uˮ S8L([k;2sr"ߌDPگ/ i[@ݗc6^Wg#u׹ JG&[6ltmėl?~~/!?ԬQ_? $2AY}x݊?^Q[eJJK4?.ƙ!s:ᬨl<@C&-IɑbmA  FRchS^jIKj+KIJPW]F5m[Q,uNӁɕZc!qgGO媵7YSzVfE(JZD Ȝ+?M=I= wp?X547rbNபXNH4o]fgףoMWl`XM͍lZEӣJZҔw=Y iێۂREf^ Vt$2 @O91OZ L-;LO>X9PTOf_MyS1"΋Pm^z1/TX ĚFR4e1l/FRƝgjBϩQ\DZ4s-(#)yIVq ?Lxնub/qJ9*Jk+UMWÉNסtOk=@S̅Lҗ[m5c-H*,o%rIK GV aY0#gI(fSM%~-IDӱĈ`rOJИlD)JS {ҖPhO@bcCDP,$(9@DHӻfuw ?zJS/*^.%[gLb{$+7U;!2: =fV|s;~jooKn{sGw@G9\)7 RXR˰[(\`KW4mnsXės:1@SBZ# 9ԇ&ERdyk'] BIITA 㸷ĨlB  $yXL\ToOf4&`{"Ija5Vwl0md훁)pC8d.V/Ǝ}|{ rr<=# LC=i! FR2!T`jNx.󈶂fz`w>d0ĵokhPuZMbU)X]B 0n0Vz(݉PEqm;Z%]ahH!|dKQ&)dVbDm9}RmåmMZ 3!$%a ]ut.&/Y^ kIrٚ尅͗OA=H<nXJAmS$Jiu$k*+.k&CaJp &6Rz5%Ǥ E hJ`O? aF {- L@zD/xqI)[* > In/w_֯Y>tPKղ?:ri.*QC4ٓ([$diaWկ^9lAyT Bg>lt s\ ~~rC?= D16]D i F=süɡ?4ÀAO028<=L:&f@VȤC"'zy 8ɟڍ+A\k>(/@)FjR"0vaUWL6t_QJ+>nE~+S0@^-XҎ+wF+ 6ͭ/EOV./.p?Von 7mkrsahFRX85J\tuAUm?u|mb;A5nPqNsZ "){]C|rmhL}E?gT7'r藊$߀DB6Y"ENIUd]'HLEb *82BN5#=m/\wOo2u.Ig۠y(kH+Q UH$>pm^?kϼ ~(IJEvl*VM׈/Pp38&F$Y≉*ِ)EsRUFᆲ_mo]U<}9[qcDI1LSaB|L\j?{a]wޣe*Mm&0k;>A+w%_Iu)*6lǷqE1dV鋒J> '5)ICK6E !tApȳi~P;Zq>t?J6;.v+|^ز:@ V/ǟA ~WMlut/^3 ddCp.52Ģf\c̍ړ4@4:^:9rӕiڰK:#H΀Zq85_pW_нve'BG6׮|w#1܍/BS_M;m~F/_6WS$)dT(_ my b(a6)D$byG܃A+E wc՚OV5\^Y{Gn}&*'CTB%#@ H;B>#oHHމxm/~HRy/`4"?5MQv&\-qńݢ F]ΏηXApͦj7*IQ*3%]ED5OJ Wޠ A}FÐMSHY;pD78G:"9 IѴ"4zΟlENgѰ.K~ڒVʳ&"5"D5ʤ"ɨͿ{ah,l׮7jJqS{#b mCRGX.BAr;o4re, @,2ӣA|)46|?>\2ː"β/?ې qP:jɯΊr?Kᒩc!.3e׈fNY%PE\$-'\Rj G a-I+X!Ӯ=OIE|oIye`ڝD1~ګLR0 >C'V1xlO0;rXw &RfѨۼ+[ѽ(ԵKۚdȤm;{쌤X^#AkڕfL4!(~aoKq-osYM(-RUY}ܤ+<g·L LX<grq*tΚDju|:-F`_ЌJDg_.۪$EE+&,.*(8 #gQKsqQ@zްϿL)K&#gc/Dx잇O~;Jo3],>;(O_eȱ}֔*eOXㅈjEus \G+!Q(U jKZ^Z3Gx%^9'aY&ElBŌH^eЍnL&hc*p偀#-] $"|%"b9#)›2_3hP\([pE0I,u'g~´4Ɯ_HxI/gv{{聎|ʰX[Ҭ!*DNnRpDҸn מ9f2<jG>/)vRѐ[/ :vn . Z9Nܫˀy$!DPYaC9Ǜ|"G-9KFu(ޟr/97"yTWa A_zP@y[' 5d"*[s䪪`vNYNu\0:ʊKy+py-3|+#чmPe$$\=tAɄZnI+_~ȉS m_ZP iizh']-JEv/DcjZ]{0~ƹf'#<~_?ꓪ J'Qnj-Iœ꾁n~vxȧ>7+|ۚ5U#0Ħ+I1 'rWX6'왽7~IEbNᨵj`j;E4[~%s*;:З|}V_%~t:J:'y( NbN|eQ!Gwߴ`jrM L8Ȧ|g5@8(쉾$+(? Ӓ$ŋb3!;3pÜb3B"*DPb4727|ThR$Q{P#9ٜu+埤JQ,)2}^EQ}؎h3n:I!eGxrܰs!8:JP(%tENɌ@cCi5gE_ĚM E@0#fu/42o|[Ifsoևen2')Ga̭6ܲt$r6{BҠQɌlq'D MtWj. Y>?u6"!;yIҌHTI^9Y·/,$)_= ǟc.!+IG2iiUԚ8ء`$z$DBT$:~q ( 5xPHP+?~snT.|#KR":璪{$)O~6 Li יau@ /kJ$*gEMw,4.N*qEtwuE!iLhNGߢ^"*}"W69:1ʿc;w/MI;Ky@V[_E__{S^ҿFM[FB䄢ʇ"OOOINMn4pNd`0)'VLErXs^>vJ:")wz'/ܱjI`E9VH_u ,dBȂ׉X-VQ N 32sֹUN)0=v释;3ۖ4C"tzކGAXָ((t(Ȃ3ǐܒkAC 'ݞ|PRiPh(2A#y,V,EV'Ҟ~b:@R4i%R>]m#@fZMTBFRDt!IIug->d kC TW©#o1G<}5)f3JHDe)DBmDVnnc9HsB(|*yy Y#뵟J<F#pBQcq#`%w"b'G""2S pNѴ"c Q< (0!#)ɘ.cE|T6[! q2Q.Qd oYMj |&Ө195#9~pHPΖмdQ K-fg5 X/ŀ%!5 @~"rG4"w ɴDtf_J&u!Hn !G;wtcl鉨V|TR%%J˜^ʅWi>253Fk֘a\l=_B}FZB R!kCG}E$u2Ɋ3i*wRt!I8LjIQ k"QNDRjaFg4dq Q0@04p1Icd%p}yM NI(EJ !5%BLUX{uJG՚kkh#?8*Gpr9׷%mѰQ/E`%0)dB0 Kus6Iϕd4 dw.gV89;\Qf]s9>l ?MAC l7o֙I6휝I2 ]re򡻵_d\,Yس|)h3H]dXށzj]Y{d+҈H$,o%#ע x,p>A &d{JvmC߿r zPI0*frE(X8] uOva28d]fXhLe~ԪT-+iZPHdVO :ԶeC@vNt34NG:Ho_dp#{N;!6wM P˳ʲ24 Ň@{ߏڍ]#g*r:HE="(ih#TQ,B7 hX98jVo.]|^̞)ײz 0RjX6 >#`abF3pi>KHJVN k >N(_^Ob!4*"HNz9&\VlX ˫l a89p[B|rF&ګĜmշt+BOT1onyiDJ2546%',EaO[H`z#@Bw\rq iy[hBzdK`u88ЂUeUvA|PdQrPLE䄎Lmuf_&z*5d e31# KP[V{wsoo^4ۮC|84)9~FRcZ2,5pdG)CR;AA lnܹ>kUmFDh8UKD@S~<D7brˡd|l0بEJv#!W0 JՍ&)1&lj|k%(Nn}胒ʠHV͞#iU*Kӈ"מX+?9Ft7Rd=d5"eޑ㽋,piۯXC譼bKɩL(}V֮'Z4(pYqVn=5V%ߖHJ2*Qu6ڔHEvE;ӄ)Sol>=z:zZFR ]hDjČUv%SvHBD(bڹdRLUXW\;I= ft+\S6 Jϝ9jG A ck͚cbIYn4*aE`g!YL2^t7Z=OG>s4̆%V]A *2Qr{ʲQdz!&_:["(4$E;m r^ ~͆m9Ȉ@Կo8AA5qJnYn;rOP^$Sb+=99)6"ˉXyI01lkRxMZWHX(<>`9<:x)ֹdќe%Z^FmJ16 2{1\8jCVI=Ғ&=ID~o9suFRuaOƃ8)4] kL:рȍؑQR*L-9tU,@ $m}-,Kn30څS-^;6's7L1L{;l"C 3MJ>n)#)@0 VvS^\4y/^LjnDZ JNE)ܒ[%lcT[ٔ&rK!Rd)K=IQL .gD4!Ϊ36aVuUIQB&[Zt kjh]SX϶4tz^TԦ|6DR&3yf@th%3nW&,HZ1 yaړ[la [ظ۲:#)9:3@[߃ߏAvvM2a8ɢЪW++tqgEB=N+6Z^NMQy%^eiZ<iz{TH\^(f;A@wcYM:1Qu+Il^I&#οy Y*&-K b+GA2slY{l7%OmʗၲO肆S0\se) @NQ|I#i`K?(o0`^ҽ1#)CdX oG⥢hS諂dT"+`(2;Cfŝe}ؕuOq8$)`@IMx%gMA 4D2@!I3P+30!ЦPl$WZc|s~%) i%iWXIF>Rc Oc\JҦ\~ˤMg<@ %HIۥ3vd68!+ݴB5+RUM{63wbgzpuQ GM;4e=D pÎ5Ψj-h ELԈNf`Bdry仢_ژARXc>`8.N5x6e,`0U[V`>(* {c3T!+%eIR92x t<'0MJ:T^&?; Аʞ*yb*{QoҦPD'\h* =C!PTD(brc(E36NԞ_ RyOp?ST9WLvFRt~pM=\dQEG0YiyWw7:}:!To'bB {Q<ꓶiS_El6[x'6jΟ"g{CpbE%[Tb1n7[bFoMqN!\ٞ6*H E"^`gsaGd1"="'<=T1HF؋¶DL>ce8>y?6ٍ.)fFcuki3.[Q@'v6Ib%/^8TE,dVV_#E kV.jIp |}gV%2vHV7ƦiB6ihv҆7%-i@޴M R6Xljd 2 l݇w3v5jٙ|>;;^0ģ̔G* E\05P}bCt@IDATJjד}16@TTHyp{~_XLWKp!ҭ  P`Ei⡓Q@m嫮/SKDfʊ4.^JѻoJoM7;6mg;\ %TT"q!''5Ϯk[h{qBQ1' H +J8?3G PR+푱Ⱥ;^Ӵn [W_7_##gu5LS+&#KӾf}>9*DК%+ڙmꂇFJXTEs'?i,#~r8,J2ʃuA@b+Vx,@(.uK:ؑ׏и';Ii"sMNyЋ?./UI2Mb\cdkgS}q&ީ23:&ӓyc2|,DnPTPdIKh|ā, PU>ȷu_d4¤ux _<o)sZ@~̄3rVD+-4ǤgEfr)\R03>bҭƂ|T/Eb$s_&f^ungCW:XK=@Mtpo3 @[WNcG^;r|cxp,m?d:=سZۓJK 2"/"N۞ g{B *bD8D @ (Lt܅l/՟^^yn7WRӘ*e9'q,{+vHEEƨd:} Pl<6AމRi(k_nlz&n!Re3 v3Odg_|`m}M_W<) / ZʨW֗U'*;0$ s)]a.a:(%iՏc6])Ƴ T1TEW˗t[ٍ0c6::5Ƙou2@ym\u"pN9 IO_P:JLfKٿKGNp? XD>A*v-xEzZb}Zөբ]z 1®bzՔAMok1; )dC;V(W yyBI| *fҨуf(}y QznʤuubOOQRmuJeM@%V+8c3 D**Xd@m],baCmwVVBǚgW ~֏m֫2>Y+N&U'my'H (+@UX~z*ȊG ^Da"A)O^+jlH"\F؋Shj 9ӌզzad}}ύU^xd1Mm¡g2yf救vBI< PDf|Yi΂9OLV*.uxg+PA(@UzNsz,DY72n`aXBYyϱѣY&G8["x₴K ɒR"-*x&f/V*d<>QG^d@a/2AIG@*t:9ЖӚ-5 [s;ɕ bWP/_!\MX GO:W܁UtA(G:8ʼ[ƋŖ ػz}T@4On=̣)|͹Rb1ͬ)֓$|s6=yϻ&[7SeJ9+*SJ^|| XʵG ig/ xO!@?N\SWS|hv89Bۊ݅A@Eo5DN-j )L]EQFN8wq/D" ((eyi ,]1+&f˖S]90eͤ\pWDjS**׍Fi+phVPP0d+kA{C"' 8*Y\\hʙHqErg lMwR<0dqe& SZ_kR Jb()r"1 (._ L[XRӺ e\}˹RpSQ[%'~Zt 0)'Ǒ$K _xRgJJeG & ]`5@7J:pO=δV@}RQ 0Wz2}k%ucSFfi5M tJ>j /~/1OYKg0YAt:1@\'L8ѐC-K]JpU/Zen_:zYrZMG'^2ʢ$ˡ!9ہ4VGY()q %@QR4ExdU͌1aX$1m9*uoR .^Uɋ?^%kIJ()p0T69)S._N0qsT|?vnLh N/:V[P4h6jA!Ҝ.()E P4/Ir@^X@,ZvRn<7e6>yOkE.h_F(bk.G/pa]6@9 +įGN 5Izxm۲q4>CA}3峑J GFXnr=+#ѓco>/eY8-2?XϋoNSHGs`m &&fNuqF ~وO4}-r;ƴg'0K@pM6[rK**;vWhd|l OZ9ia6O]tXgMcNT<()1@G_\5|#&V^U}5+2SʍqE:>_ʋp\TR&-?3z^ 15=Ɵ [/U iLh%TPz6[B5Ab[ y!UࡤTPA:Nbz jLMXa^K嶬Wm jT;zBՎbmMW2_ mkj5u!泟ض0T&'>e |U[MS{a )'%\}>QcWy8_y#bQod&-q;o!ȊZPc8 _ە@;OR~9=4&!B</g6|*a *KVY]_xy J@>Lw]C*(E֔M[đJ"KJ%M&Nrfm]jJZrui(xEtSJ ݢ aU).-&_o ͘mh`ږjwRǣI7D]Ow{PɟD.$wF^\k^HY5AJJ1((k]HI)&᫒|򾒒~j ˿#>PQRZ4RZJ1>^ kB0 I$SW(%YqAʉM-n؅ $%O*N5e6},0L=@,2SBByG]4FHƥ\g~jkSYjGBMUIyi/d˜=sq+HEDBpjeD1wKN)'S]~utk %%BO,N|,\QnsxX@]Kq8uP꣖W 3@c|bF0~ى(!v+;v*S;"Rɧ&~\`x,X/_r csg<GJn_4cZ(qPR<~ x] 3iV8:V- !M@4Ķ+;Yjfz5 IeqMq%o8q/  ~Cn_vyɇ4uЍN+=*\ISޘ4)b=댩o<`HwDCgQ~NF1S>.D¥fherTtY[2+B=<8 WYd| a!!0 ݟYtU`*{^$) MYRRjx16Pp&zDR%K3gCU`5C?M%šʹBW+,ϾBZ;=.8yB).Wb/΄钿m4yb$T&yre/k8k>9L33Q9菇lb8ܾ:k8()v /@gq7ܬ 3O3n7mL9MѺXR풒B\߰-o[@I8]GŴfȇҬì޷BGPx;+_AUH, 뫋~kӕ3?v4zRTIQٜubMXyu|:HL|TwmO}T2}eBJJ( ^!@7r~Jǃi{mrpܢ7s-KzL7, P8Hf6jݏ0nYZZrYeW ~,׏hoR78x[e$EeKteC+[HJNs,c6Ւ_ȿ@l;zW!=TJNDb8}f.g4qh,P?oCD`s>5m0Hd鍽|4 r_ %@ ?. _XL=`i.-礰.ꩃX)g;(^[EBJIBRX3knx;WtR1\YcMfbbe⧾W{º5n_&{H Az+Y^Cr,5j`(n˹($ӌ1䬑TВ4o6n^GI2&|mNV3f3~ah!tkK,"Zo\Y4D!HmMV!.Rʈ^Pp] 3뤨t=R$ʉQ9c}a6{wx8:ܾr)cFc ʆQ0*Q(A@gRrHVOEf;@?x䳒\l=z6M+Sv5~PuΏQI16.bSDO)-OvbSǞcMb=wDj|K}ߢ6HNI1B͂>ifr5m@a[B1J BP6~`'IeL&A,0*>)4 F='U5A/Dӭʆ맱uyF5(sL+)AYr(smx+E) ?IB vˎl<"Q1- z}wմܶT^;N}wzN1d/}L[bP" A[ѕ}[~짟c_rc7Ӧ]t ^nҺoHGi x[n_nk|J*JʅnzVå1\N^n-\0L g bL%WV4?`|$[@i|HTÃ.#E"+J=0p]YX=;FX"=ng[YqyJN7<+cTxrOlGVL)#51_PvbvC>ULJs(gO:!d\) ezCsT^hFSƾن8})Y"r4HzEWO1c&N]EJ7p5y|%\-,oeÖ&{I17G^%'t\4(()ƸmMh-L$t I !ȇiFg}sqMhqJ[Ѩ"z8l?\<奔6FF09ve핿u/ӝ)p୓ 2&YY,0#{{wκGQx#LL('ȵ0+=Wxގ'τmAIqi(5l7NAleKVjE{+Y(֓9o8`dL31<|ʪ _^p2+wəF az~5ҲɊ?^~t*CVH*#d[&'iӝ+qJJ<ɾ)/ Nߟk=芢"HQ=]#`ˑ8#⁓P",yKr cio%A߬l:=_ 2ksd;'?*jլ[[͎-gaoR.dc`CI`R2L!{ύ7޹kMk'8J}wW)vhp^ȽeOjQ*hiVK[)d]aDڨ=iaֆa)WD7Xsm&-eD??{bbkr3Dp:VJG'ל~3ʛ><ؙ 4'~G߭ο'W>\+b0,SLa*Y!7I-Xo<ҿrd~i ]=| .H*y{^FŃrBJTN 7nU~%3=&w ZZ6۠a;9%i% P|L.]Hԁ!G!JJa•CB '~fW2-!~EzM;+?;1Ymld5]AˉBٍI$MbPRҀwB_͡YuA'r5YϼʎyrҪBwYkԃ4L4d`|oJPdp7F.ORy)D9Õ _@,?dݪ'GzJܪ[YYt _K$#9FVNe5>\os.@8872qW+\gZQ!kʬV zv()2cXiݬ\PIŤLm4V2?qqۧoYeENle_.z@K(̍_៛WU~{?䡶1v9C!R޲<[P;?n %@I) AZO¶/'dEl#ϲC R3 EH뙬'r2 픙Gͽd~۱f`VIq|Je)fzL8 f5Iw_KVҵƏx–%/^응Cj$r#EE亴L}/`|ΥYV}dM.ѷ[m|'wwm4 %%+>7R\ $mN3uN}8/[uN*(3Jj~暡#'()9xRi)g25}Ca08G@2_\z)ߥVd*a;M.zZؔ[ x@ثd9|TUYAe2d7J&m2|/TO4/gYTLڛYs(v, @IɈś;ެn%tz ;ʺMR9I`88ij 32,'rb_9IULL{kyC&L;R?kǯN4h$p7l lZ?F!._E ;oe58i1QQt#)y*Rɺ|]즀PHF^hs]I8C>~aߌvë0J6:?2x0ʥnBezTN/+-JRa3Z5seQ ص{٢)xGGNlG|FYIQ/S*y-%8ޛ?LkKЋqM0CU2ֱQ[7 vxTb]ͥbv>:_W(rumq`ҽ) ~tT6(LILۣޤXG{ONhyz+ @ ȇgmw:rF:S'T:U՟"Ych|_~diPt8>lGY|49TL_` zS,JƟ`D;cѽ5ALFݠ]r?}T5o\JRB, =` 'Rl08m`C"w~wkd d;N6m;]2?]Aۓs/İmb_T'iiEa q1'cT\ެקvaeV2݋1&vom& >\bG3"qs:{]eaF^虿ODp;J[_n14fK%yfVs?h cVRNXe֯ Ya) L2]10S)Bn϶쒳rҧ &fab}y-)zq^ 4}onh*, P>t_s:j2D粞dkWE%~()h[Q.fYƆ@+J'hbE&d`Vc^RN*m*MO9"Xԛ.]**-"*3L> G]^ `" >)'3% =ҥj^N**+؆N+DY]V#ދV49PR XRA7Vvˤ\ZJaR. R@ۭ(*JKE&5%46" ]\=i5Nv@liΟo]+-ŒWN2)]mN`Yل 0%Z!Y ) WH ))I+tm)1{ڥB~1-oRQi5,QJ y){m+fY A d毯*MyrhLf ?ݗ ߿L젤d}#8&?6*@ YST}9'LXaG3?a..ņ>h>h*'HAfڼM f8qPR2@®6Ev83Ț s1( bUQik̓E:*GEZRԺ}vb EQ"Ne*rCSy uO()Z/`ʃXhdJ"_D${䁒ⅳPe2k*zӊ )8#O.mf䛳E4/76;cs̍Š v|dF0&&Wɵf'bth"z,N#ۜ82xdNHEEۛf䓮_Gco "֔V>aM@zGRT*"Κ{Zz+CV>\KI!"|hwzlЧaʃW _>ٻꎿ;@i#';_NyrӢlxjPR8V>#`GQ87 EeҚQmc+ ުTTD<6TP/wAKecߋyM6w/"tǯ vw?-BU~vCz1V=Z>*ǤBĦTT8F-!jY@ٳ-u Py SǤrՃ }=acX `饢27 ):EaH#@('Y :s]ҽ:1l()X ߰ġ' %%?RqL ϫ/n[_c񾻋iU'x@bfzό\^Z c1 z(v~3>F~_c'jpeT6i=ј{m& Ò|Jv\8u4e?-(L}|tmזʪbeLc8I`{cZv3m(wjJ9 (>&nt>ָ$gXvg#CNJ86*'lːw.dC)iO_l;,*#C"j1δuP$p$quxa7&mV6׸)ڮ\22RsQPkfhks1r۽X%:ԠXn':J((z<]A1?uͪx,JԄV+@zpϘK_& LcOc ɉ dU*(U'oˡL,n]4] N2Sk_"Sne'sM=:iU9汬j"jփ8%$?zx zpm_2տ`6c<W|n\m%]99ϷNh^)sHܳ‹t8b>`ҭE}PN,P`*7{8g w^/ۘS3V'K.Ilxɢe=p=2%wJ:kh .Yg;r2O ( c4}4yo8f+?giWΟTGm$#uA&1IFX痯U_sҎ|/tʾq`G^}c-\x?h/,e{t)k7  AtXvRNzӚIF42gґ|3>ь/ x&$aFj{О>MP RVfeEzmX9fjz_~}lu@ ;1x=w({ٺ#}3F~E 9[mvzR|=Ct!VCve/ycg-?#ٳaBÍ GzudmK[}ܿ.;S[O{! gm>9K@+LK)D(ׯˠMʅl,b)f~2kYe=k/]R_V[\,k M ;޺m?rvĞg N@r &tۆۂ[`7|eVy򅖓2ٖ6lǰH@P?ZoBo(LKLsD^:P/aRփ &1tɠe6Xt%Dt{.+>A_ S)pW#W0o^PRy^Z=9q~2^AkBޫYC B@WV lOH_GJ!lD@>hh9F/RJ㒑PARiFe(n% 5&*p.Ol lzdqtCQL/RofI;<;r{eO ƾbW|LEJ#ӋkJ]R`%*nk )G I)&yyOVOJJ~F(^0f`A*9%ȳ;uWGoǩ Pd;+q-sI ytB`եz,i"B)O⦋YPYPRZkL_F7^f:##RP"Xވ Pd)uT`Sy!-2X@t"HDUV5a֝?ѿ9M|>ESe* Ǝ /w ^! ߂S|ނI1 FNB)Hy]F&)`)6-KWB:QˉbJJ3fAQ::Rz2GV1qwomw@JD`M2AoH*ݶրIUNI(I]<.|aȤv6^/"&fBy KJDm+*\<= i vX?ld`֓bG? 0DoÀ؜#{ͨ2#el .fLCuH"X~taƑIDATt$cA~(bR,.#G7ǻ¶q2~mzli hScLitA&_η~ OOIp-RN.T159OVEDSe(%-On' F˄6\HasxXm]4sjũ\x\( [#7'o@Ef4҃z$kv_O? ?3%ԏQ&͡~s?˙@_X(!|f${,l>/egriiC:b)FFD ۺ2}c8ҏAH'J$%'7F;YU֓vYLNk;ޙm~Tmovi.c)(er0UWd7M"#|buЕQ'[=;Jmk6kZ%cI܅=N@*+]?~b'qx,zngG?ߍDž'0/d~哮tAHF T 2*zrƷxZH%%% &' ֓g=]dx2]iuMؤ[i `ʅaIx3#ݕh鐒xs쭁A("{vu5 .aEAƚ&yºBB<{J"]iu. 0R?7ٔcr?a٭ _T6ʅ<A@@98Dz*Z/n=㌏qǫ/n$ + wbls PIԘ%NA@@PR\Z=NͰa20R"& K$_kIENDB`golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/example_test.go000066400000000000000000000125531456366605600253050ustar00rootroot00000000000000package scalewaysdkgo import ( "fmt" "time" "github.com/scaleway/scaleway-sdk-go/api/instance/v1" "github.com/scaleway/scaleway-sdk-go/api/lb/v1" "github.com/scaleway/scaleway-sdk-go/scw" ) func Example_apiClient() { // Create a Scaleway client client, err := scw.NewClient( scw.WithAuth("ACCESS_KEY", "SECRET_KEY"), // Get your credentials at https://console.scaleway.com/project/credentials ) if err != nil { // handle error } // Create SDK objects for specific Scaleway Products instanceAPI := instance.NewAPI(client) lbAPI := lb.NewAPI(client) // Start using the SDKs _, _ = instanceAPI, lbAPI } func Example_apiClientWithConfig() { // Get Scaleway Config config, err := scw.LoadConfig() if err != nil { // handle error } // Use active profile profile, err := config.GetActiveProfile() if err != nil { // handle error } // Create a Scaleway client client, err := scw.NewClient( scw.WithProfile(profile), scw.WithEnv(), // env variable may overwrite profile values ) if err != nil { // handle error } // Create SDK objects for specific Scaleway Products instanceAPI := instance.NewAPI(client) lbAPI := lb.NewAPI(client) // Start using the SDKs _, _ = instanceAPI, lbAPI } func Example_listServers() { // Create a Scaleway client client, err := scw.NewClient( scw.WithAuth("ACCESS_KEY", "SECRET_KEY"), // Get your credentials at https://console.scaleway.com/project/credentials ) if err != nil { // handle error } // Create SDK objects for Scaleway Instance product instanceAPI := instance.NewAPI(client) // Call the ListServers method on the Instance SDK response, err := instanceAPI.ListServers(&instance.ListServersRequest{ Zone: scw.ZoneFrPar1, }) if err != nil { // handle error } // Do something with the response... fmt.Println(response) } func Example_listServersWithZones() { // Create a Scaleway client client, err := scw.NewClient( scw.WithAuth("ACCESS_KEY", "SECRET_KEY"), // Get your credentials at https://console.scaleway.com/project/credentials ) if err != nil { // handle error } // Create SDK objects for Scaleway Instance product instanceAPI := instance.NewAPI(client) // Call the ListServers method on the Instance SDK response, err := instanceAPI.ListServers(&instance.ListServersRequest{}, // Add WithZones option to list servers from multiple zones scw.WithZones(scw.ZoneFrPar1, scw.ZoneNlAms1, scw.ZonePlWaw1)) if err != nil { // handle error } // Do something with the response... fmt.Println(response) } func Example_createServer() { // Create a Scaleway client client, err := scw.NewClient( scw.WithAuth("ACCESS_KEY", "SECRET_KEY"), // Get your credentials at https://console.scaleway.com/project/credentials scw.WithDefaultOrganizationID("ORGANIZATION_ID"), scw.WithDefaultZone(scw.ZoneFrPar1), ) if err != nil { panic(err) } // Create SDK objects for Scaleway Instance and marketplace instanceAPI := instance.NewAPI(client) serverType := "DEV1-S" image := "ubuntu_focal" // Create a new DEV1-S server createRes, err := instanceAPI.CreateServer(&instance.CreateServerRequest{ Name: "my-server-01", CommercialType: serverType, Image: image, DynamicIPRequired: scw.BoolPtr(true), }) if err != nil { panic(err) } // Start the server and wait until it's ready. timeout := 5 * time.Minute err = instanceAPI.ServerActionAndWait(&instance.ServerActionAndWaitRequest{ ServerID: createRes.Server.ID, Action: instance.ServerActionPoweron, Timeout: &timeout, }) if err != nil { panic(err) } } func Example_rebootAllServers() { // Create a Scaleway client client, err := scw.NewClient( scw.WithAuth("ACCESS_KEY", "SECRET_KEY"), // Get your credentials at https://console.scaleway.com/project/credentials scw.WithDefaultZone(scw.ZoneFrPar1), ) if err != nil { panic(err) } // Create SDK objects for Scaleway Instance product instanceAPI := instance.NewAPI(client) // Call the ListServers method of the Instance SDK response, err := instanceAPI.ListServers(&instance.ListServersRequest{}) if err != nil { panic(err) } // For each server if they are running we reboot them using ServerActionAndWait timeout := 5 * time.Minute for _, server := range response.Servers { if server.State == instance.ServerStateRunning { fmt.Println("Rebooting server with ID", server.ID) err = instanceAPI.ServerActionAndWait(&instance.ServerActionAndWaitRequest{ ServerID: server.ID, Action: instance.ServerActionReboot, Timeout: &timeout, }) if err != nil { panic(err) } } } fmt.Println("All servers were successfully rebooted") } func Example_createLoadBalancer() { // Create a Scaleway client client, err := scw.NewClient( scw.WithAuth("ACCESS_KEY", "SECRET_KEY"), // Get your credentials at https://console.scaleway.com/project/credentials ) if err != nil { // handle error } // Create SDK objects for Scaleway LoadConfig Balancer product lbAPI := lb.NewAPI(client) // Call the CreateLb method on the LB SDK to create a new load balancer. newLB, err := lbAPI.CreateLB(&lb.CreateLBRequest{ Name: "My new load balancer", Description: "This is a example of a load balancer", OrganizationID: scw.StringPtr("000a115d-2852-4b0a-9ce8-47f1134ba95a"), Region: scw.RegionFrPar, }) if err != nil { // handle error } // Do something with the newly created LB... fmt.Println(newLB) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/go.mod000066400000000000000000000002231456366605600233610ustar00rootroot00000000000000module github.com/scaleway/scaleway-sdk-go go 1.17 require ( github.com/dnaeon/go-vcr v1.2.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/go.sum000066400000000000000000000012661456366605600234160ustar00rootroot00000000000000github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/000077500000000000000000000000001456366605600240725ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/async/000077500000000000000000000000001456366605600252075ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/async/wait.go000066400000000000000000000040501456366605600265010ustar00rootroot00000000000000package async import ( "fmt" "time" ) var ( defaultInterval = time.Second defaultTimeout = time.Minute * 5 ) type IntervalStrategy func() <-chan time.Time // WaitSyncConfig defines the waiting options. type WaitSyncConfig struct { // This method will be called from another goroutine. Get func() (value interface{}, isTerminal bool, err error) IntervalStrategy IntervalStrategy Timeout time.Duration } // LinearIntervalStrategy defines a linear interval duration. func LinearIntervalStrategy(interval time.Duration) IntervalStrategy { return func() <-chan time.Time { return time.After(interval) } } // FibonacciIntervalStrategy defines an interval duration who follow the Fibonacci sequence. func FibonacciIntervalStrategy(base time.Duration, factor float32) IntervalStrategy { var x, y float32 = 0, 1 return func() <-chan time.Time { x, y = y, x+(y*factor) return time.After(time.Duration(x) * base) } } // WaitSync waits and returns when a given stop condition is true or if an error occurs. func WaitSync(config *WaitSyncConfig) (terminalValue interface{}, err error) { // initialize configuration if config.IntervalStrategy == nil { config.IntervalStrategy = LinearIntervalStrategy(defaultInterval) } if config.Timeout == 0 { config.Timeout = defaultTimeout } resultValue := make(chan interface{}) resultErr := make(chan error) timeout := make(chan bool) go func() { for { // get the payload value, stopCondition, err := config.Get() // send the payload if err != nil { resultErr <- err return } if stopCondition { resultValue <- value return } // waiting for an interval before next get() call or a timeout select { case <-timeout: return case <-config.IntervalStrategy(): // sleep } } }() // waiting for a result or a timeout select { case val := <-resultValue: return val, nil case err := <-resultErr: return nil, err case <-time.After(config.Timeout): timeout <- true return nil, fmt.Errorf("timeout after %v", config.Timeout) } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/async/wait_test.go000066400000000000000000000054531456366605600275500ustar00rootroot00000000000000package async import ( "fmt" "testing" "time" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" ) const flakiness = 500 * time.Millisecond type value struct { doneIterations int totalDuration time.Duration } func getMock(iterations int, sleepTime time.Duration) func() (interface{}, bool, error) { cpt := iterations var startTime time.Time return func() (interface{}, bool, error) { if cpt == iterations { startTime = time.Now() } cpt-- // fake working time time.Sleep(sleepTime) v := &value{ doneIterations: iterations - cpt, totalDuration: time.Since(startTime), } return v, cpt == 0, nil } } func TestWaitSync(t *testing.T) { testsCases := []struct { name string config *WaitSyncConfig expValue interface{} expErr error }{ { name: "With default timeout and interval", config: &WaitSyncConfig{ Get: getMock(2, 0), }, expValue: &value{ doneIterations: 2, totalDuration: time.Second, }, }, { name: "With useless timeout", config: &WaitSyncConfig{ Get: getMock(2, time.Second), Timeout: 4 * time.Second, }, expValue: &value{ doneIterations: 2, totalDuration: 3 * time.Second, }, }, { name: "Should timeout", config: &WaitSyncConfig{ Get: getMock(2, 2*time.Second), Timeout: time.Second, }, expValue: nil, expErr: fmt.Errorf("timeout after 1s"), }, { name: "With interval", config: &WaitSyncConfig{ Get: getMock(2, 0), IntervalStrategy: LinearIntervalStrategy(2 * time.Second), }, expValue: &value{ doneIterations: 2, totalDuration: 2 * time.Second, }, }, { name: "With fibonacci interval", config: &WaitSyncConfig{ Get: getMock(5, 0), IntervalStrategy: FibonacciIntervalStrategy(time.Second, 1), }, expValue: &value{ doneIterations: 5, totalDuration: 7 * time.Second, }, }, { name: "Should timeout with interval", config: &WaitSyncConfig{ Get: getMock(2, time.Second), Timeout: 2 * time.Second, IntervalStrategy: LinearIntervalStrategy(2 * time.Second), }, expValue: nil, expErr: fmt.Errorf("timeout after 2s"), }, } for _, c := range testsCases { c := c // do not remove me t.Run(c.name, func(t *testing.T) { t.Parallel() terminalValue, err := WaitSync(c.config) testhelpers.Equals(t, c.expErr, err) if c.expValue != nil { exp := c.expValue.(*value) acc := terminalValue.(*value) testhelpers.Equals(t, exp.doneIterations, acc.doneIterations) ok := exp.totalDuration > acc.totalDuration-flakiness && exp.totalDuration < acc.totalDuration+flakiness testhelpers.Assert(t, ok, "totalDuration don't match the target: (acc: %v, exp: %v)", acc.totalDuration, exp.totalDuration) } }) } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/auth/000077500000000000000000000000001456366605600250335ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/auth/access_key.go000066400000000000000000000007131456366605600274740ustar00rootroot00000000000000package auth import "net/http" type AccessKeyOnly struct { // auth config may contain an access key without being authenticated AccessKey string } // NewNoAuth return an auth with no authentication method func NewAccessKeyOnly(accessKey string) *AccessKeyOnly { return &AccessKeyOnly{accessKey} } func (t *AccessKeyOnly) Headers() http.Header { return http.Header{} } func (t *AccessKeyOnly) AnonymizedHeaders() http.Header { return http.Header{} } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/auth/auth.go000066400000000000000000000013201456366605600263170ustar00rootroot00000000000000package auth import "net/http" // Auth implement methods required for authentication. // Valid authentication are currently a token or no auth. type Auth interface { // Headers returns headers that must be add to the http request Headers() http.Header // AnonymizedHeaders returns an anonymised version of Headers() // This method could be use for logging purpose. AnonymizedHeaders() http.Header } type headerAnonymizer func(header http.Header) http.Header var headerAnonymizers = []headerAnonymizer{ AnonymizeTokenHeaders, AnonymizeJWTHeaders, } func AnonymizeHeaders(headers http.Header) http.Header { for _, anonymizer := range headerAnonymizers { headers = anonymizer(headers) } return headers } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/auth/jwt.go000066400000000000000000000022461456366605600261720ustar00rootroot00000000000000package auth import ( "net/http" "strings" ) // JWT is the session token used in browser. type JWT struct { Token string } // XSessionTokenHeader is Scaleway auth header for browser const XSessionTokenHeader = "x-session-token" // #nosec G101 // NewJWT create a token authentication from a jwt func NewJWT(token string) *JWT { return &JWT{Token: token} } // Headers returns headers that must be added to the http request func (j *JWT) Headers() http.Header { headers := http.Header{} headers.Set(XSessionTokenHeader, j.Token) return headers } func AnonymizeJWTHeaders(headers http.Header) http.Header { token := headers.Get(XSessionTokenHeader) if token != "" { headers.Set(XSessionTokenHeader, HideJWT(token)) } return headers } // AnonymizedHeaders returns an anonymized version of Headers() // This method could be used for logging purpose. func (j *JWT) AnonymizedHeaders() http.Header { return AnonymizeJWTHeaders(j.Headers()) } func HideJWT(token string) string { if len(token) == 0 { return "" } // token should be (header).(payload).(signature) lastDot := strings.LastIndex(token, ".") if lastDot != -1 { token = token[:lastDot] } return token } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/auth/no_auth.go000066400000000000000000000004601456366605600270170ustar00rootroot00000000000000package auth import "net/http" type NoAuth struct { } // NewNoAuth return an auth with no authentication method func NewNoAuth() *NoAuth { return &NoAuth{} } func (t *NoAuth) Headers() http.Header { return http.Header{} } func (t *NoAuth) AnonymizedHeaders() http.Header { return http.Header{} } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/auth/token.go000066400000000000000000000024221456366605600265020ustar00rootroot00000000000000package auth import "net/http" // Token is the pair accessKey + secretKey. // This type is public because it's an internal package. type Token struct { AccessKey string SecretKey string } // XAuthTokenHeader is Scaleway standard auth header const XAuthTokenHeader = "X-Auth-Token" // #nosec G101 // NewToken create a token authentication from an // access key and a secret key func NewToken(accessKey, secretKey string) *Token { return &Token{AccessKey: accessKey, SecretKey: secretKey} } // Headers returns headers that must be add to the http request func (t *Token) Headers() http.Header { headers := http.Header{} headers.Set(XAuthTokenHeader, t.SecretKey) return headers } func AnonymizeTokenHeaders(headers http.Header) http.Header { key := headers.Get(XAuthTokenHeader) if key != "" { headers.Set(XAuthTokenHeader, HideSecretKey(key)) } return headers } // AnonymizedHeaders returns an anonymized version of Headers() // This method could be use for logging purpose. func (t *Token) AnonymizedHeaders() http.Header { return AnonymizeTokenHeaders(t.Headers()) } func HideSecretKey(k string) string { switch { case len(k) == 0: return "" case len(k) > 8: return k[0:8] + "-xxxx-xxxx-xxxx-xxxxxxxxxxxx" default: return "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/auth/token_test.go000066400000000000000000000005401456366605600275400ustar00rootroot00000000000000package auth import ( "net/http" "testing" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" ) func TestToken_Headers(t *testing.T) { const ( accessKey = "ACCESS_KEY" secretKey = "SECRET_KEY" ) auth := NewToken(accessKey, secretKey) testhelpers.Equals(t, http.Header{ "X-Auth-Token": []string{secretKey}, }, auth.Headers()) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/e2e/000077500000000000000000000000001456366605600245455ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/e2e/errors_test.go000066400000000000000000000062431456366605600274540ustar00rootroot00000000000000package e2e import ( "testing" "github.com/scaleway/scaleway-sdk-go/api/test/v1" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" "github.com/scaleway/scaleway-sdk-go/scw" ) func TestStandardErrors(t *testing.T) { client, _, _, err := newE2EClient(true) testhelpers.AssertNoError(t, err) t.Run("not found", func(t *testing.T) { _, err = client.GetHuman(&test.GetHumanRequest{ HumanID: "b3ba839a-dcf2-4b0a-ac81-fc32370052a0", }) testhelpers.Equals(t, &scw.ResourceNotFoundError{ Resource: "human", ResourceID: "b3ba839a-dcf2-4b0a-ac81-fc32370052a0", RawBody: []byte(`{"message":"resource is not found","resource":"human","resource_id":"b3ba839a-dcf2-4b0a-ac81-fc32370052a0","type":"not_found"}`), }, err) }) t.Run("invalid argument", func(t *testing.T) { _, err = client.CreateHuman(&test.CreateHumanRequest{ AltitudeInMeter: -7000000, }) testhelpers.Equals(t, &scw.InvalidArgumentsError{ Details: []scw.InvalidArgumentsErrorDetail{ { ArgumentName: "altitude_in_meter", Reason: "constraint", HelpMessage: "lowest altitude on earth is -6371km", }, }, RawBody: []byte(`{"details":[{"argument_name":"altitude_in_meter","help_message":"lowest altitude on earth is -6371km","reason":"constraint"}],"message":"invalid argument(s)","type":"invalid_arguments"}`), }, err) }) t.Run("quotas exceeded", func(t *testing.T) { var humans []*test.Human for i := 0; i < 10; i++ { human, err := client.CreateHuman(&test.CreateHumanRequest{}) testhelpers.AssertNoError(t, err) humans = append(humans, human) } _, err = client.CreateHuman(&test.CreateHumanRequest{}) testhelpers.Equals(t, &scw.QuotasExceededError{ Details: []scw.QuotasExceededErrorDetail{ { Resource: "human", Quota: 10, Current: 10, }, }, RawBody: []byte(`{"details":[{"current":10,"quota":10,"resource":"human"}],"message":"quota(s) exceeded for this resource","type":"quotas_exceeded"}`), }, err) for _, human := range humans { _, err := client.DeleteHuman(&test.DeleteHumanRequest{HumanID: human.ID}) testhelpers.AssertNoError(t, err) } }) t.Run("transient state", func(t *testing.T) { human, err := client.CreateHuman(&test.CreateHumanRequest{}) testhelpers.AssertNoError(t, err) defer func() { _, _ = client.DeleteHuman(&test.DeleteHumanRequest{HumanID: human.ID}) }() _, err = client.RunHuman(&test.RunHumanRequest{HumanID: human.ID}) testhelpers.AssertNoError(t, err) _, err = client.UpdateHuman(&test.UpdateHumanRequest{HumanID: human.ID}) testhelpers.Equals(t, &scw.TransientStateError{ Resource: "human", ResourceID: human.ID, CurrentState: "running", RawBody: []byte(`{"current_state":"running","message":"resource is in a transient state","resource":"human","resource_id":"` + human.ID + `","type":"transient_state"}`), }, err) }) t.Run("out of stock", func(t *testing.T) { _, err = client.CreateHuman(&test.CreateHumanRequest{ ShoeSize: 60, }) testhelpers.Equals(t, &scw.OutOfStockError{ Resource: "ShoeSize60", RawBody: []byte(`{"message":"resource is out of stock","resource":"ShoeSize60","type":"out_of_stock"}`), }, err) }) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/e2e/human_test.go000066400000000000000000000120501456366605600272410ustar00rootroot00000000000000package e2e import ( "testing" "github.com/scaleway/scaleway-sdk-go/api/test/v1" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" "github.com/scaleway/scaleway-sdk-go/scw" ) var ( defaultOrganizationID = "6170692e-7363-616c-6577-61792e636f6d" // hint: | xxd -ps -r ) func newE2EClient(withAuthInClient bool) (*test.API, string, string, error) { client, err := scw.NewClient( scw.WithDefaultRegion(scw.RegionFrPar), scw.WithDefaultOrganizationID(defaultOrganizationID), scw.WithUserAgent("sdk-e2e-test"), ) if err != nil { return nil, "", "", err } testClient := test.NewAPI(client) registerResponse, err := testClient.Register(&test.RegisterRequest{ Username: "sidi", }) if err != nil { return nil, "", "", err } if withAuthInClient { client, err = scw.NewClient( scw.WithDefaultRegion(scw.RegionFrPar), scw.WithDefaultOrganizationID(defaultOrganizationID), scw.WithAuth(registerResponse.AccessKey, registerResponse.SecretKey), scw.WithUserAgent("sdk-e2e-test"), ) testClient = test.NewAPI(client) } return testClient, registerResponse.AccessKey, registerResponse.SecretKey, err } func TestAuthInRequest(t *testing.T) { client, accessKey, secretKey, err := newE2EClient(false) testhelpers.AssertNoError(t, err) requestWithAuth := scw.WithAuthRequest(accessKey, secretKey) _, err = client.CreateHuman(&test.CreateHumanRequest{}, requestWithAuth) testhelpers.AssertNoError(t, err) } func TestHuman(t *testing.T) { client, _, _, err := newE2EClient(true) testhelpers.AssertNoError(t, err) // create human, err := client.CreateHuman(&test.CreateHumanRequest{ Height: 170.5, ShoeSize: 35.1, AltitudeInMeter: -12, AltitudeInMillimeter: -12050, FingersCount: 21, HairCount: 9223372036854775808, IsHappy: true, EyesColor: test.EyeColorsAmber, OrganizationID: scw.StringPtr("b3ba839a-dcf2-4b0a-ac81-fc32370052a0"), }) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, human.Height, 170.5) testhelpers.Equals(t, human.ShoeSize, float32(35.1)) testhelpers.Equals(t, human.AltitudeInMeter, int32(-12)) testhelpers.Equals(t, human.AltitudeInMillimeter, int64(-12050)) testhelpers.Equals(t, human.FingersCount, uint32(21)) testhelpers.Equals(t, human.HairCount, uint64(9223372036854775808)) testhelpers.Equals(t, human.IsHappy, true) testhelpers.Equals(t, human.EyesColor, test.EyeColorsAmber) testhelpers.Equals(t, human.OrganizationID, "b3ba839a-dcf2-4b0a-ac81-fc32370052a0") // single parameter update human, err = client.UpdateHuman(&test.UpdateHumanRequest{ HumanID: human.ID, IsHappy: scw.BoolPtr(false), }) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, human.Height, 170.5) testhelpers.Equals(t, human.ShoeSize, float32(35.1)) testhelpers.Equals(t, human.AltitudeInMeter, int32(-12)) testhelpers.Equals(t, human.AltitudeInMillimeter, int64(-12050)) testhelpers.Equals(t, human.FingersCount, uint32(21)) testhelpers.Equals(t, human.HairCount, uint64(9223372036854775808)) testhelpers.Equals(t, human.IsHappy, false) testhelpers.Equals(t, human.EyesColor, test.EyeColorsAmber) testhelpers.Equals(t, human.OrganizationID, "b3ba839a-dcf2-4b0a-ac81-fc32370052a0") // update human, err = client.UpdateHuman(&test.UpdateHumanRequest{ HumanID: human.ID, Height: scw.Float64Ptr(155.666), ShoeSize: scw.Float32Ptr(36.0), AltitudeInMeter: scw.Int32Ptr(2147483647), AltitudeInMillimeter: scw.Int64Ptr(2147483647285), FingersCount: scw.Uint32Ptr(20), HairCount: scw.Uint64Ptr(9223372036854775809), IsHappy: scw.BoolPtr(true), EyesColor: test.EyeColorsBlue, }) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, human.Height, 155.666) testhelpers.Equals(t, human.ShoeSize, float32(36.0)) testhelpers.Equals(t, human.AltitudeInMeter, int32(2147483647)) testhelpers.Equals(t, human.AltitudeInMillimeter, int64(2147483647285)) testhelpers.Equals(t, human.FingersCount, uint32(20)) testhelpers.Equals(t, human.HairCount, uint64(9223372036854775809)) testhelpers.Equals(t, human.IsHappy, true) testhelpers.Equals(t, human.EyesColor, test.EyeColorsBlue) testhelpers.Equals(t, human.OrganizationID, "b3ba839a-dcf2-4b0a-ac81-fc32370052a0") // get human, err = client.GetHuman(&test.GetHumanRequest{ HumanID: human.ID, }) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, human.Height, 155.666) testhelpers.Equals(t, human.ShoeSize, float32(36.0)) testhelpers.Equals(t, human.AltitudeInMeter, int32(2147483647)) testhelpers.Equals(t, human.AltitudeInMillimeter, int64(2147483647285)) testhelpers.Equals(t, human.FingersCount, uint32(20)) testhelpers.Equals(t, human.HairCount, uint64(9223372036854775809)) testhelpers.Equals(t, human.IsHappy, true) testhelpers.Equals(t, human.EyesColor, test.EyeColorsBlue) testhelpers.Equals(t, human.OrganizationID, "b3ba839a-dcf2-4b0a-ac81-fc32370052a0") // delete _, err = client.DeleteHuman(&test.DeleteHumanRequest{ HumanID: human.ID, }) testhelpers.AssertNoError(t, err) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/errors/000077500000000000000000000000001456366605600254065ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/errors/error.go000066400000000000000000000015261456366605600270720ustar00rootroot00000000000000package errors import "fmt" // Error is a base error that implement scw.SdkError type Error struct { Str string Err error } // Error implement standard xerror.Wrapper interface func (e *Error) Unwrap() error { return e.Err } // Error implement standard error interface func (e *Error) Error() string { str := "scaleway-sdk-go: " + e.Str if e.Err != nil { str += ": " + e.Err.Error() } return str } // IsScwSdkError implement SdkError interface func (e *Error) IsScwSdkError() {} // New creates a new error with that same interface as fmt.Errorf func New(format string, args ...interface{}) *Error { return &Error{ Str: fmt.Sprintf(format, args...), } } // Wrap an error with additional information func Wrap(err error, format string, args ...interface{}) *Error { return &Error{ Err: err, Str: fmt.Sprintf(format, args...), } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/generic/000077500000000000000000000000001456366605600255065ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/generic/fields.go000066400000000000000000000006471456366605600273120ustar00rootroot00000000000000package generic import "reflect" // HasField returns true if given struct has a field with given name // Also allow a slice, it will use the underlying type func HasField(i interface{}, fieldName string) bool { value := reflect.Indirect(reflect.ValueOf(i)) typ := value.Type() if value.Kind() == reflect.Slice { typ = indirectType(typ.Elem()) } _, fieldExists := typ.FieldByName(fieldName) return fieldExists } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/generic/fields_test.go000066400000000000000000000014321456366605600303420ustar00rootroot00000000000000package generic import "testing" func TestHasField(t *testing.T) { tests := []struct { name string i interface{} fieldName string want bool }{ { "native type", struct { Zone string }{}, "Zone", true, }, { "ptr type", struct { Zone *string }{}, "Zone", true, }, { "invalid case", struct { Zone *string }{}, "zone", false, }, { "slice", []struct { Zone string }{}, "Zone", true, }, { "slice invalid case", []struct { Zone string }{}, "zone", false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := HasField(tt.i, tt.fieldName); got != tt.want { t.Errorf("HasField() = %v, want %v", got, tt.want) } }) } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/generic/ptr.go000066400000000000000000000002341456366605600266410ustar00rootroot00000000000000package generic import "reflect" func indirectType(typ reflect.Type) reflect.Type { if typ.Kind() == reflect.Ptr { return typ.Elem() } return typ } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/generic/sort.go000066400000000000000000000010471456366605600270260ustar00rootroot00000000000000package generic import ( "reflect" "sort" ) // SortSliceByField sorts given slice of struct by passing the specified field to given compare function // given slice must be a slice of Ptr func SortSliceByField(list interface{}, field string, compare func(interface{}, interface{}) bool) { listValue := reflect.ValueOf(list) sort.SliceStable(list, func(i, j int) bool { field1 := listValue.Index(i).Elem().FieldByName(field).Interface() field2 := listValue.Index(j).Elem().FieldByName(field).Interface() return compare(field1, field2) }) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/generic/sort_test.go000066400000000000000000000010531456366605600300620ustar00rootroot00000000000000package generic import ( "testing" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" ) func Test_SortSliceByField(t *testing.T) { type Elem struct { Field string } elems := []*Elem{ {"2"}, {"1"}, {"3"}, } SortSliceByField(elems, "Field", func(i interface{}, i2 interface{}) bool { return i.(string) < i2.(string) }) testhelpers.Assert(t, elems[0].Field == "1", "slice is not sorted") testhelpers.Assert(t, elems[1].Field == "2", "slice is not sorted") testhelpers.Assert(t, elems[2].Field == "3", "slice is not sorted") } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/marshaler/000077500000000000000000000000001456366605600260505ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/marshaler/duration.go000066400000000000000000000101021456366605600302160ustar00rootroot00000000000000package marshaler import ( "encoding/json" "time" ) // Duration implements a JSON Marshaler to encode a time.Duration in milliseconds. type Duration int64 const milliSec = Duration(time.Millisecond) // NewDuration converts a *time.Duration to a *Duration type. func NewDuration(t *time.Duration) *Duration { if t == nil { return nil } d := Duration(t.Nanoseconds()) return &d } // Standard converts a *Duration to a *time.Duration type. func (d *Duration) Standard() *time.Duration { return (*time.Duration)(d) } // MarshalJSON encodes the Duration in milliseconds. func (d Duration) MarshalJSON() ([]byte, error) { return json.Marshal(int64(d / milliSec)) } // UnmarshalJSON decodes milliseconds to Duration. func (d *Duration) UnmarshalJSON(b []byte) error { var tmp int64 err := json.Unmarshal(b, &tmp) if err != nil { return err } *d = Duration(tmp) * milliSec return nil } // DurationSlice is a slice of *Duration type DurationSlice []*Duration // NewDurationSlice converts a []*time.Duration to a DurationSlice type. func NewDurationSlice(t []*time.Duration) DurationSlice { ds := make([]*Duration, len(t)) for i := range ds { ds[i] = NewDuration(t[i]) } return ds } // Standard converts a DurationSlice to a []*time.Duration type. func (ds *DurationSlice) Standard() []*time.Duration { t := make([]*time.Duration, len(*ds)) for i := range t { t[i] = (*ds)[i].Standard() } return t } // Durationint32Map is a int32 map of *Duration type Durationint32Map map[int32]*Duration // NewDurationint32Map converts a map[int32]*time.Duration to a Durationint32Map type. func NewDurationint32Map(t map[int32]*time.Duration) Durationint32Map { dm := make(Durationint32Map, len(t)) for i := range t { dm[i] = NewDuration(t[i]) } return dm } // Standard converts a Durationint32Map to a map[int32]*time.Duration type. func (dm *Durationint32Map) Standard() map[int32]*time.Duration { t := make(map[int32]*time.Duration, len(*dm)) for key, value := range *dm { t[key] = value.Standard() } return t } // LongDuration implements a JSON Marshaler to encode a time.Duration in days. type LongDuration int64 const day = LongDuration(time.Hour) * 24 // NewLongDuration converts a *time.Duration to a *LongDuration type. func NewLongDuration(t *time.Duration) *LongDuration { if t == nil { return nil } d := LongDuration(t.Nanoseconds()) return &d } // Standard converts a *LongDuration to a *time.Duration type. func (d *LongDuration) Standard() *time.Duration { return (*time.Duration)(d) } // MarshalJSON encodes the LongDuration in days. func (d LongDuration) MarshalJSON() ([]byte, error) { return json.Marshal(int64(d / day)) } // UnmarshalJSON decodes days to LongDuration. func (d *LongDuration) UnmarshalJSON(b []byte) error { var tmp int64 err := json.Unmarshal(b, &tmp) if err != nil { return err } *d = LongDuration(tmp) * day return nil } // LongDurationSlice is a slice of *LongDuration type LongDurationSlice []*LongDuration // NewLongDurationSlice converts a []*time.Duration to a LongDurationSlice type. func NewLongDurationSlice(t []*time.Duration) LongDurationSlice { ds := make([]*LongDuration, len(t)) for i := range ds { ds[i] = NewLongDuration(t[i]) } return ds } // Standard converts a LongDurationSlice to a []*time.Duration type. func (ds *LongDurationSlice) Standard() []*time.Duration { t := make([]*time.Duration, len(*ds)) for i := range t { t[i] = (*ds)[i].Standard() } return t } // LongDurationint32Map is a int32 map of *LongDuration type LongDurationint32Map map[int32]*LongDuration // NewLongDurationint32Map converts a map[int32]*time.LongDuration to a LongDurationint32Map type. func NewLongDurationint32Map(t map[int32]*time.Duration) LongDurationint32Map { dm := make(LongDurationint32Map, len(t)) for i := range t { dm[i] = NewLongDuration(t[i]) } return dm } // Standard converts a LongDurationint32Map to a map[int32]*time.LongDuration type. func (dm *LongDurationint32Map) Standard() map[int32]*time.Duration { t := make(map[int32]*time.Duration, len(*dm)) for key, value := range *dm { t[key] = value.Standard() } return t } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/parameter/000077500000000000000000000000001456366605600260525ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/parameter/query.go000066400000000000000000000021211456366605600275420ustar00rootroot00000000000000package parameter import ( "fmt" "net" "net/url" "reflect" "time" "github.com/scaleway/scaleway-sdk-go/scw" ) // AddToQuery add a key/value pair to an URL query func AddToQuery(query url.Values, key string, value interface{}) { elemValue := reflect.ValueOf(value) if elemValue.Kind() == reflect.Invalid || elemValue.Kind() == reflect.Ptr && elemValue.IsNil() { return } for elemValue.Kind() == reflect.Ptr { elemValue = reflect.ValueOf(value).Elem() } elemType := elemValue.Type() switch { case elemType == reflect.TypeOf(net.IP{}): query.Add(key, value.(*net.IP).String()) case elemType == reflect.TypeOf(net.IPNet{}): query.Add(key, value.(*net.IPNet).String()) case elemType == reflect.TypeOf(scw.IPNet{}): query.Add(key, value.(*scw.IPNet).String()) case elemType.Kind() == reflect.Slice: for i := 0; i < elemValue.Len(); i++ { query.Add(key, fmt.Sprint(elemValue.Index(i).Interface())) } case elemType == reflect.TypeOf(time.Time{}): query.Add(key, value.(*time.Time).Format(time.RFC3339)) default: query.Add(key, fmt.Sprint(elemValue.Interface())) } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/testhelpers/000077500000000000000000000000001456366605600264345ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/testhelpers/httprecorder/000077500000000000000000000000001456366605600311415ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/testhelpers/httprecorder/recorder.go000066400000000000000000000055101456366605600332760ustar00rootroot00000000000000package httprecorder import ( "fmt" "net/http" "os" "strings" "github.com/dnaeon/go-vcr/cassette" "github.com/dnaeon/go-vcr/recorder" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/scw" ) // IsUpdatingCassette returns true if we are updating cassettes. func IsUpdatingCassette() bool { return os.Getenv("SDK_UPDATE_CASSETTES") == "true" } // CreateRecordedScwClient creates a new scw.Client that records all HTTP requests in a cassette. // This cassette is then replayed whenever tests are executed again. This means that once the // requests are recorded in the cassette, no more real HTTP request must be made to run the tests. // // It is important to call add a `defer recorder.Stop()` so the given cassette files are correctly // closed and saved after the requests. // // To update the cassette files, add `SDK_UPDATE_CASSETTES=true` to the environment variables. // When updating cassettes, make sure your Scaleway credentials are set in your config or in the // variables `SCW_ACCESS_KEY` and `SCW_SECRET_KEY`. func CreateRecordedScwClient(cassetteName string) (*scw.Client, *recorder.Recorder, error) { UpdateCassette := IsUpdatingCassette() var activeProfile *scw.Profile recorderMode := recorder.ModeReplaying if UpdateCassette { recorderMode = recorder.ModeRecording config, err := scw.LoadConfig() if err != nil { return nil, nil, err } activeProfile, err = config.GetActiveProfile() if err != nil { return nil, nil, err } } // Setup recorder and scw client r, err := recorder.NewAsMode(fmt.Sprintf("testdata/%s", cassetteName), recorderMode, nil) if err != nil { return nil, nil, err } // Add a filter which removes Authorization headers from all requests: r.AddFilter(func(i *cassette.Interaction) error { delete(i.Request.Headers, "x-auth-token") delete(i.Request.Headers, "X-Auth-Token") if UpdateCassette { secretKey := *activeProfile.SecretKey if i != nil && strings.Contains(fmt.Sprintf("%v", *i), secretKey) { panic(errors.New("found secret key in cassette")) } } return nil }) // Create new http.Client where transport is the recorder httpClient := &http.Client{Transport: r} var client *scw.Client if UpdateCassette { // When updating the recoreded test requests, we need the access key and secret key. client, err = scw.NewClient( scw.WithHTTPClient(httpClient), scw.WithProfile(activeProfile), scw.WithEnv(), scw.WithDefaultRegion(scw.RegionFrPar), scw.WithDefaultZone(scw.ZoneFrPar1), ) if err != nil { return nil, nil, err } } else { // No need for auth when using cassette client, err = scw.NewClient( scw.WithHTTPClient(httpClient), scw.WithDefaultRegion(scw.RegionFrPar), scw.WithDefaultZone(scw.ZoneFrPar1), ) if err != nil { return nil, nil, err } } return client, r, nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/internal/testhelpers/test_helpers.go000066400000000000000000000017431456366605600314710ustar00rootroot00000000000000package testhelpers import ( "fmt" "path/filepath" "reflect" "runtime" "testing" ) // Assert fails the test if the condition is false. func Assert(tb testing.TB, condition bool, msg string, v ...interface{}) { if !condition { _, file, line, _ := runtime.Caller(1) fmt.Printf("\033[31m%s:%d: "+msg+"\033[39m\n\n", append([]interface{}{filepath.Base(file), line}, v...)...) tb.FailNow() } } // AssertNoError fails the test if an err is not nil. func AssertNoError(tb testing.TB, err error) { if err != nil { _, file, line, _ := runtime.Caller(1) fmt.Printf("\033[31m%s:%d: unexpected error: %s\033[39m\n\n", filepath.Base(file), line, err.Error()) tb.FailNow() } } // Equals fails the test if exp is not equal to act. func Equals(tb testing.TB, exp, act interface{}) { if !reflect.DeepEqual(exp, act) { _, file, line, _ := runtime.Caller(1) fmt.Printf("\033[31m%s:%d:\n\n\texp: %#v\n\n\tgot: %#v\033[39m\n\n", filepath.Base(file), line, exp, act) tb.FailNow() } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/logger/000077500000000000000000000000001456366605600235355ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/logger/default_logger.go000066400000000000000000000063701456366605600270550ustar00rootroot00000000000000package logger import ( "fmt" "io" "io/ioutil" "log" "os" "strconv" ) var DefaultLogger = newLogger(os.Stderr, LogLevelWarning) var logger Logger = DefaultLogger // loggerT is the default logger used by scaleway-sdk-go. type loggerT struct { m [4]*log.Logger v LogLevel } // Init create a new default logger. // Not mutex-protected, should be called before any scaleway-sdk-go functions. func (g *loggerT) Init(w io.Writer, level LogLevel) { g.m = newLogger(w, level).m g.v = level } // Debugf logs to the DEBUG log. Arguments are handled in the manner of fmt.Printf. func Debugf(format string, args ...interface{}) { logger.Debugf(format, args...) } func (g *loggerT) Debugf(format string, args ...interface{}) { g.m[LogLevelDebug].Printf(format, args...) } // Infof logs to the INFO log. Arguments are handled in the manner of fmt.Printf. func Infof(format string, args ...interface{}) { logger.Infof(format, args...) } func (g *loggerT) Infof(format string, args ...interface{}) { g.m[LogLevelInfo].Printf(format, args...) } // Warningf logs to the WARNING log. Arguments are handled in the manner of fmt.Printf. func Warningf(format string, args ...interface{}) { logger.Warningf(format, args...) } func (g *loggerT) Warningf(format string, args ...interface{}) { g.m[LogLevelWarning].Printf(format, args...) } // Errorf logs to the ERROR log. Arguments are handled in the manner of fmt.Printf. func Errorf(format string, args ...interface{}) { logger.Errorf(format, args...) } func (g *loggerT) Errorf(format string, args ...interface{}) { g.m[LogLevelError].Printf(format, args...) } // ShouldLog reports whether verbosity level l is at least the requested verbose level. func ShouldLog(level LogLevel) bool { return logger.ShouldLog(level) } func (g *loggerT) ShouldLog(level LogLevel) bool { return level >= g.v } func isEnabled(envKey string) bool { env, exist := os.LookupEnv(envKey) if !exist { return false } value, err := strconv.ParseBool(env) if err != nil { fmt.Fprintf(os.Stderr, "ERROR: environment variable %s has invalid boolean value\n", envKey) } return value } // newLogger creates a logger to be used as default logger. // All logs are written to w. func newLogger(w io.Writer, level LogLevel) *loggerT { errorW := ioutil.Discard warningW := ioutil.Discard infoW := ioutil.Discard debugW := ioutil.Discard if isEnabled(DebugEnv) { level = LogLevelDebug } switch level { case LogLevelDebug: debugW = w case LogLevelInfo: infoW = w case LogLevelWarning: warningW = w case LogLevelError: errorW = w } // Error logs will be written to errorW, warningW, infoW and debugW. // Warning logs will be written to warningW, infoW and debugW. // Info logs will be written to infoW and debugW. // Debug logs will be written to debugW. var m [4]*log.Logger m[LogLevelError] = log.New(io.MultiWriter(debugW, infoW, warningW, errorW), severityName[LogLevelError]+": ", log.LstdFlags) m[LogLevelWarning] = log.New(io.MultiWriter(debugW, infoW, warningW), severityName[LogLevelWarning]+": ", log.LstdFlags) m[LogLevelInfo] = log.New(io.MultiWriter(debugW, infoW), severityName[LogLevelInfo]+": ", log.LstdFlags) m[LogLevelDebug] = log.New(debugW, severityName[LogLevelDebug]+": ", log.LstdFlags) return &loggerT{m: m, v: level} } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/logger/logger.go000066400000000000000000000031641456366605600253470ustar00rootroot00000000000000package logger import "os" type LogLevel int const DebugEnv = "SCW_DEBUG" const ( // LogLevelDebug indicates Debug severity. LogLevelDebug LogLevel = iota // LogLevelInfo indicates Info severity. LogLevelInfo // LogLevelWarning indicates Warning severity. LogLevelWarning // LogLevelError indicates Error severity. LogLevelError ) // severityName contains the string representation of each severity. var severityName = []string{ LogLevelDebug: "DEBUG", LogLevelInfo: "INFO", LogLevelWarning: "WARNING", LogLevelError: "ERROR", } // Logger does underlying logging work for scaleway-sdk-go. type Logger interface { // Debugf logs to DEBUG log. Arguments are handled in the manner of fmt.Printf. Debugf(format string, args ...interface{}) // Infof logs to INFO log. Arguments are handled in the manner of fmt.Printf. Infof(format string, args ...interface{}) // Warningf logs to WARNING log. Arguments are handled in the manner of fmt.Printf. Warningf(format string, args ...interface{}) // Errorf logs to ERROR log. Arguments are handled in the manner of fmt.Printf. Errorf(format string, args ...interface{}) // ShouldLog reports whether verbosity level l is at least the requested verbose level. ShouldLog(level LogLevel) bool } // SetLogger sets logger that is used in by the SDK. // Not mutex-protected, should be called before any scaleway-sdk-go functions. func SetLogger(l Logger) { logger = l } // EnableDebugMode enable LogLevelDebug on the default logger. // If a custom logger was provided with SetLogger this method has no effect. func EnableDebugMode() { DefaultLogger.Init(os.Stderr, LogLevelDebug) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/logger/logger_test.go000066400000000000000000000034121456366605600264020ustar00rootroot00000000000000package logger import ( "bytes" "os" "strings" "testing" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" ) var ( expectedErrorf = "ERROR: cd" expectedWarningf = "WARNING: ij" expectedInfof = "INFO: op" expectedDebugf = "DEBUG: uv" ) func TestDebug(t *testing.T) { buf := &bytes.Buffer{} logThings(newLogger(buf, LogLevelDebug)) testThings(t, []string{ expectedErrorf, expectedWarningf, expectedInfof, expectedDebugf, }, buf.String()) } func TestInfo(t *testing.T) { buf := &bytes.Buffer{} logThings(newLogger(buf, LogLevelInfo)) testThings(t, []string{ expectedErrorf, expectedWarningf, expectedInfof, }, buf.String()) } func TestWarning(t *testing.T) { buf := &bytes.Buffer{} logThings(newLogger(buf, LogLevelWarning)) testThings(t, []string{ expectedErrorf, expectedWarningf, }, buf.String()) } func TestError(t *testing.T) { buf := &bytes.Buffer{} logThings(newLogger(buf, LogLevelError)) testThings(t, []string{ expectedErrorf, }, buf.String()) } func TestEnableDebugMode(t *testing.T) { _defaultLogger := DefaultLogger DefaultLogger = newLogger(os.Stderr, LogLevelWarning) EnableDebugMode() testhelpers.Equals(t, true, DefaultLogger.ShouldLog(LogLevelDebug)) DefaultLogger = _defaultLogger } func testThings(t *testing.T, expectedEvents []string, actualOutput string) { lines := strings.Split(actualOutput, "\n") for i, line := range lines[:len(lines)-1] { // last line is always empty tmp := strings.Split(line, " ") actualMessage := strings.Join(append([]string{tmp[0]}, tmp[3:]...), " ") // date and hour is not kept testhelpers.Equals(t, expectedEvents[i], actualMessage) } } func logThings(log Logger) { log.Errorf("c%s", "d") log.Warningf("i%s", "j") log.Infof("o%s", "p") log.Debugf("u%s", "v") } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/namegenerator/000077500000000000000000000000001456366605600251055ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/namegenerator/name_generator.go000066400000000000000000001430721456366605600304310ustar00rootroot00000000000000// Source: github.com/docker/docker/pkg/namesgenerator package namegenerator import ( "math/rand" "strings" "time" ) var r *rand.Rand func init() { source := rand.NewSource(time.Now().UnixNano()) r = rand.New(source) } var ( left = [...]string{ "admiring", "adoring", "affectionate", "agitated", "amazing", "angry", "awesome", "beautiful", "blissful", "bold", "boring", "brave", "busy", "charming", "clever", "cocky", "cool", "compassionate", "competent", "condescending", "confident", "cranky", "crazy", "dazzling", "determined", "distracted", "dreamy", "eager", "ecstatic", "elastic", "elated", "elegant", "eloquent", "epic", "exciting", "fervent", "festive", "flamboyant", "focused", "friendly", "frosty", "funny", "gallant", "gifted", "goofy", "gracious", "great", "happy", "hardcore", "heuristic", "hopeful", "hungry", "infallible", "inspiring", "interesting", "intelligent", "jolly", "jovial", "keen", "kind", "laughing", "loving", "lucid", "magical", "mystifying", "modest", "musing", "naughty", "nervous", "nice", "nifty", "nostalgic", "objective", "optimistic", "peaceful", "pedantic", "pensive", "practical", "priceless", "quirky", "quizzical", "recursing", "relaxed", "reverent", "romantic", "sad", "serene", "sharp", "silly", "sleepy", "stoic", "strange", "stupefied", "suspicious", "sweet", "tender", "thirsty", "trusting", "unruffled", "upbeat", "vibrant", "vigilant", "vigorous", "wizardly", "wonderful", "xenodochial", "youthful", "zealous", "zen", } // Docker, starting from 0.7.x, generates names from notable scientists and hackers. // Please, for any amazing man that you add to the list, consider adding an equally amazing woman to it, and vice versa. right = [...]string{ // Muhammad ibn Jābir al-Ḥarrānī al-Battānī was a founding father of astronomy. https://en.wikipedia.org/wiki/Mu%E1%B8%A5ammad_ibn_J%C4%81bir_al-%E1%B8%A4arr%C4%81n%C4%AB_al-Batt%C4%81n%C4%AB "albattani", // Frances E. Allen, became the first female IBM Fellow in 1989. In 2006, she became the first female recipient of the ACM's Turing Award. https://en.wikipedia.org/wiki/Frances_E._Allen "allen", // June Almeida - Scottish virologist who took the first pictures of the rubella virus - https://en.wikipedia.org/wiki/June_Almeida "almeida", // Kathleen Antonelli, American computer programmer and one of the six original programmers of the ENIAC - https://en.wikipedia.org/wiki/Kathleen_Antonelli "antonelli", // Maria Gaetana Agnesi - Italian mathematician, philosopher, theologian and humanitarian. She was the first woman to write a mathematics handbook and the first woman appointed as a Mathematics Professor at a University. https://en.wikipedia.org/wiki/Maria_Gaetana_Agnesi "agnesi", // Archimedes was a physicist, engineer and mathematician who invented too many things to list them here. https://en.wikipedia.org/wiki/Archimedes "archimedes", // Maria Ardinghelli - Italian translator, mathematician and physicist - https://en.wikipedia.org/wiki/Maria_Ardinghelli "ardinghelli", // Aryabhata - Ancient Indian mathematician-astronomer during 476-550 CE https://en.wikipedia.org/wiki/Aryabhata "aryabhata", // Wanda Austin - Wanda Austin is the President and CEO of The Aerospace Corporation, a leading architect for the US security space programs. https://en.wikipedia.org/wiki/Wanda_Austin "austin", // Charles Babbage invented the concept of a programmable computer. https://en.wikipedia.org/wiki/Charles_Babbage. "babbage", // Stefan Banach - Polish mathematician, was one of the founders of modern functional analysis. https://en.wikipedia.org/wiki/Stefan_Banach "banach", // Buckaroo Banzai and his mentor Dr. Hikita perfectd the "oscillation overthruster", a device that allows one to pass through solid matter. - https://en.wikipedia.org/wiki/The_Adventures_of_Buckaroo_Banzai_Across_the_8th_Dimension "banzai", // John Bardeen co-invented the transistor - https://en.wikipedia.org/wiki/John_Bardeen "bardeen", // Jean Bartik, born Betty Jean Jennings, was one of the original programmers for the ENIAC computer. https://en.wikipedia.org/wiki/Jean_Bartik "bartik", // Laura Bassi, the world's first female professor https://en.wikipedia.org/wiki/Laura_Bassi "bassi", // Hugh Beaver, British engineer, founder of the Guinness Book of World Records https://en.wikipedia.org/wiki/Hugh_Beaver "beaver", // Alexander Graham Bell - an eminent Scottish-born scientist, inventor, engineer and innovator who is credited with inventing the first practical telephone - https://en.wikipedia.org/wiki/Alexander_Graham_Bell "bell", // Karl Friedrich Benz - a German automobile engineer. Inventor of the first practical motorcar. https://en.wikipedia.org/wiki/Karl_Benz "benz", // Homi J Bhabha - was an Indian nuclear physicist, founding director, and professor of physics at the Tata Institute of Fundamental Research. Colloquially known as "father of Indian nuclear programme"- https://en.wikipedia.org/wiki/Homi_J._Bhabha "bhabha", // Bhaskara II - Ancient Indian mathematician-astronomer whose work on calculus predates Newton and Leibniz by over half a millennium - https://en.wikipedia.org/wiki/Bh%C4%81skara_II#Calculus "bhaskara", // Sue Black - British computer scientist and campaigner. She has been instrumental in saving Bletchley Park, the site of World War II codebreaking - https://en.wikipedia.org/wiki/Sue_Black_(computer_scientist) "black", // Elizabeth Helen Blackburn - Australian-American Nobel laureate; best known for co-discovering telomerase. https://en.wikipedia.org/wiki/Elizabeth_Blackburn "blackburn", // Elizabeth Blackwell - American doctor and first American woman to receive a medical degree - https://en.wikipedia.org/wiki/Elizabeth_Blackwell "blackwell", // Niels Bohr is the father of quantum theory. https://en.wikipedia.org/wiki/Niels_Bohr. "bohr", // Kathleen Booth, she's credited with writing the first assembly language. https://en.wikipedia.org/wiki/Kathleen_Booth "booth", // Anita Borg - Anita Borg was the founding director of the Institute for Women and Technology (IWT). https://en.wikipedia.org/wiki/Anita_Borg "borg", // Satyendra Nath Bose - He provided the foundation for Bose–Einstein statistics and the theory of the Bose–Einstein condensate. - https://en.wikipedia.org/wiki/Satyendra_Nath_Bose "bose", // Katherine Louise Bouman is an imaging scientist and Assistant Professor of Computer Science at the California Institute of Technology. She researches computational methods for imaging, and developed an algorithm that made possible the picture first visualization of a black hole using the Event Horizon Telescope. - https://en.wikipedia.org/wiki/Katie_Bouman "bouman", // Evelyn Boyd Granville - She was one of the first African-American woman to receive a Ph.D. in mathematics; she earned it in 1949 from Yale University. https://en.wikipedia.org/wiki/Evelyn_Boyd_Granville "boyd", // Brahmagupta - Ancient Indian mathematician during 598-670 CE who gave rules to compute with zero - https://en.wikipedia.org/wiki/Brahmagupta#Zero "brahmagupta", // Walter Houser Brattain co-invented the transistor - https://en.wikipedia.org/wiki/Walter_Houser_Brattain "brattain", // Emmett Brown invented time travel. https://en.wikipedia.org/wiki/Emmett_Brown (thanks Brian Goff) "brown", // Linda Brown Buck - American biologist and Nobel laureate best known for her genetic and molecular analyses of the mechanisms of smell. https://en.wikipedia.org/wiki/Linda_B._Buck "buck", // Dame Susan Jocelyn Bell Burnell - Northern Irish astrophysicist who discovered radio pulsars and was the first to analyse them. https://en.wikipedia.org/wiki/Jocelyn_Bell_Burnell "burnell", // Annie Jump Cannon - pioneering female astronomer who classified hundreds of thousands of stars and created the system we use to understand stars today. https://en.wikipedia.org/wiki/Annie_Jump_Cannon "cannon", // Rachel Carson - American marine biologist and conservationist, her book Silent Spring and other writings are credited with advancing the global environmental movement. https://en.wikipedia.org/wiki/Rachel_Carson "carson", // Dame Mary Lucy Cartwright - British mathematician who was one of the first to study what is now known as chaos theory. Also known for Cartwright's theorem which finds applications in signal processing. https://en.wikipedia.org/wiki/Mary_Cartwright "cartwright", // Vinton Gray Cerf - American Internet pioneer, recognised as one of "the fathers of the Internet". With Robert Elliot Kahn, he designed TCP and IP, the primary data communication protocols of the Internet and other computer networks. https://en.wikipedia.org/wiki/Vint_Cerf "cerf", // Subrahmanyan Chandrasekhar - Astrophysicist known for his mathematical theory on different stages and evolution in structures of the stars. He has won nobel prize for physics - https://en.wikipedia.org/wiki/Subrahmanyan_Chandrasekhar "chandrasekhar", // Sergey Alexeyevich Chaplygin (Russian: Серге́й Алексе́евич Чаплы́гин; April 5, 1869 – October 8, 1942) was a Russian and Soviet physicist, mathematician, and mechanical engineer. He is known for mathematical formulas such as Chaplygin's equation and for a hypothetical substance in cosmology called Chaplygin gas, named after him. https://en.wikipedia.org/wiki/Sergey_Chaplygin "chaplygin", // Émilie du Châtelet - French natural philosopher, mathematician, physicist, and author during the early 1730s, known for her translation of and commentary on Isaac Newton's book Principia containing basic laws of physics. https://en.wikipedia.org/wiki/%C3%89milie_du_Ch%C3%A2telet "chatelet", // Asima Chatterjee was an Indian organic chemist noted for her research on vinca alkaloids, development of drugs for treatment of epilepsy and malaria - https://en.wikipedia.org/wiki/Asima_Chatterjee "chatterjee", // Pafnuty Chebyshev - Russian mathematician. He is known fo his works on probability, statistics, mechanics, analytical geometry and number theory https://en.wikipedia.org/wiki/Pafnuty_Chebyshev "chebyshev", // Bram Cohen - American computer programmer and author of the BitTorrent peer-to-peer protocol. https://en.wikipedia.org/wiki/Bram_Cohen "cohen", // David Lee Chaum - American computer scientist and cryptographer. Known for his seminal contributions in the field of anonymous communication. https://en.wikipedia.org/wiki/David_Chaum "chaum", // Joan Clarke - Bletchley Park code breaker during the Second World War who pioneered techniques that remained top secret for decades. Also an accomplished numismatist https://en.wikipedia.org/wiki/Joan_Clarke "clarke", // Jane Colden - American botanist widely considered the first female American botanist - https://en.wikipedia.org/wiki/Jane_Colden "colden", // Gerty Theresa Cori - American biochemist who became the third woman—and first American woman—to win a Nobel Prize in science, and the first woman to be awarded the Nobel Prize in Physiology or Medicine. Cori was born in Prague. https://en.wikipedia.org/wiki/Gerty_Cori "cori", // Seymour Roger Cray was an American electrical engineer and supercomputer architect who designed a series of computers that were the fastest in the world for decades. https://en.wikipedia.org/wiki/Seymour_Cray "cray", // This entry reflects a husband and wife team who worked together: // Joan Curran was a Welsh scientist who developed radar and invented chaff, a radar countermeasure. https://en.wikipedia.org/wiki/Joan_Curran // Samuel Curran was an Irish physicist who worked alongside his wife during WWII and invented the proximity fuse. https://en.wikipedia.org/wiki/Samuel_Curran "curran", // Marie Curie discovered radioactivity. https://en.wikipedia.org/wiki/Marie_Curie. "curie", // Charles Darwin established the principles of natural evolution. https://en.wikipedia.org/wiki/Charles_Darwin. "darwin", // Leonardo Da Vinci invented too many things to list here. https://en.wikipedia.org/wiki/Leonardo_da_Vinci. "davinci", // A. K. (Alexander Keewatin) Dewdney, Canadian mathematician, computer scientist, author and filmmaker. Contributor to Scientific American's "Computer Recreations" from 1984 to 1991. Author of Core War (program), The Planiverse, The Armchair Universe, The Magic Machine, The New Turing Omnibus, and more. https://en.wikipedia.org/wiki/Alexander_Dewdney "dewdney", // Satish Dhawan - Indian mathematician and aerospace engineer, known for leading the successful and indigenous development of the Indian space programme. https://en.wikipedia.org/wiki/Satish_Dhawan "dhawan", // Bailey Whitfield Diffie - American cryptographer and one of the pioneers of public-key cryptography. https://en.wikipedia.org/wiki/Whitfield_Diffie "diffie", // Edsger Wybe Dijkstra was a Dutch computer scientist and mathematical scientist. https://en.wikipedia.org/wiki/Edsger_W._Dijkstra. "dijkstra", // Paul Adrien Maurice Dirac - English theoretical physicist who made fundamental contributions to the early development of both quantum mechanics and quantum electrodynamics. https://en.wikipedia.org/wiki/Paul_Dirac "dirac", // Agnes Meyer Driscoll - American cryptanalyst during World Wars I and II who successfully cryptanalysed a number of Japanese ciphers. She was also the co-developer of one of the cipher machines of the US Navy, the CM. https://en.wikipedia.org/wiki/Agnes_Meyer_Driscoll "driscoll", // Donna Dubinsky - played an integral role in the development of personal digital assistants (PDAs) serving as CEO of Palm, Inc. and co-founding Handspring. https://en.wikipedia.org/wiki/Donna_Dubinsky "dubinsky", // Annie Easley - She was a leading member of the team which developed software for the Centaur rocket stage and one of the first African-Americans in her field. https://en.wikipedia.org/wiki/Annie_Easley "easley", // Thomas Alva Edison, prolific inventor https://en.wikipedia.org/wiki/Thomas_Edison "edison", // Albert Einstein invented the general theory of relativity. https://en.wikipedia.org/wiki/Albert_Einstein "einstein", // Alexandra Asanovna Elbakyan (Russian: Алекса́ндра Аса́новна Элбакя́н) is a Kazakhstani graduate student, computer programmer, internet pirate in hiding, and the creator of the site Sci-Hub. Nature has listed her in 2016 in the top ten people that mattered in science, and Ars Technica has compared her to Aaron Swartz. - https://en.wikipedia.org/wiki/Alexandra_Elbakyan "elbakyan", // Taher A. ElGamal - Egyptian cryptographer best known for the ElGamal discrete log cryptosystem and the ElGamal digital signature scheme. https://en.wikipedia.org/wiki/Taher_Elgamal "elgamal", // Gertrude Elion - American biochemist, pharmacologist and the 1988 recipient of the Nobel Prize in Medicine - https://en.wikipedia.org/wiki/Gertrude_Elion "elion", // James Henry Ellis - British engineer and cryptographer employed by the GCHQ. Best known for conceiving for the first time, the idea of public-key cryptography. https://en.wikipedia.org/wiki/James_H._Ellis "ellis", // Douglas Engelbart gave the mother of all demos: https://en.wikipedia.org/wiki/Douglas_Engelbart "engelbart", // Euclid invented geometry. https://en.wikipedia.org/wiki/Euclid "euclid", // Leonhard Euler invented large parts of modern mathematics. https://de.wikipedia.org/wiki/Leonhard_Euler "euler", // Michael Faraday - British scientist who contributed to the study of electromagnetism and electrochemistry. https://en.wikipedia.org/wiki/Michael_Faraday "faraday", // Horst Feistel - German-born American cryptographer who was one of the earliest non-government researchers to study the design and theory of block ciphers. Co-developer of DES and Lucifer. Feistel networks, a symmetric structure used in the construction of block ciphers are named after him. https://en.wikipedia.org/wiki/Horst_Feistel "feistel", // Pierre de Fermat pioneered several aspects of modern mathematics. https://en.wikipedia.org/wiki/Pierre_de_Fermat "fermat", // Enrico Fermi invented the first nuclear reactor. https://en.wikipedia.org/wiki/Enrico_Fermi. "fermi", // Richard Feynman was a key contributor to quantum mechanics and particle physics. https://en.wikipedia.org/wiki/Richard_Feynman "feynman", // Benjamin Franklin is famous for his experiments in electricity and the invention of the lightning rod. "franklin", // Yuri Alekseyevich Gagarin - Soviet pilot and cosmonaut, best known as the first human to journey into outer space. https://en.wikipedia.org/wiki/Yuri_Gagarin "gagarin", // Galileo was a founding father of modern astronomy, and faced politics and obscurantism to establish scientific truth. https://en.wikipedia.org/wiki/Galileo_Galilei "galileo", // Évariste Galois - French mathematician whose work laid the foundations of Galois theory and group theory, two major branches of abstract algebra, and the subfield of Galois connections, all while still in his late teens. https://en.wikipedia.org/wiki/%C3%89variste_Galois "galois", // Kadambini Ganguly - Indian physician, known for being the first South Asian female physician, trained in western medicine, to graduate in South Asia. https://en.wikipedia.org/wiki/Kadambini_Ganguly "ganguly", // William Henry "Bill" Gates III is an American business magnate, philanthropist, investor, computer programmer, and inventor. https://en.wikipedia.org/wiki/Bill_Gates "gates", // Johann Carl Friedrich Gauss - German mathematician who made significant contributions to many fields, including number theory, algebra, statistics, analysis, differential geometry, geodesy, geophysics, mechanics, electrostatics, magnetic fields, astronomy, matrix theory, and optics. https://en.wikipedia.org/wiki/Carl_Friedrich_Gauss "gauss", // Marie-Sophie Germain - French mathematician, physicist and philosopher. Known for her work on elasticity theory, number theory and philosophy. https://en.wikipedia.org/wiki/Sophie_Germain "germain", // Adele Goldberg, was one of the designers and developers of the Smalltalk language. https://en.wikipedia.org/wiki/Adele_Goldberg_(computer_scientist) "goldberg", // Adele Goldstine, born Adele Katz, wrote the complete technical description for the first electronic digital computer, ENIAC. https://en.wikipedia.org/wiki/Adele_Goldstine "goldstine", // Shafi Goldwasser is a computer scientist known for creating theoretical foundations of modern cryptography. Winner of 2012 ACM Turing Award. https://en.wikipedia.org/wiki/Shafi_Goldwasser "goldwasser", // James Golick, all around gangster. "golick", // Jane Goodall - British primatologist, ethologist, and anthropologist who is considered to be the world's foremost expert on chimpanzees - https://en.wikipedia.org/wiki/Jane_Goodall "goodall", // Stephen Jay Gould was was an American paleontologist, evolutionary biologist, and historian of science. He is most famous for the theory of punctuated equilibrium - https://en.wikipedia.org/wiki/Stephen_Jay_Gould "gould", // Carolyn Widney Greider - American molecular biologist and joint winner of the 2009 Nobel Prize for Physiology or Medicine for the discovery of telomerase. https://en.wikipedia.org/wiki/Carol_W._Greider "greider", // Alexander Grothendieck - German-born French mathematician who became a leading figure in the creation of modern algebraic geometry. https://en.wikipedia.org/wiki/Alexander_Grothendieck "grothendieck", // Lois Haibt - American computer scientist, part of the team at IBM that developed FORTRAN - https://en.wikipedia.org/wiki/Lois_Haibt "haibt", // Margaret Hamilton - Director of the Software Engineering Division of the MIT Instrumentation Laboratory, which developed on-board flight software for the Apollo space program. https://en.wikipedia.org/wiki/Margaret_Hamilton_(scientist) "hamilton", // Caroline Harriet Haslett - English electrical engineer, electricity industry administrator and champion of women's rights. Co-author of British Standard 1363 that specifies AC power plugs and sockets used across the United Kingdom (which is widely considered as one of the safest designs). https://en.wikipedia.org/wiki/Caroline_Haslett "haslett", // Stephen Hawking pioneered the field of cosmology by combining general relativity and quantum mechanics. https://en.wikipedia.org/wiki/Stephen_Hawking "hawking", // Martin Edward Hellman - American cryptologist, best known for his invention of public-key cryptography in co-operation with Whitfield Diffie and Ralph Merkle. https://en.wikipedia.org/wiki/Martin_Hellman "hellman", // Werner Heisenberg was a founding father of quantum mechanics. https://en.wikipedia.org/wiki/Werner_Heisenberg "heisenberg", // Grete Hermann was a German philosopher noted for her philosophical work on the foundations of quantum mechanics. https://en.wikipedia.org/wiki/Grete_Hermann "hermann", // Caroline Lucretia Herschel - German astronomer and discoverer of several comets. https://en.wikipedia.org/wiki/Caroline_Herschel "herschel", // Heinrich Rudolf Hertz - German physicist who first conclusively proved the existence of the electromagnetic waves. https://en.wikipedia.org/wiki/Heinrich_Hertz "hertz", // Jaroslav Heyrovský was the inventor of the polarographic method, father of the electroanalytical method, and recipient of the Nobel Prize in 1959. His main field of work was polarography. https://en.wikipedia.org/wiki/Jaroslav_Heyrovsk%C3%BD "heyrovsky", // Dorothy Hodgkin was a British biochemist, credited with the development of protein crystallography. She was awarded the Nobel Prize in Chemistry in 1964. https://en.wikipedia.org/wiki/Dorothy_Hodgkin "hodgkin", // Douglas R. Hofstadter is an American professor of cognitive science and author of the Pulitzer Prize and American Book Award-winning work Goedel, Escher, Bach: An Eternal Golden Braid in 1979. A mind-bending work which coined Hofstadter's Law: "It always takes longer than you expect, even when you take into account Hofstadter's Law." https://en.wikipedia.org/wiki/Douglas_Hofstadter "hofstadter", // Erna Schneider Hoover revolutionized modern communication by inventing a computerized telephone switching method. https://en.wikipedia.org/wiki/Erna_Schneider_Hoover "hoover", // Grace Hopper developed the first compiler for a computer programming language and is credited with popularizing the term "debugging" for fixing computer glitches. https://en.wikipedia.org/wiki/Grace_Hopper "hopper", // Frances Hugle, she was an American scientist, engineer, and inventor who contributed to the understanding of semiconductors, integrated circuitry, and the unique electrical principles of microscopic materials. https://en.wikipedia.org/wiki/Frances_Hugle "hugle", // Hypatia - Greek Alexandrine Neoplatonist philosopher in Egypt who was one of the earliest mothers of mathematics - https://en.wikipedia.org/wiki/Hypatia "hypatia", // Teruko Ishizaka - Japanese scientist and immunologist who co-discovered the antibody class Immunoglobulin E. https://en.wikipedia.org/wiki/Teruko_Ishizaka "ishizaka", // Mary Jackson, American mathematician and aerospace engineer who earned the highest title within NASA's engineering department - https://en.wikipedia.org/wiki/Mary_Jackson_(engineer) "jackson", // Yeong-Sil Jang was a Korean scientist and astronomer during the Joseon Dynasty; he invented the first metal printing press and water gauge. https://en.wikipedia.org/wiki/Jang_Yeong-sil "jang", // Betty Jennings - one of the original programmers of the ENIAC. https://en.wikipedia.org/wiki/ENIAC - https://en.wikipedia.org/wiki/Jean_Bartik "jennings", // Mary Lou Jepsen, was the founder and chief technology officer of One Laptop Per Child (OLPC), and the founder of Pixel Qi. https://en.wikipedia.org/wiki/Mary_Lou_Jepsen "jepsen", // Katherine Coleman Goble Johnson - American physicist and mathematician contributed to the NASA. https://en.wikipedia.org/wiki/Katherine_Johnson "johnson", // Irène Joliot-Curie - French scientist who was awarded the Nobel Prize for Chemistry in 1935. Daughter of Marie and Pierre Curie. https://en.wikipedia.org/wiki/Ir%C3%A8ne_Joliot-Curie "joliot", // Karen Spärck Jones came up with the concept of inverse document frequency, which is used in most search engines today. https://en.wikipedia.org/wiki/Karen_Sp%C3%A4rck_Jones "jones", // A. P. J. Abdul Kalam - is an Indian scientist aka Missile Man of India for his work on the development of ballistic missile and launch vehicle technology - https://en.wikipedia.org/wiki/A._P._J._Abdul_Kalam "kalam", // Sergey Petrovich Kapitsa (Russian: Серге́й Петро́вич Капи́ца; 14 February 1928 – 14 August 2012) was a Russian physicist and demographer. He was best known as host of the popular and long-running Russian scientific TV show, Evident, but Incredible. His father was the Nobel laureate Soviet-era physicist Pyotr Kapitsa, and his brother was the geographer and Antarctic explorer Andrey Kapitsa. - https://en.wikipedia.org/wiki/Sergey_Kapitsa "kapitsa", // Susan Kare, created the icons and many of the interface elements for the original Apple Macintosh in the 1980s, and was an original employee of NeXT, working as the Creative Director. https://en.wikipedia.org/wiki/Susan_Kare "kare", // Mstislav Keldysh - a Soviet scientist in the field of mathematics and mechanics, academician of the USSR Academy of Sciences (1946), President of the USSR Academy of Sciences (1961–1975), three times Hero of Socialist Labor (1956, 1961, 1971), fellow of the Royal Society of Edinburgh (1968). https://en.wikipedia.org/wiki/Mstislav_Keldysh "keldysh", // Mary Kenneth Keller, Sister Mary Kenneth Keller became the first American woman to earn a PhD in Computer Science in 1965. https://en.wikipedia.org/wiki/Mary_Kenneth_Keller "keller", // Johannes Kepler, German astronomer known for his three laws of planetary motion - https://en.wikipedia.org/wiki/Johannes_Kepler "kepler", // Omar Khayyam - Persian mathematician, astronomer and poet. Known for his work on the classification and solution of cubic equations, for his contribution to the understanding of Euclid's fifth postulate and for computing the length of a year very accurately. https://en.wikipedia.org/wiki/Omar_Khayyam "khayyam", // Har Gobind Khorana - Indian-American biochemist who shared the 1968 Nobel Prize for Physiology - https://en.wikipedia.org/wiki/Har_Gobind_Khorana "khorana", // Jack Kilby invented silicone integrated circuits and gave Silicon Valley its name. - https://en.wikipedia.org/wiki/Jack_Kilby "kilby", // Maria Kirch - German astronomer and first woman to discover a comet - https://en.wikipedia.org/wiki/Maria_Margarethe_Kirch "kirch", // Donald Knuth - American computer scientist, author of "The Art of Computer Programming" and creator of the TeX typesetting system. https://en.wikipedia.org/wiki/Donald_Knuth "knuth", // Sophie Kowalevski - Russian mathematician responsible for important original contributions to analysis, differential equations and mechanics - https://en.wikipedia.org/wiki/Sofia_Kovalevskaya "kowalevski", // Marie-Jeanne de Lalande - French astronomer, mathematician and cataloguer of stars - https://en.wikipedia.org/wiki/Marie-Jeanne_de_Lalande "lalande", // Hedy Lamarr - Actress and inventor. The principles of her work are now incorporated into modern Wi-Fi, CDMA and Bluetooth technology. https://en.wikipedia.org/wiki/Hedy_Lamarr "lamarr", // Leslie B. Lamport - American computer scientist. Lamport is best known for his seminal work in distributed systems and was the winner of the 2013 Turing Award. https://en.wikipedia.org/wiki/Leslie_Lamport "lamport", // Mary Leakey - British paleoanthropologist who discovered the first fossilized Proconsul skull - https://en.wikipedia.org/wiki/Mary_Leakey "leakey", // Henrietta Swan Leavitt - she was an American astronomer who discovered the relation between the luminosity and the period of Cepheid variable stars. https://en.wikipedia.org/wiki/Henrietta_Swan_Leavitt "leavitt", // Esther Miriam Zimmer Lederberg - American microbiologist and a pioneer of bacterial genetics. https://en.wikipedia.org/wiki/Esther_Lederberg "lederberg", // Inge Lehmann - Danish seismologist and geophysicist. Known for discovering in 1936 that the Earth has a solid inner core inside a molten outer core. https://en.wikipedia.org/wiki/Inge_Lehmann "lehmann", // Daniel Lewin - Mathematician, Akamai co-founder, soldier, 9/11 victim-- Developed optimization techniques for routing traffic on the internet. Died attempting to stop the 9-11 hijackers. https://en.wikipedia.org/wiki/Daniel_Lewin "lewin", // Ruth Lichterman - one of the original programmers of the ENIAC. https://en.wikipedia.org/wiki/ENIAC - https://en.wikipedia.org/wiki/Ruth_Teitelbaum "lichterman", // Barbara Liskov - co-developed the Liskov substitution principle. Liskov was also the winner of the Turing Prize in 2008. - https://en.wikipedia.org/wiki/Barbara_Liskov "liskov", // Ada Lovelace invented the first algorithm. https://en.wikipedia.org/wiki/Ada_Lovelace (thanks James Turnbull) "lovelace", // Auguste and Louis Lumière - the first filmmakers in history - https://en.wikipedia.org/wiki/Auguste_and_Louis_Lumi%C3%A8re "lumiere", // Mahavira - Ancient Indian mathematician during 9th century AD who discovered basic algebraic identities - https://en.wikipedia.org/wiki/Mah%C4%81v%C4%ABra_(mathematician) "mahavira", // Lynn Margulis (b. Lynn Petra Alexander) - an American evolutionary theorist and biologist, science author, educator, and popularizer, and was the primary modern proponent for the significance of symbiosis in evolution. - https://en.wikipedia.org/wiki/Lynn_Margulis "margulis", // Yukihiro Matsumoto - Japanese computer scientist and software programmer best known as the chief designer of the Ruby programming language. https://en.wikipedia.org/wiki/Yukihiro_Matsumoto "matsumoto", // James Clerk Maxwell - Scottish physicist, best known for his formulation of electromagnetic theory. https://en.wikipedia.org/wiki/James_Clerk_Maxwell "maxwell", // Maria Mayer - American theoretical physicist and Nobel laureate in Physics for proposing the nuclear shell model of the atomic nucleus - https://en.wikipedia.org/wiki/Maria_Mayer "mayer", // John McCarthy invented LISP: https://en.wikipedia.org/wiki/John_McCarthy_(computer_scientist) "mccarthy", // Barbara McClintock - a distinguished American cytogeneticist, 1983 Nobel Laureate in Physiology or Medicine for discovering transposons. https://en.wikipedia.org/wiki/Barbara_McClintock "mcclintock", // Anne Laura Dorinthea McLaren - British developmental biologist whose work helped lead to human in-vitro fertilisation. https://en.wikipedia.org/wiki/Anne_McLaren "mclaren", // Malcolm McLean invented the modern shipping container: https://en.wikipedia.org/wiki/Malcom_McLean "mclean", // Kay McNulty - one of the original programmers of the ENIAC. https://en.wikipedia.org/wiki/ENIAC - https://en.wikipedia.org/wiki/Kathleen_Antonelli "mcnulty", // Gregor Johann Mendel - Czech scientist and founder of genetics. https://en.wikipedia.org/wiki/Gregor_Mendel "mendel", // Dmitri Mendeleev - a chemist and inventor. He formulated the Periodic Law, created a farsighted version of the periodic table of elements, and used it to correct the properties of some already discovered elements and also to predict the properties of eight elements yet to be discovered. https://en.wikipedia.org/wiki/Dmitri_Mendeleev "mendeleev", // Lise Meitner - Austrian/Swedish physicist who was involved in the discovery of nuclear fission. The element meitnerium is named after her - https://en.wikipedia.org/wiki/Lise_Meitner "meitner", // Carla Meninsky, was the game designer and programmer for Atari 2600 games Dodge 'Em and Warlords. https://en.wikipedia.org/wiki/Carla_Meninsky "meninsky", // Ralph C. Merkle - American computer scientist, known for devising Merkle's puzzles - one of the very first schemes for public-key cryptography. Also, inventor of Merkle trees and co-inventor of the Merkle-Damgård construction for building collision-resistant cryptographic hash functions and the Merkle-Hellman knapsack cryptosystem. https://en.wikipedia.org/wiki/Ralph_Merkle "merkle", // Johanna Mestorf - German prehistoric archaeologist and first female museum director in Germany - https://en.wikipedia.org/wiki/Johanna_Mestorf "mestorf", // Marvin Minsky - Pioneer in Artificial Intelligence, co-founder of the MIT's AI Lab, won the Turing Award in 1969. https://en.wikipedia.org/wiki/Marvin_Minsky "minsky", // Maryam Mirzakhani - an Iranian mathematician and the first woman to win the Fields Medal. https://en.wikipedia.org/wiki/Maryam_Mirzakhani "mirzakhani", // Gordon Earle Moore - American engineer, Silicon Valley founding father, author of Moore's law. https://en.wikipedia.org/wiki/Gordon_Moore "moore", // Samuel Morse - contributed to the invention of a single-wire telegraph system based on European telegraphs and was a co-developer of the Morse code - https://en.wikipedia.org/wiki/Samuel_Morse "morse", // Ian Murdock - founder of the Debian project - https://en.wikipedia.org/wiki/Ian_Murdock "murdock", // May-Britt Moser - Nobel prize winner neuroscientist who contributed to the discovery of grid cells in the brain. https://en.wikipedia.org/wiki/May-Britt_Moser "moser", // John Napier of Merchiston - Scottish landowner known as an astronomer, mathematician and physicist. Best known for his discovery of logarithms. https://en.wikipedia.org/wiki/John_Napier "napier", // John Forbes Nash, Jr. - American mathematician who made fundamental contributions to game theory, differential geometry, and the study of partial differential equations. https://en.wikipedia.org/wiki/John_Forbes_Nash_Jr. "nash", // John von Neumann - todays computer architectures are based on the von Neumann architecture. https://en.wikipedia.org/wiki/Von_Neumann_architecture "neumann", // Isaac Newton invented classic mechanics and modern optics. https://en.wikipedia.org/wiki/Isaac_Newton "newton", // Xavier Niel - ;) https://en.wikipedia.org/wiki/Xavier_Niel "niel", // Florence Nightingale, more prominently known as a nurse, was also the first female member of the Royal Statistical Society and a pioneer in statistical graphics https://en.wikipedia.org/wiki/Florence_Nightingale#Statistics_and_sanitary_reform "nightingale", // Alfred Nobel - a Swedish chemist, engineer, innovator, and armaments manufacturer (inventor of dynamite) - https://en.wikipedia.org/wiki/Alfred_Nobel "nobel", // Emmy Noether, German mathematician. Noether's Theorem is named after her. https://en.wikipedia.org/wiki/Emmy_Noether "noether", // Poppy Northcutt. Poppy Northcutt was the first woman to work as part of NASA’s Mission Control. http://www.businessinsider.com/poppy-northcutt-helped-apollo-astronauts-2014-12?op=1 "northcutt", // Robert Noyce invented silicone integrated circuits and gave Silicon Valley its name. - https://en.wikipedia.org/wiki/Robert_Noyce "noyce", // Panini - Ancient Indian linguist and grammarian from 4th century CE who worked on the world's first formal system - https://en.wikipedia.org/wiki/P%C4%81%E1%B9%87ini#Comparison_with_modern_formal_systems "panini", // Ambroise Pare invented modern surgery. https://en.wikipedia.org/wiki/Ambroise_Par%C3%A9 "pare", // Blaise Pascal, French mathematician, physicist, and inventor - https://en.wikipedia.org/wiki/Blaise_Pascal "pascal", // Louis Pasteur discovered vaccination, fermentation and pasteurization. https://en.wikipedia.org/wiki/Louis_Pasteur. "pasteur", // Cecilia Payne-Gaposchkin was an astronomer and astrophysicist who, in 1925, proposed in her Ph.D. thesis an explanation for the composition of stars in terms of the relative abundances of hydrogen and helium. https://en.wikipedia.org/wiki/Cecilia_Payne-Gaposchkin "payne", // Radia Perlman is a software designer and network engineer and most famous for her invention of the spanning-tree protocol (STP). https://en.wikipedia.org/wiki/Radia_Perlman "perlman", // Rob Pike was a key contributor to Unix, Plan 9, the X graphic system, utf-8, and the Go programming language. https://en.wikipedia.org/wiki/Rob_Pike "pike", // Henri Poincaré made fundamental contributions in several fields of mathematics. https://en.wikipedia.org/wiki/Henri_Poincar%C3%A9 "poincare", // Laura Poitras is a director and producer whose work, made possible by open source crypto tools, advances the causes of truth and freedom of information by reporting disclosures by whistleblowers such as Edward Snowden. https://en.wikipedia.org/wiki/Laura_Poitras "poitras", // Tat’yana Avenirovna Proskuriakova (Russian: Татья́на Авени́ровна Проскуряко́ва) (January 23 [O.S. January 10] 1909 – August 30, 1985) was a Russian-American Mayanist scholar and archaeologist who contributed significantly to the deciphering of Maya hieroglyphs, the writing system of the pre-Columbian Maya civilization of Mesoamerica. https://en.wikipedia.org/wiki/Tatiana_Proskouriakoff "proskuriakova", // Claudius Ptolemy - a Greco-Egyptian writer of Alexandria, known as a mathematician, astronomer, geographer, astrologer, and poet of a single epigram in the Greek Anthology - https://en.wikipedia.org/wiki/Ptolemy "ptolemy", // C. V. Raman - Indian physicist who won the Nobel Prize in 1930 for proposing the Raman effect. - https://en.wikipedia.org/wiki/C._V._Raman "raman", // Srinivasa Ramanujan - Indian mathematician and autodidact who made extraordinary contributions to mathematical analysis, number theory, infinite series, and continued fractions. - https://en.wikipedia.org/wiki/Srinivasa_Ramanujan "ramanujan", // Sally Kristen Ride was an American physicist and astronaut. She was the first American woman in space, and the youngest American astronaut. https://en.wikipedia.org/wiki/Sally_Ride "ride", // Rita Levi-Montalcini - Won Nobel Prize in Physiology or Medicine jointly with colleague Stanley Cohen for the discovery of nerve growth factor (https://en.wikipedia.org/wiki/Rita_Levi-Montalcini) "montalcini", // Dennis Ritchie - co-creator of UNIX and the C programming language. - https://en.wikipedia.org/wiki/Dennis_Ritchie "ritchie", // Ida Rhodes - American pioneer in computer programming, designed the first computer used for Social Security. https://en.wikipedia.org/wiki/Ida_Rhodes "rhodes", // Julia Hall Bowman Robinson - American mathematician renowned for her contributions to the fields of computability theory and computational complexity theory. https://en.wikipedia.org/wiki/Julia_Robinson "robinson", // Wilhelm Conrad Röntgen - German physicist who was awarded the first Nobel Prize in Physics in 1901 for the discovery of X-rays (Röntgen rays). https://en.wikipedia.org/wiki/Wilhelm_R%C3%B6ntgen "roentgen", // Rosalind Franklin - British biophysicist and X-ray crystallographer whose research was critical to the understanding of DNA - https://en.wikipedia.org/wiki/Rosalind_Franklin "rosalind", // Vera Rubin - American astronomer who pioneered work on galaxy rotation rates. https://en.wikipedia.org/wiki/Vera_Rubin "rubin", // Meghnad Saha - Indian astrophysicist best known for his development of the Saha equation, used to describe chemical and physical conditions in stars - https://en.wikipedia.org/wiki/Meghnad_Saha "saha", // Jean E. Sammet developed FORMAC, the first widely used computer language for symbolic manipulation of mathematical formulas. https://en.wikipedia.org/wiki/Jean_E._Sammet "sammet", // Mildred Sanderson - American mathematician best known for Sanderson's theorem concerning modular invariants. https://en.wikipedia.org/wiki/Mildred_Sanderson "sanderson", // Satoshi Nakamoto is the name used by the unknown person or group of people who developed bitcoin, authored the bitcoin white paper, and created and deployed bitcoin's original reference implementation. https://en.wikipedia.org/wiki/Satoshi_Nakamoto "satoshi", // Adi Shamir - Israeli cryptographer whose numerous inventions and contributions to cryptography include the Ferge Fiat Shamir identification scheme, the Rivest Shamir Adleman (RSA) public-key cryptosystem, the Shamir's secret sharing scheme, the breaking of the Merkle-Hellman cryptosystem, the TWINKLE and TWIRL factoring devices and the discovery of differential cryptanalysis (with Eli Biham). https://en.wikipedia.org/wiki/Adi_Shamir "shamir", // Claude Shannon - The father of information theory and founder of digital circuit design theory. (https://en.wikipedia.org/wiki/Claude_Shannon) "shannon", // Carol Shaw - Originally an Atari employee, Carol Shaw is said to be the first female video game designer. https://en.wikipedia.org/wiki/Carol_Shaw_(video_game_designer) "shaw", // Dame Stephanie "Steve" Shirley - Founded a software company in 1962 employing women working from home. https://en.wikipedia.org/wiki/Steve_Shirley "shirley", // William Shockley co-invented the transistor - https://en.wikipedia.org/wiki/William_Shockley "shockley", // Lina Solomonovna Stern (or Shtern; Russian: Лина Соломоновна Штерн; 26 August 1878 – 7 March 1968) was a Soviet biochemist, physiologist and humanist whose medical discoveries saved thousands of lives at the fronts of World War II. She is best known for her pioneering work on blood–brain barrier, which she described as hemato-encephalic barrier in 1921. https://en.wikipedia.org/wiki/Lina_Stern "shtern", // Françoise Barré-Sinoussi - French virologist and Nobel Prize Laureate in Physiology or Medicine; her work was fundamental in identifying HIV as the cause of AIDS. https://en.wikipedia.org/wiki/Fran%C3%A7oise_Barr%C3%A9-Sinoussi "sinoussi", // Betty Snyder - one of the original programmers of the ENIAC. https://en.wikipedia.org/wiki/ENIAC - https://en.wikipedia.org/wiki/Betty_Holberton "snyder", // Cynthia Solomon - Pioneer in the fields of artificial intelligence, computer science and educational computing. Known for creation of Logo, an educational programming language. https://en.wikipedia.org/wiki/Cynthia_Solomon "solomon", // Frances Spence - one of the original programmers of the ENIAC. https://en.wikipedia.org/wiki/ENIAC - https://en.wikipedia.org/wiki/Frances_Spence "spence", // Richard Matthew Stallman - the founder of the Free Software movement, the GNU project, the Free Software Foundation, and the League for Programming Freedom. He also invented the concept of copyleft to protect the ideals of this movement, and enshrined this concept in the widely-used GPL (General Public License) for software. https://en.wikiquote.org/wiki/Richard_Stallman "stallman", // Michael Stonebraker is a database research pioneer and architect of Ingres, Postgres, VoltDB and SciDB. Winner of 2014 ACM Turing Award. https://en.wikipedia.org/wiki/Michael_Stonebraker "stonebraker", // Ivan Edward Sutherland - American computer scientist and Internet pioneer, widely regarded as the father of computer graphics. https://en.wikipedia.org/wiki/Ivan_Sutherland "sutherland", // Janese Swanson (with others) developed the first of the Carmen Sandiego games. She went on to found Girl Tech. https://en.wikipedia.org/wiki/Janese_Swanson "swanson", // Aaron Swartz was influential in creating RSS, Markdown, Creative Commons, Reddit, and much of the internet as we know it today. He was devoted to freedom of information on the web. https://en.wikiquote.org/wiki/Aaron_Swartz "swartz", // Bertha Swirles was a theoretical physicist who made a number of contributions to early quantum theory. https://en.wikipedia.org/wiki/Bertha_Swirles "swirles", // Helen Brooke Taussig - American cardiologist and founder of the field of paediatric cardiology. https://en.wikipedia.org/wiki/Helen_B._Taussig "taussig", // Valentina Tereshkova is a Russian engineer, cosmonaut and politician. She was the first woman to fly to space in 1963. In 2013, at the age of 76, she offered to go on a one-way mission to Mars. https://en.wikipedia.org/wiki/Valentina_Tereshkova "tereshkova", // Nikola Tesla invented the AC electric system and every gadget ever used by a James Bond villain. https://en.wikipedia.org/wiki/Nikola_Tesla "tesla", // Marie Tharp - American geologist and oceanic cartographer who co-created the first scientific map of the Atlantic Ocean floor. Her work led to the acceptance of the theories of plate tectonics and continental drift. https://en.wikipedia.org/wiki/Marie_Tharp "tharp", // Ken Thompson - co-creator of UNIX and the C programming language - https://en.wikipedia.org/wiki/Ken_Thompson "thompson", // Linus Torvalds invented Linux and Git. https://en.wikipedia.org/wiki/Linus_Torvalds "torvalds", // Youyou Tu - Chinese pharmaceutical chemist and educator known for discovering artemisinin and dihydroartemisinin, used to treat malaria, which has saved millions of lives. Joint winner of the 2015 Nobel Prize in Physiology or Medicine. https://en.wikipedia.org/wiki/Tu_Youyou "tu", // Alan Turing was a founding father of computer science. https://en.wikipedia.org/wiki/Alan_Turing. "turing", // Varahamihira - Ancient Indian mathematician who discovered trigonometric formulae during 505-587 CE - https://en.wikipedia.org/wiki/Var%C4%81hamihira#Contributions "varahamihira", // Dorothy Vaughan was a NASA mathematician and computer programmer on the SCOUT launch vehicle program that put America's first satellites into space - https://en.wikipedia.org/wiki/Dorothy_Vaughan "vaughan", // Sir Mokshagundam Visvesvaraya - is a notable Indian engineer. He is a recipient of the Indian Republic's highest honour, the Bharat Ratna, in 1955. On his birthday, 15 September is celebrated as Engineer's Day in India in his memory - https://en.wikipedia.org/wiki/Visvesvaraya "visvesvaraya", // Christiane Nüsslein-Volhard - German biologist, won Nobel Prize in Physiology or Medicine in 1995 for research on the genetic control of embryonic development. https://en.wikipedia.org/wiki/Christiane_N%C3%BCsslein-Volhard "volhard", // Cédric Villani - French mathematician, won Fields Medal, Fermat Prize and Poincaré Price for his work in differential geometry and statistical mechanics. https://en.wikipedia.org/wiki/C%C3%A9dric_Villani "villani", // Marlyn Wescoff - one of the original programmers of the ENIAC. https://en.wikipedia.org/wiki/ENIAC - https://en.wikipedia.org/wiki/Marlyn_Meltzer "wescoff", // Sylvia B. Wilbur - British computer scientist who helped develop the ARPANET, was one of the first to exchange email in the UK and a leading researcher in computer-supported collaborative work. https://en.wikipedia.org/wiki/Sylvia_Wilbur "wilbur", // Andrew Wiles - Notable British mathematician who proved the enigmatic Fermat's Last Theorem - https://en.wikipedia.org/wiki/Andrew_Wiles "wiles", // Roberta Williams, did pioneering work in graphical adventure games for personal computers, particularly the King's Quest series. https://en.wikipedia.org/wiki/Roberta_Williams "williams", // Malcolm John Williamson - British mathematician and cryptographer employed by the GCHQ. Developed in 1974 what is now known as Diffie-Hellman key exchange (Diffie and Hellman first published the scheme in 1976). https://en.wikipedia.org/wiki/Malcolm_J._Williamson "williamson", // Sophie Wilson designed the first Acorn Micro-Computer and the instruction set for ARM processors. https://en.wikipedia.org/wiki/Sophie_Wilson "wilson", // Jeannette Wing - co-developed the Liskov substitution principle. - https://en.wikipedia.org/wiki/Jeannette_Wing "wing", // Steve Wozniak invented the Apple I and Apple II. https://en.wikipedia.org/wiki/Steve_Wozniak "wozniak", // The Wright brothers, Orville and Wilbur - credited with inventing and building the world's first successful airplane and making the first controlled, powered and sustained heavier-than-air human flight - https://en.wikipedia.org/wiki/Wright_brothers "wright", // Chien-Shiung Wu - Chinese-American experimental physicist who made significant contributions to nuclear physics. https://en.wikipedia.org/wiki/Chien-Shiung_Wu "wu", // Rosalyn Sussman Yalow - Rosalyn Sussman Yalow was an American medical physicist, and a co-winner of the 1977 Nobel Prize in Physiology or Medicine for development of the radioimmunoassay technique. https://en.wikipedia.org/wiki/Rosalyn_Sussman_Yalow "yalow", // Ada Yonath - an Israeli crystallographer, the first woman from the Middle East to win a Nobel prize in the sciences. https://en.wikipedia.org/wiki/Ada_Yonath "yonath", // Nikolay Yegorovich Zhukovsky (Russian: Никола́й Его́рович Жуко́вский, January 17 1847 – March 17, 1921) was a Russian scientist, mathematician and engineer, and a founding father of modern aero- and hydrodynamics. Whereas contemporary scientists scoffed at the idea of human flight, Zhukovsky was the first to undertake the study of airflow. He is often called the Father of Russian Aviation. https://en.wikipedia.org/wiki/Nikolay_Yegorovich_Zhukovsky "zhukovsky", } ) // GetRandomName generates a random name from the list of adjectives and surnames in this package // formatted as "scw-adjective-surname". For example 'scw-focused-turing'. func GetRandomName(prefixes ...string) string { begin: parts := append(prefixes, left[r.Intn(len(left))], right[r.Intn(len(right))]) name := strings.Join(parts, "-") if strings.Contains(name, "boring-wozniak") /* Steve Wozniak is not boring */ { goto begin } return name } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/namegenerator/name_generator_test.go000066400000000000000000000021631456366605600314630ustar00rootroot00000000000000// Source: github.com/docker/docker/pkg/namesgenerator package namegenerator import ( "strings" "testing" ) func TestNameFormat(t *testing.T) { name := GetRandomName() if strings.Count(name, "-") != 1 { t.Fatalf("Generated name does not contain exactly 1 hyphen") } if strings.ContainsAny(name, "0123456789") { t.Fatalf("Generated name contains numbers!") } } func TestNameFormatWithPrefix(t *testing.T) { name := GetRandomName("scw") if strings.Count(name, "-") != 2 { t.Fatalf("Generated name does not contain exactly 2 hyphens") } if !strings.HasPrefix(name, "scw-") { t.Fatalf("Generated name must begin with \"tf-scw-\"") } if strings.ContainsAny(name, "0123456789") { t.Fatalf("Generated name contains numbers!") } } func TestNameFormatWithPrefixes(t *testing.T) { name := GetRandomName("tf", "scw") if strings.Count(name, "-") != 3 { t.Fatalf("Generated name does not contain exactly 3 hyphens") } if !strings.HasPrefix(name, "tf-scw-") { t.Fatalf("Generated name must begin with \"tf-scw-\"") } if strings.ContainsAny(name, "0123456789") { t.Fatalf("Generated name contains numbers!") } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scripts/000077500000000000000000000000001456366605600237455ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scripts/README.md000066400000000000000000000006351456366605600252300ustar00rootroot00000000000000# Scaleway GO SDK - Scripts This directory contains useful scripts to work on scaleway-go-sdk. ### check_for_tokens.sh \*\* Checks that no token are present in cassette file ``` Usage: ./script/check_for_tokens.sh ``` ### release.sh \*\* This script will trigger the release process. For more information on the release process you can refer to ./release/release.js file ``` Usage: ./script/release.sh ``` golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scripts/check_for_tokens.sh000077500000000000000000000003711456366605600276130ustar00rootroot00000000000000#!/bin/bash files=$(find . -type f -print | grep testdata); for file in $files do echo "checking $file"; if grep -i --quiet "x-auth-token" $file then echo "found x-auth-token in file $file"; exit 1; fi done exit 0; golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scripts/lint.sh000077500000000000000000000030311456366605600252470ustar00rootroot00000000000000#!/usr/bin/env bash SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" ## # Colorize output ## function color() { case $1 in yellow) echo -e -n "\033[33m" ;; green) echo -e -n "\033[32m" ;; red) echo -e -n "\033[0;31m" ;; esac echo "$2" echo -e -n "\033[0m" } ## # Print Usage ## function usage() { color yellow "Usage:" echo " $SCRIPT_DIR [OPTIONS]" echo "" color yellow "Options:" color green " -w, --write" echo -e "\tFix found issues (if it's supported by the linter)." color green " --list" echo -e "\tList current linters configuration." color green " -h, --help" echo -e "\tDisplay this help." echo "" exit "$1"; } OPT_CMD="run" OPT_FLAGS="" OPT_DIRS="$ROOT_DIR/..." ## # Parse arguments ## while [[ $# -gt 0 ]] do case "$1" in -h|--help) usage 0 ;; -w|--write) OPT_CMD="run" OPT_FLAGS+=" --fix" ;; --list) OPT_DIRS="" OPT_CMD="linters" ;; -v|--verbose) OPT_FLAGS+=" -v" ;; *) color red "Unkown argument '$1'" echo usage 1 ;; esac shift done ## # Check golangci-lint command existence ## if [ ! -x "$(command -v golangci-lint)" ]; then echo "golangci-lint is not installed" echo "On macOS, you can run: brew install golangci/tap/golangci-lint" echo "On other systems, refer to installation instructions: https://github.com/golangci/golangci-lint#install" exit 1 fi ## # Execute golangci-lint command ## golangci-lint $OPT_CMD $OPT_FLAGS $OPT_DIRS golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scripts/release.sh000077500000000000000000000002161456366605600257230ustar00rootroot00000000000000#!/bin/bash cd scripts/release || (echo "Please run this script from repo root" && exit 1) yarn install --frozen-lock-file yarn run release golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/000077500000000000000000000000001456366605600230525ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/README.md000066400000000000000000000100571456366605600243340ustar00rootroot00000000000000# Scaleway config ## TL;DR Recommended config file: ```yaml # Get your credentials on https://console.scaleway.com/project/credentials access_key: SCWXXXXXXXXXXXXXXXXX secret_key: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx default_organization_id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx default_project_id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx default_region: fr-par default_zone: fr-par-1 ``` ## Config file path The function [`GetConfigPath`](https://godoc.org/github.com/scaleway/scaleway-sdk-go/scw#GetConfigPath) will try to locate the config file in the following ways: 1. Custom directory: `$SCW_CONFIG_PATH` 2. [XDG base directory](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html): `$XDG_CONFIG_HOME/scw/config.yaml` 3. Unix home directory: `$HOME/.config/scw/config.yaml` 4. Windows home directory: `%USERPROFILE%/.config/scw/config.yaml` ## Reading config order [ClientOption](https://godoc.org/github.com/scaleway/scaleway-sdk-go/scw#ClientOption) ordering will decide the order in which the config should apply: ```go p, _ := scw.MustLoadConfig().GetActiveProfile() scw.NewClient( scw.WithProfile(p), // active profile applies first scw.WithEnv(), // existing env variables may overwrite active profile scw.WithDefaultRegion(scw.RegionFrPar) // any prior region set will be discarded to usr the new one ) ``` ## Environment variables | Variable | Description | Legacy variables | | :----------------------------- | :----------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------ | | `$SCW_ACCESS_KEY` | Access key of a token ([get yours](https://console.scaleway.com/project/credentials)) | `$SCALEWAY_ACCESS_KEY` (used by terraform) | | `$SCW_SECRET_KEY` | Secret key of a token ([get yours](https://console.scaleway.com/project/credentials)) | `$SCW_TOKEN` (used by cli), `$SCALEWAY_TOKEN` (used by terraform), `$SCALEWAY_ACCESS_KEY` (used by terraform) | | `$SCW_DEFAULT_ORGANIZATION_ID` | Your default organization ID ([get yours](https://console.scaleway.com/project/credentials)) | `$SCW_ORGANIZATION` (used by cli),`$SCALEWAY_ORGANIZATION` (used by terraform) | | `$SCW_DEFAULT_PROJECT_ID` | Your default project ID ([get yours](https://console.scaleway.com/project/credentials)) | | | `$SCW_DEFAULT_REGION` | Your default [region](https://developers.scaleway.com/en/quickstart/#region-and-zone) | `$SCW_REGION` (used by cli),`$SCALEWAY_REGION` (used by terraform) | | `$SCW_DEFAULT_ZONE` | Your default [availability zone](https://developers.scaleway.com/en/quickstart/#region-and-zone) | `$SCW_ZONE` (used by cli),`$SCALEWAY_ZONE` (used by terraform) | | `$SCW_API_URL` | Url of the API | - | | `$SCW_INSECURE` | Set this to `true` to enable the insecure mode | `$SCW_TLSVERIFY` (inverse flag used by the cli) | | `$SCW_PROFILE` | Set the config profile to use | - | golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/client.go000066400000000000000000000403231456366605600246610ustar00rootroot00000000000000package scw import ( "crypto/tls" "encoding/json" "fmt" "io" "math" "net/http" "reflect" "strconv" "strings" "sync" "time" "github.com/scaleway/scaleway-sdk-go/internal/auth" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/generic" "github.com/scaleway/scaleway-sdk-go/logger" ) // Client is the Scaleway client which performs API requests. // // This client should be passed in the `NewApi` functions whenever an API instance is created. // Creating a Client is done with the `NewClient` function. type Client struct { httpClient httpClient auth auth.Auth apiURL string userAgent string defaultOrganizationID *string defaultProjectID *string defaultRegion *Region defaultZone *Zone defaultPageSize *uint32 } func defaultOptions() []ClientOption { return []ClientOption{ WithoutAuth(), WithAPIURL("https://api.scaleway.com"), withDefaultUserAgent(userAgent), } } // NewClient instantiate a new Client object. // // Zero or more ClientOption object can be passed as a parameter. // These options will then be applied to the client. func NewClient(opts ...ClientOption) (*Client, error) { s := newSettings() // apply options s.apply(append(defaultOptions(), opts...)) // validate settings err := s.validate() if err != nil { return nil, err } // dial the API if s.httpClient == nil { s.httpClient = newHTTPClient() } // insecure mode if s.insecure { logger.Debugf("client: using insecure mode") setInsecureMode(s.httpClient) } if logger.ShouldLog(logger.LogLevelDebug) { logger.Debugf("client: using request logger") setRequestLogging(s.httpClient) } logger.Debugf("client: using sdk version " + version) return &Client{ auth: s.token, httpClient: s.httpClient, apiURL: s.apiURL, userAgent: s.userAgent, defaultOrganizationID: s.defaultOrganizationID, defaultProjectID: s.defaultProjectID, defaultRegion: s.defaultRegion, defaultZone: s.defaultZone, defaultPageSize: s.defaultPageSize, }, nil } // GetDefaultOrganizationID returns the default organization ID // of the client. This value can be set in the client option // WithDefaultOrganizationID(). Be aware this value can be empty. func (c *Client) GetDefaultOrganizationID() (organizationID string, exists bool) { if c.defaultOrganizationID != nil { return *c.defaultOrganizationID, true } return "", false } // GetDefaultProjectID returns the default project ID // of the client. This value can be set in the client option // WithDefaultProjectID(). Be aware this value can be empty. func (c *Client) GetDefaultProjectID() (projectID string, exists bool) { if c.defaultProjectID != nil { return *c.defaultProjectID, true } return "", false } // GetDefaultRegion returns the default region of the client. // This value can be set in the client option // WithDefaultRegion(). Be aware this value can be empty. func (c *Client) GetDefaultRegion() (region Region, exists bool) { if c.defaultRegion != nil { return *c.defaultRegion, true } return Region(""), false } // GetDefaultZone returns the default zone of the client. // This value can be set in the client option // WithDefaultZone(). Be aware this value can be empty. func (c *Client) GetDefaultZone() (zone Zone, exists bool) { if c.defaultZone != nil { return *c.defaultZone, true } return Zone(""), false } func (c *Client) GetSecretKey() (secretKey string, exists bool) { if token, isToken := c.auth.(*auth.Token); isToken { return token.SecretKey, isToken } return "", false } func (c *Client) GetAccessKey() (accessKey string, exists bool) { if token, isToken := c.auth.(*auth.Token); isToken { return token.AccessKey, isToken } else if token, isAccessKey := c.auth.(*auth.AccessKeyOnly); isAccessKey { return token.AccessKey, isAccessKey } return "", false } // GetDefaultPageSize returns the default page size of the client. // This value can be set in the client option // WithDefaultPageSize(). Be aware this value can be empty. func (c *Client) GetDefaultPageSize() (pageSize uint32, exists bool) { if c.defaultPageSize != nil { return *c.defaultPageSize, true } return 0, false } // Do performs HTTP request(s) based on the ScalewayRequest object. // RequestOptions are applied prior to doing the request. func (c *Client) Do(req *ScalewayRequest, res interface{}, opts ...RequestOption) (err error) { // apply request options req.apply(opts) // validate request options err = req.validate() if err != nil { return err } if req.auth == nil { req.auth = c.auth } if req.zones != nil { return c.doListZones(req, res, req.zones) } if req.regions != nil { return c.doListRegions(req, res, req.regions) } if req.allPages { return c.doListAll(req, res) } return c.do(req, res) } // do performs a single HTTP request based on the ScalewayRequest object. func (c *Client) do(req *ScalewayRequest, res interface{}) (sdkErr error) { if req == nil { return errors.New("request must be non-nil") } // build url url, sdkErr := req.getURL(c.apiURL) if sdkErr != nil { return sdkErr } logger.Debugf("creating %s request on %s", req.Method, url.String()) // build request httpRequest, err := http.NewRequest(req.Method, url.String(), req.Body) if err != nil { return errors.Wrap(err, "could not create request") } httpRequest.Header = req.getAllHeaders(req.auth, c.userAgent, false) if req.ctx != nil { httpRequest = httpRequest.WithContext(req.ctx) } // execute request httpResponse, err := c.httpClient.Do(httpRequest) if err != nil { return errors.Wrap(err, "error executing request") } defer func() { closeErr := httpResponse.Body.Close() if sdkErr == nil && closeErr != nil { sdkErr = errors.Wrap(closeErr, "could not close http response") } }() sdkErr = hasResponseError(httpResponse) if sdkErr != nil { return sdkErr } if res != nil { contentType := httpResponse.Header.Get("Content-Type") if strings.HasPrefix(contentType, "application/json") { err = json.NewDecoder(httpResponse.Body).Decode(&res) if err != nil { return errors.Wrap(err, "could not parse %s response body", contentType) } } else { buffer, isBuffer := res.(io.Writer) if !isBuffer { return errors.Wrap(err, "could not handle %s response body with %T result type", contentType, buffer) } _, err := io.Copy(buffer, httpResponse.Body) if err != nil { return errors.Wrap(err, "could not copy %s response body", contentType) } } // Handle instance API X-Total-Count header xTotalCountStr := httpResponse.Header.Get("X-Total-Count") if legacyLister, isLegacyLister := res.(legacyLister); isLegacyLister && xTotalCountStr != "" { xTotalCount, err := strconv.ParseInt(xTotalCountStr, 10, 32) if err != nil { return errors.Wrap(err, "could not parse X-Total-Count header") } legacyLister.UnsafeSetTotalCount(int(xTotalCount)) } } return nil } type lister interface { UnsafeGetTotalCount() uint64 UnsafeAppend(interface{}) (uint64, error) } // Old lister for uint32 // Used for retro-compatibility with response that use uint32 type lister32 interface { UnsafeGetTotalCount() uint32 UnsafeAppend(interface{}) (uint32, error) } type legacyLister interface { UnsafeSetTotalCount(totalCount int) } func listerGetTotalCount(i interface{}) uint64 { if l, isLister := i.(lister); isLister { return l.UnsafeGetTotalCount() } if l32, isLister32 := i.(lister32); isLister32 { return uint64(l32.UnsafeGetTotalCount()) } panic(fmt.Errorf("%T does not support pagination but checks failed, should not happen", i)) } func listerAppend(recv interface{}, elems interface{}) (uint64, error) { if l, isLister := recv.(lister); isLister { return l.UnsafeAppend(elems) } else if l32, isLister32 := recv.(lister32); isLister32 { total, err := l32.UnsafeAppend(elems) return uint64(total), err } panic(fmt.Errorf("%T does not support pagination but checks failed, should not happen", recv)) } func isLister(i interface{}) bool { switch i.(type) { case lister: return true case lister32: return true default: return false } } const maxPageCount uint64 = math.MaxUint32 // doListAll collects all pages of a List request and aggregate all results on a single response. func (c *Client) doListAll(req *ScalewayRequest, res interface{}) (err error) { // check for lister interface if isLister(res) { pageCount := maxPageCount for page := uint64(1); page <= pageCount; page++ { // set current page req.Query.Set("page", strconv.FormatUint(page, 10)) // request the next page nextPage := newVariableFromType(res) err := c.do(req, nextPage) if err != nil { return err } // append results pageSize, err := listerAppend(res, nextPage) if err != nil { return err } if pageSize == 0 { return nil } // set total count on first request if pageCount == maxPageCount { totalCount := listerGetTotalCount(nextPage) pageCount = (totalCount + pageSize - 1) / pageSize } } return nil } return errors.New("%T does not support pagination", res) } // doListLocalities collects all localities using mutliple list requests and aggregate all results on a lister response // results is sorted by locality func (c *Client) doListLocalities(req *ScalewayRequest, res interface{}, localities []string) (err error) { path := req.Path if !strings.Contains(path, "%locality%") { return fmt.Errorf("request is not a valid locality request") } // Requests are parallelized responseMutex := sync.Mutex{} requestGroup := sync.WaitGroup{} errChan := make(chan error, len(localities)) requestGroup.Add(len(localities)) for _, locality := range localities { go func(locality string) { defer requestGroup.Done() // Request is cloned as doListAll will change header // We remove zones as it would recurse in the same function req := req.clone() req.zones = []Zone(nil) req.Path = strings.ReplaceAll(path, "%locality%", locality) // We create a new response that we append to main response zoneResponse := newVariableFromType(res) err := c.Do(req, zoneResponse) if err != nil { errChan <- err } responseMutex.Lock() _, err = listerAppend(res, zoneResponse) responseMutex.Unlock() if err != nil { errChan <- err } }(locality) } requestGroup.Wait() L: // We gather potential errors and return them all together for { select { case newErr := <-errChan: err = errors.Wrap(err, newErr.Error()) default: break L } } close(errChan) if err != nil { return err } return nil } // doListZones collects all zones using multiple list requests and aggregate all results on a single response. // result is sorted by zone func (c *Client) doListZones(req *ScalewayRequest, res interface{}, zones []Zone) (err error) { if isLister(res) { // Prepare request with %zone% that can be replaced with actual zone for _, zone := range AllZones { if strings.Contains(req.Path, string(zone)) { req.Path = strings.ReplaceAll(req.Path, string(zone), "%locality%") break } } if !strings.Contains(req.Path, "%locality%") { return fmt.Errorf("request is not a valid zoned request") } localities := make([]string, 0, len(zones)) for _, zone := range zones { localities = append(localities, string(zone)) } err := c.doListLocalities(req, res, localities) if err != nil { return fmt.Errorf("failed to list localities: %w", err) } sortResponseByZones(res, zones) return nil } return errors.New("%T does not support pagination", res) } // doListRegions collects all regions using multiple list requests and aggregate all results on a single response. // result is sorted by region func (c *Client) doListRegions(req *ScalewayRequest, res interface{}, regions []Region) (err error) { if isLister(res) { // Prepare request with %locality% that can be replaced with actual region for _, region := range AllRegions { if strings.Contains(req.Path, string(region)) { req.Path = strings.ReplaceAll(req.Path, string(region), "%locality%") break } } if !strings.Contains(req.Path, "%locality%") { return fmt.Errorf("request is not a valid zoned request") } localities := make([]string, 0, len(regions)) for _, region := range regions { localities = append(localities, string(region)) } err := c.doListLocalities(req, res, localities) if err != nil { return fmt.Errorf("failed to list localities: %w", err) } sortResponseByRegions(res, regions) return nil } return errors.New("%T does not support pagination", res) } // sortSliceByZones sorts a slice of struct using a Zone field that should exist func sortSliceByZones(list interface{}, zones []Zone) { if !generic.HasField(list, "Zone") { return } zoneMap := map[Zone]int{} for i, zone := range zones { zoneMap[zone] = i } generic.SortSliceByField(list, "Zone", func(i interface{}, i2 interface{}) bool { return zoneMap[i.(Zone)] < zoneMap[i2.(Zone)] }) } // sortSliceByRegions sorts a slice of struct using a Region field that should exist func sortSliceByRegions(list interface{}, regions []Region) { if !generic.HasField(list, "Region") { return } regionMap := map[Region]int{} for i, region := range regions { regionMap[region] = i } generic.SortSliceByField(list, "Region", func(i interface{}, i2 interface{}) bool { return regionMap[i.(Region)] < regionMap[i2.(Region)] }) } // sortResponseByZones find first field that is a slice in a struct and sort it by zone func sortResponseByZones(res interface{}, zones []Zone) { // res may be ListServersResponse // // type ListServersResponse struct { // TotalCount uint32 `json:"total_count"` // Servers []*Server `json:"servers"` // } // We iterate over fields searching for the slice one to sort it resType := reflect.TypeOf(res).Elem() fields := reflect.VisibleFields(resType) for _, field := range fields { if field.Type.Kind() == reflect.Slice { sortSliceByZones(reflect.ValueOf(res).Elem().FieldByName(field.Name).Interface(), zones) return } } } // sortResponseByRegions find first field that is a slice in a struct and sort it by region func sortResponseByRegions(res interface{}, regions []Region) { // res may be ListServersResponse // // type ListServersResponse struct { // TotalCount uint32 `json:"total_count"` // Servers []*Server `json:"servers"` // } // We iterate over fields searching for the slice one to sort it resType := reflect.TypeOf(res).Elem() fields := reflect.VisibleFields(resType) for _, field := range fields { if field.Type.Kind() == reflect.Slice { sortSliceByRegions(reflect.ValueOf(res).Elem().FieldByName(field.Name).Interface(), regions) return } } } // newVariableFromType returns a variable set to the zero value of the given type func newVariableFromType(t interface{}) interface{} { // reflect.New always create a pointer, that's why we use reflect.Indirect before return reflect.New(reflect.Indirect(reflect.ValueOf(t)).Type()).Interface() } func newHTTPClient() *http.Client { return &http.Client{ Timeout: 30 * time.Second, Transport: http.DefaultTransport.(*http.Transport).Clone(), } } func setInsecureMode(c httpClient) { standardHTTPClient, ok := c.(*http.Client) if !ok { logger.Warningf("client: cannot use insecure mode with HTTP client of type %T", c) return } transportClient, ok := standardHTTPClient.Transport.(*http.Transport) if !ok { logger.Warningf("client: cannot use insecure mode with Transport client of type %T", standardHTTPClient.Transport) return } if transportClient.TLSClientConfig == nil { transportClient.TLSClientConfig = &tls.Config{} } transportClient.TLSClientConfig.InsecureSkipVerify = true } func setRequestLogging(c httpClient) { standardHTTPClient, ok := c.(*http.Client) if !ok { logger.Warningf("client: cannot use request logger with HTTP client of type %T", c) return } // Do not wrap transport if it is already a logger // As client is a pointer, changing transport will change given client // If the same httpClient is used in multiple scwClient, it would add multiple logger transports _, isLogger := standardHTTPClient.Transport.(*requestLoggerTransport) if !isLogger { standardHTTPClient.Transport = &requestLoggerTransport{rt: standardHTTPClient.Transport} } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/client_option.go000066400000000000000000000174371456366605600262630ustar00rootroot00000000000000package scw import ( "net/http" "strings" "github.com/scaleway/scaleway-sdk-go/internal/auth" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/validation" ) // ClientOption is a function which applies options to a settings object. type ClientOption func(*settings) // httpClient wraps the net/http Client Do method type httpClient interface { Do(*http.Request) (*http.Response, error) } // WithHTTPClient client option allows passing a custom http.Client which will be used for all requests. func WithHTTPClient(httpClient httpClient) ClientOption { return func(s *settings) { s.httpClient = httpClient } } // WithoutAuth client option sets the client token to an empty token. func WithoutAuth() ClientOption { return func(s *settings) { s.token = auth.NewNoAuth() } } // WithAuth client option sets the client access key and secret key. func WithAuth(accessKey, secretKey string) ClientOption { return func(s *settings) { s.token = auth.NewToken(accessKey, secretKey) } } // WithJWT client option sets the client session token. func WithJWT(token string) ClientOption { return func(s *settings) { s.token = auth.NewJWT(token) } } // WithAPIURL client option overrides the API URL of the Scaleway API to the given URL. func WithAPIURL(apiURL string) ClientOption { return func(s *settings) { s.apiURL = apiURL } } // WithInsecure client option enables insecure transport on the client. func WithInsecure() ClientOption { return func(s *settings) { s.insecure = true } } // WithUserAgent client option append a user agent to the default user agent of the SDK. func WithUserAgent(ua string) ClientOption { return func(s *settings) { if s.userAgent != "" && ua != "" { s.userAgent += " " } s.userAgent += ua } } // withDefaultUserAgent client option overrides the default user agent of the SDK. func withDefaultUserAgent(ua string) ClientOption { return func(s *settings) { s.userAgent = ua } } // WithProfile client option configures a client from the given profile. func WithProfile(p *Profile) ClientOption { return func(s *settings) { accessKey := "" if p.AccessKey != nil { accessKey = *p.AccessKey s.token = auth.NewAccessKeyOnly(accessKey) } if p.SecretKey != nil { s.token = auth.NewToken(accessKey, *p.SecretKey) } if p.APIURL != nil { s.apiURL = *p.APIURL } if p.Insecure != nil { s.insecure = *p.Insecure } if p.DefaultOrganizationID != nil { organizationID := *p.DefaultOrganizationID s.defaultOrganizationID = &organizationID } if p.DefaultProjectID != nil { projectID := *p.DefaultProjectID s.defaultProjectID = &projectID } if p.DefaultRegion != nil { defaultRegion := Region(*p.DefaultRegion) s.defaultRegion = &defaultRegion } if p.DefaultZone != nil { defaultZone := Zone(*p.DefaultZone) s.defaultZone = &defaultZone } } } // WithEnv client option configures a client from the environment variables. func WithEnv() ClientOption { return WithProfile(LoadEnvProfile()) } // WithDefaultOrganizationID client option sets the client default organization ID. // // It will be used as the default value of the organization_id field in all requests made with this client. func WithDefaultOrganizationID(organizationID string) ClientOption { return func(s *settings) { s.defaultOrganizationID = &organizationID } } // WithDefaultProjectID client option sets the client default project ID. // // It will be used as the default value of the projectID field in all requests made with this client. func WithDefaultProjectID(projectID string) ClientOption { return func(s *settings) { s.defaultProjectID = &projectID } } // WithDefaultRegion client option sets the client default region. // // It will be used as the default value of the region field in all requests made with this client. func WithDefaultRegion(region Region) ClientOption { return func(s *settings) { s.defaultRegion = ®ion } } // WithDefaultZone client option sets the client default zone. // // It will be used as the default value of the zone field in all requests made with this client. func WithDefaultZone(zone Zone) ClientOption { return func(s *settings) { s.defaultZone = &zone } } // WithDefaultPageSize client option overrides the default page size of the SDK. // // It will be used as the default value of the page_size field in all requests made with this client. func WithDefaultPageSize(pageSize uint32) ClientOption { return func(s *settings) { s.defaultPageSize = &pageSize } } // settings hold the values of all client options type settings struct { apiURL string token auth.Auth userAgent string httpClient httpClient insecure bool defaultOrganizationID *string defaultProjectID *string defaultRegion *Region defaultZone *Zone defaultPageSize *uint32 } func newSettings() *settings { return &settings{} } func (s *settings) apply(opts []ClientOption) { for _, opt := range opts { opt(s) } } func (s *settings) validate() error { // Auth. if s.token == nil { // It should not happen, WithoutAuth option is used by default. panic(errors.New("no credential option provided")) } if token, isToken := s.token.(*auth.Token); isToken { if token.AccessKey == "" { return NewInvalidClientOptionError("access key cannot be empty") } if !validation.IsAccessKey(token.AccessKey) { return NewInvalidClientOptionError("invalid access key format '%s', expected SCWXXXXXXXXXXXXXXXXX format", token.AccessKey) } if token.SecretKey == "" { return NewInvalidClientOptionError("secret key cannot be empty") } if !validation.IsSecretKey(token.SecretKey) { return NewInvalidClientOptionError("invalid secret key format '%s', expected a UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", token.SecretKey) } } // Default Organization ID. if s.defaultOrganizationID != nil { if *s.defaultOrganizationID == "" { return NewInvalidClientOptionError("default organization ID cannot be empty") } if !validation.IsOrganizationID(*s.defaultOrganizationID) { return NewInvalidClientOptionError("invalid organization ID format '%s', expected a UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", *s.defaultOrganizationID) } } // Default Project ID. if s.defaultProjectID != nil { if *s.defaultProjectID == "" { return NewInvalidClientOptionError("default project ID cannot be empty") } if !validation.IsProjectID(*s.defaultProjectID) { return NewInvalidClientOptionError("invalid project ID format '%s', expected a UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", *s.defaultProjectID) } } // Default Region. if s.defaultRegion != nil { if *s.defaultRegion == "" { return NewInvalidClientOptionError("default region cannot be empty") } if !validation.IsRegion(string(*s.defaultRegion)) { regions := []string(nil) for _, r := range AllRegions { regions = append(regions, string(r)) } return NewInvalidClientOptionError("invalid default region format '%s', available regions are: %s", *s.defaultRegion, strings.Join(regions, ", ")) } } // Default Zone. if s.defaultZone != nil { if *s.defaultZone == "" { return NewInvalidClientOptionError("default zone cannot be empty") } if !validation.IsZone(string(*s.defaultZone)) { zones := []string(nil) for _, z := range AllZones { zones = append(zones, string(z)) } return NewInvalidClientOptionError("invalid default zone format '%s', available zones are: %s", *s.defaultZone, strings.Join(zones, ", ")) } } // API URL. if !validation.IsURL(s.apiURL) { return NewInvalidClientOptionError("invalid url %s", s.apiURL) } if s.apiURL[len(s.apiURL)-1:] == "/" { return NewInvalidClientOptionError("invalid url %s it should not have a trailing slash", s.apiURL) } // TODO: check for max s.defaultPageSize return nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/client_option_test.go000066400000000000000000000214511456366605600273110ustar00rootroot00000000000000package scw import ( "os" "strings" "testing" "github.com/scaleway/scaleway-sdk-go/internal/auth" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" ) var ( defaultOrganizationID = "6170692e-7363-616c-6577-61792e636f6d" // hint: | xxd -ps -r defaultProjectID = "6170692e-7363-616c-6577-61792e636f6d" // hint: | xxd -ps -r defaultRegion = RegionNlAms defaultZone = ZoneNlAms1 ) func TestClientOptions(t *testing.T) { testCases := []struct { name string clientOption ClientOption errStr string }{ { name: "Create a valid client option", clientOption: func(s *settings) { s.token = auth.NewToken(v2ValidAccessKey, v2ValidSecretKey) s.apiURL = v2ValidAPIURL s.defaultOrganizationID = &defaultOrganizationID s.defaultProjectID = &defaultProjectID s.defaultRegion = &defaultRegion s.defaultZone = &defaultZone }, }, { name: "Should throw an empty access key error", clientOption: func(s *settings) { s.token = auth.NewToken("", v2ValidSecretKey) }, errStr: "scaleway-sdk-go: access key cannot be empty", }, { name: "Should throw a bad access key error", clientOption: func(s *settings) { s.token = auth.NewToken(v2InvalidAccessKey, v2ValidSecretKey) }, errStr: "scaleway-sdk-go: invalid access key format 'invalid', expected SCWXXXXXXXXXXXXXXXXX format", }, { name: "Should throw an empty secret key error", clientOption: func(s *settings) { s.token = auth.NewToken(v2ValidAccessKey, "") }, errStr: "scaleway-sdk-go: secret key cannot be empty", }, { name: "Should throw a bad secret key error", clientOption: func(s *settings) { s.token = auth.NewToken(v2ValidAccessKey, v2InvalidSecretKey) }, errStr: "scaleway-sdk-go: invalid secret key format 'invalid', expected a UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", }, { name: "Should throw an url error", clientOption: func(s *settings) { s.apiURL = ":test" s.token = auth.NewToken(v2ValidAccessKey, v2ValidSecretKey) }, errStr: "scaleway-sdk-go: invalid url :test", }, { name: "Should throw an empty organization ID error", clientOption: func(s *settings) { s.token = auth.NewToken(v2ValidAccessKey, v2ValidSecretKey) s.defaultOrganizationID = StringPtr("") }, errStr: "scaleway-sdk-go: default organization ID cannot be empty", }, { name: "Should throw a bad organization ID error", clientOption: func(s *settings) { s.token = auth.NewToken(v2ValidAccessKey, v2ValidSecretKey) s.defaultOrganizationID = StringPtr(v2InvalidDefaultOrganizationID) }, errStr: "scaleway-sdk-go: invalid organization ID format 'invalid', expected a UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", }, { name: "Should throw an empty project ID error", clientOption: func(s *settings) { s.token = auth.NewToken(v2ValidAccessKey, v2ValidSecretKey) s.defaultProjectID = StringPtr("") }, errStr: "scaleway-sdk-go: default project ID cannot be empty", }, { name: "Should throw a bad project ID error", clientOption: func(s *settings) { s.token = auth.NewToken(v2ValidAccessKey, v2ValidSecretKey) s.defaultProjectID = StringPtr(v2InvalidDefaultProjectID) }, errStr: "scaleway-sdk-go: invalid project ID format 'invalid', expected a UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", }, { name: "Should throw a region error", clientOption: func(s *settings) { v := Region("") s.token = auth.NewToken(testAccessKey, testSecretKey) s.defaultRegion = &v }, errStr: "scaleway-sdk-go: default region cannot be empty", }, { name: "Should throw a bad region error", clientOption: func(s *settings) { v := Region(v2InvalidDefaultRegion) s.token = auth.NewToken(testAccessKey, testSecretKey) s.defaultRegion = &v }, errStr: "scaleway-sdk-go: invalid default region format 'invalid', available regions are: fr-par, nl-ams, pl-waw", }, { name: "Should throw a zone error", clientOption: func(s *settings) { v := Zone("") s.token = auth.NewToken(testAccessKey, testSecretKey) s.defaultZone = &v }, errStr: "scaleway-sdk-go: default zone cannot be empty", }, { name: "Should throw a bad zone error", clientOption: func(s *settings) { v := Zone(v2InvalidDefaultZone) s.token = auth.NewToken(testAccessKey, testSecretKey) s.defaultZone = &v }, errStr: "scaleway-sdk-go: invalid default zone format 'invalid', available zones are: fr-par-1, fr-par-2, fr-par-3, nl-ams-1, nl-ams-2, nl-ams-3, pl-waw-1, pl-waw-2, pl-waw-3", }, } for _, c := range testCases { t.Run(c.name, func(t *testing.T) { // New s := newSettings() // Apply s.apply([]ClientOption{c.clientOption}) // Validate err := s.validate() if c.errStr != "" { testhelpers.Assert(t, err != nil, "Should have error") testhelpers.Equals(t, c.errStr, err.Error()) } else { testhelpers.AssertNoError(t, err) } }) } } func TestCombinedClientOptions(t *testing.T) { tests := []struct { name string env map[string]string files map[string]string expectedError string expectedAccessKey string expectedSecretKey string expectedAPIURL string expectedDefaultOrganizationID *string expectedDefaultProjectID *string expectedDefaultRegion *Region expectedDefaultZone *Zone }{ { name: "Complete config file with env variables", env: map[string]string{ "HOME": "{HOME}", ScwAccessKeyEnv: v2ValidAccessKey2, ScwSecretKeyEnv: v2ValidSecretKey2, ScwAPIURLEnv: v2ValidAPIURL2, ScwDefaultOrganizationIDEnv: v2ValidDefaultOrganizationID2, ScwDefaultProjectIDEnv: v2ValidDefaultProjectID2, ScwDefaultRegionEnv: v2ValidDefaultRegion2, ScwDefaultZoneEnv: v2ValidDefaultZone2, }, files: map[string]string{ ".config/scw/config.yaml": v2CompleteValidConfigFile, }, expectedAccessKey: v2ValidAccessKey2, expectedSecretKey: v2ValidSecretKey2, expectedAPIURL: v2ValidAPIURL2, expectedDefaultOrganizationID: s(v2ValidDefaultOrganizationID2), expectedDefaultProjectID: s(v2ValidDefaultProjectID2), expectedDefaultRegion: r(Region(v2ValidDefaultRegion2)), expectedDefaultZone: z(Zone(v2ValidDefaultZone2)), }, { name: "Complete config with active profile env variable and all env variables", env: map[string]string{ "HOME": "{HOME}", ScwActiveProfileEnv: v2ValidProfile, ScwAccessKeyEnv: v2ValidAccessKey, ScwSecretKeyEnv: v2ValidSecretKey, ScwAPIURLEnv: v2ValidAPIURL, ScwDefaultOrganizationIDEnv: v2ValidDefaultOrganizationID, ScwDefaultProjectIDEnv: v2ValidDefaultProjectID, ScwDefaultRegionEnv: v2ValidDefaultRegion, ScwDefaultZoneEnv: v2ValidDefaultZone, }, files: map[string]string{ ".config/scw/config.yaml": v2CompleteValidConfigFile, }, expectedAccessKey: v2ValidAccessKey, expectedSecretKey: v2ValidSecretKey, expectedAPIURL: v2ValidAPIURL, expectedDefaultOrganizationID: s(v2ValidDefaultOrganizationID), expectedDefaultProjectID: s(v2ValidDefaultProjectID), expectedDefaultRegion: r(Region(v2ValidDefaultRegion)), expectedDefaultZone: z(Zone(v2ValidDefaultZone)), }, } // create home dir dir := initEnv(t) // delete home dir and reset env variables defer resetEnv(t, os.Environ(), dir) for _, test := range tests { t.Run(test.name, func(t *testing.T) { // set up env and config file(s) setEnv(t, test.env, test.files, dir) test.expectedError = strings.Replace(test.expectedError, "{HOME}", dir, -1) // remove config file(s) defer cleanEnv(t, test.files, dir) config, err := LoadConfig() testhelpers.AssertNoError(t, err) p, err := config.GetActiveProfile() testhelpers.AssertNoError(t, err) client, err := NewClient(WithProfile(p), WithEnv()) if test.expectedError == "" { testhelpers.AssertNoError(t, err) // assert getters testhelpers.Equals(t, test.expectedAccessKey, client.auth.(*auth.Token).AccessKey) testhelpers.Equals(t, test.expectedSecretKey, client.auth.(*auth.Token).SecretKey) testhelpers.Equals(t, test.expectedAPIURL, client.apiURL) testhelpers.Equals(t, test.expectedDefaultOrganizationID, client.defaultOrganizationID) testhelpers.Equals(t, test.expectedDefaultProjectID, client.defaultProjectID) testhelpers.Equals(t, test.expectedDefaultRegion, client.defaultRegion) testhelpers.Equals(t, test.expectedDefaultZone, client.defaultZone) // skip insecure tests } else { testhelpers.Equals(t, test.expectedError, err.Error()) } }) } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/client_test.go000066400000000000000000000200061456366605600257140ustar00rootroot00000000000000package scw import ( "bytes" "net/http" "os" "strings" "testing" "github.com/scaleway/scaleway-sdk-go/internal/auth" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" "github.com/scaleway/scaleway-sdk-go/logger" ) const ( testAPIURL = "https://api.example.com" defaultAPIURL = "https://api.scaleway.com" testAccessKey = "SCW1234567890ABCDEFG" testSecretKey = "7363616c-6577-6573-6862-6f7579616161" // hint: | xxd -ps -r testDefaultOrganizationID = "6170692e-7363-616c-6577-61792e636f6d" // hint: | xxd -ps -r testDefaultProjectID = "6170692e-7363-616c-6577-61792e636f6e" testDefaultRegion = RegionFrPar testDefaultZone = ZoneFrPar1 testDefaultPageSize = uint32(5) testInsecure = true ) func TestNewClientWithNoAuth(t *testing.T) { t.Run("Basic", func(t *testing.T) { client, err := NewClient() testhelpers.AssertNoError(t, err) secretKey, exist := client.GetSecretKey() testhelpers.Equals(t, "", secretKey) testhelpers.Assert(t, !exist, "secretKey must not exist") accessKey, exist := client.GetAccessKey() testhelpers.Equals(t, "", accessKey) testhelpers.Assert(t, !exist, "accessKey must not exist") }) t.Run("Only access key", func(t *testing.T) { client, err := NewClient(WithProfile(&Profile{ AccessKey: StringPtr(testAccessKey), })) testhelpers.AssertNoError(t, err) secretKey, exist := client.GetSecretKey() testhelpers.Equals(t, "", secretKey) testhelpers.Assert(t, !exist, "secretKey must not exist") accessKey, exist := client.GetAccessKey() testhelpers.Assert(t, exist, "accessKey must exist") testhelpers.Equals(t, accessKey, testAccessKey) }) } func TestNewClientMultipleClients(t *testing.T) { t.Run("Basic", func(t *testing.T) { logger.EnableDebugMode() httpClient := &http.Client{} _, err := NewClient(WithHTTPClient(httpClient)) testhelpers.AssertNoError(t, err) _, isLogger := httpClient.Transport.(*requestLoggerTransport) testhelpers.Assert(t, isLogger, "transport should be a request logger") _, err = NewClient(WithHTTPClient(httpClient)) testhelpers.AssertNoError(t, err) transport, isLogger := httpClient.Transport.(*requestLoggerTransport) testhelpers.Assert(t, isLogger, "transport should be a request logger") _, isLogger = transport.rt.(*requestLoggerTransport) testhelpers.Assert(t, !isLogger, "nested transport should not be a request logger") }) } func TestNewClientWithDefaults(t *testing.T) { options := []ClientOption{ WithInsecure(), } client, err := NewClient(options...) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, defaultAPIURL, client.apiURL) testhelpers.Equals(t, auth.NewNoAuth(), client.auth) } func TestNewClientWithOptions(t *testing.T) { t.Run("Basic", func(t *testing.T) { someHTTPClient := &http.Client{} options := []ClientOption{ WithAPIURL(testAPIURL), WithAuth(testAccessKey, testSecretKey), WithHTTPClient(someHTTPClient), WithDefaultOrganizationID(testDefaultOrganizationID), WithDefaultProjectID(testDefaultProjectID), WithDefaultRegion(testDefaultRegion), WithDefaultZone(testDefaultZone), WithDefaultPageSize(testDefaultPageSize), } client, err := NewClient(options...) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, testAPIURL, client.apiURL) testhelpers.Equals(t, auth.NewToken(testAccessKey, testSecretKey), client.auth) testhelpers.Equals(t, someHTTPClient, client.httpClient) defaultOrganizationID, exist := client.GetDefaultOrganizationID() testhelpers.Equals(t, testDefaultOrganizationID, defaultOrganizationID) testhelpers.Assert(t, exist, "defaultOrganizationID must exist") defaultProjectID, exist := client.GetDefaultProjectID() testhelpers.Equals(t, testDefaultProjectID, defaultProjectID) testhelpers.Assert(t, exist, "defaultProjectID must exist") defaultRegion, exist := client.GetDefaultRegion() testhelpers.Equals(t, testDefaultRegion, defaultRegion) testhelpers.Assert(t, exist, "defaultRegion must exist") defaultZone, exist := client.GetDefaultZone() testhelpers.Equals(t, testDefaultZone, defaultZone) testhelpers.Assert(t, exist, "defaultZone must exist") defaultPageSize, exist := client.GetDefaultPageSize() testhelpers.Equals(t, testDefaultPageSize, defaultPageSize) testhelpers.Assert(t, exist, "defaultPageSize must exist") secretKey, exist := client.GetSecretKey() testhelpers.Equals(t, testSecretKey, secretKey) testhelpers.Assert(t, exist, "secretKey must exist") accessKey, exist := client.GetAccessKey() testhelpers.Equals(t, testAccessKey, accessKey) testhelpers.Assert(t, exist, "accessKey must exist") }) t.Run("With custom profile", func(t *testing.T) { profile := &Profile{ s(testAccessKey), s(testSecretKey), s(testAPIURL), b(testInsecure), s(testDefaultOrganizationID), s(testDefaultProjectID), s(string(testDefaultRegion)), s(string(testDefaultZone)), b(true), } client, err := NewClient(WithProfile(profile)) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, auth.NewToken(testAccessKey, testSecretKey), client.auth) testhelpers.Equals(t, testAPIURL, client.apiURL) clientTransport, ok := client.httpClient.(*http.Client).Transport.(*http.Transport) if loggerTransport, isLogger := client.httpClient.(*http.Client).Transport.(*requestLoggerTransport); !ok && isLogger { clientTransport, ok = loggerTransport.rt.(*http.Transport) } testhelpers.Assert(t, ok, "clientTransport must be not nil") testhelpers.Assert(t, clientTransport.TLSClientConfig != nil, "TLSClientConfig must be not nil") testhelpers.Equals(t, testInsecure, clientTransport.TLSClientConfig.InsecureSkipVerify) defaultOrganizationID, exist := client.GetDefaultOrganizationID() testhelpers.Equals(t, testDefaultOrganizationID, defaultOrganizationID) testhelpers.Assert(t, exist, "defaultOrganizationID must exist") defaultProjectID, exist := client.GetDefaultProjectID() testhelpers.Equals(t, testDefaultProjectID, defaultProjectID) testhelpers.Assert(t, exist, "defaultProjectID must exist") defaultRegion, exist := client.GetDefaultRegion() testhelpers.Equals(t, testDefaultRegion, defaultRegion) testhelpers.Assert(t, exist, "defaultRegion must exist") defaultZone, exist := client.GetDefaultZone() testhelpers.Equals(t, testDefaultZone, defaultZone) testhelpers.Assert(t, exist, "defaultZone must exist") _, exist = client.GetDefaultPageSize() testhelpers.Assert(t, !exist, "defaultPageSize must not exist") secretKey, exist := client.GetSecretKey() testhelpers.Equals(t, testSecretKey, secretKey) testhelpers.Assert(t, exist, "secretKey must exist") accessKey, exist := client.GetAccessKey() testhelpers.Equals(t, testAccessKey, accessKey) testhelpers.Assert(t, exist, "accessKey must exist") }) } type fakeHTTPClient struct{} func (fakeHTTPClient) Do(*http.Request) (*http.Response, error) { return nil, nil } func (fakeHTTPClient) RoundTrip(*http.Request) (*http.Response, error) { return nil, nil } // TestSetInsecureMode test if setInsecureMode panic when given custom HTTP client func TestSetInsecureMode(t *testing.T) { var buf bytes.Buffer logger.DefaultLogger.Init(&buf, logger.LogLevelWarning) // custom Transport client clientWithFakeTransport := newHTTPClient() clientWithFakeTransport.Transport = fakeHTTPClient{} setInsecureMode(clientWithFakeTransport) // custom HTTP client setInsecureMode(fakeHTTPClient{}) // check log messages lines := strings.Split(buf.String(), "\n") getLogMessage := func(s string) string { return strings.Join(strings.Split(s, " ")[3:], " ") } testhelpers.Equals(t, "client: cannot use insecure mode with Transport client of type scw.fakeHTTPClient", getLogMessage(lines[0])) testhelpers.Equals(t, "client: cannot use insecure mode with HTTP client of type scw.fakeHTTPClient", getLogMessage(lines[1])) logger.DefaultLogger.Init(os.Stderr, logger.LogLevelWarning) } func TestNewVariableFromType(t *testing.T) { type fakeType struct { plop int } testhelpers.Equals(t, &fakeType{}, newVariableFromType(&fakeType{3})) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/config.go000066400000000000000000000311061456366605600246470ustar00rootroot00000000000000package scw import ( "bytes" goerrors "errors" "io/ioutil" "os" "path/filepath" "strings" "text/template" "gopkg.in/yaml.v2" "github.com/scaleway/scaleway-sdk-go/internal/auth" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/logger" ) const ( documentationLink = "https://github.com/scaleway/scaleway-sdk-go/blob/master/scw/README.md" defaultConfigPermission = 0600 // Reserved name for the default profile. DefaultProfileName = "default" ) const configFileTemplate = `# Scaleway configuration file # https://github.com/scaleway/scaleway-sdk-go/tree/master/scw#scaleway-config # This configuration file can be used with: # - Scaleway SDK Go (https://github.com/scaleway/scaleway-sdk-go) # - Scaleway CLI (>2.0.0) (https://github.com/scaleway/scaleway-cli) # - Scaleway Terraform Provider (https://www.terraform.io/docs/providers/scaleway/index.html) # You need an access key and a secret key to connect to Scaleway API. # Generate your token at the following address: https://console.scaleway.com/iam/api-keys # An access key is a secret key identifier. {{ if .AccessKey }}access_key: {{.AccessKey}}{{ else }}# access_key: SCW11111111111111111{{ end }} # The secret key is the value that can be used to authenticate against the API (the value used in X-Auth-Token HTTP-header). # The secret key MUST remain secret and not given to anyone or published online. {{ if .SecretKey }}secret_key: {{ .SecretKey }}{{ else }}# secret_key: 11111111-1111-1111-1111-111111111111{{ end }} # Your organization ID is the identifier of your account inside Scaleway infrastructure. {{ if .DefaultOrganizationID }}default_organization_id: {{ .DefaultOrganizationID }}{{ else }}# default_organization_id: 11111111-1111-1111-1111-111111111111{{ end }} # Your project ID is the identifier of the project your resources are attached to (beta). {{ if .DefaultProjectID }}default_project_id: {{ .DefaultProjectID }}{{ else }}# default_project_id: 11111111-1111-1111-1111-111111111111{{ end }} # A region is represented as a geographical area such as France (Paris) or the Netherlands (Amsterdam). # It can contain multiple availability zones. # Example of region: fr-par, nl-ams {{ if .DefaultRegion }}default_region: {{ .DefaultRegion }}{{ else }}# default_region: fr-par{{ end }} # A region can be split into many availability zones (AZ). # Latency between multiple AZ of the same region are low as they have a common network layer. # Example of zones: fr-par-1, nl-ams-1 {{ if .DefaultZone }}default_zone: {{.DefaultZone}}{{ else }}# default_zone: fr-par-1{{ end }} # APIURL overrides the API URL of the Scaleway API to the given URL. # Change that if you want to direct requests to a different endpoint. {{ if .APIURL }}apiurl: {{ .APIURL }}{{ else }}# api_url: https://api.scaleway.com{{ end }} # Insecure enables insecure transport on the client. # Default to false {{ if .Insecure }}insecure: {{ .Insecure }}{{ else }}# insecure: false{{ end }} # A configuration is a named set of Scaleway properties. # Starting off with a Scaleway SDK or Scaleway CLI, you’ll work with a single configuration named default. # You can set properties of the default profile by running either scw init or scw config set. # This single default configuration is suitable for most use cases. {{ if .ActiveProfile }}active_profile: {{ .ActiveProfile }}{{ else }}# active_profile: myProfile{{ end }} # To improve the Scaleway CLI we rely on diagnostic and usage data. # Sending such data is optional and can be disable at any time by setting send_telemetry variable to false. {{ if .SendTelemetry }}send_telemetry: {{ .SendTelemetry }}{{ else }}# send_telemetry: false{{ end }} # To work with multiple projects or authorization accounts, you can set up multiple configurations with scw config configurations create and switch among them accordingly. # You can use a profile by either: # - Define the profile you want to use as the SCW_PROFILE environment variable # - Use the GetActiveProfile() function in the SDK # - Use the --profile flag with the CLI # You can define a profile using the following syntax: {{ if gt (len .Profiles) 0 }} profiles: {{- range $k,$v := .Profiles }} {{ $k }}: {{ if $v.AccessKey }}access_key: {{ $v.AccessKey }}{{ else }}# access_key: SCW11111111111111111{{ end }} {{ if $v.SecretKey }}secret_key: {{ $v.SecretKey }}{{ else }}# secret_key: 11111111-1111-1111-1111-111111111111{{ end }} {{ if $v.DefaultOrganizationID }}default_organization_id: {{ $v.DefaultOrganizationID }}{{ else }}# default_organization_id: 11111111-1111-1111-1111-111111111111{{ end }} {{ if $v.DefaultProjectID }}default_project_id: {{ $v.DefaultProjectID }}{{ else }}# default_project_id: 11111111-1111-1111-1111-111111111111{{ end }} {{ if $v.DefaultZone }}default_zone: {{ $v.DefaultZone }}{{ else }}# default_zone: fr-par-1{{ end }} {{ if $v.DefaultRegion }}default_region: {{ $v.DefaultRegion }}{{ else }}# default_region: fr-par{{ end }} {{ if $v.APIURL }}api_url: {{ $v.APIURL }}{{ else }}# api_url: https://api.scaleway.com{{ end }} {{ if $v.Insecure }}insecure: {{ $v.Insecure }}{{ else }}# insecure: false{{ end }} {{ end }} {{- else }} # profiles: # myProfile: # access_key: 11111111-1111-1111-1111-111111111111 # secret_key: 11111111-1111-1111-1111-111111111111 # default_organization_id: 11111111-1111-1111-1111-111111111111 # default_project_id: 11111111-1111-1111-1111-111111111111 # default_zone: fr-par-1 # default_region: fr-par # api_url: https://api.scaleway.com # insecure: false {{ end -}} ` type Config struct { Profile `yaml:",inline"` ActiveProfile *string `yaml:"active_profile,omitempty" json:"active_profile,omitempty"` Profiles map[string]*Profile `yaml:"profiles,omitempty" json:"profiles,omitempty"` } type Profile struct { AccessKey *string `yaml:"access_key,omitempty" json:"access_key,omitempty"` SecretKey *string `yaml:"secret_key,omitempty" json:"secret_key,omitempty"` APIURL *string `yaml:"api_url,omitempty" json:"api_url,omitempty"` Insecure *bool `yaml:"insecure,omitempty" json:"insecure,omitempty"` DefaultOrganizationID *string `yaml:"default_organization_id,omitempty" json:"default_organization_id,omitempty"` DefaultProjectID *string `yaml:"default_project_id,omitempty" json:"default_project_id,omitempty"` DefaultRegion *string `yaml:"default_region,omitempty" json:"default_region,omitempty"` DefaultZone *string `yaml:"default_zone,omitempty" json:"default_zone,omitempty"` SendTelemetry *bool `yaml:"send_telemetry,omitempty" json:"send_telemetry,omitempty"` } func (p *Profile) String() string { p2 := *p p2.SecretKey = hideSecretKey(p2.SecretKey) configRaw, _ := yaml.Marshal(p2) return string(configRaw) } // clone deep copy config object func (c *Config) clone() *Config { c2 := &Config{} configRaw, _ := yaml.Marshal(c) _ = yaml.Unmarshal(configRaw, c2) return c2 } func (c *Config) String() string { c2 := c.clone() c2.SecretKey = hideSecretKey(c2.SecretKey) for _, p := range c2.Profiles { p.SecretKey = hideSecretKey(p.SecretKey) } configRaw, _ := yaml.Marshal(c2) return string(configRaw) } func (c *Config) IsEmpty() bool { return c.String() == "{}\n" } func hideSecretKey(key *string) *string { if key == nil { return nil } newKey := auth.HideSecretKey(*key) return &newKey } func unmarshalConfV2(content []byte) (*Config, error) { var config Config err := yaml.Unmarshal(content, &config) if err != nil { return nil, err } return &config, nil } // MustLoadConfig is like LoadConfig but panic instead of returning an error. func MustLoadConfig() *Config { c, err := LoadConfigFromPath(GetConfigPath()) if err != nil { panic(err) } return c } // LoadConfig read the config from the default path. func LoadConfig() (*Config, error) { configPath := GetConfigPath() cfg, err := LoadConfigFromPath(configPath) // Special case if using default config path // if config.yaml does not exist, we should try to read config.yml if os.Getenv(ScwConfigPathEnv) == "" { var configNotFoundError *ConfigFileNotFoundError if err != nil && goerrors.As(err, &configNotFoundError) && strings.HasSuffix(configPath, ".yaml") { configPath = strings.TrimSuffix(configPath, ".yaml") + ".yml" cfgYml, errYml := LoadConfigFromPath(configPath) // If .yml config is not found, return first error when reading .yaml if errYml == nil || (errYml != nil && !goerrors.As(errYml, &configNotFoundError)) { return cfgYml, errYml } } } return cfg, err } // LoadConfigFromPath read the config from the given path. func LoadConfigFromPath(path string) (*Config, error) { _, err := os.Stat(path) if os.IsNotExist(err) { return nil, configFileNotFound(path) } if err != nil { return nil, err } file, err := ioutil.ReadFile(path) if err != nil { return nil, errors.Wrap(err, "cannot read config file") } confV2, err := unmarshalConfV2(file) if err != nil { return nil, errors.Wrap(err, "content of config file %s is invalid", path) } return confV2, nil } // GetProfile returns the profile corresponding to the given profile name. func (c *Config) GetProfile(profileName string) (*Profile, error) { if profileName == "" { return nil, errors.New("profileName cannot be empty") } if profileName == DefaultProfileName { return &c.Profile, nil } p, exist := c.Profiles[profileName] if !exist { return nil, errors.New("given profile %s does not exist", profileName) } // Merge selected profile on top of default profile return MergeProfiles(&c.Profile, p), nil } // GetActiveProfile returns the active profile of the config based on the following order: // env SCW_PROFILE > config active_profile > config root profile func (c *Config) GetActiveProfile() (*Profile, error) { switch { case os.Getenv(ScwActiveProfileEnv) != "": logger.Debugf("using active profile from env: %s=%s", ScwActiveProfileEnv, os.Getenv(ScwActiveProfileEnv)) return c.GetProfile(os.Getenv(ScwActiveProfileEnv)) case c.ActiveProfile != nil: logger.Debugf("using active profile from config: active_profile=%s", ScwActiveProfileEnv, *c.ActiveProfile) return c.GetProfile(*c.ActiveProfile) default: return &c.Profile, nil } } // SaveTo will save the config to the default config path. This // action will overwrite the previous file when it exists. func (c *Config) Save() error { return c.SaveTo(GetConfigPath()) } // HumanConfig will generate a config file with documented arguments. func (c *Config) HumanConfig() (string, error) { tmpl, err := template.New("configuration").Parse(configFileTemplate) if err != nil { return "", err } var buf bytes.Buffer err = tmpl.Execute(&buf, c) if err != nil { return "", err } return buf.String(), nil } // SaveTo will save the config to the given path. This action will // overwrite the previous file when it exists. func (c *Config) SaveTo(path string) error { path = filepath.Clean(path) // STEP 1: Render the configuration file as a file file, err := c.HumanConfig() if err != nil { return err } // STEP 2: create config path dir in cases it didn't exist before err = os.MkdirAll(filepath.Dir(path), 0700) if err != nil { return err } // STEP 3: write new config file err = ioutil.WriteFile(path, []byte(file), defaultConfigPermission) if err != nil { return err } return nil } // MergeProfiles merges profiles in a new one. The last profile has priority. func MergeProfiles(original *Profile, others ...*Profile) *Profile { np := &Profile{ AccessKey: original.AccessKey, SecretKey: original.SecretKey, APIURL: original.APIURL, Insecure: original.Insecure, DefaultOrganizationID: original.DefaultOrganizationID, DefaultProjectID: original.DefaultProjectID, DefaultRegion: original.DefaultRegion, DefaultZone: original.DefaultZone, SendTelemetry: original.SendTelemetry, } for _, other := range others { if other.AccessKey != nil { np.AccessKey = other.AccessKey } if other.SecretKey != nil { np.SecretKey = other.SecretKey } if other.APIURL != nil { np.APIURL = other.APIURL } if other.Insecure != nil { np.Insecure = other.Insecure } if other.DefaultOrganizationID != nil { np.DefaultOrganizationID = other.DefaultOrganizationID } if other.DefaultProjectID != nil { np.DefaultProjectID = other.DefaultProjectID } if other.DefaultRegion != nil { np.DefaultRegion = other.DefaultRegion } if other.DefaultZone != nil { np.DefaultZone = other.DefaultZone } if other.SendTelemetry != nil { np.SendTelemetry = other.SendTelemetry } } return np } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/config_test.go000066400000000000000000000717161456366605600257210ustar00rootroot00000000000000package scw import ( "io/ioutil" "os" "path/filepath" "strings" "testing" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" "github.com/scaleway/scaleway-sdk-go/logger" ) const emptyFile = "" // v2 config var ( v2ValidAccessKey2 = "SCW234567890ABCDEFGH" v2ValidSecretKey2 = "6f6e6574-6f72-756c-6c74-68656d616c6c" // hint: | xxd -ps -r v2ValidAPIURL2 = "api-fr-par.scaleway.com" v2ValidInsecure2 = "true" v2ValidSendTelemetry2 = "true" v2ValidDefaultOrganizationID2 = "6d6f7264-6f72-6772-6561-74616761696e" // hint: | xxd -ps -r v2ValidDefaultProjectID2 = "6d6f7264-6f72-6772-6561-74616761696f" v2ValidDefaultRegion2 = string(RegionFrPar) v2ValidDefaultZone2 = string(ZoneFrPar2) v2ValidAccessKey = "SCW1234567890ABCDEFG" v2ValidSecretKey = "7363616c-6577-6573-6862-6f7579616161" // hint: | xxd -ps -r v2ValidAPIURL = "api.scaleway.com" v2ValidInsecure = "false" v2ValidSendTelemetry = "true" v2ValidDefaultOrganizationID = "6170692e-7363-616c-6577-61792e636f6d" // hint: | xxd -ps -r v2ValidDefaultProjectID = "6170692e-7363-616c-6577-61792e636f6e" v2ValidDefaultRegion = string(RegionNlAms) v2ValidDefaultZone = string(ZoneNlAms1) v2ValidProfile = "flantier" v2InvalidAccessKey = "invalid" v2InvalidSecretKey = "invalid" v2InvalidDefaultOrganizationID = "invalid" v2InvalidDefaultProjectID = "invalid" v2InvalidDefaultRegion = "invalid" v2InvalidDefaultZone = "invalid" v2SimpleValidConfig = &Config{ Profile: Profile{ AccessKey: &v2ValidAccessKey, SecretKey: &v2ValidSecretKey, DefaultOrganizationID: &v2ValidDefaultOrganizationID, DefaultProjectID: &v2ValidDefaultProjectID, DefaultRegion: &v2ValidDefaultRegion, }, } v2PartialValidConfigFile = ` access_key: ` + v2ValidAccessKey + ` secret_key: ` + v2ValidSecretKey + ` api_url: ` + v2ValidAPIURL + ` insecure: ` + v2ValidInsecure + ` default_organization_id: ` + v2ValidDefaultOrganizationID + ` default_project_id: ` + v2ValidDefaultProjectID + ` default_region: ` + v2ValidDefaultRegion + ` default_zone: ` + v2ValidDefaultZone v2CompleteValidConfigFile = v2PartialValidConfigFile + ` profiles: ` + v2ValidProfile + `: access_key: ` + v2ValidAccessKey2 + ` secret_key: ` + v2ValidSecretKey2 + ` api_url: ` + v2ValidAPIURL2 + ` insecure: ` + v2ValidInsecure2 + ` send_telemetry: ` + v2ValidSendTelemetry2 + ` default_organization_id: ` + v2ValidDefaultOrganizationID2 + ` default_project_id: ` + v2ValidDefaultProjectID2 + ` default_region: ` + v2ValidDefaultRegion2 + ` default_zone: ` + v2ValidDefaultZone2 + ` ` v2CompleteValidConfigWithActiveProfileFile = ` access_key: ` + v2ValidAccessKey + ` secret_key: ` + v2ValidSecretKey + ` api_url: ` + v2ValidAPIURL + ` insecure: ` + v2ValidInsecure + ` send_telemetry: ` + v2ValidSendTelemetry2 + ` default_organization_id: ` + v2ValidDefaultOrganizationID + ` default_project_id: ` + v2ValidDefaultProjectID + ` default_region: ` + v2ValidDefaultRegion + ` default_zone: ` + v2ValidDefaultZone + ` active_profile: ` + v2ValidProfile + ` profiles: ` + v2ValidProfile + `: access_key: ` + v2ValidAccessKey2 + ` secret_key: ` + v2ValidSecretKey2 + ` api_url: ` + v2ValidAPIURL2 + ` insecure: ` + v2ValidInsecure2 + ` default_organization_id: ` + v2ValidDefaultOrganizationID2 + ` default_project_id: ` + v2ValidDefaultProjectID2 + ` default_region: ` + v2ValidDefaultRegion2 + ` default_zone: ` + v2ValidDefaultZone2 + ` ` v2MixedValidConfigWithActiveProfileFile = ` access_key: ` + v2ValidAccessKey + ` secret_key: ` + v2ValidSecretKey + ` api_url: ` + v2ValidAPIURL + ` insecure: ` + v2ValidInsecure + ` send_telemetry: ` + v2ValidSendTelemetry + ` default_organization_id: ` + v2ValidDefaultOrganizationID + ` default_project_id: ` + v2ValidDefaultProjectID + ` default_region: ` + v2ValidDefaultRegion + ` default_zone: ` + v2ValidDefaultZone + ` active_profile: ` + v2ValidProfile + ` profiles: ` + v2ValidProfile + `: access_key: ` + v2ValidAccessKey2 + ` secret_key: ` + v2ValidSecretKey2 + ` ` v2SimpleValidConfigFile = ` access_key: ` + v2ValidAccessKey + ` secret_key: ` + v2ValidSecretKey + ` default_organization_id: ` + v2ValidDefaultOrganizationID + ` default_project_id: ` + v2ValidDefaultProjectID + ` default_region: ` + v2ValidDefaultRegion + ` ` v2SimpleInvalidConfigFile = `insecure: "bool""` v2SimpleConfigFileWithInvalidProfile = `active_profile: flantier` ) // TestSaveConfig tests config write the correct values in the config file func TestSaveConfig(t *testing.T) { tests := []struct { name string env map[string]string files map[string]string config *Config funcUpdateConfig func(*Config) expectedFiles map[string]string }{ { name: "Custom-path config", env: map[string]string{ ScwConfigPathEnv: "{HOME}/valid1/test.conf", }, files: map[string]string{ "valid1/test.conf": emptyFile, }, config: &Config{ Profile: Profile{ AccessKey: s(v2ValidAccessKey), SecretKey: s(v2ValidSecretKey), DefaultOrganizationID: s(v2ValidDefaultOrganizationID), DefaultProjectID: s(v2ValidDefaultProjectID), DefaultRegion: s(v2ValidDefaultRegion), }, }, expectedFiles: map[string]string{ "valid1/test.conf": v2SimpleValidConfigFile, }, }, { name: "Default config path", env: map[string]string{ "HOME": "{HOME}", }, config: &Config{ Profile: Profile{ AccessKey: s(v2ValidAccessKey), SecretKey: s(v2ValidSecretKey), DefaultOrganizationID: s(v2ValidDefaultOrganizationID), DefaultProjectID: s(v2ValidDefaultProjectID), DefaultRegion: s(v2ValidDefaultRegion), }, }, expectedFiles: map[string]string{ ".config/scw/config.yaml": v2SimpleValidConfigFile, }, }, { name: "Add zone only", env: map[string]string{ "HOME": "{HOME}", }, files: map[string]string{ ".config/scw/config.yaml": v2SimpleValidConfigFile, }, config: &Config{}, funcUpdateConfig: func(c *Config) { *c = *MustLoadConfig() c.DefaultZone = s(v2ValidDefaultZone) }, expectedFiles: map[string]string{ ".config/scw/config.yaml": v2SimpleValidConfigFile + "default_zone: " + v2ValidDefaultZone + "\n", }, }, { name: "Add new profile", env: map[string]string{ "HOME": "{HOME}", }, files: map[string]string{ ".config/scw/config.yaml": v2PartialValidConfigFile, }, config: &Config{}, funcUpdateConfig: func(c *Config) { *c = *MustLoadConfig() c.Profiles = map[string]*Profile{v2ValidProfile: { AccessKey: s(v2ValidAccessKey2), SecretKey: s(v2ValidSecretKey2), APIURL: s(v2ValidAPIURL2), Insecure: b(true), DefaultOrganizationID: s(v2ValidDefaultOrganizationID2), DefaultProjectID: s(v2ValidDefaultProjectID2), DefaultRegion: s(v2ValidDefaultRegion2), DefaultZone: s(v2ValidDefaultZone2), }} }, expectedFiles: map[string]string{ ".config/scw/config.yaml": v2CompleteValidConfigFile, }, }, } // create home dir dir := initEnv(t) // delete home dir and reset env variables defer resetEnv(t, os.Environ(), dir) for _, test := range tests { t.Run(test.name, func(t *testing.T) { // set up env and config file(s) setEnv(t, test.env, test.files, dir) // remove config file(s) defer cleanEnv(t, test.files, dir) defer cleanEnv(t, test.expectedFiles, dir) if test.funcUpdateConfig != nil { test.funcUpdateConfig(test.config) } testhelpers.AssertNoError(t, test.config.Save()) // test expected files for fileName := range test.expectedFiles { expectedContent, err := test.config.HumanConfig() testhelpers.AssertNoError(t, err) content, err := ioutil.ReadFile(filepath.Join(dir, fileName)) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, expectedContent, string(content)) } }) } } // TestLoadConfig tests config getters return correct values func TestLoadProfileAndActiveProfile(t *testing.T) { tests := []struct { name string env map[string]string files map[string]string expectedError string expectedAccessKey *string expectedSecretKey *string expectedAPIURL *string expectedInsecure *bool expectedSendTelemetry *bool expectedDefaultOrganizationID *string expectedDefaultProjectID *string expectedDefaultRegion *string expectedDefaultZone *string }{ // no env variables { name: "No config without home dir", expectedError: "scaleway-sdk-go: cannot read config file: read .: is a directory", }, { name: "No config", expectedError: "scaleway-sdk-go: cannot read config file {HOME}/.config/scw/config.yaml: no such file or directory", env: map[string]string{ "HOME": "{HOME}", }, }, { name: "Custom-path config is empty", // custom config path env: map[string]string{ ScwConfigPathEnv: "{HOME}/valid1/test.conf", }, files: map[string]string{ "valid1/test.conf": emptyFile, }, }, { name: "Custom-path config with valid V2", env: map[string]string{ ScwConfigPathEnv: "{HOME}/valid3/test.conf", }, files: map[string]string{ "valid3/test.conf": v2SimpleValidConfigFile, }, expectedAccessKey: s(v2ValidAccessKey), expectedSecretKey: s(v2ValidSecretKey), expectedDefaultOrganizationID: s(v2ValidDefaultOrganizationID), expectedDefaultProjectID: s(v2ValidDefaultProjectID), expectedDefaultRegion: s(v2ValidDefaultRegion), }, { name: "Simple config with valid V2", // default config path env: map[string]string{ "HOME": "{HOME}", }, files: map[string]string{ ".config/scw/config.yaml": v2SimpleValidConfigFile, }, expectedAccessKey: s(v2ValidAccessKey), expectedSecretKey: s(v2ValidSecretKey), expectedDefaultOrganizationID: s(v2ValidDefaultOrganizationID), expectedDefaultProjectID: s(v2ValidDefaultProjectID), expectedDefaultRegion: s(v2ValidDefaultRegion), }, { name: "Complete config", env: map[string]string{ "HOME": "{HOME}", }, files: map[string]string{ ".config/scw/config.yaml": v2CompleteValidConfigFile, }, expectedAccessKey: s(v2ValidAccessKey), expectedSecretKey: s(v2ValidSecretKey), expectedAPIURL: s(v2ValidAPIURL), expectedInsecure: b(false), expectedDefaultOrganizationID: s(v2ValidDefaultOrganizationID), expectedDefaultProjectID: s(v2ValidDefaultProjectID), expectedDefaultRegion: s(v2ValidDefaultRegion), expectedDefaultZone: s(v2ValidDefaultZone), }, { name: "Complete config with active profile", env: map[string]string{ "HOME": "{HOME}", }, files: map[string]string{ ".config/scw/config.yaml": v2CompleteValidConfigWithActiveProfileFile, }, expectedAccessKey: s(v2ValidAccessKey2), expectedSecretKey: s(v2ValidSecretKey2), expectedAPIURL: s(v2ValidAPIURL2), expectedInsecure: b(true), expectedDefaultOrganizationID: s(v2ValidDefaultOrganizationID2), expectedDefaultProjectID: s(v2ValidDefaultProjectID2), expectedDefaultRegion: s(v2ValidDefaultRegion2), expectedDefaultZone: s(v2ValidDefaultZone2), expectedSendTelemetry: b(true), }, { name: "Mixed config with active profile", env: map[string]string{ "HOME": "{HOME}", }, files: map[string]string{ ".config/scw/config.yaml": v2MixedValidConfigWithActiveProfileFile, }, expectedAccessKey: s(v2ValidAccessKey2), expectedSecretKey: s(v2ValidSecretKey2), expectedAPIURL: s(v2ValidAPIURL), expectedInsecure: b(false), expectedDefaultOrganizationID: s(v2ValidDefaultOrganizationID), expectedDefaultProjectID: s(v2ValidDefaultProjectID), expectedDefaultRegion: s(v2ValidDefaultRegion), expectedDefaultZone: s(v2ValidDefaultZone), expectedSendTelemetry: b(true), }, { name: "Complete config with active profile env variable", env: map[string]string{ "HOME": "{HOME}", ScwActiveProfileEnv: v2ValidProfile, }, files: map[string]string{ ".config/scw/config.yaml": v2CompleteValidConfigFile, }, expectedAccessKey: s(v2ValidAccessKey2), expectedSecretKey: s(v2ValidSecretKey2), expectedAPIURL: s(v2ValidAPIURL2), expectedInsecure: b(true), expectedDefaultOrganizationID: s(v2ValidDefaultOrganizationID2), expectedDefaultProjectID: s(v2ValidDefaultProjectID2), expectedDefaultRegion: s(v2ValidDefaultRegion2), expectedDefaultZone: s(v2ValidDefaultZone2), }, // Config file config.yaml and config.yml { name: "Read config.yml", env: map[string]string{ "HOME": "{HOME}", }, files: map[string]string{ ".config/scw/config.yml": v2SimpleValidConfigFile, }, expectedAccessKey: s(v2ValidAccessKey), expectedSecretKey: s(v2ValidSecretKey), expectedDefaultOrganizationID: s(v2ValidDefaultOrganizationID), expectedDefaultProjectID: s(v2ValidDefaultProjectID), expectedDefaultRegion: s(v2ValidDefaultRegion), }, } // create home dir dir := initEnv(t) // delete home dir and reset env variables defer resetEnv(t, os.Environ(), dir) logger.EnableDebugMode() for _, test := range tests { t.Run(test.name, func(t *testing.T) { // set up env and config file(s) setEnv(t, test.env, test.files, dir) test.expectedError = strings.Replace(test.expectedError, "{HOME}", dir, -1) // remove config file(s) defer cleanEnv(t, test.files, dir) config, err := LoadConfig() if test.expectedError == "" { testhelpers.AssertNoError(t, err) p, err := config.GetActiveProfile() testhelpers.AssertNoError(t, err) // assert getters testhelpers.Equals(t, test.expectedAccessKey, p.AccessKey) testhelpers.Equals(t, test.expectedSecretKey, p.SecretKey) testhelpers.Equals(t, test.expectedAPIURL, p.APIURL) testhelpers.Equals(t, test.expectedDefaultOrganizationID, p.DefaultOrganizationID) testhelpers.Equals(t, test.expectedDefaultProjectID, p.DefaultProjectID) testhelpers.Equals(t, test.expectedDefaultRegion, p.DefaultRegion) testhelpers.Equals(t, test.expectedDefaultZone, p.DefaultZone) testhelpers.Equals(t, test.expectedInsecure, p.Insecure) testhelpers.Equals(t, test.expectedSendTelemetry, config.SendTelemetry) } else { testhelpers.Equals(t, test.expectedError, err.Error()) } }) } } func TestConfigString(t *testing.T) { var c = &Config{ Profile: Profile{ AccessKey: s(v2ValidAccessKey), SecretKey: s(v2ValidSecretKey), SendTelemetry: b(true), }, ActiveProfile: s(v2ValidProfile), Profiles: map[string]*Profile{ v2ValidProfile: { AccessKey: s(v2ValidAccessKey2), SecretKey: s(v2ValidSecretKey2), }, }, } testhelpers.Equals(t, `access_key: SCW1234567890ABCDEFG secret_key: 7363616c-xxxx-xxxx-xxxx-xxxxxxxxxxxx send_telemetry: true active_profile: flantier profiles: flantier: access_key: SCW234567890ABCDEFGH secret_key: 6f6e6574-xxxx-xxxx-xxxx-xxxxxxxxxxxx `, c.String()) testhelpers.Equals(t, v2ValidSecretKey, *c.SecretKey) p, err := c.GetActiveProfile() testhelpers.AssertNoError(t, err) testhelpers.Equals(t, `access_key: SCW234567890ABCDEFGH secret_key: 6f6e6574-xxxx-xxxx-xxxx-xxxxxxxxxxxx send_telemetry: true `, p.String()) testhelpers.Equals(t, v2ValidSecretKey2, *p.SecretKey) } func TestMergeProfiles(t *testing.T) { p1 := &Profile{ AccessKey: StringPtr("1"), SecretKey: StringPtr("1"), } p2 := &Profile{ AccessKey: StringPtr("2"), Insecure: BoolPtr(true), } p3 := &Profile{ Insecure: BoolPtr(false), DefaultZone: StringPtr(string(ZoneFrPar1)), } act := MergeProfiles(p1, p2, p3) exp := &Profile{ AccessKey: StringPtr("2"), SecretKey: StringPtr("1"), Insecure: BoolPtr(false), DefaultZone: StringPtr(string(ZoneFrPar1)), } testhelpers.Equals(t, exp, act) } func initEnv(t *testing.T) string { dir, err := ioutil.TempDir("", "home") if err != nil { t.Fatal(err) } return dir } func cleanEnv(t *testing.T, files map[string]string, homeDir string) { for path := range files { testhelpers.AssertNoError(t, os.RemoveAll(filepath.Join(homeDir, path))) } } func setEnv(t *testing.T, env, files map[string]string, homeDir string) { os.Clearenv() for key, value := range env { value = strings.Replace(value, "{HOME}", homeDir, -1) testhelpers.AssertNoError(t, os.Setenv(key, value)) } for path, content := range files { targetPath := filepath.Join(homeDir, path) testhelpers.AssertNoError(t, os.MkdirAll(filepath.Dir(targetPath), 0700)) testhelpers.AssertNoError(t, ioutil.WriteFile(targetPath, []byte(content), defaultConfigPermission)) } } // function taken from https://golang.org/src/os/env_test.go func resetEnv(t *testing.T, origEnv []string, homeDir string) { testhelpers.AssertNoError(t, os.RemoveAll(homeDir)) for _, pair := range origEnv { // Environment variables on Windows can begin with = // https://blogs.msdn.com/b/oldnewthing/archive/2010/05/06/10008132.aspx i := strings.Index(pair[1:], "=") + 1 if err := os.Setenv(pair[:i], pair[i+1:]); err != nil { t.Errorf("Setenv(%q, %q) failed during reset: %v", pair[:i], pair[i+1:], err) } } } func s(value string) *string { return &value } func r(value Region) *Region { return &value } func z(value Zone) *Zone { return &value } func b(value bool) *bool { return &value } func TestConfig_ConfigFile(t *testing.T) { type testCase struct { config *Config result string } run := func(c *testCase) func(t *testing.T) { return func(t *testing.T) { config, err := c.config.HumanConfig() testhelpers.AssertNoError(t, err) testhelpers.Equals(t, c.result, config) loaded, err2 := unmarshalConfV2([]byte(config)) testhelpers.AssertNoError(t, err2) testhelpers.Equals(t, c.config, loaded) } } t.Run("empty", run(&testCase{ config: &Config{}, result: `# Scaleway configuration file # https://github.com/scaleway/scaleway-sdk-go/tree/master/scw#scaleway-config # This configuration file can be used with: # - Scaleway SDK Go (https://github.com/scaleway/scaleway-sdk-go) # - Scaleway CLI (>2.0.0) (https://github.com/scaleway/scaleway-cli) # - Scaleway Terraform Provider (https://www.terraform.io/docs/providers/scaleway/index.html) # You need an access key and a secret key to connect to Scaleway API. # Generate your token at the following address: https://console.scaleway.com/iam/api-keys # An access key is a secret key identifier. # access_key: SCW11111111111111111 # The secret key is the value that can be used to authenticate against the API (the value used in X-Auth-Token HTTP-header). # The secret key MUST remain secret and not given to anyone or published online. # secret_key: 11111111-1111-1111-1111-111111111111 # Your organization ID is the identifier of your account inside Scaleway infrastructure. # default_organization_id: 11111111-1111-1111-1111-111111111111 # Your project ID is the identifier of the project your resources are attached to (beta). # default_project_id: 11111111-1111-1111-1111-111111111111 # A region is represented as a geographical area such as France (Paris) or the Netherlands (Amsterdam). # It can contain multiple availability zones. # Example of region: fr-par, nl-ams # default_region: fr-par # A region can be split into many availability zones (AZ). # Latency between multiple AZ of the same region are low as they have a common network layer. # Example of zones: fr-par-1, nl-ams-1 # default_zone: fr-par-1 # APIURL overrides the API URL of the Scaleway API to the given URL. # Change that if you want to direct requests to a different endpoint. # api_url: https://api.scaleway.com # Insecure enables insecure transport on the client. # Default to false # insecure: false # A configuration is a named set of Scaleway properties. # Starting off with a Scaleway SDK or Scaleway CLI, you’ll work with a single configuration named default. # You can set properties of the default profile by running either scw init or scw config set. # This single default configuration is suitable for most use cases. # active_profile: myProfile # To improve the Scaleway CLI we rely on diagnostic and usage data. # Sending such data is optional and can be disable at any time by setting send_telemetry variable to false. # send_telemetry: false # To work with multiple projects or authorization accounts, you can set up multiple configurations with scw config configurations create and switch among them accordingly. # You can use a profile by either: # - Define the profile you want to use as the SCW_PROFILE environment variable # - Use the GetActiveProfile() function in the SDK # - Use the --profile flag with the CLI # You can define a profile using the following syntax: # profiles: # myProfile: # access_key: 11111111-1111-1111-1111-111111111111 # secret_key: 11111111-1111-1111-1111-111111111111 # default_organization_id: 11111111-1111-1111-1111-111111111111 # default_project_id: 11111111-1111-1111-1111-111111111111 # default_zone: fr-par-1 # default_region: fr-par # api_url: https://api.scaleway.com # insecure: false `, })) t.Run("partial", run(&testCase{ config: &Config{ Profile: Profile{ AccessKey: s(v2ValidAccessKey), }}, result: `# Scaleway configuration file # https://github.com/scaleway/scaleway-sdk-go/tree/master/scw#scaleway-config # This configuration file can be used with: # - Scaleway SDK Go (https://github.com/scaleway/scaleway-sdk-go) # - Scaleway CLI (>2.0.0) (https://github.com/scaleway/scaleway-cli) # - Scaleway Terraform Provider (https://www.terraform.io/docs/providers/scaleway/index.html) # You need an access key and a secret key to connect to Scaleway API. # Generate your token at the following address: https://console.scaleway.com/iam/api-keys # An access key is a secret key identifier. access_key: SCW1234567890ABCDEFG # The secret key is the value that can be used to authenticate against the API (the value used in X-Auth-Token HTTP-header). # The secret key MUST remain secret and not given to anyone or published online. # secret_key: 11111111-1111-1111-1111-111111111111 # Your organization ID is the identifier of your account inside Scaleway infrastructure. # default_organization_id: 11111111-1111-1111-1111-111111111111 # Your project ID is the identifier of the project your resources are attached to (beta). # default_project_id: 11111111-1111-1111-1111-111111111111 # A region is represented as a geographical area such as France (Paris) or the Netherlands (Amsterdam). # It can contain multiple availability zones. # Example of region: fr-par, nl-ams # default_region: fr-par # A region can be split into many availability zones (AZ). # Latency between multiple AZ of the same region are low as they have a common network layer. # Example of zones: fr-par-1, nl-ams-1 # default_zone: fr-par-1 # APIURL overrides the API URL of the Scaleway API to the given URL. # Change that if you want to direct requests to a different endpoint. # api_url: https://api.scaleway.com # Insecure enables insecure transport on the client. # Default to false # insecure: false # A configuration is a named set of Scaleway properties. # Starting off with a Scaleway SDK or Scaleway CLI, you’ll work with a single configuration named default. # You can set properties of the default profile by running either scw init or scw config set. # This single default configuration is suitable for most use cases. # active_profile: myProfile # To improve the Scaleway CLI we rely on diagnostic and usage data. # Sending such data is optional and can be disable at any time by setting send_telemetry variable to false. # send_telemetry: false # To work with multiple projects or authorization accounts, you can set up multiple configurations with scw config configurations create and switch among them accordingly. # You can use a profile by either: # - Define the profile you want to use as the SCW_PROFILE environment variable # - Use the GetActiveProfile() function in the SDK # - Use the --profile flag with the CLI # You can define a profile using the following syntax: # profiles: # myProfile: # access_key: 11111111-1111-1111-1111-111111111111 # secret_key: 11111111-1111-1111-1111-111111111111 # default_organization_id: 11111111-1111-1111-1111-111111111111 # default_project_id: 11111111-1111-1111-1111-111111111111 # default_zone: fr-par-1 # default_region: fr-par # api_url: https://api.scaleway.com # insecure: false `, })) t.Run("full", run(&testCase{ config: &Config{ Profile: Profile{ AccessKey: s(v2ValidAccessKey), SecretKey: s(v2ValidSecretKey), SendTelemetry: b(true), }, ActiveProfile: s(v2ValidProfile), Profiles: map[string]*Profile{ "profile1": { AccessKey: s(v2ValidAccessKey2), SecretKey: s(v2ValidSecretKey2), }, "profile2": { AccessKey: s(v2ValidAccessKey2), SecretKey: s(v2ValidSecretKey2), }, }, }, result: `# Scaleway configuration file # https://github.com/scaleway/scaleway-sdk-go/tree/master/scw#scaleway-config # This configuration file can be used with: # - Scaleway SDK Go (https://github.com/scaleway/scaleway-sdk-go) # - Scaleway CLI (>2.0.0) (https://github.com/scaleway/scaleway-cli) # - Scaleway Terraform Provider (https://www.terraform.io/docs/providers/scaleway/index.html) # You need an access key and a secret key to connect to Scaleway API. # Generate your token at the following address: https://console.scaleway.com/iam/api-keys # An access key is a secret key identifier. access_key: SCW1234567890ABCDEFG # The secret key is the value that can be used to authenticate against the API (the value used in X-Auth-Token HTTP-header). # The secret key MUST remain secret and not given to anyone or published online. secret_key: 7363616c-6577-6573-6862-6f7579616161 # Your organization ID is the identifier of your account inside Scaleway infrastructure. # default_organization_id: 11111111-1111-1111-1111-111111111111 # Your project ID is the identifier of the project your resources are attached to (beta). # default_project_id: 11111111-1111-1111-1111-111111111111 # A region is represented as a geographical area such as France (Paris) or the Netherlands (Amsterdam). # It can contain multiple availability zones. # Example of region: fr-par, nl-ams # default_region: fr-par # A region can be split into many availability zones (AZ). # Latency between multiple AZ of the same region are low as they have a common network layer. # Example of zones: fr-par-1, nl-ams-1 # default_zone: fr-par-1 # APIURL overrides the API URL of the Scaleway API to the given URL. # Change that if you want to direct requests to a different endpoint. # api_url: https://api.scaleway.com # Insecure enables insecure transport on the client. # Default to false # insecure: false # A configuration is a named set of Scaleway properties. # Starting off with a Scaleway SDK or Scaleway CLI, you’ll work with a single configuration named default. # You can set properties of the default profile by running either scw init or scw config set. # This single default configuration is suitable for most use cases. active_profile: flantier # To improve the Scaleway CLI we rely on diagnostic and usage data. # Sending such data is optional and can be disable at any time by setting send_telemetry variable to false. send_telemetry: true # To work with multiple projects or authorization accounts, you can set up multiple configurations with scw config configurations create and switch among them accordingly. # You can use a profile by either: # - Define the profile you want to use as the SCW_PROFILE environment variable # - Use the GetActiveProfile() function in the SDK # - Use the --profile flag with the CLI # You can define a profile using the following syntax: profiles: profile1: access_key: SCW234567890ABCDEFGH secret_key: 6f6e6574-6f72-756c-6c74-68656d616c6c # default_organization_id: 11111111-1111-1111-1111-111111111111 # default_project_id: 11111111-1111-1111-1111-111111111111 # default_zone: fr-par-1 # default_region: fr-par # api_url: https://api.scaleway.com # insecure: false profile2: access_key: SCW234567890ABCDEFGH secret_key: 6f6e6574-6f72-756c-6c74-68656d616c6c # default_organization_id: 11111111-1111-1111-1111-111111111111 # default_project_id: 11111111-1111-1111-1111-111111111111 # default_zone: fr-par-1 # default_region: fr-par # api_url: https://api.scaleway.com # insecure: false `, })) } func TestEmptyConfig(t *testing.T) { testhelpers.Assert(t, (&Config{}).IsEmpty(), "Config must be empty") } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/convert.go000066400000000000000000000076211456366605600250670ustar00rootroot00000000000000package scw import ( "net" "time" ) // StringPtr returns a pointer to the string value passed in. func StringPtr(v string) *string { return &v } // StringSlicePtr converts a slice of string values into a slice of // string pointers func StringSlicePtr(src []string) []*string { dst := make([]*string, len(src)) for i := 0; i < len(src); i++ { dst[i] = &(src[i]) } return dst } // StringsPtr returns a pointer to the []string value passed in. func StringsPtr(v []string) *[]string { return &v } // StringsSlicePtr converts a slice of []string values into a slice of // []string pointers func StringsSlicePtr(src [][]string) []*[]string { dst := make([]*[]string, len(src)) for i := 0; i < len(src); i++ { dst[i] = &(src[i]) } return dst } // BytesPtr returns a pointer to the []byte value passed in. func BytesPtr(v []byte) *[]byte { return &v } // BytesSlicePtr converts a slice of []byte values into a slice of // []byte pointers func BytesSlicePtr(src [][]byte) []*[]byte { dst := make([]*[]byte, len(src)) for i := 0; i < len(src); i++ { dst[i] = &(src[i]) } return dst } // BoolPtr returns a pointer to the bool value passed in. func BoolPtr(v bool) *bool { return &v } // BoolSlicePtr converts a slice of bool values into a slice of // bool pointers func BoolSlicePtr(src []bool) []*bool { dst := make([]*bool, len(src)) for i := 0; i < len(src); i++ { dst[i] = &(src[i]) } return dst } // Int32Ptr returns a pointer to the int32 value passed in. func Int32Ptr(v int32) *int32 { return &v } // Int32SlicePtr converts a slice of int32 values into a slice of // int32 pointers func Int32SlicePtr(src []int32) []*int32 { dst := make([]*int32, len(src)) for i := 0; i < len(src); i++ { dst[i] = &(src[i]) } return dst } // Int64Ptr returns a pointer to the int64 value passed in. func Int64Ptr(v int64) *int64 { return &v } // Int64SlicePtr converts a slice of int64 values into a slice of // int64 pointers func Int64SlicePtr(src []int64) []*int64 { dst := make([]*int64, len(src)) for i := 0; i < len(src); i++ { dst[i] = &(src[i]) } return dst } // Uint32Ptr returns a pointer to the uint32 value passed in. func Uint32Ptr(v uint32) *uint32 { return &v } // Uint32SlicePtr converts a slice of uint32 values into a slice of // uint32 pointers func Uint32SlicePtr(src []uint32) []*uint32 { dst := make([]*uint32, len(src)) for i := 0; i < len(src); i++ { dst[i] = &(src[i]) } return dst } // Uint64Ptr returns a pointer to the uint64 value passed in. func Uint64Ptr(v uint64) *uint64 { return &v } // Uint64SlicePtr converts a slice of uint64 values into a slice of // uint64 pointers func Uint64SlicePtr(src []uint64) []*uint64 { dst := make([]*uint64, len(src)) for i := 0; i < len(src); i++ { dst[i] = &(src[i]) } return dst } // Float32Ptr returns a pointer to the float32 value passed in. func Float32Ptr(v float32) *float32 { return &v } // Float32SlicePtr converts a slice of float32 values into a slice of // float32 pointers func Float32SlicePtr(src []float32) []*float32 { dst := make([]*float32, len(src)) for i := 0; i < len(src); i++ { dst[i] = &(src[i]) } return dst } // Float64Ptr returns a pointer to the float64 value passed in. func Float64Ptr(v float64) *float64 { return &v } // Float64SlicePtr converts a slice of float64 values into a slice of // float64 pointers func Float64SlicePtr(src []float64) []*float64 { dst := make([]*float64, len(src)) for i := 0; i < len(src); i++ { dst[i] = &(src[i]) } return dst } // TimeDurationPtr returns a pointer to the Duration value passed in. func TimeDurationPtr(v time.Duration) *time.Duration { return &v } // TimePtr returns a pointer to the Time value passed in. func TimePtr(v time.Time) *time.Time { return &v } // SizePtr returns a pointer to the Size value passed in. func SizePtr(v Size) *Size { return &v } // IPPtr returns a pointer to the net.IP value passed in. func IPPtr(v net.IP) *net.IP { return &v } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/convert_test.go000066400000000000000000000137041456366605600261250ustar00rootroot00000000000000package scw import ( "testing" "time" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" ) var ( testString = "some string" testBytes = []byte{0, 1, 2} testBool = true testInt32 int32 = 42 testInt64 int64 = 43 testUInt32 uint32 = 44 testUInt64 uint64 = 45 testFloat32 float32 = 46 testFloat64 float64 = 47 testDuration time.Duration = 48 testTime time.Time = time.Date(2009, 11, 10, 23, 0, 0, 0, time.UTC) testSize Size = 3 * GB ) func TestStringPtr(t *testing.T) { pointer := StringPtr(testString) slice := []string{testString} sliceOfPointers := StringSlicePtr(slice) pointerToSlice := StringsPtr(slice) // value to pointer value testhelpers.Assert(t, pointer != nil, "Pointer should have value") testhelpers.Equals(t, testString, *pointer) // slice of values to slice of pointers to value testhelpers.Equals(t, 1, len(sliceOfPointers)) testhelpers.Assert(t, sliceOfPointers[0] != nil, "Pointer should have value") testhelpers.Equals(t, testString, *sliceOfPointers[0]) // slice of value to pointer to slice of values testhelpers.Assert(t, pointerToSlice != nil, "Pointer should have value") testhelpers.Equals(t, slice, *pointerToSlice) } func TestBytesPtr(t *testing.T) { pointer := BytesPtr(testBytes) slice := [][]byte{testBytes} sliceOfPointers := BytesSlicePtr(slice) // value to pointer value testhelpers.Assert(t, pointer != nil, "Pointer should have value") testhelpers.Equals(t, testBytes, *pointer) // slice of values to slice of pointers to value testhelpers.Equals(t, 1, len(sliceOfPointers)) testhelpers.Assert(t, sliceOfPointers[0] != nil, "Pointer should have value") testhelpers.Equals(t, testBytes, *sliceOfPointers[0]) } func TestBoolPtr(t *testing.T) { pointer := BoolPtr(testBool) slice := []bool{testBool} sliceOfPointers := BoolSlicePtr(slice) // value to pointer value testhelpers.Assert(t, pointer != nil, "Pointer should have value") testhelpers.Equals(t, testBool, *pointer) // slice of values to slice of pointers to value testhelpers.Equals(t, 1, len(sliceOfPointers)) testhelpers.Assert(t, sliceOfPointers[0] != nil, "Pointer should have value") testhelpers.Equals(t, testBool, *sliceOfPointers[0]) } func TestInt32Ptr(t *testing.T) { pointer := Int32Ptr(testInt32) slice := []int32{testInt32} sliceOfPointers := Int32SlicePtr(slice) // value to pointer value testhelpers.Assert(t, pointer != nil, "Pointer should have value") testhelpers.Equals(t, testInt32, *pointer) // slice of values to slice of pointers to value testhelpers.Equals(t, 1, len(sliceOfPointers)) testhelpers.Assert(t, sliceOfPointers[0] != nil, "Pointer should have value") testhelpers.Equals(t, testInt32, *sliceOfPointers[0]) } func TestInt64Ptr(t *testing.T) { pointer := Int64Ptr(testInt64) slice := []int64{testInt64} sliceOfPointers := Int64SlicePtr(slice) // value to pointer value testhelpers.Assert(t, pointer != nil, "Pointer should have value") testhelpers.Equals(t, testInt64, *pointer) // slice of values to slice of pointers to value testhelpers.Equals(t, 1, len(sliceOfPointers)) testhelpers.Assert(t, sliceOfPointers[0] != nil, "Pointer should have value") testhelpers.Equals(t, testInt64, *sliceOfPointers[0]) } func TestUint32Ptr(t *testing.T) { pointer := Uint32Ptr(testUInt32) slice := []uint32{testUInt32} sliceOfPointers := Uint32SlicePtr(slice) // value to pointer value testhelpers.Assert(t, pointer != nil, "Pointer should have value") testhelpers.Equals(t, testUInt32, *pointer) // slice of values to slice of pointers to value testhelpers.Equals(t, 1, len(sliceOfPointers)) testhelpers.Assert(t, sliceOfPointers[0] != nil, "Pointer should have value") testhelpers.Equals(t, testUInt32, *sliceOfPointers[0]) } func TestUint64Ptr(t *testing.T) { pointer := Uint64Ptr(testUInt64) slice := []uint64{testUInt64} sliceOfPointers := Uint64SlicePtr(slice) // value to pointer value testhelpers.Assert(t, pointer != nil, "Pointer should have value") testhelpers.Equals(t, testUInt64, *pointer) // slice of values to slice of pointers to value testhelpers.Equals(t, 1, len(sliceOfPointers)) testhelpers.Assert(t, sliceOfPointers[0] != nil, "Pointer should have value") testhelpers.Equals(t, testUInt64, *sliceOfPointers[0]) } func TestFloat32Ptr(t *testing.T) { pointer := Float32Ptr(testFloat32) slice := []float32{testFloat32} sliceOfPointers := Float32SlicePtr(slice) // value to pointer value testhelpers.Assert(t, pointer != nil, "Pointer should have value") testhelpers.Equals(t, testFloat32, *pointer) // slice of values to slice of pointers to value testhelpers.Equals(t, 1, len(sliceOfPointers)) testhelpers.Assert(t, sliceOfPointers[0] != nil, "Pointer should have value") testhelpers.Equals(t, testFloat32, *sliceOfPointers[0]) } func TestFloat64Ptr(t *testing.T) { pointer := Float64Ptr(testFloat64) slice := []float64{testFloat64} sliceOfPointers := Float64SlicePtr(slice) // value to pointer value testhelpers.Assert(t, pointer != nil, "Pointer should have value") testhelpers.Equals(t, testFloat64, *pointer) // slice of values to slice of pointers to value testhelpers.Equals(t, 1, len(sliceOfPointers)) testhelpers.Assert(t, sliceOfPointers[0] != nil, "Pointer should have value") testhelpers.Equals(t, testFloat64, *sliceOfPointers[0]) } func TestDurationPtr(t *testing.T) { pointer := TimeDurationPtr(testDuration) // value to pointer value testhelpers.Assert(t, pointer != nil, "Pointer should have value") testhelpers.Equals(t, testDuration, *pointer) } func TestTimePtr(t *testing.T) { pointer := TimePtr(testTime) // value to pointer value testhelpers.Assert(t, pointer != nil, "Pointer should have value") testhelpers.Equals(t, testTime, *pointer) } func TestSizePtr(t *testing.T) { pointer := SizePtr(testSize) // value to pointer value testhelpers.Assert(t, pointer != nil, "Pointer should have value") testhelpers.Equals(t, testSize, *pointer) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/custom_types.go000066400000000000000000000250411456366605600261410ustar00rootroot00000000000000package scw import ( "bytes" "encoding/base64" "encoding/json" "fmt" "io" "net" "strconv" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/logger" ) // ServiceInfo contains API metadata // These metadata are only here for debugging. Do not rely on these values type ServiceInfo struct { // Name is the name of the API Name string `json:"name"` // Description is a human readable description for the API Description string `json:"description"` // Version is the version of the API Version string `json:"version"` // DocumentationURL is the a web url where the documentation of the API can be found DocumentationURL *string `json:"documentation_url"` } // File is the structure used to receive / send a file from / to the API type File struct { // Name of the file Name string `json:"name"` // ContentType used in the HTTP header `Content-Type` ContentType string `json:"content_type"` // Content of the file Content io.Reader `json:"content"` } func (f *File) MarshalJSON() ([]byte, error) { buf := new(bytes.Buffer) if f.Content != nil { _, err := io.Copy(buf, f.Content) if err != nil { return nil, err } } tmpFile := struct { Name string `json:"name"` ContentType string `json:"content_type"` Content string `json:"content"` }{ Name: f.Name, ContentType: f.ContentType, Content: buf.String(), } return json.Marshal(tmpFile) } func (f *File) UnmarshalJSON(b []byte) error { type file File var tmpFile struct { file Content []byte `json:"content"` } err := json.Unmarshal(b, &tmpFile) if err != nil { return err } tmpFile.file.Content = bytes.NewReader(tmpFile.Content) *f = File(tmpFile.file) return nil } // Money represents an amount of money with its currency type. type Money struct { // CurrencyCode is the 3-letter currency code defined in ISO 4217. CurrencyCode string `json:"currency_code"` // Units is the whole units of the amount. // For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar. Units int64 `json:"units"` // Nanos is the number of nano (10^-9) units of the amount. // The value must be between -999,999,999 and +999,999,999 inclusive. // If `units` is positive, `nanos` must be positive or zero. // If `units` is zero, `nanos` can be positive, zero, or negative. // If `units` is negative, `nanos` must be negative or zero. // For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000. Nanos int32 `json:"nanos"` } // NewMoneyFromFloat converts a float with currency to a Money. // // value: The float value. // currencyCode: The 3-letter currency code defined in ISO 4217. // precision: The number of digits after the decimal point used to parse the nanos part of the value. // // Examples: // - (value = 1.3333, precision = 2) => Money{Units = 1, Nanos = 330000000} // - (value = 1.123456789, precision = 9) => Money{Units = 1, Nanos = 123456789} func NewMoneyFromFloat(value float64, currencyCode string, precision int) *Money { if precision > 9 { panic(fmt.Errorf("max precision is 9")) } strValue := strconv.FormatFloat(value, 'f', precision, 64) units, nanos, err := splitFloatString(strValue) if err != nil { panic(err) } return &Money{ CurrencyCode: currencyCode, Units: units, Nanos: nanos, } } // String returns the string representation of Money. func (m Money) String() string { currencySignsByCodes := map[string]string{ "EUR": "€", "USD": "$", } currencySign, currencySignFound := currencySignsByCodes[m.CurrencyCode] if !currencySignFound { logger.Debugf("%s currency code is not supported", m.CurrencyCode) currencySign = m.CurrencyCode } cents := fmt.Sprintf("%09d", m.Nanos) cents = cents[:2] + strings.TrimRight(cents[2:], "0") return fmt.Sprintf("%s %d.%s", currencySign, m.Units, cents) } // ToFloat converts a Money object to a float. func (m Money) ToFloat() float64 { return float64(m.Units) + float64(m.Nanos)/1e9 } // Size represents a size in bytes. type Size uint64 const ( B Size = 1 KB = 1000 * B MB = 1000 * KB GB = 1000 * MB TB = 1000 * GB PB = 1000 * TB ) // String returns the string representation of a Size. func (s Size) String() string { return fmt.Sprintf("%d", s) } // TimeSeries represents a time series that could be used for graph purposes. type TimeSeries struct { // Name of the metric. Name string `json:"name"` // Points contains all the points that composed the series. Points []*TimeSeriesPoint `json:"points"` // Metadata contains some string metadata related to a metric. Metadata map[string]string `json:"metadata"` } // TimeSeriesPoint represents a point of a time series. type TimeSeriesPoint struct { Timestamp time.Time Value float32 } func (tsp TimeSeriesPoint) MarshalJSON() ([]byte, error) { timestamp := tsp.Timestamp.Format(time.RFC3339) value, err := json.Marshal(tsp.Value) if err != nil { return nil, err } return []byte(`["` + timestamp + `",` + string(value) + "]"), nil } func (tsp *TimeSeriesPoint) UnmarshalJSON(b []byte) error { point := [2]interface{}{} err := json.Unmarshal(b, &point) if err != nil { return err } if len(point) != 2 { return fmt.Errorf("invalid point array") } strTimestamp, isStrTimestamp := point[0].(string) if !isStrTimestamp { return fmt.Errorf("%s timestamp is not a string in RFC 3339 format", point[0]) } timestamp, err := time.Parse(time.RFC3339, strTimestamp) if err != nil { return fmt.Errorf("%s timestamp is not in RFC 3339 format", point[0]) } tsp.Timestamp = timestamp // By default, JSON unmarshal a float in float64 but the TimeSeriesPoint is a float32 value. value, isValue := point[1].(float64) if !isValue { return fmt.Errorf("%s is not a valid float32 value", point[1]) } tsp.Value = float32(value) return nil } // IPNet inherits net.IPNet and represents an IP network. type IPNet struct { net.IPNet } func (n IPNet) MarshalJSON() ([]byte, error) { value := n.String() if value == "" { value = "" } return []byte(`"` + value + `"`), nil } func (n *IPNet) UnmarshalJSON(b []byte) error { var str string err := json.Unmarshal(b, &str) if err != nil { return err } if str == "" { *n = IPNet{} return nil } switch ip := net.ParseIP(str); { case ip.To4() != nil: str += "/32" case ip.To16() != nil: str += "/128" } ip, value, err := net.ParseCIDR(str) if err != nil { return err } value.IP = ip n.IPNet = *value return nil } // Duration represents a signed, fixed-length span of time represented as a // count of seconds and fractions of seconds at nanosecond resolution. It is // independent of any calendar and concepts like "day" or "month". It is related // to Timestamp in that the difference between two Timestamp values is a Duration // and it can be added or subtracted from a Timestamp. // Range is approximately +-10,000 years. type Duration struct { Seconds int64 Nanos int32 } func (d *Duration) ToTimeDuration() *time.Duration { if d == nil { return nil } timeDuration := time.Duration(d.Nanos) + time.Duration(d.Seconds)*time.Second return &timeDuration } func (d Duration) MarshalJSON() ([]byte, error) { nanos := d.Nanos if nanos < 0 { nanos = -nanos } return []byte(`"` + fmt.Sprintf("%d.%09d", d.Seconds, nanos) + `s"`), nil } func (d *Duration) UnmarshalJSON(b []byte) error { if string(b) == "null" { return nil } var str string err := json.Unmarshal(b, &str) if err != nil { return err } if str == "" { *d = Duration{} return nil } seconds, nanos, err := splitFloatString(strings.TrimRight(str, "s")) if err != nil { return err } *d = Duration{ Seconds: seconds, Nanos: nanos, } return nil } func NewDurationFromTimeDuration(t time.Duration) *Duration { duration := Duration{ Seconds: int64(t.Seconds()), } duration.Nanos = int32(t.Nanoseconds() - (time.Duration(duration.Seconds) * time.Second).Nanoseconds()) return &duration } // splitFloatString splits a float represented in a string, and returns its units (left-coma part) and nanos (right-coma part). // E.g.: // "3" ==> units = 3 | nanos = 0 // "3.14" ==> units = 3 | nanos = 14*1e7 // "-3.14" ==> units = -3 | nanos = -14*1e7 func splitFloatString(input string) (units int64, nanos int32, err error) { parts := strings.SplitN(input, ".", 2) // parse units as int64 units, err = strconv.ParseInt(parts[0], 10, 64) if err != nil { return 0, 0, errors.Wrap(err, "invalid units") } // handle nanos if len(parts) == 2 { // add leading zeros strNanos := parts[1] + "000000000"[len(parts[1]):] // parse nanos as int32 n, err := strconv.ParseUint(strNanos, 10, 32) if err != nil { return 0, 0, errors.Wrap(err, "invalid nanos") } nanos = int32(n) } if units < 0 { nanos = -nanos } return units, nanos, nil } // JSONObject represent any JSON object. See struct.proto. // It will be marshaled into a json string. // This type can be used just like any other map. // // Example: // // values := scw.JSONValue{ // "Foo": "Bar", // } // values["Baz"] = "Qux" type JSONObject map[string]interface{} // EscapeMode is the mode that should be use for escaping a value type EscapeMode uint // The modes for escaping a value before it is marshaled, and unmarshalled. const ( NoEscape EscapeMode = iota Base64Escape QuotedEscape ) // DecodeJSONObject will attempt to decode the string input as a JSONValue. // Optionally decoding base64 the value first before JSON unmarshalling. // // Will panic if the escape mode is unknown. func DecodeJSONObject(v string, escape EscapeMode) (JSONObject, error) { var b []byte var err error switch escape { case NoEscape: b = []byte(v) case Base64Escape: b, err = base64.StdEncoding.DecodeString(v) case QuotedEscape: var u string u, err = strconv.Unquote(v) b = []byte(u) default: panic(fmt.Sprintf("DecodeJSONObject called with unknown EscapeMode, %v", escape)) } if err != nil { return nil, err } m := JSONObject{} err = json.Unmarshal(b, &m) if err != nil { return nil, err } return m, nil } // EncodeJSONObject marshals the value into a JSON string, and optionally base64 // encodes the string before returning it. // // Will panic if the escape mode is unknown. func EncodeJSONObject(v JSONObject, escape EscapeMode) (string, error) { b, err := json.Marshal(v) if err != nil { return "", err } switch escape { case NoEscape: return string(b), nil case Base64Escape: return base64.StdEncoding.EncodeToString(b), nil case QuotedEscape: return strconv.Quote(string(b)), nil } panic(fmt.Sprintf("EncodeJSONObject called with unknown EscapeMode, %v", escape)) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/custom_types_test.go000066400000000000000000000426311456366605600272040ustar00rootroot00000000000000package scw import ( "encoding/json" "fmt" "io" "net" "strings" "testing" "time" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" ) func TestMoney_NewMoneyFromFloat(t *testing.T) { cases := []struct { value float64 currency string precision int want *Money }{ { value: 0.0, currency: "EUR", precision: 0, want: &Money{ CurrencyCode: "EUR", Units: 0, Nanos: 0, }, }, { value: 1.0, currency: "EUR", precision: 3, want: &Money{ CurrencyCode: "EUR", Units: 1, Nanos: 0, }, }, { value: 1.3, currency: "EUR", precision: 3, want: &Money{ CurrencyCode: "EUR", Units: 1, Nanos: 300000000, }, }, { value: 1.333, currency: "EUR", precision: 2, want: &Money{ CurrencyCode: "EUR", Units: 1, Nanos: 330000000, }, }, { value: 1.04, currency: "EUR", precision: 1, want: &Money{ CurrencyCode: "EUR", Units: 1, Nanos: 0, }, }, { value: 1.05, currency: "EUR", precision: 1, want: &Money{ CurrencyCode: "EUR", Units: 1, Nanos: 100000000, }, }, { value: 1.123456789, currency: "EUR", precision: 9, want: &Money{ CurrencyCode: "EUR", Units: 1, Nanos: 123456789, }, }, { value: 1.999999999, currency: "EUR", precision: 9, want: &Money{ CurrencyCode: "EUR", Units: 1, Nanos: 999999999, }, }, } for _, c := range cases { t.Run(c.want.String(), func(t *testing.T) { testhelpers.Equals(t, c.want, NewMoneyFromFloat(c.value, c.currency, c.precision)) }) } } func TestMoney_String(t *testing.T) { cases := []struct { money *Money want string }{ { money: &Money{ CurrencyCode: "EUR", Units: 10, }, want: "€ 10.00", }, { money: &Money{ CurrencyCode: "USD", Units: 10, Nanos: 1, }, want: "$ 10.000000001", }, { money: &Money{ CurrencyCode: "EUR", Nanos: 100000000, }, want: "€ 0.10", }, { money: &Money{ CurrencyCode: "EUR", Nanos: 500000, }, want: "€ 0.0005", }, { money: &Money{ CurrencyCode: "EUR", Nanos: 333000000, }, want: "€ 0.333", }, { money: &Money{ CurrencyCode: "EUR", Nanos: 123456789, }, want: "€ 0.123456789", }, { money: &Money{ CurrencyCode: "?", }, want: "? 0.00", }, } for _, c := range cases { t.Run(c.want, func(t *testing.T) { testhelpers.Equals(t, c.want, c.money.String()) }) } } func TestSize_String(t *testing.T) { cases := []struct { size Size want string }{ {size: 42 * MB, want: "42000000"}, {size: 42 * B, want: "42"}, } for _, c := range cases { t.Run(c.want, func(t *testing.T) { testhelpers.Equals(t, c.want, c.size.String()) }) } } func TestTimeSeries_MarshallJSON(t *testing.T) { cases := []struct { name string ts *TimeSeries want string err error }{ { name: "basic", ts: &TimeSeries{ Name: "cpu_usage", Points: []*TimeSeriesPoint{ { Timestamp: time.Date(2019, time.August, 8, 15, 00, 00, 0, time.UTC), Value: 0.2, }, { Timestamp: time.Date(2019, time.August, 8, 15, 01, 00, 0, time.UTC), Value: 10.6, }, }, Metadata: map[string]string{ "node": "a77e0ce3", }, }, want: `{"name":"cpu_usage","points":[["2019-08-08T15:00:00Z",0.2],["2019-08-08T15:01:00Z",10.6]],"metadata":{"node":"a77e0ce3"}}`, }, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { got, err := json.Marshal(c.ts) testhelpers.Equals(t, c.err, err) if c.err == nil { testhelpers.Equals(t, c.want, string(got)) } }) } } func TestTimeSeries_UnmarshalJSON(t *testing.T) { cases := []struct { name string json string want *TimeSeries err error }{ { name: "basic", json: ` { "name": "cpu_usage", "points": [ ["2019-08-08T15:00:00Z", 0.2], ["2019-08-08T15:01:00Z", 10.6] ], "metadata": { "node": "a77e0ce3" } } `, want: &TimeSeries{ Name: "cpu_usage", Points: []*TimeSeriesPoint{ { Timestamp: time.Date(2019, time.August, 8, 15, 00, 00, 0, time.UTC), Value: 0.2, }, { Timestamp: time.Date(2019, time.August, 8, 15, 01, 00, 0, time.UTC), Value: 10.6, }, }, Metadata: map[string]string{ "node": "a77e0ce3", }, }, }, { name: "with timestamp error", json: `{"name":"cpu_usage","points":[["2019/08/08T15-00-00Z",0.2]]}`, err: fmt.Errorf("2019/08/08T15-00-00Z timestamp is not in RFC 3339 format"), }, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { ts := &TimeSeries{} err := json.Unmarshal([]byte(c.json), ts) testhelpers.Equals(t, c.err, err) if c.err == nil { testhelpers.Equals(t, c.want, ts) } }) } } func TestFile_MarshalJSON(t *testing.T) { cases := []struct { name string file *File want string err error }{ { name: "basic", file: &File{ Name: "example.txt", ContentType: "text/plain", Content: strings.NewReader("Hello, world!"), }, want: `{"name":"example.txt","content_type":"text/plain","content":"Hello, world!"}`, }, { name: "empty", file: &File{}, want: `{"name":"","content_type":"","content":""}`, }, { name: "nil content", file: &File{ Name: "example.txt", ContentType: "text/plain", Content: nil, }, want: `{"name":"example.txt","content_type":"text/plain","content":""}`, }, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { got, err := json.Marshal(c.file) testhelpers.Equals(t, c.err, err) if c.err == nil { testhelpers.Equals(t, c.want, string(got)) } }) } } func TestFile_UnmarshalJSON(t *testing.T) { type testCase struct { json string name string contentType string content []byte } run := func(c *testCase) func(t *testing.T) { return func(t *testing.T) { f := File{} err := json.Unmarshal([]byte(c.json), &f) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, c.name, f.Name) testhelpers.Equals(t, c.contentType, f.ContentType) s, err := io.ReadAll(f.Content) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, c.content, s) } } t.Run("empty", run(&testCase{ json: `{}`, content: []byte{}, })) t.Run("strint_content", run(&testCase{ json: `{"name": "test", "content_type":"text/plain", "content": "dGVzdDQyCg=="}`, name: "test", contentType: "text/plain", content: []byte("test42\n"), })) t.Run("binary_content", run(&testCase{ json: `{"name": "test", "content_type":"text/plain", "content": "AAAACg=="}`, name: "test", contentType: "text/plain", content: []byte("\x00\x00\x00\n"), })) } func TestIPNet_MarshallJSON(t *testing.T) { cases := []struct { name string ipRange IPNet want string err error }{ { name: "ip", ipRange: IPNet{IPNet: net.IPNet{IP: net.IPv4(42, 42, 42, 42), Mask: net.CIDRMask(32, 32)}}, want: `"42.42.42.42/32"`, }, { name: "network", ipRange: IPNet{IPNet: net.IPNet{IP: net.IPv4(42, 42, 42, 42), Mask: net.CIDRMask(16, 32)}}, want: `"42.42.42.42/16"`, }, { name: "network with ip", ipRange: IPNet{IPNet: net.IPNet{IP: net.IPv4(192, 168, 1, 42), Mask: net.CIDRMask(24, 32)}}, want: `"192.168.1.42/24"`, }, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { got, err := json.Marshal(c.ipRange) testhelpers.Equals(t, c.err, err) if c.err == nil { testhelpers.Equals(t, c.want, string(got)) } }) } } func TestIPNet_UnmarshalJSON(t *testing.T) { cases := []struct { name string json string want IPNet err string }{ { name: "IPv4 with CIDR", json: `"42.42.42.42/32"`, want: IPNet{IPNet: net.IPNet{IP: net.IPv4(42, 42, 42, 42), Mask: net.CIDRMask(32, 32)}}, }, { name: "IPv4 with network", json: `"192.0.2.1/24"`, want: IPNet{IPNet: net.IPNet{IP: net.IPv4(192, 0, 2, 1), Mask: net.CIDRMask(24, 32)}}, }, { name: "IPv4 with network 2", json: `"192.168.1.42/24"`, want: IPNet{IPNet: net.IPNet{IP: net.IPv4(192, 168, 1, 42), Mask: net.CIDRMask(24, 32)}}, }, { name: "IPv6 with network", json: `"2001:db8:abcd:8000::/50"`, want: IPNet{IPNet: net.IPNet{IP: net.ParseIP("2001:db8:abcd:8000::"), Mask: net.CIDRMask(50, 128)}}, }, { name: "IPv4 alone", json: `"42.42.42.42"`, want: IPNet{IPNet: net.IPNet{IP: net.IPv4(42, 42, 42, 42), Mask: net.CIDRMask(32, 32)}}, }, { name: "IPv6 alone", json: `"2001:db8:abcd:8000::"`, want: IPNet{IPNet: net.IPNet{IP: net.ParseIP("2001:db8:abcd:8000::"), Mask: net.CIDRMask(128, 128)}}, }, { name: "invalid CIDR error", json: `"invalidvalue"`, err: "invalid CIDR address: invalidvalue", }, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { ipNet := &IPNet{} err := json.Unmarshal([]byte(c.json), ipNet) if err != nil { testhelpers.Equals(t, c.err, err.Error()) } testhelpers.Equals(t, c.want.String(), ipNet.String()) }) } } func TestDuration_MarshallJSON(t *testing.T) { cases := []struct { name string duration *Duration want string err error }{ { name: "small seconds", duration: &Duration{Seconds: 3, Nanos: 0}, want: `"3.000000000s"`, }, { name: "small seconds, small nanos", duration: &Duration{Seconds: 3, Nanos: 12e7}, want: `"3.120000000s"`, }, { name: "small seconds, big nanos", duration: &Duration{Seconds: 3, Nanos: 123456789}, want: `"3.123456789s"`, }, { name: "big seconds, big nanos", duration: &Duration{Seconds: 345679384, Nanos: 123456789}, want: `"345679384.123456789s"`, }, { name: "negative small seconds", duration: &Duration{Seconds: -3, Nanos: 0}, want: `"-3.000000000s"`, }, { name: "negative small seconds, small nanos", duration: &Duration{Seconds: -3, Nanos: -12e7}, want: `"-3.120000000s"`, }, { name: "negative small seconds, big nanos", duration: &Duration{Seconds: -3, Nanos: -123456789}, want: `"-3.123456789s"`, }, { name: "negative big seconds, big nanos", duration: &Duration{Seconds: -345679384, Nanos: -123456789}, want: `"-345679384.123456789s"`, }, { name: "negative big seconds, big nanos", duration: &Duration{}, want: `"0.000000000s"`, }, { name: "null duration", duration: nil, want: `null`, }, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { got, err := json.Marshal(c.duration) testhelpers.Equals(t, c.err, err) if c.err == nil { testhelpers.Equals(t, c.want, string(got)) } }) } } func TestDuration_UnmarshalJSON(t *testing.T) { cases := []struct { name string json string want *Duration err string }{ { name: "error negative nanos", json: `{"duration":"a.12s"}`, want: nil, err: "scaleway-sdk-go: invalid units: strconv.ParseInt: parsing \"a\": invalid syntax", }, { name: "error negative nanos", json: `{"duration":"3.-12s"}`, want: nil, err: "scaleway-sdk-go: invalid nanos: strconv.ParseUint: parsing \"-12000000\": invalid syntax", }, { name: "null", json: `{"duration":null}`, want: nil, }, { name: "small seconds", json: `{"duration":"3.00s"}`, want: &Duration{Seconds: 3, Nanos: 0}, }, { name: "small seconds, small nanos", json: `{"duration":"3.12s"}`, want: &Duration{Seconds: 3, Nanos: 12e7}, }, { name: "bug seconds", json: `{"duration":"987654321.00s"}`, want: &Duration{Seconds: 987654321, Nanos: 0}, }, { name: "big seconds, big nanos", json: `{"duration":"987654321.123456789s"}`, want: &Duration{Seconds: 987654321, Nanos: 123456789}, }, { name: "negative small seconds", json: `{"duration":"-3.00s"}`, want: &Duration{Seconds: -3, Nanos: 0}, }, { name: "negative small seconds, small nanos", json: `{"duration":"-3.12s"}`, want: &Duration{Seconds: -3, Nanos: -12e7}, }, { name: "negative bug seconds", json: `{"duration":"-987654321.00s"}`, want: &Duration{Seconds: -987654321, Nanos: 0}, }, { name: "negative big seconds, big nanos", json: `{"duration":"-987654321.123456789s"}`, want: &Duration{Seconds: -987654321, Nanos: -123456789}, }, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { var testType struct { Duration *Duration } err := json.Unmarshal([]byte(c.json), &testType) if err != nil { testhelpers.Equals(t, c.err, err.Error()) } else { testhelpers.Equals(t, c.want, testType.Duration) } }) } } func TestDuration_ToTimeDuration(t *testing.T) { cases := []struct { name string duration *Duration want time.Duration }{ { name: "nil duration", duration: nil, want: time.Duration(0), }, { name: "zero duration", duration: &Duration{Seconds: 0, Nanos: 0}, want: time.Duration(0), }, { name: "seconds only", duration: &Duration{Seconds: 10, Nanos: 0}, want: time.Duration(10) * time.Second, }, { name: "nanoseconds only", duration: &Duration{Seconds: 0, Nanos: 500}, want: time.Duration(500), }, { name: "seconds and nanoseconds", duration: &Duration{Seconds: 10, Nanos: 500}, want: time.Duration(10)*time.Second + time.Duration(500), }, { name: "negative seconds", duration: &Duration{Seconds: -10, Nanos: 0}, want: time.Duration(-10) * time.Second, }, { name: "negative nanoseconds", duration: &Duration{Seconds: 0, Nanos: -500}, want: time.Duration(-500), }, { name: "negative seconds and nanoseconds", duration: &Duration{Seconds: -10, Nanos: -500}, want: time.Duration(-10)*time.Second + time.Duration(-500), }, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { got := c.duration.ToTimeDuration() if got == nil { if c.want != 0 { t.Errorf("got nil, want %s", c.want) } } else if *got != c.want { t.Errorf("got %s, want %s", *got, c.want) } }) } } func TestDuration_FromTimeDuration(t *testing.T) { cases := []struct { name string duration time.Duration want *Duration }{ { name: "zero duration", want: &Duration{Seconds: 0, Nanos: 0}, duration: time.Duration(0), }, { name: "seconds only", want: &Duration{Seconds: 10, Nanos: 0}, duration: time.Duration(10) * time.Second, }, { name: "nanoseconds only", want: &Duration{Seconds: 0, Nanos: 500}, duration: time.Duration(500), }, { name: "seconds and nanoseconds", want: &Duration{Seconds: 10, Nanos: 500}, duration: time.Duration(10)*time.Second + time.Duration(500), }, { name: "negative seconds", want: &Duration{Seconds: -10, Nanos: 0}, duration: time.Duration(-10) * time.Second, }, { name: "negative nanoseconds", want: &Duration{Seconds: 0, Nanos: -500}, duration: time.Duration(-500), }, { name: "negative seconds and nanoseconds", want: &Duration{Seconds: -10, Nanos: -500}, duration: time.Duration(-10)*time.Second + time.Duration(-500), }, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { got := NewDurationFromTimeDuration(c.duration) if got == nil { t.Errorf("got nil, want %v", c.want) } else if got.Seconds != c.want.Seconds && got.Nanos != c.want.Nanos { t.Errorf("got %v, want %v", *got, c.want) } }) } } func TestJSONObject_UnmarshalJSON(t *testing.T) { cases := []struct { name string json string want *JSONObject err error }{ { name: "basic", json: ` { "test": "scw" } `, want: &JSONObject{ "test": "scw", }, }, { name: "multi-types", json: ` { "firstName": "John", "lastName": "Smith", "isAlive": true, "age": 23, "address": { "city": "Paris", "country": "FR" } } `, want: &JSONObject{ "firstName": "John", "lastName": "Smith", "isAlive": true, "age": float64(23), "address": map[string]interface{}{ "city": "Paris", "country": "FR", }, }, }, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { ts, err := DecodeJSONObject(c.json, NoEscape) testhelpers.Equals(t, c.err, err) if c.err == nil { testhelpers.Equals(t, *c.want, ts) } }) } } func TestJSONObject_MarshalJSON(t *testing.T) { cases := []struct { name string jsonValue *JSONObject want string err error }{ { name: "basic", jsonValue: &JSONObject{ "test": "scw", }, want: `{"test":"scw"}`, }, { name: "multi-types", want: `{"address":{"city":"Paris","country":"FR"},"age":23,"firstName":"John","isAlive":true,"lastName":"Smith"}`, jsonValue: &JSONObject{ "firstName": "John", "lastName": "Smith", "isAlive": true, "age": float64(23), "address": map[string]interface{}{ "city": "Paris", "country": "FR", }, }, }, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { got, err := EncodeJSONObject(*c.jsonValue, NoEscape) testhelpers.Equals(t, c.err, err) if c.err == nil { testhelpers.Equals(t, c.want, string(got)) } }) } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/env.go000066400000000000000000000100631456366605600241710ustar00rootroot00000000000000package scw import ( "os" "strconv" "github.com/scaleway/scaleway-sdk-go/logger" ) // Environment variables const ( // Up-to-date ScwCacheDirEnv = "SCW_CACHE_DIR" ScwConfigPathEnv = "SCW_CONFIG_PATH" ScwAccessKeyEnv = "SCW_ACCESS_KEY" ScwSecretKeyEnv = "SCW_SECRET_KEY" // #nosec G101 ScwActiveProfileEnv = "SCW_PROFILE" ScwAPIURLEnv = "SCW_API_URL" ScwInsecureEnv = "SCW_INSECURE" ScwDefaultOrganizationIDEnv = "SCW_DEFAULT_ORGANIZATION_ID" ScwDefaultProjectIDEnv = "SCW_DEFAULT_PROJECT_ID" ScwDefaultRegionEnv = "SCW_DEFAULT_REGION" ScwDefaultZoneEnv = "SCW_DEFAULT_ZONE" ScwEnableBeta = "SCW_ENABLE_BETA" DebugEnv = logger.DebugEnv // All deprecated (cli&terraform) terraformAccessKeyEnv = "SCALEWAY_ACCESS_KEY" // used both as access key and secret key terraformSecretKeyEnv = "SCALEWAY_TOKEN" terraformOrganizationEnv = "SCALEWAY_ORGANIZATION" terraformRegionEnv = "SCALEWAY_REGION" cliTLSVerifyEnv = "SCW_TLSVERIFY" cliOrganizationEnv = "SCW_ORGANIZATION" cliRegionEnv = "SCW_REGION" cliSecretKeyEnv = "SCW_TOKEN" // TBD //cliVerboseEnv = "SCW_VERBOSE_API" //cliDebugEnv = "DEBUG" //cliNoCheckVersionEnv = "SCW_NOCHECKVERSION" //cliTestWithRealAPIEnv = "TEST_WITH_REAL_API" //cliSecureExecEnv = "SCW_SECURE_EXEC" //cliGatewayEnv = "SCW_GATEWAY" //cliSensitiveEnv = "SCW_SENSITIVE" //cliAccountAPIEnv = "SCW_ACCOUNT_API" //cliMetadataAPIEnv = "SCW_METADATA_API" //cliMarketPlaceAPIEnv = "SCW_MARKETPLACE_API" //cliComputePar1APIEnv = "SCW_COMPUTE_PAR1_API" //cliComputeAms1APIEnv = "SCW_COMPUTE_AMS1_API" //cliCommercialTypeEnv = "SCW_COMMERCIAL_TYPE" //cliTargetArchEnv = "SCW_TARGET_ARCH" ) const ( v1RegionFrPar = "par1" v1RegionNlAms = "ams1" ) func LoadEnvProfile() *Profile { p := &Profile{} accessKey, _, envExist := getEnv(ScwAccessKeyEnv, terraformAccessKeyEnv) if envExist { p.AccessKey = &accessKey } secretKey, _, envExist := getEnv(ScwSecretKeyEnv, cliSecretKeyEnv, terraformSecretKeyEnv, terraformAccessKeyEnv) if envExist { p.SecretKey = &secretKey } apiURL, _, envExist := getEnv(ScwAPIURLEnv) if envExist { p.APIURL = &apiURL } insecureValue, envKey, envExist := getEnv(ScwInsecureEnv, cliTLSVerifyEnv) if envExist { insecure, err := strconv.ParseBool(insecureValue) if err != nil { logger.Warningf("env variable %s cannot be parsed: %s is invalid boolean", envKey, insecureValue) } if envKey == cliTLSVerifyEnv { insecure = !insecure // TLSVerify is the inverse of Insecure } p.Insecure = &insecure } organizationID, _, envExist := getEnv(ScwDefaultOrganizationIDEnv, cliOrganizationEnv, terraformOrganizationEnv) if envExist { p.DefaultOrganizationID = &organizationID } projectID, _, envExist := getEnv(ScwDefaultProjectIDEnv) if envExist { p.DefaultProjectID = &projectID } region, _, envExist := getEnv(ScwDefaultRegionEnv, cliRegionEnv, terraformRegionEnv) if envExist { region = v1RegionToV2(region) p.DefaultRegion = ®ion } zone, _, envExist := getEnv(ScwDefaultZoneEnv) if envExist { p.DefaultZone = &zone } return p } func getEnv(upToDateKey string, deprecatedKeys ...string) (string, string, bool) { value, exist := os.LookupEnv(upToDateKey) if exist { logger.Debugf("reading value from %s", upToDateKey) return value, upToDateKey, true } for _, key := range deprecatedKeys { value, exist := os.LookupEnv(key) if exist { logger.Debugf("reading value from %s", key) logger.Warningf("%s is deprecated, please use %s instead", key, upToDateKey) return value, key, true } } return "", "", false } func v1RegionToV2(region string) string { switch region { case v1RegionFrPar: logger.Warningf("par1 is a deprecated name for region, use fr-par instead") return "fr-par" case v1RegionNlAms: logger.Warningf("ams1 is a deprecated name for region, use nl-ams instead") return "nl-ams" default: return region } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/env_test.go000066400000000000000000000070231456366605600252320ustar00rootroot00000000000000package scw import ( "os" "testing" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" ) // TestLoadConfig tests config getters return correct values func TestLoadEnvProfile(t *testing.T) { tests := []struct { name string env map[string]string expectedAccessKey *string expectedSecretKey *string expectedAPIURL *string expectedInsecure *bool expectedDefaultOrganizationID *string expectedDefaultProjectID *string expectedDefaultRegion *string expectedDefaultZone *string }{ // up-to-date env variables { name: "No config with env variables", env: map[string]string{ ScwAccessKeyEnv: v2ValidAccessKey, ScwSecretKeyEnv: v2ValidSecretKey, ScwAPIURLEnv: v2ValidAPIURL, ScwInsecureEnv: "false", ScwDefaultOrganizationIDEnv: v2ValidDefaultOrganizationID, ScwDefaultProjectIDEnv: v2ValidDefaultProjectID, ScwDefaultRegionEnv: v2ValidDefaultRegion, ScwDefaultZoneEnv: v2ValidDefaultZone, }, expectedAccessKey: s(v2ValidAccessKey), expectedSecretKey: s(v2ValidSecretKey), expectedAPIURL: s(v2ValidAPIURL), expectedInsecure: b(false), expectedDefaultOrganizationID: s(v2ValidDefaultOrganizationID), expectedDefaultProjectID: s(v2ValidDefaultProjectID), expectedDefaultRegion: s(v2ValidDefaultRegion), expectedDefaultZone: s(v2ValidDefaultZone), }, { name: "No config with terraform legacy env variables", env: map[string]string{ terraformAccessKeyEnv: v2ValidAccessKey, terraformSecretKeyEnv: v2ValidSecretKey, terraformOrganizationEnv: v2ValidDefaultOrganizationID, terraformRegionEnv: v2ValidDefaultRegion, }, expectedAccessKey: s(v2ValidAccessKey), expectedSecretKey: s(v2ValidSecretKey), expectedDefaultOrganizationID: s(v2ValidDefaultOrganizationID), expectedDefaultProjectID: s(v2ValidDefaultProjectID), expectedDefaultRegion: s(v2ValidDefaultRegion), }, { name: "No config with CLI legacy env variables", env: map[string]string{ cliSecretKeyEnv: v2ValidSecretKey2, cliOrganizationEnv: v2ValidDefaultOrganizationID2, cliRegionEnv: v2ValidDefaultRegion2, cliTLSVerifyEnv: "false", }, expectedSecretKey: s(v2ValidSecretKey2), expectedInsecure: b(true), expectedDefaultOrganizationID: s(v2ValidDefaultOrganizationID2), expectedDefaultProjectID: s(v2ValidDefaultProjectID2), expectedDefaultRegion: s(v2ValidDefaultRegion2), }, } // create home dir dir := initEnv(t) // delete home dir and reset env variables defer resetEnv(t, os.Environ(), dir) for _, test := range tests { t.Run(test.name, func(t *testing.T) { // set up env and config file(s) setEnv(t, test.env, nil, dir) // remove config file(s) defer cleanEnv(t, nil, dir) // load config p := LoadEnvProfile() // assert getters testhelpers.Equals(t, test.expectedAccessKey, p.AccessKey) testhelpers.Equals(t, test.expectedSecretKey, p.SecretKey) testhelpers.Equals(t, test.expectedAPIURL, p.APIURL) testhelpers.Equals(t, test.expectedDefaultOrganizationID, p.DefaultOrganizationID) testhelpers.Equals(t, test.expectedDefaultRegion, p.DefaultRegion) testhelpers.Equals(t, test.expectedDefaultZone, p.DefaultZone) testhelpers.Equals(t, test.expectedInsecure, p.Insecure) }) } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/errors.go000066400000000000000000000354351456366605600247270ustar00rootroot00000000000000package scw import ( "encoding/json" "fmt" "io/ioutil" "net/http" "sort" "strings" "time" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/validation" ) // SdkError is a base interface for all Scaleway SDK errors. type SdkError interface { Error() string IsScwSdkError() } // ResponseError is an error type for the Scaleway API type ResponseError struct { // Message is a human-friendly error message Message string `json:"message"` // Type is a string code that defines the kind of error. This field is only used by instance API Type string `json:"type,omitempty"` // Resource is a string code that defines the resource concerned by the error. This field is only used by instance API Resource string `json:"resource,omitempty"` // Fields contains detail about validation error. This field is only used by instance API Fields map[string][]string `json:"fields,omitempty"` // StatusCode is the HTTP status code received StatusCode int `json:"-"` // Status is the HTTP status received Status string `json:"-"` RawBody json.RawMessage `json:"-"` } func (e *ResponseError) UnmarshalJSON(b []byte) error { type tmpResponseError ResponseError tmp := tmpResponseError(*e) err := json.Unmarshal(b, &tmp) if err != nil { return err } tmp.Message = strings.ToLower(tmp.Message) *e = ResponseError(tmp) return nil } // IsScwSdkError implement SdkError interface func (e *ResponseError) IsScwSdkError() {} func (e *ResponseError) Error() string { s := fmt.Sprintf("scaleway-sdk-go: http error %s", e.Status) if e.Resource != "" { s = fmt.Sprintf("%s: resource %s", s, e.Resource) } if e.Message != "" { s = fmt.Sprintf("%s: %s", s, e.Message) } if len(e.Fields) > 0 { s = fmt.Sprintf("%s: %v", s, e.Fields) } return s } func (e *ResponseError) GetRawBody() json.RawMessage { return e.RawBody } // hasResponseError returns an SdkError when the HTTP status is not OK. func hasResponseError(res *http.Response) error { if res.StatusCode >= 200 && res.StatusCode <= 299 { return nil } newErr := &ResponseError{ StatusCode: res.StatusCode, Status: res.Status, } if res.Body == nil { return newErr } body, err := ioutil.ReadAll(res.Body) if err != nil { return errors.Wrap(err, "cannot read error response body") } newErr.RawBody = body // The error content is not encoded in JSON, only returns HTTP data. contentType := res.Header.Get("Content-Type") if !strings.HasPrefix(contentType, "application/json") { newErr.Message = res.Status return newErr } err = json.Unmarshal(body, newErr) if err != nil { return errors.Wrap(err, "could not parse error response body") } err = unmarshalStandardError(newErr.Type, body) if err != nil { return err } err = unmarshalNonStandardError(newErr.Type, body) if err != nil { return err } return newErr } func unmarshalStandardError(errorType string, body []byte) error { var stdErr SdkError switch errorType { case "invalid_arguments": stdErr = &InvalidArgumentsError{RawBody: body} case "quotas_exceeded": stdErr = &QuotasExceededError{RawBody: body} case "transient_state": stdErr = &TransientStateError{RawBody: body} case "not_found": stdErr = &ResourceNotFoundError{RawBody: body} case "locked": stdErr = &ResourceLockedError{RawBody: body} case "permissions_denied": stdErr = &PermissionsDeniedError{RawBody: body} case "out_of_stock": stdErr = &OutOfStockError{RawBody: body} case "resource_expired": stdErr = &ResourceExpiredError{RawBody: body} case "denied_authentication": stdErr = &DeniedAuthenticationError{RawBody: body} case "precondition_failed": stdErr = &PreconditionFailedError{RawBody: body} default: return nil } err := json.Unmarshal(body, stdErr) if err != nil { return errors.Wrap(err, "could not parse error %s response body", errorType) } return stdErr } func unmarshalNonStandardError(errorType string, body []byte) error { switch errorType { // Only in instance API. case "unknown_resource": unknownResourceError := &UnknownResource{RawBody: body} err := json.Unmarshal(body, unknownResourceError) if err != nil { return errors.Wrap(err, "could not parse error %s response body", errorType) } return unknownResourceError.ToResourceNotFoundError() case "invalid_request_error": invalidRequestError := &InvalidRequestError{RawBody: body} err := json.Unmarshal(body, invalidRequestError) if err != nil { return errors.Wrap(err, "could not parse error %s response body", errorType) } invalidArgumentsError := invalidRequestError.ToInvalidArgumentsError() if invalidArgumentsError != nil { return invalidArgumentsError } quotasExceededError := invalidRequestError.ToQuotasExceededError() if quotasExceededError != nil { return quotasExceededError } // At this point, the invalid_request_error is not an InvalidArgumentsError and // the default marshalling will be used. return nil default: return nil } } type InvalidArgumentsErrorDetail struct { ArgumentName string `json:"argument_name"` Reason string `json:"reason"` HelpMessage string `json:"help_message"` } type InvalidArgumentsError struct { Details []InvalidArgumentsErrorDetail `json:"details"` RawBody json.RawMessage `json:"-"` } // IsScwSdkError implements the SdkError interface func (e *InvalidArgumentsError) IsScwSdkError() {} func (e *InvalidArgumentsError) Error() string { invalidArgs := make([]string, len(e.Details)) for i, d := range e.Details { invalidArgs[i] = d.ArgumentName switch d.Reason { case "unknown": invalidArgs[i] += " is invalid for unexpected reason" case "required": invalidArgs[i] += " is required" case "format": invalidArgs[i] += " is wrongly formatted" case "constraint": invalidArgs[i] += " does not respect constraint" } if d.HelpMessage != "" { invalidArgs[i] += ", " + d.HelpMessage } } return "scaleway-sdk-go: invalid argument(s): " + strings.Join(invalidArgs, "; ") } func (e *InvalidArgumentsError) GetRawBody() json.RawMessage { return e.RawBody } // UnknownResource is only returned by the instance API. // Warning: this is not a standard error. type UnknownResource struct { Message string `json:"message"` RawBody json.RawMessage `json:"-"` } // ToSdkError returns a standard error InvalidArgumentsError or nil Fields is nil. func (e *UnknownResource) ToResourceNotFoundError() SdkError { resourceNotFound := &ResourceNotFoundError{ RawBody: e.RawBody, } messageParts := strings.Split(e.Message, `"`) // Some errors uses ' and not " if len(messageParts) == 1 { messageParts = strings.Split(e.Message, "'") } switch len(messageParts) { case 2: // message like: `"111..." not found` resourceNotFound.ResourceID = messageParts[0] case 3: // message like: `Security Group "111..." not found` resourceNotFound.ResourceID = messageParts[1] // transform `Security group ` to `security_group` resourceNotFound.Resource = strings.ReplaceAll(strings.ToLower(strings.TrimSpace(messageParts[0])), " ", "_") default: return nil } if !validation.IsUUID(resourceNotFound.ResourceID) { return nil } return resourceNotFound } // InvalidRequestError is only returned by the instance API. // Warning: this is not a standard error. type InvalidRequestError struct { Message string `json:"message"` Fields map[string][]string `json:"fields"` Resource string `json:"resource"` RawBody json.RawMessage `json:"-"` } // ToSdkError returns a standard error InvalidArgumentsError or nil Fields is nil. func (e *InvalidRequestError) ToInvalidArgumentsError() SdkError { // If error has no fields, it is not an InvalidArgumentsError. if e.Fields == nil || len(e.Fields) == 0 { return nil } invalidArguments := &InvalidArgumentsError{ RawBody: e.RawBody, } fieldNames := []string(nil) for fieldName := range e.Fields { fieldNames = append(fieldNames, fieldName) } sort.Strings(fieldNames) for _, fieldName := range fieldNames { for _, message := range e.Fields[fieldName] { invalidArguments.Details = append(invalidArguments.Details, InvalidArgumentsErrorDetail{ ArgumentName: fieldName, Reason: "constraint", HelpMessage: message, }) } } return invalidArguments } func (e *InvalidRequestError) ToQuotasExceededError() SdkError { if !strings.Contains(strings.ToLower(e.Message), "quota exceeded for this resource") { return nil } return &QuotasExceededError{ Details: []QuotasExceededErrorDetail{ { Resource: e.Resource, Quota: 0, Current: 0, }, }, RawBody: e.RawBody, } } type QuotasExceededErrorDetail struct { Resource string `json:"resource"` Quota uint32 `json:"quota"` Current uint32 `json:"current"` } type QuotasExceededError struct { Details []QuotasExceededErrorDetail `json:"details"` RawBody json.RawMessage `json:"-"` } // IsScwSdkError implements the SdkError interface func (e *QuotasExceededError) IsScwSdkError() {} func (e *QuotasExceededError) Error() string { invalidArgs := make([]string, len(e.Details)) for i, d := range e.Details { invalidArgs[i] = fmt.Sprintf("%s has reached its quota (%d/%d)", d.Resource, d.Current, d.Quota) } return "scaleway-sdk-go: quota exceeded(s): " + strings.Join(invalidArgs, "; ") } func (e *QuotasExceededError) GetRawBody() json.RawMessage { return e.RawBody } type PermissionsDeniedError struct { Details []struct { Resource string `json:"resource"` Action string `json:"action"` } `json:"details"` RawBody json.RawMessage `json:"-"` } // IsScwSdkError implements the SdkError interface func (e *PermissionsDeniedError) IsScwSdkError() {} func (e *PermissionsDeniedError) Error() string { invalidArgs := make([]string, len(e.Details)) for i, d := range e.Details { invalidArgs[i] = fmt.Sprintf("%s %s", d.Action, d.Resource) } return "scaleway-sdk-go: insufficient permissions: " + strings.Join(invalidArgs, "; ") } func (e *PermissionsDeniedError) GetRawBody() json.RawMessage { return e.RawBody } type TransientStateError struct { Resource string `json:"resource"` ResourceID string `json:"resource_id"` CurrentState string `json:"current_state"` RawBody json.RawMessage `json:"-"` } // IsScwSdkError implements the SdkError interface func (e *TransientStateError) IsScwSdkError() {} func (e *TransientStateError) Error() string { return fmt.Sprintf("scaleway-sdk-go: resource %s with ID %s is in a transient state: %s", e.Resource, e.ResourceID, e.CurrentState) } func (e *TransientStateError) GetRawBody() json.RawMessage { return e.RawBody } type ResourceNotFoundError struct { Resource string `json:"resource"` ResourceID string `json:"resource_id"` RawBody json.RawMessage `json:"-"` } // IsScwSdkError implements the SdkError interface func (e *ResourceNotFoundError) IsScwSdkError() {} func (e *ResourceNotFoundError) Error() string { return fmt.Sprintf("scaleway-sdk-go: resource %s with ID %s is not found", e.Resource, e.ResourceID) } func (e *ResourceNotFoundError) GetRawBody() json.RawMessage { return e.RawBody } type ResourceLockedError struct { Resource string `json:"resource"` ResourceID string `json:"resource_id"` RawBody json.RawMessage `json:"-"` } // IsScwSdkError implements the SdkError interface func (e *ResourceLockedError) IsScwSdkError() {} func (e *ResourceLockedError) Error() string { return fmt.Sprintf("scaleway-sdk-go: resource %s with ID %s is locked", e.Resource, e.ResourceID) } func (e *ResourceLockedError) GetRawBody() json.RawMessage { return e.RawBody } type OutOfStockError struct { Resource string `json:"resource"` RawBody json.RawMessage `json:"-"` } // IsScwSdkError implements the SdkError interface func (e *OutOfStockError) IsScwSdkError() {} func (e *OutOfStockError) Error() string { return fmt.Sprintf("scaleway-sdk-go: resource %s is out of stock", e.Resource) } func (e *OutOfStockError) GetRawBody() json.RawMessage { return e.RawBody } // InvalidClientOptionError indicates that at least one of client data has been badly provided for the client creation. type InvalidClientOptionError struct { errorType string } func NewInvalidClientOptionError(format string, a ...interface{}) *InvalidClientOptionError { return &InvalidClientOptionError{errorType: fmt.Sprintf(format, a...)} } // IsScwSdkError implements the SdkError interface func (e InvalidClientOptionError) IsScwSdkError() {} func (e InvalidClientOptionError) Error() string { return fmt.Sprintf("scaleway-sdk-go: %s", e.errorType) } // ConfigFileNotFound indicates that the config file could not be found type ConfigFileNotFoundError struct { path string } func configFileNotFound(path string) *ConfigFileNotFoundError { return &ConfigFileNotFoundError{path: path} } // ConfigFileNotFoundError implements the SdkError interface func (e ConfigFileNotFoundError) IsScwSdkError() {} func (e ConfigFileNotFoundError) Error() string { return fmt.Sprintf("scaleway-sdk-go: cannot read config file %s: no such file or directory", e.path) } // ResourceExpiredError implements the SdkError interface type ResourceExpiredError struct { Resource string `json:"resource"` ResourceID string `json:"resource_id"` ExpiredSince time.Time `json:"expired_since"` RawBody json.RawMessage `json:"-"` } func (r ResourceExpiredError) Error() string { return fmt.Sprintf("scaleway-sdk-go: resource %s with ID %s expired since %s", r.Resource, r.ResourceID, r.ExpiredSince.String()) } func (r ResourceExpiredError) IsScwSdkError() {} // DeniedAuthenticationError implements the SdkError interface type DeniedAuthenticationError struct { Method string `json:"method"` Reason string `json:"reason"` RawBody json.RawMessage `json:"-"` } func (r DeniedAuthenticationError) Error() string { var reason string var method string switch r.Method { case "unknown_method": method = "unknown method" case "jwt": method = "JWT" case "api_key": method = "API key" } switch r.Reason { case "unknown_reason": reason = "unknown reason" case "invalid_argument": reason = "invalid " + method + " format or empty value" case "not_found": reason = method + " does not exist" case "expired": reason = method + " is expired" } return fmt.Sprintf("scaleway-sdk-go: denied authentication: %s", reason) } func (r DeniedAuthenticationError) IsScwSdkError() {} // PreconditionFailedError implements the SdkError interface type PreconditionFailedError struct { Precondition string `json:"precondition"` HelpMessage string `json:"help_message"` RawBody json.RawMessage `json:"-"` } func (r PreconditionFailedError) Error() string { var msg string switch r.Precondition { case "unknown_precondition": msg = "unknown precondition" case "resource_still_in_use": msg = "resource is still in use" case "attribute_must_be_set": msg = "attribute must be set" } if r.HelpMessage != "" { msg += ", " + r.HelpMessage } return fmt.Sprintf("scaleway-sdk-go: precondition failed: %s", msg) } func (r PreconditionFailedError) IsScwSdkError() {} golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/errors_test.go000066400000000000000000000155471456366605600257700ustar00rootroot00000000000000package scw import ( "bytes" "encoding/json" "io/ioutil" "net/http" "strings" "testing" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" ) func TestHasResponseErrorWithStatus200(t *testing.T) { res := &http.Response{StatusCode: 200} newErr := hasResponseError(res) testhelpers.AssertNoError(t, newErr) } func TestHasResponseErrorWithoutBody(t *testing.T) { res := &http.Response{StatusCode: 400} newErr := hasResponseError(res) testhelpers.Assert(t, newErr != nil, "Should have error") } func TestNonStandardError(t *testing.T) { type testCase struct { resStatus string resStatusCode int resBody string contentType string expectedError SdkError } run := func(c *testCase) func(t *testing.T) { return func(t *testing.T) { res := &http.Response{ Status: c.resStatus, StatusCode: c.resStatusCode, Body: ioutil.NopCloser(strings.NewReader(c.resBody)), Header: http.Header{ "Content-Type": []string{c.contentType}, }, } // Test that hasResponseError converts the response to the expected SdkError. newErr := hasResponseError(res) testhelpers.Assert(t, newErr != nil, "Should have error") testhelpers.Equals(t, c.expectedError, newErr) } } t.Run("invalid_request_error type with fields", run(&testCase{ resStatus: "400 Bad Request", resStatusCode: http.StatusBadRequest, contentType: "application/json", resBody: `{"fields":{"volumes.5.id":["92 is not a valid UUID."],"volumes.5.name":["required key not provided"]},"message":"Validation Error","type":"invalid_request_error"}`, expectedError: &InvalidArgumentsError{ Details: []InvalidArgumentsErrorDetail{ { ArgumentName: "volumes.5.id", Reason: "constraint", HelpMessage: "92 is not a valid UUID.", }, { ArgumentName: "volumes.5.name", Reason: "constraint", HelpMessage: "required key not provided", }, }, RawBody: []byte(`{"fields":{"volumes.5.id":["92 is not a valid UUID."],"volumes.5.name":["required key not provided"]},"message":"Validation Error","type":"invalid_request_error"}`), }, })) t.Run("invalid_request_error type with message", run(&testCase{ resStatus: "400 Bad Request", resStatusCode: http.StatusBadRequest, contentType: "application/json", resBody: `{"message": "server should be running", "type": "invalid_request_error"}`, expectedError: &ResponseError{ Status: "400 Bad Request", StatusCode: http.StatusBadRequest, Message: "server should be running", Type: "invalid_request_error", RawBody: []byte(`{"message": "server should be running", "type": "invalid_request_error"}`), }, })) t.Run("invalid_request_error quota exceeded", run(&testCase{ resStatus: "403 Forbidden", resStatusCode: http.StatusForbidden, contentType: "application/json", resBody: `{"type": "invalid_request_error", "message": "Quota exceeded for this resource.", "resource": "compute_snapshots_type_b_ssd_available"}`, expectedError: &QuotasExceededError{ Details: []QuotasExceededErrorDetail{ { Resource: "compute_snapshots_type_b_ssd_available", Current: 0, Quota: 0, }, }, RawBody: []byte(`{"type": "invalid_request_error", "message": "Quota exceeded for this resource.", "resource": "compute_snapshots_type_b_ssd_available"}`), }, })) t.Run("unknown_resource ", run(&testCase{ resStatus: "404 Not Found", resStatusCode: http.StatusNotFound, contentType: "application/json", resBody: `{"type": "unknown_resource", "message": "\"11111111-1111-4111-8111-111111111111\" not found"}`, expectedError: &ResourceNotFoundError{ ResourceID: "11111111-1111-4111-8111-111111111111", RawBody: []byte(`{"type": "unknown_resource", "message": "\"11111111-1111-4111-8111-111111111111\" not found"}`), }, })) t.Run("unknown_resource bis", run(&testCase{ resStatus: "404 Not Found", resStatusCode: http.StatusNotFound, contentType: "application/json", resBody: `{"type": "unknown_resource", "message": "Security group \"11111111-1111-4111-8111-111111111111\" not found"}`, expectedError: &ResourceNotFoundError{ ResourceID: "11111111-1111-4111-8111-111111111111", Resource: "security_group", RawBody: []byte(`{"type": "unknown_resource", "message": "Security group \"11111111-1111-4111-8111-111111111111\" not found"}`), }, })) t.Run("unknown_resource single qupte", run(&testCase{ resStatus: "404 Not Found", resStatusCode: http.StatusNotFound, contentType: "application/json", resBody: `{"type": "unknown_resource", "message": "Volume '11111111-1111-4111-8111-111111111111' not found"}`, expectedError: &ResourceNotFoundError{ ResourceID: "11111111-1111-4111-8111-111111111111", Resource: "volume", RawBody: []byte(`{"type": "unknown_resource", "message": "Volume '11111111-1111-4111-8111-111111111111' not found"}`), }, })) t.Run("conflict type", run(&testCase{ resStatus: "409 Conflict", resStatusCode: http.StatusConflict, contentType: "application/json", resBody: `{"message": "Group is in use. You cannot delete it.", "type": "conflict"}`, expectedError: &ResponseError{ Status: "409 Conflict", StatusCode: http.StatusConflict, Message: "group is in use. you cannot delete it.", Type: "conflict", RawBody: []byte(`{"message": "Group is in use. You cannot delete it.", "type": "conflict"}`), }, })) t.Run("text/plain content type", run(&testCase{ resStatus: "404 Not Found", resStatusCode: http.StatusNotFound, contentType: "text/plain", resBody: ``, expectedError: &ResponseError{ Status: "404 Not Found", StatusCode: http.StatusNotFound, Message: "404 Not Found", RawBody: []byte(""), }, })) } func TestHasResponseErrorWithValidError(t *testing.T) { var ( errorMessage = "some message" errorType = "some type" errorFields = map[string][]string{"some_field": {"some_value"}} errorStatusCode = 400 errorStatus = "400 Bad Request" ) // Create expected error response testErrorReponse := &ResponseError{ Message: errorMessage, Type: errorType, Fields: errorFields, StatusCode: errorStatusCode, Status: errorStatus, RawBody: []byte(`{"message":"some message","type":"some type","fields":{"some_field":["some_value"]}}`), } // Create response body with marshalled error response bodyBytes, err := json.Marshal(testErrorReponse) testhelpers.AssertNoError(t, err) res := &http.Response{ Status: errorStatus, StatusCode: errorStatusCode, Header: map[string][]string{ "Content-Type": []string{"application/json"}, }, Body: ioutil.NopCloser(bytes.NewReader(bodyBytes)), } // Test hasResponseError() newErr := hasResponseError(res) testhelpers.Assert(t, newErr != nil, "Should have error") testhelpers.Equals(t, testErrorReponse, newErr) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/load_config_test.go000066400000000000000000000103171456366605600267060ustar00rootroot00000000000000package scw import ( "io/ioutil" "os" "path/filepath" "strings" "testing" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" ) // TestLoad tests all valid configuration files: // - v2 config // - custom-path with v2 config // - XDG config path with v2 config func TestLoad(t *testing.T) { tests := []struct { name string env map[string]string files map[string]string expected *Config expectedError string expectedFiles map[string]string }{ // valid config { name: "Custom-path config is empty", // custom config path env: map[string]string{ ScwConfigPathEnv: "{HOME}/valid1/test.conf", }, files: map[string]string{ "valid1/test.conf": emptyFile, }, expected: &Config{}, }, { name: "Custom-path config with valid V2", env: map[string]string{ ScwConfigPathEnv: "{HOME}/valid3/test.conf", }, files: map[string]string{ "valid3/test.conf": v2SimpleValidConfigFile, }, expected: v2SimpleValidConfig, }, { name: "Default config with valid V2", // default config path env: map[string]string{ "HOME": "{HOME}", }, files: map[string]string{ ".config/scw/config.yaml": v2SimpleValidConfigFile, }, expected: v2SimpleValidConfig, expectedFiles: map[string]string{ ".config/scw/config.yaml": v2SimpleValidConfigFile, }, }, { name: "XDG config with valid V2", env: map[string]string{ "HOME": "{HOME}", xdgConfigDirEnv: "{HOME}/plop", }, files: map[string]string{ "plop/scw/config.yaml": v2SimpleValidConfigFile, }, expected: v2SimpleValidConfig, }, // errors { name: "Err: custom-path config does not exist", env: map[string]string{ ScwConfigPathEnv: "{HOME}/fake/test.conf", }, expectedError: "scaleway-sdk-go: cannot read config file {HOME}/fake/test.conf: no such file or directory", }, { name: "Err: custom-path config with invalid V2", env: map[string]string{ ScwConfigPathEnv: "{HOME}/invalid1/test.conf", }, files: map[string]string{ "invalid1/test.conf": v2SimpleInvalidConfigFile, }, expectedError: "scaleway-sdk-go: content of config file {HOME}/invalid1/test.conf is invalid: yaml: found unexpected end of stream", }, { name: "Err: default config with invalid V2", env: map[string]string{ "HOME": "{HOME}", }, files: map[string]string{ ".config/scw/config.yaml": v2SimpleInvalidConfigFile, }, expectedError: "scaleway-sdk-go: content of config file {HOME}/.config/scw/config.yaml is invalid: yaml: found unexpected end of stream", }, { name: "Err: default config with invalid profile", env: map[string]string{ "HOME": "{HOME}", }, files: map[string]string{ ".config/scw/config.yaml": v2SimpleConfigFileWithInvalidProfile, }, expectedError: "scaleway-sdk-go: given profile flantier does not exist", }, } // create home dir dir := initEnv(t) // delete home dir and reset env variables defer resetEnv(t, os.Environ(), dir) for _, test := range tests { t.Run(test.name, func(t *testing.T) { // set up env and config file(s) setEnv(t, test.env, test.files, dir) test.expectedError = strings.Replace(test.expectedError, "{HOME}", dir, -1) // remove config file(s) defer cleanEnv(t, test.files, dir) // load config config, err := LoadConfig() // test expected outputs if test.expectedError != "" { if err == nil { _, tmpErr := config.GetActiveProfile() if tmpErr != nil { testhelpers.Equals(t, test.expectedError, tmpErr.Error()) return } } testhelpers.Assert(t, err != nil, "error should not be nil") testhelpers.Equals(t, test.expectedError, err.Error()) } else { testhelpers.AssertNoError(t, err) testhelpers.Equals(t, test.expected, config) _, err = config.GetActiveProfile() testhelpers.AssertNoError(t, err) } // test expected files for path, expectedContent := range test.expectedFiles { targetPath := filepath.Join(dir, path) content, err := ioutil.ReadFile(targetPath) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, expectedContent, string(content)) testhelpers.AssertNoError(t, os.RemoveAll(targetPath)) // delete at the end } }) } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/locality.go000066400000000000000000000130611456366605600252220ustar00rootroot00000000000000package scw import ( "encoding/json" "fmt" "strings" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/logger" "github.com/scaleway/scaleway-sdk-go/validation" ) // localityPartsSeparator is the separator used in Zone and Region const localityPartsSeparator = "-" // Zone is an availability zone type Zone string const ( // ZoneFrPar1 represents the fr-par-1 zone ZoneFrPar1 = Zone("fr-par-1") // ZoneFrPar2 represents the fr-par-2 zone ZoneFrPar2 = Zone("fr-par-2") // ZoneFrPar3 represents the fr-par-3 zone ZoneFrPar3 = Zone("fr-par-3") // ZoneNlAms1 represents the nl-ams-1 zone ZoneNlAms1 = Zone("nl-ams-1") // ZoneNlAms2 represents the nl-ams-2 zone ZoneNlAms2 = Zone("nl-ams-2") // ZoneNlAms3 represents the nl-ams-3 zone ZoneNlAms3 = Zone("nl-ams-3") // ZonePlWaw1 represents the pl-waw-1 zone ZonePlWaw1 = Zone("pl-waw-1") // ZonePlWaw2 represents the pl-waw-2 zone ZonePlWaw2 = Zone("pl-waw-2") // ZonePlWaw3 represents the pl-waw-3 zone ZonePlWaw3 = Zone("pl-waw-3") ) var ( // AllZones is an array that list all zones AllZones = []Zone{ ZoneFrPar1, ZoneFrPar2, ZoneFrPar3, ZoneNlAms1, ZoneNlAms2, ZoneNlAms3, ZonePlWaw1, ZonePlWaw2, ZonePlWaw3, } ) // Exists checks whether a zone exists func (zone Zone) Exists() bool { for _, z := range AllZones { if z == zone { return true } } return false } // String returns a Zone as a string func (zone Zone) String() string { return string(zone) } // Region returns the parent Region for the Zone. // Manipulates the string directly to allow unlisted zones formatted as xx-yyy-z. func (zone Zone) Region() (Region, error) { zoneStr := zone.String() if !validation.IsZone(zoneStr) { return "", fmt.Errorf("invalid zone '%v'", zoneStr) } zoneParts := strings.Split(zoneStr, localityPartsSeparator) return Region(strings.Join(zoneParts[:2], localityPartsSeparator)), nil } // Region is a geographical location type Region string const ( // RegionFrPar represents the fr-par region RegionFrPar = Region("fr-par") // RegionNlAms represents the nl-ams region RegionNlAms = Region("nl-ams") // RegionPlWaw represents the pl-waw region RegionPlWaw = Region("pl-waw") ) var ( // AllRegions is an array that list all regions AllRegions = []Region{ RegionFrPar, RegionNlAms, RegionPlWaw, } ) // Exists checks whether a region exists func (region Region) Exists() bool { for _, r := range AllRegions { if r == region { return true } } return false } // GetZones is a function that returns the zones for the specified region func (region Region) GetZones() []Zone { switch region { case RegionFrPar: return []Zone{ZoneFrPar1, ZoneFrPar2, ZoneFrPar3} case RegionNlAms: return []Zone{ZoneNlAms1, ZoneNlAms2, ZoneNlAms3} case RegionPlWaw: return []Zone{ZonePlWaw1, ZonePlWaw2, ZonePlWaw3} default: return []Zone{} } } // ParseZone parses a string value into a Zone and returns an error if it has a bad format. func ParseZone(zone string) (Zone, error) { switch zone { case "par1": // would be triggered by API market place // logger.Warningf("par1 is a deprecated name for zone, use fr-par-1 instead") return ZoneFrPar1, nil case "ams1": // would be triggered by API market place // logger.Warningf("ams1 is a deprecated name for zone, use nl-ams-1 instead") return ZoneNlAms1, nil default: if !validation.IsZone(zone) { zones := []string(nil) for _, z := range AllZones { zones = append(zones, string(z)) } return "", errors.New("bad zone format, available zones are: %s", strings.Join(zones, ", ")) } newZone := Zone(zone) if !newZone.Exists() { logger.Infof("%s is an unknown zone\n", newZone) } return newZone, nil } } // UnmarshalJSON implements the Unmarshaler interface for a Zone. // this to call ParseZone on the string input and return the correct Zone object. func (zone *Zone) UnmarshalJSON(input []byte) error { // parse input value as string var stringValue string err := json.Unmarshal(input, &stringValue) if err != nil { return err } // parse string as Zone *zone, err = ParseZone(stringValue) if err != nil { return err } return nil } // ParseRegion parses a string value into a Region and returns an error if it has a bad format. func ParseRegion(region string) (Region, error) { switch region { case "par1": // would be triggered by API market place // logger.Warningf("par1 is a deprecated name for region, use fr-par instead") return RegionFrPar, nil case "ams1": // would be triggered by API market place // logger.Warningf("ams1 is a deprecated name for region, use nl-ams instead") return RegionNlAms, nil default: if !validation.IsRegion(region) { regions := []string(nil) for _, r := range AllRegions { regions = append(regions, string(r)) } return "", errors.New("bad region format, available regions are: %s", strings.Join(regions, ", ")) } newRegion := Region(region) if !newRegion.Exists() { logger.Infof("%s is an unknown region\n", newRegion) } return newRegion, nil } } // UnmarshalJSON implements the Unmarshaler interface for a Region. // this to call ParseRegion on the string input and return the correct Region object. func (region *Region) UnmarshalJSON(input []byte) error { // parse input value as string var stringValue string err := json.Unmarshal(input, &stringValue) if err != nil { return err } // parse string as Region *region, err = ParseRegion(stringValue) if err != nil { return err } return nil } // String returns a Region as a string func (region Region) String() string { return string(region) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/locality_test.go000066400000000000000000000057611456366605600262710ustar00rootroot00000000000000package scw import ( "encoding/json" "testing" "github.com/scaleway/scaleway-sdk-go/internal/errors" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" ) func TestParseZone(t *testing.T) { tests := []struct { input string err error expected Zone }{ { input: "fr-par-1", expected: ZoneFrPar1, }, { input: "pl-waw-1", expected: ZonePlWaw1, }, { input: "pl-waw-2", expected: ZonePlWaw2, }, { input: "pl-waw-3", expected: ZonePlWaw3, }, { input: "nl-ams-2", expected: ZoneNlAms2, }, { input: "nl-ams-3", expected: ZoneNlAms3, }, { input: "par1", expected: ZoneFrPar1, }, { input: "ams1", expected: ZoneNlAms1, }, { input: "xx-xxx-1", expected: "xx-xxx-1", }, { input: "fr-par", expected: "", err: errors.New("bad zone format, available zones are: fr-par-1, fr-par-2, fr-par-3, nl-ams-1, nl-ams-2, nl-ams-3, pl-waw-1, pl-waw-2, pl-waw-3"), }, { input: "fr-par-n", expected: "", err: errors.New("bad zone format, available zones are: fr-par-1, fr-par-2, fr-par-3, nl-ams-1, nl-ams-2, nl-ams-3, pl-waw-1, pl-waw-2, pl-waw-3"), }, { input: "fr-par-0", expected: "", err: errors.New("bad zone format, available zones are: fr-par-1, fr-par-2, fr-par-3, nl-ams-1, nl-ams-2, nl-ams-3, pl-waw-1, pl-waw-2, pl-waw-3"), }, } for _, test := range tests { t.Run(test.input, func(t *testing.T) { z, err := ParseZone(test.input) testhelpers.Equals(t, test.err, err) testhelpers.Equals(t, test.expected, z) }) } } func TestZoneJSONUnmarshall(t *testing.T) { t.Run("test with zone", func(t *testing.T) { input := `{"Test": "par1"}` value := struct{ Test Zone }{} err := json.Unmarshal([]byte(input), &value) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, ZoneFrPar1, value.Test) }) t.Run("test with region", func(t *testing.T) { input := `{"Test": "par1"}` value := struct{ Test Region }{} err := json.Unmarshal([]byte(input), &value) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, RegionFrPar, value.Test) }) } func TestParseRegion(t *testing.T) { tests := []struct { input string err error expected Region }{ { input: "fr-par", expected: RegionFrPar, }, { input: "par1", expected: RegionFrPar, }, { input: "ams1", expected: RegionNlAms, }, { input: "pl-waw", expected: RegionPlWaw, }, { input: "xx-xxx", expected: "xx-xxx", }, { input: "fr-par-1", expected: "", err: errors.New("bad region format, available regions are: fr-par, nl-ams, pl-waw"), }, { input: "fr-pa1", expected: "", err: errors.New("bad region format, available regions are: fr-par, nl-ams, pl-waw"), }, } for _, test := range tests { t.Run(test.input, func(t *testing.T) { r, err := ParseRegion(test.input) testhelpers.Equals(t, test.err, err) testhelpers.Equals(t, test.expected, r) }) } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/path.go000066400000000000000000000044701456366605600243420ustar00rootroot00000000000000package scw import ( "errors" "os" "path/filepath" ) const ( // XDG wiki: https://wiki.archlinux.org/index.php/XDG_Base_Directory xdgConfigDirEnv = "XDG_CONFIG_HOME" xdgCacheDirEnv = "XDG_CACHE_HOME" unixHomeDirEnv = "HOME" windowsHomeDirEnv = "USERPROFILE" defaultConfigFileName = "config.yaml" ) var ( // ErrNoHomeDir errors when no user directory is found ErrNoHomeDir = errors.New("user home directory not found") ) // GetCacheDirectory returns the default cache directory. // Cache directory is based on the following priority order: // - $SCW_CACHE_DIR // - $XDG_CACHE_HOME/scw // - $HOME/.cache/scw // - $USERPROFILE/.cache/scw func GetCacheDirectory() string { cacheDir := "" switch { case os.Getenv(ScwCacheDirEnv) != "": cacheDir = os.Getenv(ScwCacheDirEnv) case os.Getenv(xdgCacheDirEnv) != "": cacheDir = filepath.Join(os.Getenv(xdgCacheDirEnv), "scw") case os.Getenv(unixHomeDirEnv) != "": cacheDir = filepath.Join(os.Getenv(unixHomeDirEnv), ".cache", "scw") case os.Getenv(windowsHomeDirEnv) != "": cacheDir = filepath.Join(os.Getenv(windowsHomeDirEnv), ".cache", "scw") default: // TODO: fallback on local folder? } // Clean the cache directory path when exiting the function return filepath.Clean(cacheDir) } // GetConfigPath returns the default path. // Default path is based on the following priority order: // - $SCW_CONFIG_PATH // - $XDG_CONFIG_HOME/scw/config.yaml // - $HOME/.config/scw/config.yaml // - $USERPROFILE/.config/scw/config.yaml func GetConfigPath() string { configPath := os.Getenv(ScwConfigPathEnv) if configPath == "" { configPath, _ = getConfigV2FilePath() } return filepath.Clean(configPath) } // getConfigV2FilePath returns the path to the v2 config file func getConfigV2FilePath() (string, bool) { configDir, err := GetScwConfigDir() if err != nil { return "", false } return filepath.Clean(filepath.Join(configDir, defaultConfigFileName)), true } // GetScwConfigDir returns the path to scw config folder func GetScwConfigDir() (string, error) { if xdgPath := os.Getenv(xdgConfigDirEnv); xdgPath != "" { return filepath.Join(xdgPath, "scw"), nil } homeDir, err := os.UserHomeDir() if err != nil { return "", err } return filepath.Join(homeDir, ".config", "scw"), nil } func fileExist(name string) bool { _, err := os.Stat(name) return err == nil } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/request.go000066400000000000000000000040651456366605600250760ustar00rootroot00000000000000package scw import ( "bytes" "context" "encoding/json" "io" "net/http" "net/url" "github.com/scaleway/scaleway-sdk-go/internal/auth" "github.com/scaleway/scaleway-sdk-go/internal/errors" ) // ScalewayRequest contains all the contents related to performing a request on the Scaleway API. type ScalewayRequest struct { Method string Path string Headers http.Header Query url.Values Body io.Reader // request options ctx context.Context auth auth.Auth allPages bool zones []Zone regions []Region } // getURL constructs a URL based on the base url and the client. func (req *ScalewayRequest) getURL(baseURL string) (*url.URL, error) { url, err := url.Parse(baseURL + req.Path) if err != nil { return nil, errors.New("invalid url %s: %s", baseURL+req.Path, err) } url.RawQuery = req.Query.Encode() return url, nil } // SetBody json marshal the given body and write the json content type // to the request. It also catches when body is a file. func (req *ScalewayRequest) SetBody(body interface{}) error { var contentType string var content io.Reader switch b := body.(type) { case *File: contentType = b.ContentType content = b.Content case io.Reader: contentType = "text/plain" content = b default: buf, err := json.Marshal(body) if err != nil { return err } contentType = "application/json" content = bytes.NewReader(buf) } if req.Headers == nil { req.Headers = http.Header{} } req.Headers.Set("Content-Type", contentType) req.Body = content return nil } func (req *ScalewayRequest) apply(opts []RequestOption) { for _, opt := range opts { opt(req) } } func (req *ScalewayRequest) validate() error { // nothing so far return nil } func (req *ScalewayRequest) clone() *ScalewayRequest { clonedReq := &ScalewayRequest{ Method: req.Method, Path: req.Path, Headers: req.Headers.Clone(), ctx: req.ctx, auth: req.auth, allPages: req.allPages, zones: req.zones, } if req.Query != nil { clonedReq.Query = url.Values(http.Header(req.Query).Clone()) } return clonedReq } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/request_header.go000066400000000000000000000013071456366605600264020ustar00rootroot00000000000000//go:build !wasm || !js package scw import ( "net/http" "github.com/scaleway/scaleway-sdk-go/internal/auth" ) // getAllHeaders constructs a http.Header object and aggregates all headers into the object. func (req *ScalewayRequest) getAllHeaders(token auth.Auth, userAgent string, anonymized bool) http.Header { var allHeaders http.Header if anonymized { allHeaders = token.AnonymizedHeaders() } else { allHeaders = token.Headers() } allHeaders.Set("User-Agent", userAgent) if req.Body != nil { allHeaders.Set("Content-Type", "application/json") } for key, value := range req.Headers { allHeaders.Del(key) for _, v := range value { allHeaders.Add(key, v) } } return allHeaders } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/request_header_wasm.go000066400000000000000000000013071456366605600274310ustar00rootroot00000000000000//go:build wasm && js package scw import ( "net/http" "github.com/scaleway/scaleway-sdk-go/internal/auth" ) // getAllHeaders constructs a http.Header object and aggregates all headers into the object. func (req *ScalewayRequest) getAllHeaders(token auth.Auth, userAgent string, anonymized bool) http.Header { var allHeaders http.Header if anonymized { allHeaders = token.AnonymizedHeaders() } else { allHeaders = token.Headers() } allHeaders.Set("X-User-Agent", userAgent) if req.Body != nil { allHeaders.Set("Content-Type", "application/json") } for key, value := range req.Headers { allHeaders.Del(key) for _, v := range value { allHeaders.Add(key, v) } } return allHeaders } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/request_option.go000066400000000000000000000030201456366605600264540ustar00rootroot00000000000000package scw import ( "context" "github.com/scaleway/scaleway-sdk-go/internal/auth" ) // RequestOption is a function that applies options to a ScalewayRequest. type RequestOption func(*ScalewayRequest) // WithContext request option sets the context of a ScalewayRequest func WithContext(ctx context.Context) RequestOption { return func(s *ScalewayRequest) { s.ctx = ctx } } // WithAllPages aggregate all pages in the response of a List request. // Will error when pagination is not supported on the request. func WithAllPages() RequestOption { return func(s *ScalewayRequest) { s.allPages = true } } // WithAuthRequest overwrites the client access key and secret key used in the request. func WithAuthRequest(accessKey, secretKey string) RequestOption { return func(s *ScalewayRequest) { s.auth = auth.NewToken(accessKey, secretKey) } } // WithZones aggregate results from requested zones in the response of a List request. // response rows are sorted by zone using order of given zones // Will error when pagination is not supported on the request. func WithZones(zones ...Zone) RequestOption { return func(s *ScalewayRequest) { s.zones = append(s.zones, zones...) } } // WithRegions aggregate results from requested regions in the response of a List request. // response rows are sorted by region using order of given regions // Will error when pagination is not supported on the request. func WithRegions(regions ...Region) RequestOption { return func(s *ScalewayRequest) { s.regions = append(s.regions, regions...) } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/request_test.go000066400000000000000000000066261456366605600261420ustar00rootroot00000000000000package scw import ( "bytes" "fmt" "net/http" "net/url" "testing" "time" "github.com/scaleway/scaleway-sdk-go/internal/auth" "github.com/scaleway/scaleway-sdk-go/internal/testhelpers" ) const ( testBaseURL = "http://example.com" testPath = "/some/path/" testKey = "some_key" testValue = "some_value" testBody = "some body" testUserAgent = "user/agent" testHeaderKey = "Some-Header-Key" testHeaderVal = "some_header_val" testTokenKey = "some_secret_key" ) func TestGetURL(t *testing.T) { req := ScalewayRequest{ Path: testPath, Query: url.Values{ testKey: []string{testValue}, }, } newURL, err := req.getURL(testBaseURL) testhelpers.AssertNoError(t, err) expectedURL := fmt.Sprintf("%s%s?%s=%s", testBaseURL, testPath, testKey, testValue) testhelpers.Equals(t, expectedURL, newURL.String()) } func TestGetHeadersWithoutBody(t *testing.T) { req := ScalewayRequest{ Headers: http.Header{ testHeaderKey: []string{testHeaderVal}, }, } token := auth.NewToken(testAccessKey, testTokenKey) expectedHeaders := http.Header{ testHeaderKey: []string{testHeaderVal}, "X-Auth-Token": []string{testTokenKey}, "User-Agent": []string{testUserAgent}, } allHeaders := req.getAllHeaders(token, testUserAgent, false) testhelpers.Equals(t, expectedHeaders, allHeaders) } func TestGetHeadersWithBody(t *testing.T) { req := ScalewayRequest{ Headers: http.Header{ testHeaderKey: []string{testHeaderVal}, }, Body: bytes.NewReader([]byte(testBody)), } token := auth.NewToken(testSecretKey, testTokenKey) expectedHeaders := http.Header{ testHeaderKey: []string{testHeaderVal}, "X-Auth-Token": []string{testTokenKey}, "Content-Type": []string{"application/json"}, "User-Agent": []string{testUserAgent}, } allHeaders := req.getAllHeaders(token, testUserAgent, false) testhelpers.Equals(t, expectedHeaders, allHeaders) } func TestSetBody(t *testing.T) { body := struct { Region Region `json:"-"` ID string `json:"-"` Name string `json:"name,omitempty"` Slice []string `json:"slice,omitempty"` Flag bool `json:"flag,omitempty"` Timeout *time.Duration `json:"timeout,omitempty"` }{ Region: RegionNlAms, ID: "plop", Name: "plop", Slice: []string{"plop", "plop"}, Flag: true, Timeout: TimeDurationPtr(time.Second), } req := ScalewayRequest{ Headers: http.Header{}, } testhelpers.AssertNoError(t, req.SetBody(body)) r, isBytesReader := req.Body.(*bytes.Reader) testhelpers.Assert(t, isBytesReader, "req.Body should be bytes Reader") b := make([]byte, r.Len()) _, err := r.Read(b) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, []string{"application/json"}, req.Headers["Content-Type"]) testhelpers.Equals(t, `{"name":"plop","slice":["plop","plop"],"flag":true,"timeout":1000000000}`, string(b)) } func TestSetFileBody(t *testing.T) { body := &File{ Content: bytes.NewReader([]byte(testBody)), ContentType: "plain/text", } req := ScalewayRequest{ Headers: http.Header{}, } testhelpers.AssertNoError(t, req.SetBody(body)) r, isBytesReader := req.Body.(*bytes.Reader) testhelpers.Assert(t, isBytesReader, "req.Body should be bytes Reader") b := make([]byte, r.Len()) _, err := r.Read(b) testhelpers.AssertNoError(t, err) testhelpers.Equals(t, []string{"plain/text"}, req.Headers["Content-Type"]) testhelpers.Equals(t, `some body`, string(b)) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/transport.go000066400000000000000000000034271456366605600254430ustar00rootroot00000000000000package scw import ( "net/http" "net/http/httputil" "sync/atomic" "github.com/scaleway/scaleway-sdk-go/internal/auth" "github.com/scaleway/scaleway-sdk-go/logger" ) type requestLoggerTransport struct { rt http.RoundTripper // requestNumber auto increments on each do(). // This allows easy distinguishing of concurrently performed requests in log. requestNumber uint32 } func (l *requestLoggerTransport) RoundTrip(request *http.Request) (*http.Response, error) { currentRequestNumber := atomic.AddUint32(&l.requestNumber, 1) // Keep original headers (before anonymization) originalHeaders := request.Header // Get anonymized headers request.Header = auth.AnonymizeHeaders(request.Header.Clone()) dump, err := httputil.DumpRequestOut(request, true) if err != nil { logger.Warningf("cannot dump outgoing request: %s", err) } else { var logString string logString += "\n--------------- Scaleway SDK REQUEST %d : ---------------\n" logString += "%s\n" logString += "---------------------------------------------------------" logger.Debugf(logString, currentRequestNumber, dump) } // Restore original headers before sending the request request.Header = originalHeaders response, requestError := l.rt.RoundTrip(request) if requestError != nil { _, isSdkError := requestError.(SdkError) if !isSdkError { return response, requestError } } dump, err = httputil.DumpResponse(response, true) if err != nil { logger.Warningf("cannot dump ingoing response: %s", err) } else { var logString string logString += "\n--------------- Scaleway SDK RESPONSE %d : ---------------\n" logString += "%s\n" logString += "----------------------------------------------------------" logger.Debugf(logString, currentRequestNumber, dump) } return response, requestError } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/scw/version.go000066400000000000000000000003451456366605600250700ustar00rootroot00000000000000package scw import ( "fmt" "runtime" ) // TODO: versioning process const version = "v1.0.0-beta.7+dev" var userAgent = fmt.Sprintf("scaleway-sdk-go/%s (%s; %s; %s)", version, runtime.Version(), runtime.GOOS, runtime.GOARCH) golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/sdk_compilation_test.go000066400000000000000000000014731456366605600270300ustar00rootroot00000000000000package scalewaysdkgo // This test file makes sure that all the auto-generated code compiles. import ( _ "github.com/scaleway/scaleway-sdk-go/api/account/v2alpha1" _ "github.com/scaleway/scaleway-sdk-go/api/baremetal/v1" _ "github.com/scaleway/scaleway-sdk-go/api/domain/v2beta1" _ "github.com/scaleway/scaleway-sdk-go/api/instance/v1" _ "github.com/scaleway/scaleway-sdk-go/api/iot/v1" _ "github.com/scaleway/scaleway-sdk-go/api/k8s/v1" _ "github.com/scaleway/scaleway-sdk-go/api/lb/v1" _ "github.com/scaleway/scaleway-sdk-go/api/marketplace/v1" _ "github.com/scaleway/scaleway-sdk-go/api/rdb/v1" _ "github.com/scaleway/scaleway-sdk-go/api/registry/v1" _ "github.com/scaleway/scaleway-sdk-go/api/test/v1" _ "github.com/scaleway/scaleway-sdk-go/api/vpc/v1" _ "github.com/scaleway/scaleway-sdk-go/api/vpcgw/v1" ) golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/strcase/000077500000000000000000000000001456366605600237225ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/strcase/bash_arg.go000066400000000000000000000033151456366605600260210ustar00rootroot00000000000000package strcase import "strings" var customBashNames = map[string]string{ "aclid": "acl-id", "ipid": "ip-id", "lbid": "lb-id", "dhcpid": "dhcp-id", } // ToBashArg returns the Bash public name of the given string. func ToBashArg(s string) string { s = ToPublicGoName(s) if customBashName, exists := customBashNames[strings.ToLower(s)]; exists { return customBashName } for _, initialism := range customInitialisms { // catch this kind of pattern: ExampleIDs ==> ExampleIds ==> example-ids s = strings.Replace(s, initialism[0], strings.Title(strings.ToLower(initialism[0])), -1) } return toKebab(s) } // toKebab converts a string to kebab-case. func toKebab(s string) string { return toDelimited(s, '-') } // toDelimited converts a string to delimited lowercase. func toDelimited(s string, del uint8) string { s = strings.Trim(s, " ") n := "" for i, v := range s { // treat acronyms as words, eg for JSONData -> JSON is a whole word nextCaseIsChanged := false if i+1 < len(s) { next := s[i+1] if (isUpperLetter(v) && isLowerLetter(int32(next))) || (isLowerLetter(v) && isUpperLetter(int32(next))) { nextCaseIsChanged = true } } if i > 0 && n[len(n)-1] != del && nextCaseIsChanged { // add delimiter if next letter case type is changed if isUpperLetter(v) { n += string(del) + string(v) } else if isLowerLetter(v) { n += string(v) + string(del) } } else if v == ' ' || v == '-' || v == '_' { // replace spaces and dashes with delimiter n += string(del) } else { n = n + string(v) } } n = strings.ToLower(n) return n } func isUpperLetter(c int32) bool { return c >= 'A' && c <= 'Z' } func isLowerLetter(c int32) bool { return c >= 'a' && c <= 'z' } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/strcase/bash_arg_test.go000066400000000000000000000015101456366605600270530ustar00rootroot00000000000000package strcase import ( "testing" ) func TestToKebabCase(t *testing.T) { cases := []struct { in string want string }{ {"testCase", "test-case"}, {"TestCase", "test-case"}, {"Test Case", "test-case"}, {" Test Case", "test-case"}, {"Test Case ", "test-case"}, {" Test Case ", "test-case"}, {"test", "test"}, {"test_case", "test-case"}, {"Test", "test"}, {"", ""}, {"ManyManyWords", "many-many-words"}, {"manyManyWords", "many-many-words"}, {"AnyKind of_string", "any-kind-of-string"}, {"numbers2and55with000", "numbers2and55with000"}, {"JSONData", "json-data"}, {"userID", "user-id"}, {"AAAbbb", "aa-abbb"}, } for _, c := range cases { t.Run(c.in, func(t *testing.T) { got := toKebab(c.in) if got != c.want { t.Errorf("toKebab(%q) == %q, want %q", c.in, got, c.want) } }) } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/strcase/camel.go000066400000000000000000000003341456366605600253320ustar00rootroot00000000000000package strcase import "strings" func ToCamel(s string) string { if s == "" { return s } if r := rune(s[0]); r >= 'A' && r <= 'Z' { s = strings.ToLower(string(r)) + s[1:] } return toPascalInitCase(s, false) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/strcase/camel_test.go000066400000000000000000000005531456366605600263740ustar00rootroot00000000000000package strcase import ( "testing" ) func TestToCamel(t *testing.T) { cases := [][]string{ {"foo-bar", "fooBar"}, {"TestCase", "testCase"}, {"", ""}, {"AnyKind of_string", "anyKindOfString"}, } for _, i := range cases { in := i[0] out := i[1] result := ToCamel(in) if result != out { t.Error("'" + result + "' != '" + out + "'") } } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/strcase/goname.go000066400000000000000000000116301456366605600255200ustar00rootroot00000000000000package strcase import ( "strings" "unicode" ) // ToPrivateGoName returns the Go public name of the given string. func ToPublicGoName(s string) string { return toGoName(TitleFirstWord(s)) } // ToPrivateGoName returns the Go private name of the given string. func ToPrivateGoName(s string) string { return toGoName(lowerCaseFirstLetterOrAcronyms(s)) } // toGoName returns a different name if it should be different. func toGoName(name string) (should string) { name = strings.Replace(name, " ", "_", -1) name = strings.Replace(name, "-", "_", -1) // Fast path for simple cases: "_" and all lowercase. if name == "_" { return name } allLower := true for _, r := range name { if !unicode.IsLower(r) { allLower = false break } } if allLower { return name } // Split camelCase at any lower->upper transition, and split on underscores. // Check each word for common initialisms. runes := []rune(name) w, i := 0, 0 // index of start of word, scan for i+1 <= len(runes) { eow := false // whether we hit the end of a word if i+1 == len(runes) { eow = true } else if runes[i+1] == '_' { // underscore; shift the remainder forward over any run of underscores eow = true n := 1 for i+n+1 < len(runes) && runes[i+n+1] == '_' { n++ } // Leave at most one underscore if the underscore is between two digits if i+n+1 < len(runes) && unicode.IsDigit(runes[i]) && unicode.IsDigit(runes[i+n+1]) { n-- } copy(runes[i+1:], runes[i+n+1:]) runes = runes[:len(runes)-n] } else if unicode.IsLower(runes[i]) && !unicode.IsLower(runes[i+1]) { // lower->non-lower eow = true } i++ if !eow { continue } // [w,i) is a word. word := string(runes[w:i]) u := strings.ToUpper(word) if commonInitialisms[u] { // Keep consistent case, which is lowercase only at the start. if w == 0 && unicode.IsLower(runes[w]) { u = strings.ToLower(u) } // All the common initialisms are ASCII, // so we can replace the bytes exactly. copy(runes[w:], []rune(u)) } else if specialCase, exist := customInitialisms[u]; exist { if w == 0 && unicode.IsLower(runes[w]) { u = specialCase[1] } else { u = specialCase[0] } copy(runes[w:], []rune(u)) } else if w > 0 && strings.ToLower(word) == word { // already all lowercase, and not the first word, so uppercase the first character. runes[w] = unicode.ToUpper(runes[w]) } w = i } return string(runes) } // Deprecated: this list should not be completed as it affects generation for our Go SDK only. // // commonInitialisms is a set of common initialisms. // Only add entries that are highly unlikely to be non-initialisms. // For instance, "ID" is fine (Freudian code is rare), but "AND" is not. var commonInitialisms = map[string]bool{ "ACL": true, "API": true, "ASCII": true, "CPU": true, "CSS": true, "DHCP": true, "DNS": true, "EOF": true, "GUID": true, "HTML": true, "HTTP": true, "HTTPS": true, "ID": true, "IP": true, "JSON": true, "LB": true, "LHS": true, "QPS": true, "RAM": true, "RHS": true, "RPC": true, "SLA": true, "SMTP": true, "SQL": true, "SSD": true, "SSH": true, "TCP": true, "TLS": true, "TTL": true, "UDP": true, "UI": true, "UID": true, "UUID": true, "URI": true, "URL": true, "UTF8": true, "VM": true, "XML": true, "XMPP": true, "XSRF": true, "XSS": true, } // customInitialisms is a set of common initialisms we use at Scaleway. // value[0] is the uppercase replacement // value[1] is the lowercase replacement var customInitialisms = map[string][2]string{ "ACLS": {"ACLs", "acls"}, "APIS": {"APIs", "apis"}, "CPUS": {"CPUs", "cpus"}, "IDS": {"IDs", "ids"}, "IPS": {"IPs", "ips"}, "IPV": {"IPv", "ipv"}, // handle IPV4 && IPV6 "LBS": {"LBs", "lbs"}, "UIDS": {"UIDs", "uids"}, "UUIDS": {"UUIDs", "uuids"}, "URIS": {"URIs", "uris"}, "URLS": {"URLs", "urls"}, } // TitleFirstWord upper case the first letter of a string. func TitleFirstWord(s string) string { if s == "" { return s } r := []rune(s) r[0] = unicode.ToUpper(r[0]) return string(r) } // UntitleFirstWord lower case the first letter of a string. func UntitleFirstWord(s string) string { if s == "" { return s } r := []rune(s) firstWord := strings.Split(s, " ")[0] _, isCommonInitialism := commonInitialisms[firstWord] _, isCustomInitialism := customInitialisms[firstWord] if !isCommonInitialism && !isCustomInitialism { r[0] = unicode.ToLower(r[0]) } return string(r) } // lowerCaseFirstLetterOrAcronyms lower case the first letter of a string. func lowerCaseFirstLetterOrAcronyms(s string) string { r := []rune(s) if len(r) == 0 { return "" } for i := 0; len(r) > i && unicode.IsUpper(r[i]); i++ { word := string(r[:i+1]) if u := strings.ToUpper(word); commonInitialisms[u] { copy(r[0:], []rune(strings.ToLower(u))) break } } r[0] = unicode.ToLower(r[0]) return string(r) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/strcase/goname_test.go000066400000000000000000000025301456366605600265560ustar00rootroot00000000000000package strcase import "testing" func TestLowerCaseFirstLetterOrAcronyms(t *testing.T) { cases := []struct { in string want string }{ {"", ""}, {"t", "t"}, {"Test Case", "test Case"}, {"test Case", "test Case"}, {"TEST CASE", "tEST CASE"}, {"tEST CASE", "tEST CASE"}, {"#EST CASE", "#EST CASE"}, {"APITest", "apiTest"}, {"AVATATest", "aVATATest"}, {"TestStuff", "testStuff"}, } for _, c := range cases { result := lowerCaseFirstLetterOrAcronyms(c.in) if result != c.want { t.Errorf("lowerCaseFirstLetterOrAcronyms(%q) == %q, want %q", c.in, result, c.want) } } } func TestTitleFirstWord(t *testing.T) { cases := [][]string{ {"", ""}, {"t", "T"}, {"Test Case", "Test Case"}, {"test Case", "Test Case"}, {"test case", "Test case"}, {"TEST CASE", "TEST CASE"}, {"tEST CASE", "TEST CASE"}, {"#EST CASE", "#EST CASE"}, } for _, i := range cases { in := i[0] out := i[1] result := TitleFirstWord(in) if result != out { t.Error("'" + result + "' != '" + out + "'") } } } func Test_UntitleFirstWord(t *testing.T) { cases := [][]string{ {"", ""}, {"T", "t"}, {"UUID", "UUID"}, {"UUI", "uUI"}, {"TEST CASE", "tEST CASE"}, } for _, i := range cases { in := i[0] out := i[1] result := UntitleFirstWord(in) if result != out { t.Error("'" + result + "' != '" + out + "'") } } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/strcase/kebab.go000066400000000000000000000004221456366605600253130ustar00rootroot00000000000000package strcase import "strings" // Converts a string to kebab-case func ToKebab(s string) string { return strings.Replace(ToSnake(s), "_", "-", -1) } // Converts a string to kebab-case func ToSpace(s string) string { return strings.Replace(ToSnake(s), "_", " ", -1) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/strcase/kebab_test.go000066400000000000000000000014101456366605600263500ustar00rootroot00000000000000package strcase import ( "testing" ) func TestToKebab(t *testing.T) { cases := [][]string{ {"testCase", "test-case"}, {"TestCase", "test-case"}, {"Test Case", "test-case"}, {" Test Case", "test-case"}, {"Test Case ", "test-case"}, {" Test Case ", "test-case"}, {"test", "test"}, {"test_case", "test-case"}, {"Test", "test"}, {"", ""}, {"ManyManyWords", "many-many-words"}, {"manyManyWords", "many-many-words"}, {"AnyKind of_string", "any-kind-of-string"}, {"numbers2and55with000", "numbers2and55with000"}, {"JSONData", "json-data"}, {"userID", "user-id"}, {"AAAbbb", "aa-abbb"}, } for _, i := range cases { in := i[0] out := i[1] result := ToKebab(in) if result != out { t.Error("'" + result + "' != '" + out + "'") } } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/strcase/number.go000066400000000000000000000004451456366605600255440ustar00rootroot00000000000000package strcase import ( "regexp" ) var numberSequence = regexp.MustCompile(`([a-zA-Z])(\d+)([a-zA-Z]?)`) var numberReplacement = []byte(`$1 $2 $3`) func addWordBoundariesToNumbers(s string) string { b := []byte(s) b = numberSequence.ReplaceAll(b, numberReplacement) return string(b) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/strcase/pascal.go000066400000000000000000000011741456366605600255170ustar00rootroot00000000000000package strcase import "strings" // Converts a string to CamelCase func toPascalInitCase(s string, initCase bool) string { s = addWordBoundariesToNumbers(s) s = strings.Trim(s, " ") n := "" capNext := initCase for _, v := range s { if v >= 'A' && v <= 'Z' { n += string(v) } if v >= '0' && v <= '9' { n += string(v) } if v >= 'a' && v <= 'z' { if capNext { n += strings.ToUpper(string(v)) } else { n += string(v) } } if v == '_' || v == ' ' || v == '-' { capNext = true } else { capNext = false } } return n } func ToPascal(s string) string { return toPascalInitCase(s, true) } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/strcase/pascal_test.go000066400000000000000000000010251456366605600265510ustar00rootroot00000000000000package strcase import "testing" func TestToPascal(t *testing.T) { cases := [][]string{ {"test_case", "TestCase"}, {"test", "Test"}, {"TestCase", "TestCase"}, {" test case ", "TestCase"}, {"", ""}, {"many_many_words", "ManyManyWords"}, {"AnyKind of_string", "AnyKindOfString"}, {"odd-fix", "OddFix"}, {"numbers2And55with000", "Numbers2And55With000"}, } for _, i := range cases { in := i[0] out := i[1] result := ToPascal(in) if result != out { t.Error("'" + result + "' != '" + out + "'") } } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/strcase/snake.go000066400000000000000000000015161456366605600253550ustar00rootroot00000000000000package strcase import ( "strings" ) // Converts a string to snake_case func ToSnake(s string) string { s = strings.Trim(s, " ") n := "" for i, v := range s { // treat acronyms as words, eg for JSONData -> JSON is a whole word nextCaseIsChanged := false if i+1 < len(s) { next := s[i+1] if (isUpperLetter(v) && isLowerLetter(int32(next))) || (isLowerLetter(v) && isUpperLetter(int32(next))) { nextCaseIsChanged = true } } if i > 0 && n[len(n)-1] != '_' && nextCaseIsChanged { // add underscore if next letter case type is changed if isUpperLetter(v) { n += "_" + string(v) } else if isLowerLetter(v) { n += string(v) + "_" } } else if v == ' ' || v == '-' { // replace spaces and dashes with underscores n += "_" } else { n = n + string(v) } } n = strings.ToLower(n) return n } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/strcase/snake_test.go000066400000000000000000000015341456366605600264140ustar00rootroot00000000000000package strcase import ( "testing" ) func TestToSnake(t *testing.T) { cases := [][2]string{ {"testCase", "test_case"}, {"TestCase", "test_case"}, {"Test Case", "test_case"}, {" Test Case", "test_case"}, {"Test Case ", "test_case"}, {" Test Case ", "test_case"}, {"test", "test"}, {"test_case", "test_case"}, {"Test", "test"}, {"", ""}, {"ManyManyWords", "many_many_words"}, {"manyManyWords", "many_many_words"}, {"AnyKind of_string", "any_kind_of_string"}, {"numbers2and55with000", "numbers2and55with000"}, {"ip-v6", "ip_v6"}, {"ipV6", "ip_v6"}, {"IPV6", "ipv6"}, {"ipv6", "ipv6"}, {"JSONData", "json_data"}, {"userID", "user_id"}, {"AAAbbb", "aa_abbb"}, } for _, i := range cases { in := i[0] out := i[1] result := ToSnake(in) if result != out { t.Error("'" + result + "' != '" + out + "'") } } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/strcase/strcase_test.go000066400000000000000000000051201456366605600267520ustar00rootroot00000000000000package strcase import ( "testing" ) func TestAllStrCases(t *testing.T) { tests := []struct { name, publicGoName, privateGoName, bashArgName string }{ {"foo_bar", "FooBar", "fooBar", "foo-bar"}, {"foo_bar_baz", "FooBarBaz", "fooBarBaz", "foo-bar-baz"}, {"Foo_bar", "FooBar", "fooBar", "foo-bar"}, {"foo_WiFi", "FooWiFi", "fooWiFi", "foo-wi-fi"}, {"id", "ID", "id", "id"}, {"Id", "ID", "id", "id"}, {"foo_id", "FooID", "fooID", "foo-id"}, {"fooId", "FooID", "fooID", "foo-id"}, {"fooUid", "FooUID", "fooUID", "foo-uid"}, {"idFoo", "IDFoo", "idFoo", "id-foo"}, {"uidFoo", "UIDFoo", "uidFoo", "uid-foo"}, {"midIdDle", "MidIDDle", "midIDDle", "mid-id-dle"}, {"APIProxy", "APIProxy", "apiProxy", "api-proxy"}, {"ApiProxy", "APIProxy", "apiProxy", "api-proxy"}, {"apiProxy", "APIProxy", "apiProxy", "api-proxy"}, {"_Leading", "_Leading", "_Leading", "-leading"}, {"___Leading", "_Leading", "_Leading", "-leading"}, {"trailing_", "Trailing", "trailing", "trailing"}, {"trailing___", "Trailing", "trailing", "trailing"}, {"a_b", "AB", "aB", "ab"}, {"a__b", "AB", "aB", "ab"}, {"a___b", "AB", "aB", "ab"}, {"Rpc1150", "RPC1150", "rpc1150", "rpc1150"}, {"case3_1", "Case3_1", "case3_1", "case3-1"}, {"case3__1", "Case3_1", "case3_1", "case3-1"}, {"IEEE802_16bit", "IEEE802_16bit", "iEEE802_16bit", "ieee802-16bit"}, {"IEEE802_16Bit", "IEEE802_16Bit", "iEEE802_16Bit", "ieee802-16-bit"}, {"IPv4", "IPv4", "ipv4", "ipv4"}, {"Ipv4", "IPv4", "ipv4", "ipv4"}, {"iPV4", "IPV4", "iPV4", "ipv4"}, {"RepeatedIpv4", "RepeatedIPv4", "repeatedIPv4", "repeated-ipv4"}, {"eSport", "ESport", "eSport", "e-sport"}, {"stopped in place", "StoppedInPlace", "stoppedInPlace", "stopped-in-place"}, {"l_ssd", "LSSD", "lSSD", "lssd"}, {"ids", "IDs", "ids", "ids"}, {"my_resource_ids", "MyResourceIDs", "myResourceIDs", "my-resource-ids"}, {"acids", "Acids", "acids", "acids"}, {"secret-key", "SecretKey", "secretKey", "secret-key"}, {"ip-id", "IPID", "ipID", "ip-id"}, {"lb-id", "LBID", "lbID", "lb-id"}, {"acl-id", "ACLID", "aclID", "acl-id"}, {"dhcp-id", "DHCPID", "dhcpID", "dhcp-id"}, } for _, test := range tests { got := ToPublicGoName(test.name) if got != test.publicGoName { t.Errorf("ToPublicGoName(%q) == %q, want %q", test.name, got, test.publicGoName) } got = ToPrivateGoName(test.name) if got != test.privateGoName { t.Errorf("ToPrivateGoName(%q) == %q, want %q", test.name, got, test.privateGoName) } got = ToBashArg(test.name) if got != test.bashArgName { t.Errorf("ToBashArg(%q) == %q, want %q", test.name, got, test.bashArgName) } } } golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/validation/000077500000000000000000000000001456366605600244105ustar00rootroot00000000000000golang-github-scaleway-scaleway-sdk-go-1.0.0~beta24/validation/is.go000066400000000000000000000033371456366605600253600ustar00rootroot00000000000000// Package validation provides format validation functions. package validation import ( "net/url" "regexp" ) var ( isUUIDRegexp = regexp.MustCompile("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$") isRegionRegex = regexp.MustCompile("^[a-z]{2}-[a-z]{3}$") isZoneRegex = regexp.MustCompile("^[a-z]{2}-[a-z]{3}-[1-9]$") isAccessKey = regexp.MustCompile("^SCW[A-Z0-9]{17}$") isEmailRegexp = regexp.MustCompile("^.+@.+$") ) // IsUUID returns true if the given string has a valid UUID format. func IsUUID(s string) bool { return isUUIDRegexp.MatchString(s) } // IsAccessKey returns true if the given string has a valid Scaleway access key format. func IsAccessKey(s string) bool { return isAccessKey.MatchString(s) } // IsSecretKey returns true if the given string has a valid Scaleway secret key format. func IsSecretKey(s string) bool { return IsUUID(s) } // IsOrganizationID returns true if the given string has a valid Scaleway organization ID format. func IsOrganizationID(s string) bool { return IsUUID(s) } // IsProjectID returns true if the given string has a valid Scaleway project ID format. func IsProjectID(s string) bool { return IsUUID(s) } // IsRegion returns true if the given string has a valid region format. func IsRegion(s string) bool { return isRegionRegex.MatchString(s) } // IsZone returns true if the given string has a valid zone format. func IsZone(s string) bool { return isZoneRegex.MatchString(s) } // IsURL returns true if the given string has a valid URL format. func IsURL(s string) bool { _, err := url.Parse(s) return err == nil } // IsEmail returns true if the given string has an email format. func IsEmail(v string) bool { return isEmailRegexp.MatchString(v) }