diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 71945a5..3dcdf2d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ name: Release on: push: tags: - - 'v*' + - "v*" # Releases need permissions to read and write the repository contents. # GitHub considers creating releases and uploading assets as writing contents. @@ -23,7 +23,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-go@v3 with: - go-version-file: 'go.mod' + go-version-file: "go.mod" cache: true - name: Import GPG key uses: crazy-max/ghaction-import-gpg@v5 @@ -34,7 +34,7 @@ jobs: - name: Run GoReleaser uses: goreleaser/goreleaser-action@v3 with: - args: release --rm-dist + args: release --clean env: # GitHub sets the GITHUB_TOKEN secret automatically. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index e4febb0..59c6a69 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,5 @@ dist/ .idea/ .vscode/ +# Environment +.env* \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml index 6761d6c..18752a0 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,49 +1,52 @@ # Visit https://goreleaser.com for documentation on how to customize this # behavior. + +version: 2 + project_name: terraform-provider-guance before: hooks: # this is just an example and not a requirement for provider building/publishing - go mod tidy builds: -- env: - # goreleaser does not work with CGO, it could also complicate - # usage by users in CI/CD systems like Terraform Cloud where - # they are unable to install libraries. - - CGO_ENABLED=0 - - GO111MODULE=on - mod_timestamp: '{{ .CommitTimestamp }}' - flags: - - -trimpath - ldflags: - - '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}' - goos: - - freebsd - - windows - - linux - - darwin - goarch: - - amd64 - - '386' - - arm - - arm64 - ignore: - - goos: darwin - goarch: '386' - binary: '{{ .ProjectName }}_v{{ .Version }}' + - env: + # goreleaser does not work with CGO, it could also complicate + # usage by users in CI/CD systems like Terraform Cloud where + # they are unable to install libraries. + - CGO_ENABLED=0 + - GO111MODULE=on + mod_timestamp: "{{ .CommitTimestamp }}" + flags: + - -trimpath + ldflags: + - "-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}" + goos: + - freebsd + - windows + - linux + - darwin + goarch: + - amd64 + - "386" + - arm + - arm64 + ignore: + - goos: darwin + goarch: "386" + binary: "{{ .ProjectName }}_v{{ .Version }}" archives: -- format: zip - name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}' + - format: zip + name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" checksum: extra_files: - - glob: 'terraform-registry-manifest.json' - name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json' - name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS' + - glob: "terraform-registry-manifest.json" + name_template: "{{ .ProjectName }}_{{ .Version }}_manifest.json" + name_template: "{{ .ProjectName }}_{{ .Version }}_SHA256SUMS" algorithm: sha256 signs: - artifacts: checksum args: - # if you are using this in a GitHub action or some other automated pipeline, you + # if you are using this in a GitHub action or some other automated pipeline, you # need to pass the batch flag to indicate its not interactive. - "--batch" - "--local-user" @@ -54,18 +57,12 @@ signs: - "${artifact}" release: extra_files: - - glob: 'terraform-registry-manifest.json' - name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json' + - glob: "terraform-registry-manifest.json" + name_template: "{{ .ProjectName }}_{{ .Version }}_manifest.json" # If you want to manually examine the release before its live, uncomment this line: # draft: true - -changelog: - # Set this to true if you don't want any changelog at all. - # Warning: this will also ignore any changelog files passed via `--release-notes`, - # and will render an empty changelog. - # This may result in an empty release notes on GitHub/GitLab/Gitea. - skip: false +changelog: # Changelog generation implementation to use. # # Valid options are: @@ -102,6 +99,5 @@ changelog: # the changelog # Default is empty exclude: - - '^docs:' + - "^docs:" - typo - diff --git a/README.md b/README.md index ecc2b86..44e3bae 100644 --- a/README.md +++ b/README.md @@ -12,26 +12,26 @@ The remainder of this document will focus on the development aspects of the prov The resource supports as follows: -* [x] notification * [x] pipeline * [x] member group -* [x] alert policy -* [x] mute * [x] black list -* [x] monitor, see built-in modules at [terraform-guance-monitor](https://github.com/GuanceCloud/terraform-guance-monitor) -* [x] dashboard, see built-in modules at [terraform-guance-dashboard](https://github.com/GuanceCloud/terraform-guance-dashboard) +* [x] role The data source supports as follows: * [x] members +* [x] permissions The region supports as follows: * [x] hangzhou * [x] ningxia -* [x] zhangjiakou * [x] guangzhou +* [x] vnet +* [x] hongkong * [x] oregon +* [x] frankfurt +* [x] singapore If there are more resources you need, create an [issue](https://github.com/GuanceCloud/terraform-provider-guance/issues) for free. @@ -55,10 +55,6 @@ that return all the details about which versions are currently available for a p ## Development -### Testing - -Guance Cloud Code Generation Pipeline generates this repository. So don't need to test. Please create issues for free. - ### Generating documentation This provider uses [terraform-plugin-docs](https://github.com/hashicorp/terraform-plugin-docs/) diff --git a/docs/data-sources/members.md b/docs/data-sources/members.md index aede058..4430d2c 100644 --- a/docs/data-sources/members.md +++ b/docs/data-sources/members.md @@ -9,6 +9,19 @@ description: |- mermaid graph LR A[Workspace] --> B[Member] + + Example Usage + ```terraform + variable "email" { + type = string + } + data "guance_members" "demo" { + search = var.email + } + output "member" { + value = data.guance_members.demo.members + } + ``` --- # guance_members (Data Source) @@ -24,41 +37,55 @@ graph LR A[Workspace] --> B[Member] ``` +## Example Usage +```terraform +variable "email" { + type = string +} - -## Schema +data "guance_members" "demo" { + search = var.email +} -### Optional +output "member" { + value = data.guance_members.demo.members +} +``` -- `filters` (Attributes List) The list of the resource (see [below for nested schema](#nestedatt--filters)) -- `max_results` (Number) The max results count of the resource will be returned. -### Read-Only -- `id` (String) The hasd id of the resource. -- `items` (Attributes List) The list of the resource (see [below for nested schema](#nestedatt--items)) + +## Schema - -### Nested Schema for `filters` +### Optional -Required: +- `search` (String) Search the member by email or name. -- `name` (String) The filter path, represent as json path. -- `values` (List of String) The filter values +### Read-Only +- `members` (Attributes List) The list of the members. (see [below for nested schema](#nestedatt--members)) - -### Nested Schema for `items` + +### Nested Schema for `members` Optional: - `email` (String) Email -- `role` (String) Role, value must be one of: *owner*, *wsAdmin*, *general*, *readOnly*, other value will be ignored. +- `name` (String) User name +- `roles` (Attributes List) Role, value must be one of: *owner*, *wsAdmin*, *general*, *readOnly*, other value will be ignored. (see [below for nested schema](#nestedatt--members--roles)) Read-Only: -- `created_at` (String) The RFC3339/ISO8601 time string of resource created at. -- `id` (String) The Guance Resource Name (GRN) of cloud resource. +- `create_at` (String) The unix timestamp in seconds of the member creation. +- `uuid` (String) The uuid of the member. + + +### Nested Schema for `members.roles` + +Optional: + +- `name` (String) The name of the role. +- `uuid` (String) The UUID of the role. diff --git a/docs/data-sources/permissions.md b/docs/data-sources/permissions.md new file mode 100644 index 0000000..8abbdff --- /dev/null +++ b/docs/data-sources/permissions.md @@ -0,0 +1,80 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "guance_permissions Data Source - guance" +subcategory: "" +description: |- + A role permission is defined to grant a user permission to perform a specific action on a specific resource. + Guance Cloud supports a number of different role permissions, and you can create new roles for users and assign permission scopes to roles to meet the permission needs of your organization. + Example Usage + ```terraform + data "guance_permissions" "demo" { + } + output "permissions" { + value = data.guance_permissions.demo + } + ``` +--- + +# guance_permissions (Data Source) + +A role permission is defined to grant a user permission to perform a specific action on a specific resource. + +Guance Cloud supports a number of different role permissions, and you can create new roles for users and assign permission scopes to roles to meet the permission needs of your organization. + + +## Example Usage + +```terraform +data "guance_permissions" "demo" { +} + +output "permissions" { + value = data.guance_permissions.demo +} +``` + + + + +## Schema + +### Optional + +- `is_support_custom_role` (Boolean) Filter the permission list that supports custom role. + +### Read-Only + +- `permissions` (Attributes List) The list of the permissions. (see [below for nested schema](#nestedatt--permissions)) + + +### Nested Schema for `permissions` + +Read-Only: + +- `desc` (String) The description of the permission. +- `disabled` (Number) The disabled status of the permission. +- `is_support_custom_role` (Number) Whether support custom role. +- `is_support_general` (Number) Whether support general. +- `is_support_owner` (Number) Whether support owner. +- `is_support_read_only` (Number) Whether support readonly. +- `is_support_ws_admin` (Number) Whether support WsAdmin. +- `key` (String) The key of the permission. +- `name` (String) The name of the permission. +- `subs` (Attributes List) The list of the sub permissions. (see [below for nested schema](#nestedatt--permissions--subs)) + + +### Nested Schema for `permissions.subs` + +Read-Only: + +- `desc` (String) The description of the permission. +- `disabled` (Number) The disabled status of the permission. +- `is_support_custom_role` (Number) Whether support custom role. +- `is_support_general` (Number) Whether support general. +- `is_support_owner` (Number) Whether support owner. +- `is_support_read_only` (Number) Whether support readonly. +- `is_support_ws_admin` (Number) Whether support WsAdmin. +- `key` (String) The key of the permission. +- `name` (String) The name of the permission. + + diff --git a/docs/index.md b/docs/index.md index b86e5cf..35c764a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -9,7 +9,7 @@ description: |- Interested in the provider's latest features, or want to make sure you're up to date? Check out the changelog for version information and release notes. Authenticating to Guance Cloud Terraform supports a number of different methods for authenticating to Guance Cloud: - Workspace Key ID https://console.guance.com/workspace/apiManage + Workspace Key https://console.guance.com/workspace/apiManage Usage ```terraform We strongly recommend using the required_providers block to set the @@ -19,7 +19,7 @@ description: |- required_providers { guance = { source = "GuanceCloud/guance" - version = "=0.0.4" + version = "=0.0.6" } } } @@ -28,9 +28,11 @@ description: |- provider "guance" { # accesstoken = "your access token, recommend store in environment variable" region = "hangzhou" + # end_point = "https://openapi.guance.com" } ``` More Examples + Example Source Code https://github.com/GuanceCloud/terraform-provider-guance/tree/main/examples --- # guance Provider @@ -47,7 +49,7 @@ Interested in the provider's latest features, or want to make sure you're up to Terraform supports a number of different methods for authenticating to Guance Cloud: -* [Workspace Key ID](https://console.guance.com/workspace/apiManage) +* [Workspace Key](https://console.guance.com/workspace/apiManage) ## Usage @@ -60,7 +62,7 @@ terraform { required_providers { guance = { source = "GuanceCloud/guance" - version = "=0.0.4" + version = "=0.0.6" } } } @@ -70,11 +72,14 @@ terraform { provider "guance" { # access_token = "your access token, recommend store in environment variable" region = "hangzhou" + # end_point = "https://openapi.guance.com" } ``` ## More Examples +* [Example Source Code](https://github.com/GuanceCloud/terraform-provider-guance/tree/main/examples) + @@ -83,4 +88,5 @@ provider "guance" { ### Optional - `access_token` (String, Sensitive) Access token for Guance Cloud API. May also be provided via GUANCE_ACCESS_TOKEN environment variable. Get an Key ID from [Guance Cloud](https://console.guance.com/workspace/apiManage) as access token. +- `end_point` (String) EndPoint for Guance Cloud API. May also be provided via GUANCE_END_POINT environment variable. See [GitHub](https://github.com/GuanceCloud/terraform-provider-guance) for a list of available regions. - `region` (String) Region for Guance Cloud API. May also be provided via GUANCE_REGION environment variable. See [GitHub](https://github.com/GuanceCloud/terraform-provider-guance) for a list of available regions. diff --git a/docs/resources/alertpolicy.md b/docs/resources/alertpolicy.md deleted file mode 100644 index 8ada8f4..0000000 --- a/docs/resources/alertpolicy.md +++ /dev/null @@ -1,227 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "guance_alertpolicy Resource - guance" -subcategory: "" -description: |- - Alert Policy - Alert policy is a set of rules that define when to trigger an alert. You can create alert policies for your data - sources, and set up alert targets to receive alerts. - Guance Cloud supports alert policy management for the results of monitor checks, by sending alert notification emails or - group message notifications, so that you can know about the abnormal data situation of the monitoring in time, find - problems, and solve problems. - Relationships: - ```mermaid - graph LR - A[Monitor] --> B[Alert Policy] --> C[Notification] - ``` - Notes: - When a monitor is created, an alert policy must be selected, and the default is selected by default;When a certain alert policy is deleted, the monitor under the deleted alert policy will automatically be classified - into the default. - Create - The first let me create a resource. We will send the create operation to the resource management service - ```terraform - variable "dingtalkwebhook" { - type = string - } - variable "dingtalksecret" { - type = string - } - variable "email" { - type = string - } - data "guance_members" "demo" { - filters = [ - { - name = "email" - values = [var.email] - } - ] - } - resource "guancemembergroup" "demo" { - name = "oac-demo" - memberids = data.guance_members.demo.items[*].id - } - resource "guancenotification" "demo" { - name = "oac-demo" - type = "dingtalkrobot" - dingtalkrobot = { - webhook = var.dingtalkwebhook - secret = var.dingtalk_secret - } - } - resource "guancealertpolicy" "demo" { - name = "oac-demo" - silenttimeout = "1h" - statuses = [ - "critical", - "error", - "warning", - "info", - "ok", - "nodata", - "nodataok", - "nodataas_ok", - ] - alerttargets = [ - { - type = "membergroup" - membergroup = { - id = guancemembergroup.demo.id - } - }, - { - type = "notification" - notification = { - id = guance_notification.demo.id - } - } - ] - } - ``` ---- - -# guance_alertpolicy (Resource) - -# Alert Policy - -Alert policy is a set of rules that define when to trigger an alert. You can create alert policies for your data -sources, and set up alert targets to receive alerts. - -Guance Cloud supports alert policy management for the results of monitor checks, by sending alert notification emails or -group message notifications, so that you can know about the abnormal data situation of the monitoring in time, find -problems, and solve problems. - -Relationships: - -```mermaid -graph LR - -A[Monitor] --> B[Alert Policy] --> C[Notification] -``` - -Notes: - -1. When a monitor is created, an alert policy must be selected, and the default is selected by default; -2. When a certain alert policy is deleted, the monitor under the deleted alert policy will automatically be classified - into the default. - -## Create - -The first let me create a resource. We will send the create operation to the resource management service - -```terraform -variable "ding_talk_webhook" { - type = string -} - -variable "ding_talk_secret" { - type = string -} - -variable "email" { - type = string -} - -data "guance_members" "demo" { - filters = [ - { - name = "email" - values = [var.email] - } - ] -} - -resource "guance_membergroup" "demo" { - name = "oac-demo" - member_ids = data.guance_members.demo.items[*].id -} - -resource "guance_notification" "demo" { - name = "oac-demo" - type = "ding_talk_robot" - ding_talk_robot = { - webhook = var.ding_talk_webhook - secret = var.ding_talk_secret - } -} - -resource "guance_alertpolicy" "demo" { - name = "oac-demo" - silent_timeout = "1h" - - statuses = [ - "critical", - "error", - "warning", - "info", - "ok", - "nodata", - "nodata_ok", - "nodata_as_ok", - ] - - alert_targets = [ - { - type = "member_group" - member_group = { - id = guance_membergroup.demo.id - } - }, - { - type = "notification" - notification = { - id = guance_notification.demo.id - } - } - ] -} -``` - - - - -## Schema - -### Required - -- `name` (String) Alert Policy Name -- `statuses` (List of String) The status value of the event to be sent - -### Optional - -- `alert_targets` (Attributes List) Alert Action (see [below for nested schema](#nestedatt--alert_targets)) -- `silent_timeout` (String) Silent timeout timestamp - -### Read-Only - -- `created_at` (String) The RFC3339/ISO8601 time string of resource created at. -- `id` (String) The Guance Resource Name (GRN) of cloud resource. - - -### Nested Schema for `alert_targets` - -Required: - -- `type` (String) Alert type, value must be one of: *member_group*, *notification*, other value will be ignored. - -Optional: - -- `member_group` (Attributes) Member Group (see [below for nested schema](#nestedatt--alert_targets--member_group)) -- `notification` (Attributes) Notification (see [below for nested schema](#nestedatt--alert_targets--notification)) - - -### Nested Schema for `alert_targets.member_group` - -Required: - -- `id` (String) Member Group - - - -### Nested Schema for `alert_targets.notification` - -Required: - -- `id` (String) Notification - - diff --git a/docs/resources/blacklist.md b/docs/resources/blacklist.md index 887c2df..2e27336 100644 --- a/docs/resources/blacklist.md +++ b/docs/resources/blacklist.md @@ -7,17 +7,14 @@ description: |- Guance Cloud supports filtering data that meets the conditions by setting a blacklist. After configuring the blacklist, the data that meets the conditions will no longer be reported to the Guance Cloud workspace, helping you save data storage costs. - Create - The first let me create a resource. We will send the create operation to the resource management service + Example Usage ```terraform resource "guance_blacklist" "demo" { - source = { - type = "logging" - name = "nginx" - } - filter_rules = [ + type = "logging" + source = "mysql" + filters = [ { - name = "foo" + name = "foo1" operation = "in" condition = "and" values = ["oac-*"] @@ -36,20 +33,16 @@ Guance Cloud supports filtering data that meets the conditions by setting a blac After configuring the blacklist, the data that meets the conditions will no longer be reported to the Guance Cloud workspace, helping you save data storage costs. -## Create - -The first let me create a resource. We will send the create operation to the resource management service +## Example Usage ```terraform resource "guance_blacklist" "demo" { - source = { - type = "logging" - name = "nginx" - } + type = "logging" + source = "mysql" - filter_rules = [ + filters = [ { - name = "foo" + name = "foo1" operation = "in" condition = "and" values = ["oac-*"] @@ -65,40 +58,29 @@ resource "guance_blacklist" "demo" { ### Required -- `source` (Attributes) Source (see [below for nested schema](#nestedatt--source)) +- `source` (String) The source of the resource. +- `type` (String) The type of the resource. ### Optional -- `filter_rules` (Attributes List) Filters (see [below for nested schema](#nestedatt--filter_rules)) +- `filters` (Attributes List) The filters of the resource. (see [below for nested schema](#nestedatt--filters)) ### Read-Only -- `created_at` (String) The RFC3339/ISO8601 time string of resource created at. -- `id` (String) The Guance Resource Name (GRN) of cloud resource. - - -### Nested Schema for `source` - -Required: - -- `type` (String) Source Type, value must be one of: *logging*, *object*, *custom_object*, *network*, *tracing*, *rum*, *security*, *keyevent*, *metric*, other value will be ignored. - -Optional: - -- `name` (String) Source - +- `created_at` (String) The timestamp seconds of the resource created at. +- `uuid` (String) The uuid of resource. - -### Nested Schema for `filter_rules` + +### Nested Schema for `filters` Required: -- `condition` (String) Condition, represented by DQL -- `name` (String) Name +- `condition` (String) The condition of the filter. +- `name` (String) The name of the filter. - `operation` (String) Operation, value must be one of: *in*, *not in*, *match*, *not match*, other value will be ignored. Optional: -- `values` (List of String) Values +- `values` (List of String) The values of the filter. diff --git a/docs/resources/dashboard.md b/docs/resources/dashboard.md deleted file mode 100644 index 86d2bc2..0000000 --- a/docs/resources/dashboard.md +++ /dev/null @@ -1,65 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "guance_dashboard Resource - guance" -subcategory: "" -description: |- - Dashboard - A dashboard is a collection of visualizations that you can use to monitor the health of your systems and applications. - Dashboards are made up of one or more panels, which are the visualizations themselves. Each panel displays a single - metric or a single aggregation of metrics. - Dashboards are a great way to visualize your data and monitor your systems. You can use them to track metrics over time, - and to quickly see how your systems are performing. You can also use them to compare metrics from different systems and - applications. - Guance Cloud's dashboard is used to clearly show the range in which the metric data values are located. It is suitable - for slicing messy data into points. - Create - The first let me create a resource. We will send the create operation to the resource management service - terraform - resource "guance_dashboard" "demo" { - name = "oac-demo" - manifest = file("${path.module}/dashboard.json") - } ---- - -# guance_dashboard (Resource) - -# Dashboard - -A dashboard is a collection of visualizations that you can use to monitor the health of your systems and applications. -Dashboards are made up of one or more panels, which are the visualizations themselves. Each panel displays a single -metric or a single aggregation of metrics. - -Dashboards are a great way to visualize your data and monitor your systems. You can use them to track metrics over time, -and to quickly see how your systems are performing. You can also use them to compare metrics from different systems and -applications. - -Guance Cloud's dashboard is used to clearly show the range in which the metric data values are located. It is suitable -for slicing messy data into points. - -## Create - -The first let me create a resource. We will send the create operation to the resource management service - -```terraform -resource "guance_dashboard" "demo" { - name = "oac-demo" - manifest = file("${path.module}/dashboard.json") -} -``` - - - - -## Schema - -### Required - -- `manifest` (String) Dashboard Manifest -- `name` (String) Dashboard Name - -### Read-Only - -- `created_at` (String) The RFC3339/ISO8601 time string of resource created at. -- `id` (String) The Guance Resource Name (GRN) of cloud resource. - - diff --git a/docs/resources/membergroup.md b/docs/resources/membergroup.md index fa856c3..5708b83 100644 --- a/docs/resources/membergroup.md +++ b/docs/resources/membergroup.md @@ -4,8 +4,7 @@ page_title: "guance_membergroup Resource - guance" subcategory: "" description: |- Member Group - Member group is a collection of members in a workspace, and member groups can be authorized to access the resources in - the workspace. + Member group is a collection of members in a workspace, and member groups can be authorized to access the resources in the workspace. Member group is an abstract concept, it can be a team, or a department, it can help us build a reasonable organizational structure, optimize the management efficiency and user experience of the observability platform. Relationships: @@ -14,23 +13,20 @@ description: |- A[Workspace] --> B[Member] A --> C[MemberGroup] ``` - Create - The first let me create a resource. We will send the create operation to the resource management service + Example Usage ```terraform variable "email" { type = string } data "guance_members" "demo" { - filters = [ - { - name = "email" - values = [var.email] - } - ] + search = var.email } resource "guancemembergroup" "demo" { - name = "oac-demo" - memberids = data.guance_members.demo.items[*].id + name = "oac-demo2" + accountuuids = data.guance_members.demo.members[*].uuid + } + output "member" { + value = data.guance_members.demo.members } ``` --- @@ -39,8 +35,7 @@ description: |- # Member Group -Member group is a collection of members in a workspace, and member groups can be authorized to access the resources in -the workspace. +Member group is a collection of members in a workspace, and member groups can be authorized to access the resources in the workspace. Member group is an abstract concept, it can be a team, or a department, it can help us build a reasonable organizational structure, optimize the management efficiency and user experience of the observability platform. @@ -54,9 +49,7 @@ A[Workspace] --> B[Member] A --> C[MemberGroup] ``` -## Create - -The first let me create a resource. We will send the create operation to the resource management service +## Example Usage ```terraform variable "email" { @@ -64,17 +57,16 @@ variable "email" { } data "guance_members" "demo" { - filters = [ - { - name = "email" - values = [var.email] - } - ] + search = var.email } resource "guance_membergroup" "demo" { - name = "oac-demo" - member_ids = data.guance_members.demo.items[*].id + name = "oac-demo2" + account_uuids = data.guance_members.demo.members[*].uuid +} + +output "member" { + value = data.guance_members.demo.members } ``` @@ -85,15 +77,14 @@ resource "guance_membergroup" "demo" { ### Required -- `name` (String) Name +- `name` (String) The name of resource. ### Optional -- `member_ids` (List of String) Member id list +- `account_uuids` (List of String) Member uuid list ### Read-Only -- `created_at` (String) The RFC3339/ISO8601 time string of resource created at. -- `id` (String) The Guance Resource Name (GRN) of cloud resource. +- `uuid` (String) The UUID of resource. diff --git a/docs/resources/monitor.md b/docs/resources/monitor.md deleted file mode 100644 index b161b7b..0000000 --- a/docs/resources/monitor.md +++ /dev/null @@ -1,182 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "guance_monitor Resource - guance" -subcategory: "" -description: |- - Monitor - A monitor is a set of checks that you can run against your data. A monitor watches your data over time and alerts you - when certain conditions are met. For example, you can create a monitor that watches the average response time of your - website and alerts you when the response time is greater than 1 second. - Monitors are made up of one or more checks. A check is a single test that you can run against your data. For example, - you can create a check that watches the average response time of your website. You can also create a check that watches - the percentage of 5xx errors in your logs. - Guance Cloud supports defining monitors, users can customize the configuration of detection rules and trigger - conditions, and open the monitors to receive related alarm events triggered by the detection rules. - Relationships: - ```mermaid - graph LR - A[Monitor] --> B[Alert Policy] --> C[Notification] - ``` - Create - The first let me create a resource. We will send the create operation to the resource management service - ```terraform - variable "email" { - type = string - } - data "guance_members" "demo" { - filters = [ - { - name = "email" - values = [var.email] - } - ] - } - resource "guancemembergroup" "demo" { - name = "oac-demo" - memberids = data.guance_members.demo.items[*].id - } - resource "guancealertpolicy" "demo" { - name = "oac-demo" - silenttimeout = "1h" - statuses = [ - "critical", - "error", - "warning", - "info", - "ok", - "nodata", - "nodataok", - "nodataas_ok", - ] - alerttargets = [ - { - type = "membergroup" - membergroup = { - id = guancemembergroup.demo.id - } - }, - ] - } - resource "guancemonitor" "demo" { - manifest = file("${path.module}/monitor.json") - alertpolicy = { - id = guance_alertpolicy.demo.id - } - } - ``` ---- - -# guance_monitor (Resource) - -# Monitor - -A monitor is a set of checks that you can run against your data. A monitor watches your data over time and alerts you -when certain conditions are met. For example, you can create a monitor that watches the average response time of your -website and alerts you when the response time is greater than 1 second. - -Monitors are made up of one or more checks. A check is a single test that you can run against your data. For example, -you can create a check that watches the average response time of your website. You can also create a check that watches -the percentage of 5xx errors in your logs. - -Guance Cloud supports defining monitors, users can customize the configuration of detection rules and trigger -conditions, and open the monitors to receive related alarm events triggered by the detection rules. - -Relationships: - -```mermaid -graph LR - -A[Monitor] --> B[Alert Policy] --> C[Notification] -``` - -## Create - -The first let me create a resource. We will send the create operation to the resource management service - -```terraform -variable "email" { - type = string -} - -data "guance_members" "demo" { - filters = [ - { - name = "email" - values = [var.email] - } - ] -} - -resource "guance_membergroup" "demo" { - name = "oac-demo" - member_ids = data.guance_members.demo.items[*].id -} - -resource "guance_alertpolicy" "demo" { - name = "oac-demo" - silent_timeout = "1h" - - statuses = [ - "critical", - "error", - "warning", - "info", - "ok", - "nodata", - "nodata_ok", - "nodata_as_ok", - ] - - alert_targets = [ - { - type = "member_group" - member_group = { - id = guance_membergroup.demo.id - } - }, - ] -} - -resource "guance_monitor" "demo" { - manifest = file("${path.module}/monitor.json") - alert_policy = { - id = guance_alertpolicy.demo.id - } -} -``` - - - - -## Schema - -### Required - -- `alert_policy` (Attributes) Alert Policy Configuration (see [below for nested schema](#nestedatt--alert_policy)) -- `manifest` (String) Monitor Configuration - -### Optional - -- `dashboard` (Attributes) Dashboard Configuration (see [below for nested schema](#nestedatt--dashboard)) - -### Read-Only - -- `created_at` (String) The RFC3339/ISO8601 time string of resource created at. -- `id` (String) The Guance Resource Name (GRN) of cloud resource. - - -### Nested Schema for `alert_policy` - -Optional: - -- `id` (String) Alert Policy ID - - - -### Nested Schema for `dashboard` - -Optional: - -- `id` (String) Dashboard ID - - diff --git a/docs/resources/mute.md b/docs/resources/mute.md deleted file mode 100644 index e9e8b47..0000000 --- a/docs/resources/mute.md +++ /dev/null @@ -1,426 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "guance_mute Resource - guance" -subcategory: "" -description: |- - Mute Rule - Mute rule is a feature that allows you to temporarily stop receiving notifications for a specific alert. You can use - mute rules to temporarily silence alerts that are not relevant to you, or to silence alerts that you are already aware - of. - Guance Cloud supports the management of all mute rules in the current workspace. It supports muting different monitors, - smart inspections, self-built inspections, SLOs, and alert policies, so that the muted objects do not send any alert - notifications to any alert notification objects during the mute time. - Relationships: - mermaid - graph LR - A[Mute Rule] --> B[Alert Policy] - - Create - The first let me create a resource. We will send the create operation to the resource management service - ```terraform - variable "dingtalkwebhook" { - type = string - } - variable "dingtalksecret" { - type = string - } - variable "email" { - type = string - } - data "guance_members" "demo" { - filters = [ - { - name = "email" - values = [var.email] - } - ] - } - resource "guancemembergroup" "demo" { - name = "oac-demo" - memberids = data.guance_members.demo.items[*].id - } - resource "guancenotification" "demo" { - name = "oac-demo" - type = "dingtalkrobot" - dingtalkrobot = { - webhook = var.dingtalkwebhook - secret = var.dingtalk_secret - } - } - resource "guancealertpolicy" "demo" { - name = "oac-demo" - silenttimeout = "1h" - statuses = [ - "critical", - "error", - "warning", - "info", - "ok", - "nodata", - "nodataok", - "nodataas_ok", - ] - alerttargets = [ - { - type = "membergroup" - membergroup = { - id = guancemembergroup.demo.id - } - }, - { - type = "notification" - notification = { - id = guance_notification.demo.id - } - } - ] - } - resource "guancemute" "demo" { - // mute ranges - muteranges = [ - { - type = "alert_policy" - alert_policy = { - id = guance_alertpolicy.demo.id - } - } - - ] - // notify options - notify = { - message = < B[Alert Policy] -``` - -## Create - -The first let me create a resource. We will send the create operation to the resource management service - -```terraform -variable "ding_talk_webhook" { - type = string -} - -variable "ding_talk_secret" { - type = string -} - -variable "email" { - type = string -} - -data "guance_members" "demo" { - filters = [ - { - name = "email" - values = [var.email] - } - ] -} - -resource "guance_membergroup" "demo" { - name = "oac-demo" - member_ids = data.guance_members.demo.items[*].id -} - -resource "guance_notification" "demo" { - name = "oac-demo" - type = "ding_talk_robot" - ding_talk_robot = { - webhook = var.ding_talk_webhook - secret = var.ding_talk_secret - } -} - -resource "guance_alertpolicy" "demo" { - name = "oac-demo" - silent_timeout = "1h" - - statuses = [ - "critical", - "error", - "warning", - "info", - "ok", - "nodata", - "nodata_ok", - "nodata_as_ok", - ] - - alert_targets = [ - { - type = "member_group" - member_group = { - id = guance_membergroup.demo.id - } - }, - { - type = "notification" - notification = { - id = guance_notification.demo.id - } - } - ] -} - -resource "guance_mute" "demo" { - // mute ranges - mute_ranges = [ - { - type = "alert_policy" - - alert_policy = { - id = guance_alertpolicy.demo.id - } - } - ] - - // notify options - notify = { - message = < -## Schema - -### Optional - -- `mute_ranges` (Attributes List) Mute Ranges (see [below for nested schema](#nestedatt--mute_ranges)) -- `mute_tags` (Attributes List) Tags (see [below for nested schema](#nestedatt--mute_tags)) -- `notify` (Attributes) Notify Options (see [below for nested schema](#nestedatt--notify)) -- `notify_targets` (Attributes List) Notify targets (see [below for nested schema](#nestedatt--notify_targets)) -- `onetime` (Attributes) Onetime (see [below for nested schema](#nestedatt--onetime)) -- `repeat` (Attributes) Repeat (see [below for nested schema](#nestedatt--repeat)) - -### Read-Only - -- `created_at` (String) The RFC3339/ISO8601 time string of resource created at. -- `id` (String) The Guance Resource Name (GRN) of cloud resource. - - -### Nested Schema for `mute_ranges` - -Required: - -- `type` (String) Mute Range Type, value must be one of: *monitor*, *alert_policy*, other value will be ignored. - -Optional: - -- `alert_policy` (Attributes) Alert Policy configuration (see [below for nested schema](#nestedatt--mute_ranges--alert_policy)) -- `monitor` (Attributes) Monitor configuration (see [below for nested schema](#nestedatt--mute_ranges--monitor)) - - -### Nested Schema for `mute_ranges.alert_policy` - -Required: - -- `id` (String) Alert Policy ID - - - -### Nested Schema for `mute_ranges.monitor` - -Required: - -- `id` (String) Monitor ID - - - - -### Nested Schema for `mute_tags` - -Required: - -- `key` (String) Tag -- `value` (String) Tag Value - - - -### Nested Schema for `notify` - -Optional: - -- `before_time` (String) Notify Time -- `message` (String) Notify Message - - - -### Nested Schema for `notify_targets` - -Required: - -- `type` (String) Notify Type, value must be one of: *member_group*, *notification*, other value will be ignored. - -Optional: - -- `member_group` (Attributes) MemberGroup (see [below for nested schema](#nestedatt--notify_targets--member_group)) -- `notification` (Attributes) Notification (see [below for nested schema](#nestedatt--notify_targets--notification)) - - -### Nested Schema for `notify_targets.member_group` - -Required: - -- `id` (String) MemberGroup ID - - - -### Nested Schema for `notify_targets.notification` - -Required: - -- `id` (String) Notification ID - - - - -### Nested Schema for `onetime` - -Optional: - -- `end` (String) End -- `start` (String) Start - - - -### Nested Schema for `repeat` - -Optional: - -- `crontab` (Attributes) Crontab configuration (see [below for nested schema](#nestedatt--repeat--crontab)) -- `crontab_duration` (String) Crontab Duration -- `end` (String) End -- `expire` (String) Repeat Expire -- `start` (String) Start - - -### Nested Schema for `repeat.crontab` - -Optional: - -- `day` (String) Day -- `hour` (String) Hour -- `min` (String) Min -- `month` (String) Month -- `week` (String) Week - - diff --git a/docs/resources/notification.md b/docs/resources/notification.md deleted file mode 100644 index cc7e7d0..0000000 --- a/docs/resources/notification.md +++ /dev/null @@ -1,151 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "guance_notification Resource - guance" -subcategory: "" -description: |- - Notification - Notification is a feature that allows you to receive alerts when an event occurs. - Guance Cloud supports setting the notification object for the alert event. When the alert event occurs, the alert - information will be sent to the notification object. - Guance Cloud supports multiple different notification methods. You can refer to the documentation to learn more. - Relationships: - ```mermaid - graph LR - A[Monitor] --> B[Alert Policy] --> C[Notification] - ``` - Create - The first let me create a resource. We will send the create operation to the resource management service - ```terraform - variable "dingtalkwebhook" { - type = string - } - variable "dingtalksecret" { - type = string - } - resource "guancenotification" "demo" { - name = "oac-demo" - type = "dingtalkrobot" - dingtalkrobot = { - webhook = var.dingtalkwebhook - secret = var.dingtalk_secret - } - } - ``` ---- - -# guance_notification (Resource) - -# Notification - -Notification is a feature that allows you to receive alerts when an event occurs. - -Guance Cloud supports setting the notification object for the alert event. When the alert event occurs, the alert -information will be sent to the notification object. - -Guance Cloud supports multiple different notification methods. You can refer to the documentation to learn more. - -Relationships: - -```mermaid -graph LR - -A[Monitor] --> B[Alert Policy] --> C[Notification] -``` - -## Create - -The first let me create a resource. We will send the create operation to the resource management service - -```terraform -variable "ding_talk_webhook" { - type = string -} - -variable "ding_talk_secret" { - type = string -} - -resource "guance_notification" "demo" { - name = "oac-demo" - type = "ding_talk_robot" - ding_talk_robot = { - webhook = var.ding_talk_webhook - secret = var.ding_talk_secret - } -} -``` - - - - -## Schema - -### Required - -- `name` (String) Notification object name -- `type` (String) Trigger rule type, value must be one of: *ding_talk_robot*, *http_request*, *wechat_robot*, *mail_group*, *feishu_robot*, *sms*, other value will be ignored. - -### Optional - -- `ding_talk_robot` (Attributes) DingTalk Robot (see [below for nested schema](#nestedatt--ding_talk_robot)) -- `feishu_robot` (Attributes) Feishu Robot (see [below for nested schema](#nestedatt--feishu_robot)) -- `http_request` (Attributes) HTTP Request (see [below for nested schema](#nestedatt--http_request)) -- `mail_group` (Attributes) Mail Group (see [below for nested schema](#nestedatt--mail_group)) -- `sms` (Attributes) SMS (see [below for nested schema](#nestedatt--sms)) -- `wechat_robot` (Attributes) WeChat Robot (see [below for nested schema](#nestedatt--wechat_robot)) - -### Read-Only - -- `created_at` (String) The RFC3339/ISO8601 time string of resource created at. -- `id` (String) The Guance Resource Name (GRN) of cloud resource. - - -### Nested Schema for `ding_talk_robot` - -Required: - -- `secret` (String) DingTalk Robot Call Secret -- `webhook` (String) DingTalk Robot Call Address - - - -### Nested Schema for `feishu_robot` - -Required: - -- `secret` (String) Feishu Robot Call Secret -- `webhook` (String) Feishu Robot Call Address - - - -### Nested Schema for `http_request` - -Required: - -- `url` (String) HTTP Call Address - - - -### Nested Schema for `mail_group` - -Required: - -- `to` (List of String) Member Account List - - - -### Nested Schema for `sms` - -Required: - -- `to` (List of String) Phone Number List - - - -### Nested Schema for `wechat_robot` - -Required: - -- `webhook` (String) Robot Call Address - - diff --git a/docs/resources/pipeline.md b/docs/resources/pipeline.md index 432bc55..7d55db1 100644 --- a/docs/resources/pipeline.md +++ b/docs/resources/pipeline.md @@ -9,8 +9,7 @@ description: |- By writing a pipeline script, you can customize the structure of the log and use the cut fields as attributes. By cutting out the attribute fields, we can quickly filter the relevant logs and perform data association analysis to help us quickly locate and solve problems. - Create - The first let me create a resource. We will send the create operation to the resource management service + Example Usage ```terraform resource "guancepipeline" "demo" { name = "oac-demo" @@ -72,9 +71,7 @@ By writing a pipeline script, you can customize the structure of the log and use By cutting out the attribute fields, we can quickly filter the relevant logs and perform data association analysis to help us quickly locate and solve problems. -## Create - -The first let me create a resource. We will send the create operation to the resource management service +## Example Usage ```terraform resource "guance_pipeline" "demo" { @@ -133,20 +130,30 @@ resource "guance_pipeline" "demo" { ### Required -- `category` (String) Category, value must be one of: *logging*, *object*, *custom_object*, *network*, *tracing*, *rum*, *security*, *keyevent*, *metric*, other value will be ignored. +- `as_default` (Number) Is Default Pipeline +- `category` (String) Category, value must be one of: *logging*, *object*, *custom_object*, *network*, *tracing*, *rum*, *security*, *keyevent*, *metric*, *profiling*, other value will be ignored. - `content` (String) Pipeline file content -- `name` (String) Name +- `is_force` (Boolean) Is Force Overwrite. If the field `as_default` is true, `is_force` will be set to be true automatically. +- `name` (String) The name of the pipeline. +- `source` (List of String) Data source list +- `test_data` (String) Test data +- `type` (String) The type of the pipeline.Valid value: `local`, `central` ### Optional -- `is_default` (Boolean) Is Default Pipeline -- `is_force` (Boolean) Is Force Overwrite -- `source` (List of String) Data source list -- `test_data` (String) Test data +- `extend` (Attributes) (see [below for nested schema](#nestedatt--extend)) ### Read-Only -- `created_at` (String) The RFC3339/ISO8601 time string of resource created at. -- `id` (String) The Guance Resource Name (GRN) of cloud resource. +- `create_at` (String) The creation time of the resource, in seconds as a timestamp. +- `uuid` (String) The uuid of the pipeline. + + +### Nested Schema for `extend` + +Optional: + +- `app_id` (List of String) +- `measurement` (List of String) diff --git a/docs/resources/role.md b/docs/resources/role.md new file mode 100644 index 0000000..ca916c5 --- /dev/null +++ b/docs/resources/role.md @@ -0,0 +1,51 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "guance_role Resource - guance" +subcategory: "" +description: |- + Role + Guance Cloud supports creating roles to manage the permissions of users. Role management provides users with an intuitive entry for permission management, supporting the flexible adjustment of the permission scope corresponding to different roles, creating new roles for users, and assigning permission scopes to roles to meet the permission needs of different users. + Example Usage + terraform + resource "guance_role" "role" { + name = "tf-test-role1" + desc = "test role" + keys = ["snapshot.delete", "workspace.readMember"] + } +--- + +# guance_role (Resource) + +# Role + +Guance Cloud supports creating roles to manage the permissions of users. Role management provides users with an intuitive entry for permission management, supporting the flexible adjustment of the permission scope corresponding to different roles, creating new roles for users, and assigning permission scopes to roles to meet the permission needs of different users. + +## Example Usage + +```terraform +resource "guance_role" "role" { + name = "tf-test-role1" + desc = "test role" + keys = ["snapshot.delete", "workspace.readMember"] +} +``` + + + + +## Schema + +### Required + +- `keys` (List of String) The permission keys. +- `name` (String) The name of the role. + +### Optional + +- `desc` (String) The description of the role. + +### Read-Only + +- `uuid` (String) The UUID of the role. + + diff --git a/examples/alertpolicy/.terraform.lock.hcl b/examples/alertpolicy/.terraform.lock.hcl deleted file mode 100644 index 590bf60..0000000 --- a/examples/alertpolicy/.terraform.lock.hcl +++ /dev/null @@ -1,24 +0,0 @@ -# This file is maintained automatically by "terraform init". -# Manual edits may be lost in future updates. - -provider "registry.terraform.io/guancecloud/guance" { - version = "0.0.3" - hashes = [ - "h1:ktsr/yAbJ0smNKxFo541ICG30yi57oiiVO7shzN6iiE=", - "zh:0b5cce1ce6178851af1210cdd59db4ac244dcd9f43fa22dd84e9738779a4e5c9", - "zh:0fb228b88c3d5de5b9a86697e36411df2339e2995a495287cbcae06f785e5024", - "zh:2805245d5c113146b450c99c9044e9c6262557c5610438e2c4bc608805a0a99b", - "zh:4428b5b09cbf3d3ac5a131f52e41914a3c7e6034a3c3a62b5992a12f5ac7dbd6", - "zh:4930d1af6f288099306f1603f612bda272ae19c0ea55f6b5f3865d415e1e66db", - "zh:5e151c456aa0f6f8e6ad39799ec116e96d4c61227e40cb6a43e5ff06a5e641f5", - "zh:6d4c1d64fc1cc0cfac68197193f806f5c51e2630023ce29514279475499d5de3", - "zh:6dfc5c6d2a89a6ca3e760d2cca269a2d92a2b6a00f615573716bf5b0aa4c12d0", - "zh:791430b33ba76bef79b185eec55a603b54015942971efc645fce6ba4435f8823", - "zh:890df766e9b839623b1f0437355032a3c006226a6c200cd911e15ee1a9014e9f", - "zh:949e331f05c15fc5469e9334d05598a26a580e32b83b2bf5a5478c42dc21eea5", - "zh:9902a214c1f27effb813221fc793c804958a5a7d35f6def68b3f34e31a7a9a29", - "zh:b72f74aff05da1086bb79fa68e8071f0f154e6a092f44c0d784919183e14f9f1", - "zh:dd26785f6d8a5913351c2906e236156bbbd54a514dbb9b1c0c2356546432418d", - "zh:f7453f2db7bfdb2be9619dbaf63f38de228e939022a68ad75aef2ab71b4106da", - ] -} diff --git a/examples/alertpolicy/README.md b/examples/alertpolicy/README.md deleted file mode 100644 index 859bb3f..0000000 --- a/examples/alertpolicy/README.md +++ /dev/null @@ -1,94 +0,0 @@ -# Alert Policy - -Alert policy is a set of rules that define when to trigger an alert. You can create alert policies for your data -sources, and set up alert targets to receive alerts. - -Guance Cloud supports alert policy management for the results of monitor checks, by sending alert notification emails or -group message notifications, so that you can know about the abnormal data situation of the monitoring in time, find -problems, and solve problems. - -Relationships: - -```mermaid -graph LR - -A[Monitor] --> B[Alert Policy] --> C[Notification] -``` - -Notes: - -1. When a monitor is created, an alert policy must be selected, and the default is selected by default; -2. When a certain alert policy is deleted, the monitor under the deleted alert policy will automatically be classified - into the default. - -## Create - -The first let me create a resource. We will send the create operation to the resource management service - -```terraform -variable "ding_talk_webhook" { - type = string -} - -variable "ding_talk_secret" { - type = string -} - -variable "email" { - type = string -} - -data "guance_members" "demo" { - filters = [ - { - name = "email" - values = [var.email] - } - ] -} - -resource "guance_membergroup" "demo" { - name = "oac-demo" - member_ids = data.guance_members.demo.items[*].id -} - -resource "guance_notification" "demo" { - name = "oac-demo" - type = "ding_talk_robot" - ding_talk_robot = { - webhook = var.ding_talk_webhook - secret = var.ding_talk_secret - } -} - -resource "guance_alertpolicy" "demo" { - name = "oac-demo" - silent_timeout = "1h" - - statuses = [ - "critical", - "error", - "warning", - "info", - "ok", - "nodata", - "nodata_ok", - "nodata_as_ok", - ] - - alert_targets = [ - { - type = "member_group" - member_group = { - id = guance_membergroup.demo.id - } - }, - { - type = "notification" - notification = { - id = guance_notification.demo.id - } - } - ] -} -``` diff --git a/examples/alertpolicy/main.tf b/examples/alertpolicy/main.tf deleted file mode 100644 index 72822ab..0000000 --- a/examples/alertpolicy/main.tf +++ /dev/null @@ -1,65 +0,0 @@ -variable "ding_talk_webhook" { - type = string -} - -variable "ding_talk_secret" { - type = string -} - -variable "email" { - type = string -} - -data "guance_members" "demo" { - filters = [ - { - name = "email" - values = [var.email] - } - ] -} - -resource "guance_membergroup" "demo" { - name = "oac-demo" - member_ids = data.guance_members.demo.items[*].id -} - -resource "guance_notification" "demo" { - name = "oac-demo" - type = "ding_talk_robot" - ding_talk_robot = { - webhook = var.ding_talk_webhook - secret = var.ding_talk_secret - } -} - -resource "guance_alertpolicy" "demo" { - name = "oac-demo" - silent_timeout = "1h" - - statuses = [ - "critical", - "error", - "warning", - "info", - "ok", - "nodata", - "nodata_ok", - "nodata_as_ok", - ] - - alert_targets = [ - { - type = "member_group" - member_group = { - id = guance_membergroup.demo.id - } - }, - { - type = "notification" - notification = { - id = guance_notification.demo.id - } - } - ] -} diff --git a/examples/alertpolicy/provider.tf b/examples/alertpolicy/provider.tf deleted file mode 100644 index 8d3b1ad..0000000 --- a/examples/alertpolicy/provider.tf +++ /dev/null @@ -1,13 +0,0 @@ - -terraform { - required_version = ">=0.12" - - required_providers { - guance = { - source = "GuanceCloud/guance" - } - } -} - -provider "guance" { -} diff --git a/examples/blacklist/main.tf b/examples/blacklist/main.tf index 6d17074..312bd8a 100644 --- a/examples/blacklist/main.tf +++ b/examples/blacklist/main.tf @@ -1,12 +1,10 @@ resource "guance_blacklist" "demo" { - source = { - type = "logging" - name = "nginx" - } + type = "logging" + source = "mysql" - filter_rules = [ + filters = [ { - name = "foo" + name = "foo1" operation = "in" condition = "and" values = ["oac-*"] diff --git a/examples/blacklist/provider.tf b/examples/blacklist/provider.tf index 8d3b1ad..75a0cdf 100644 --- a/examples/blacklist/provider.tf +++ b/examples/blacklist/provider.tf @@ -1,13 +1,14 @@ terraform { - required_version = ">=0.12" + required_version = ">=0.12" - required_providers { - guance = { - source = "GuanceCloud/guance" - } - } + required_providers { + guance = { + source = "GuanceCloud/guance" + } + } } provider "guance" { + region = "hangzhou" } diff --git a/examples/dashboard/README.md b/examples/dashboard/README.md deleted file mode 100644 index 476445b..0000000 --- a/examples/dashboard/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# Dashboard - -A dashboard is a collection of visualizations that you can use to monitor the health of your systems and applications. -Dashboards are made up of one or more panels, which are the visualizations themselves. Each panel displays a single -metric or a single aggregation of metrics. - -Dashboards are a great way to visualize your data and monitor your systems. You can use them to track metrics over time, -and to quickly see how your systems are performing. You can also use them to compare metrics from different systems and -applications. - -Guance Cloud's dashboard is used to clearly show the range in which the metric data values are located. It is suitable -for slicing messy data into points. - -## Create - -The first let me create a resource. We will send the create operation to the resource management service - -```terraform -resource "guance_dashboard" "demo" { - name = "oac-demo" - manifest = file("${path.module}/dashboard.json") -} -``` diff --git a/examples/dashboard/dashboard.json b/examples/dashboard/dashboard.json deleted file mode 100644 index 1b3fae1..0000000 --- a/examples/dashboard/dashboard.json +++ /dev/null @@ -1,636 +0,0 @@ -{ - "dashboardBindSet": [], - "dashboardExtend": {}, - "dashboardMapping": [], - "dashboardOwnerType": "node", - "dashboardType": "CUSTOM", - "iconSet": {}, - "main": { - "charts": [ - { - "extend": { - "fixedTime": "", - "settings": { - "chartType": "areaLine", - "colors": [ - { - "color": "#C57ECD", - "key": "active", - "name": "active" - } - ], - "compareTitle": "", - "compareType": "", - "currentChartType": "sequence", - "density": "medium", - "fixedTime": "", - "isPercent": false, - "isTimeInterval": true, - "levels": [], - "openCompare": false, - "openStack": false, - "showFieldMapping": false, - "showLine": false, - "showTitle": true, - "stackType": "time", - "timeInterval": "default", - "titleDesc": "", - "units": [], - "xAxisShowType": "time" - } - }, - "group": { - "name": null - }, - "name": "active/s", - "pos": { - "h": 8, - "i": "chrt_8481cfca47e34f03b4be266b23062dc4", - "w": 8, - "x": 16, - "y": 0 - }, - "queries": [ - { - "color": "", - "datasource": "dataflux", - "name": "", - "qtype": "dql", - "query": { - "alias": "active", - "code": "A", - "dataSource": "nginx", - "field": "connection_active", - "fieldFunc": "avg", - "fieldType": "integer", - "fill": null, - "fillNum": null, - "filters": [ - { - "id": "3b19df90-3860-11ec-a768-9128aba1a726", - "logic": "and", - "name": "host", - "op": "=", - "value": "#{host}" - } - ], - "funcList": [], - "groupBy": [], - "groupByTime": "", - "namespace": "metric", - "q": "NON_NEGATIVE_DERIVATIVE(\"M::`nginx`:(AVG(`connection_active`) AS `active`) { `host` = '#{host}' }\")", - "queryFuncs": [ - { - "args": [], - "name": "non_negative_derivative" - } - ], - "type": "simple", - "withLabels": [] - }, - "type": "sequence", - "unit": "" - } - ], - "type": "sequence" - }, - { - "extend": { - "fixedTime": "", - "settings": { - "chartType": "areaLine", - "colors": [ - { - "color": "#FFBD5F", - "key": "handled", - "name": "handled" - } - ], - "compareTitle": "", - "compareType": "", - "currentChartType": "sequence", - "density": "medium", - "fixedTime": "", - "isPercent": false, - "isTimeInterval": true, - "levels": [], - "openCompare": false, - "openStack": false, - "showFieldMapping": false, - "showLine": false, - "showTitle": true, - "stackType": "time", - "timeInterval": "default", - "titleDesc": "", - "units": [], - "xAxisShowType": "time" - } - }, - "group": { - "name": null - }, - "name": "handled/s", - "pos": { - "h": 8, - "i": "chrt_3948003a17ee4b9795df001387dc5633", - "w": 6, - "x": 0, - "y": 8 - }, - "queries": [ - { - "color": "", - "datasource": "dataflux", - "name": "", - "qtype": "dql", - "query": { - "alias": "handled", - "code": "A", - "dataSource": "nginx", - "field": "connection_handled", - "fieldFunc": "avg", - "fieldType": "integer", - "fill": null, - "fillNum": null, - "filters": [ - { - "id": "95fc2b70-3860-11ec-a768-9128aba1a726", - "logic": "and", - "name": "host", - "op": "=", - "value": "#{host}" - } - ], - "funcList": [], - "groupBy": [], - "groupByTime": "", - "namespace": "metric", - "q": "NON_NEGATIVE_DERIVATIVE(\"M::`nginx`:(AVG(`connection_handled`) AS `handled`) { `host` = '#{host}' }\")", - "queryFuncs": [ - { - "args": [], - "name": "non_negative_derivative" - } - ], - "type": "simple", - "withLabels": [] - }, - "type": "sequence", - "unit": "" - } - ], - "type": "sequence" - }, - { - "extend": { - "fixedTime": "", - "settings": { - "chartType": "areaLine", - "colors": [ - { - "color": "#8AE2DF", - "key": "reading", - "name": "reading" - } - ], - "compareTitle": "", - "compareType": "", - "currentChartType": "sequence", - "density": "medium", - "fixedTime": "", - "isPercent": false, - "isTimeInterval": true, - "levels": [], - "openCompare": false, - "openStack": false, - "showFieldMapping": false, - "showLine": false, - "showTitle": true, - "stackType": "time", - "timeInterval": "default", - "titleDesc": "", - "units": [], - "xAxisShowType": "time" - } - }, - "group": { - "name": null - }, - "name": "reading/s", - "pos": { - "h": 8, - "i": "chrt_3a0162b89079407aa3d918d3c5b9e807", - "w": 6, - "x": 12, - "y": 8 - }, - "queries": [ - { - "color": "", - "datasource": "dataflux", - "name": "", - "qtype": "dql", - "query": { - "alias": "reading", - "code": "A", - "dataSource": "nginx", - "field": "connection_reading", - "fieldFunc": "avg", - "fieldType": "integer", - "fill": null, - "filters": [ - { - "id": "b482db80-7770-11ec-9c8b-396765a383d1", - "logic": "and", - "name": "host", - "op": "=", - "type": "", - "value": "#{host}" - } - ], - "funcList": [], - "groupBy": [], - "groupByTime": "", - "namespace": "metric", - "q": "M::`nginx`:(AVG(`connection_reading`) AS `reading`) { `host` = '#{host}' }", - "queryFuncs": [], - "type": "simple" - }, - "type": "sequence", - "unit": "" - } - ], - "type": "sequence" - }, - { - "extend": { - "fixedTime": "", - "settings": { - "chartType": "areaLine", - "colors": [ - { - "color": "#498BFE", - "key": "accepts", - "name": "accepts" - } - ], - "compareTitle": "", - "compareType": "", - "currentChartType": "sequence", - "density": "medium", - "fixedTime": "", - "isPercent": false, - "isTimeInterval": true, - "levels": [], - "openCompare": false, - "openStack": false, - "showFieldMapping": false, - "showLine": false, - "showTitle": true, - "stackType": "time", - "timeInterval": "default", - "titleDesc": "", - "units": [], - "xAxisShowType": "time" - } - }, - "group": { - "name": null - }, - "name": "accepts/s", - "pos": { - "h": 8, - "i": "chrt_08328ee8670a4fbd95438ab317feff57", - "w": 8, - "x": 8, - "y": 0 - }, - "queries": [ - { - "color": "", - "datasource": "dataflux", - "name": "", - "qtype": "dql", - "query": { - "alias": "accepts", - "code": "A", - "dataSource": "nginx", - "field": "connection_accepts", - "fieldFunc": "avg", - "fieldType": "integer", - "fill": null, - "filters": [ - { - "id": "03c2ca70-7771-11ec-9c8b-396765a383d1", - "logic": "and", - "name": "host", - "op": "=", - "type": "", - "value": "#{host}" - } - ], - "funcList": [], - "groupBy": [], - "groupByTime": "", - "namespace": "metric", - "q": "NON_NEGATIVE_DERIVATIVE(\"M::`nginx`:(AVG(`connection_accepts`) AS `accepts`) { `host` = '#{host}' }\")", - "queryFuncs": [ - { - "args": [], - "name": "non_negative_derivative" - } - ], - "type": "simple" - }, - "type": "sequence", - "unit": "" - } - ], - "type": "sequence" - }, - { - "extend": { - "fixedTime": "", - "settings": { - "chartType": "areaLine", - "colors": [ - { - "color": "#A0DD86", - "key": "requests", - "name": "requests" - } - ], - "compareTitle": "", - "compareType": "", - "currentChartType": "sequence", - "density": "medium", - "fixedTime": "", - "isPercent": false, - "isTimeInterval": true, - "levels": [], - "openCompare": false, - "openStack": false, - "showFieldMapping": false, - "showLine": false, - "showTitle": true, - "stackType": "time", - "timeInterval": "default", - "titleDesc": "", - "units": [], - "xAxisShowType": "time" - } - }, - "group": { - "name": null - }, - "name": "requests/s", - "pos": { - "h": 8, - "i": "chrt_25a41ba45fe74ea3b480227eb045e69a", - "w": 8, - "x": 0, - "y": 0 - }, - "queries": [ - { - "color": "", - "datasource": "dataflux", - "name": "", - "qtype": "dql", - "query": { - "alias": "requests", - "code": "A", - "dataSource": "nginx", - "field": "connection_requests", - "fieldFunc": "avg", - "fieldType": "integer", - "fill": null, - "filters": [ - { - "id": "f1aafc40-7770-11ec-9c8b-396765a383d1", - "logic": "and", - "name": "host", - "op": "=", - "type": "", - "value": "#{host}" - } - ], - "funcList": [], - "groupBy": [], - "groupByTime": "", - "namespace": "metric", - "q": "NON_NEGATIVE_DERIVATIVE(\"M::`nginx`:(AVG(`connection_requests`) AS `requests`) { `host` = '#{host}' }\")", - "queryFuncs": [ - { - "args": [], - "name": "non_negative_derivative" - } - ], - "type": "simple" - }, - "type": "sequence", - "unit": "" - } - ], - "type": "sequence" - }, - { - "extend": { - "fixedTime": "", - "settings": { - "chartType": "areaLine", - "colors": [ - { - "color": "#FF92C6", - "key": "waiting", - "name": "waiting" - } - ], - "compareTitle": "", - "compareType": "", - "currentChartType": "sequence", - "density": "medium", - "fixedTime": "", - "isPercent": false, - "isTimeInterval": true, - "levels": [], - "openCompare": false, - "openStack": false, - "showFieldMapping": false, - "showLine": false, - "showTitle": true, - "stackType": "time", - "timeInterval": "default", - "titleDesc": "", - "units": [], - "xAxisShowType": "time" - } - }, - "group": { - "name": null - }, - "name": "waiting/s", - "pos": { - "h": 8, - "i": "chrt_3298fe8c9d6b403c984c2d9ce6b306e8", - "w": 6, - "x": 6, - "y": 8 - }, - "queries": [ - { - "color": "", - "datasource": "dataflux", - "name": "", - "qtype": "dql", - "query": { - "alias": "waiting", - "code": "A", - "dataSource": "nginx", - "field": "connection_waiting", - "fieldFunc": "avg", - "fieldType": "integer", - "fill": null, - "filters": [ - { - "id": "ea08f1e0-7770-11ec-9c8b-396765a383d1", - "logic": "and", - "name": "host", - "op": "=", - "type": "", - "value": "#{host}" - } - ], - "funcList": [], - "groupBy": [], - "groupByTime": "", - "namespace": "metric", - "q": "NON_NEGATIVE_DERIVATIVE(\"M::`nginx`:(AVG(`connection_waiting`) AS `waiting`) { `host` = '#{host}' }\")", - "queryFuncs": [ - { - "args": [], - "name": "non_negative_derivative" - } - ], - "type": "simple" - }, - "type": "sequence", - "unit": "" - } - ], - "type": "sequence" - }, - { - "extend": { - "fixedTime": "", - "settings": { - "chartType": "areaLine", - "colors": [ - { - "color": "#00B2CE", - "key": "writing", - "name": "writing" - } - ], - "compareTitle": "", - "compareType": "", - "currentChartType": "sequence", - "density": "medium", - "fixedTime": "", - "isPercent": false, - "isTimeInterval": true, - "levels": [], - "openCompare": false, - "openStack": false, - "showFieldMapping": false, - "showLine": false, - "showTitle": true, - "stackType": "time", - "timeInterval": "default", - "titleDesc": "", - "units": [], - "xAxisShowType": "time" - } - }, - "group": { - "name": null - }, - "name": "writing/s", - "pos": { - "h": 8, - "i": "chrt_8087b10166d74f3aab0f3be060e7746c", - "w": 6, - "x": 18, - "y": 8 - }, - "queries": [ - { - "color": "", - "datasource": "dataflux", - "name": "", - "qtype": "dql", - "query": { - "alias": "writing", - "code": "A", - "dataSource": "nginx", - "field": "connection_writing", - "fieldFunc": "avg", - "fieldType": "integer", - "fill": null, - "filters": [ - { - "id": "e26dc550-7770-11ec-9c8b-396765a383d1", - "logic": "and", - "name": "host", - "op": "=", - "type": "", - "value": "#{host}" - } - ], - "funcList": [], - "groupBy": [], - "groupByTime": "", - "namespace": "metric", - "q": "NON_NEGATIVE_DERIVATIVE(\"M::`nginx`:(AVG(`connection_writing`) AS `writing`) { `host` = '#{host}' }\")", - "queryFuncs": [ - { - "args": [], - "name": "non_negative_derivative" - } - ], - "type": "simple" - }, - "type": "sequence", - "unit": "" - } - ], - "type": "sequence" - } - ], - "groups": [], - "type": "template", - "vars": [ - { - "code": "host", - "datasource": "ftinfluxdb", - "definition": { - "field": "", - "metric": "nginx", - "object": "", - "tag": "host", - "value": "" - }, - "hide": 0, - "name": "主机", - "seq": 0, - "type": "TAG", - "valueSort": "default" - } - ] - }, - "summary": "", - "tagInfo": [], - "tags": [], - "thumbnail": "", - "title": "Nginx" -} diff --git a/examples/dashboard/main.tf b/examples/dashboard/main.tf deleted file mode 100644 index 6c8ac2f..0000000 --- a/examples/dashboard/main.tf +++ /dev/null @@ -1,4 +0,0 @@ -resource "guance_dashboard" "demo" { - name = "oac-demo" - manifest = file("${path.module}/dashboard.json") -} diff --git a/examples/dashboard/provider.tf b/examples/dashboard/provider.tf deleted file mode 100644 index 8d3b1ad..0000000 --- a/examples/dashboard/provider.tf +++ /dev/null @@ -1,13 +0,0 @@ - -terraform { - required_version = ">=0.12" - - required_providers { - guance = { - source = "GuanceCloud/guance" - } - } -} - -provider "guance" { -} diff --git a/examples/membergroup/README.md b/examples/membergroup/README.md index 681a2d5..a17e44a 100644 --- a/examples/membergroup/README.md +++ b/examples/membergroup/README.md @@ -25,16 +25,16 @@ variable "email" { } data "guance_members" "demo" { - filters = [ - { - name = "email" - values = [var.email] - } - ] + search = var.email } resource "guance_membergroup" "demo" { - name = "oac-demo" - member_ids = data.guance_members.demo.items[*].id + name = "oac-demo2" + account_uuids = data.guance_members.demo.members[*].uuid +} + +output "member" { + value = data.guance_members.demo.members } ``` + diff --git a/examples/membergroup/main.tf b/examples/membergroup/main.tf index d2e54fb..6619640 100644 --- a/examples/membergroup/main.tf +++ b/examples/membergroup/main.tf @@ -3,15 +3,14 @@ variable "email" { } data "guance_members" "demo" { - filters = [ - { - name = "email" - values = [var.email] - } - ] + search = var.email } resource "guance_membergroup" "demo" { - name = "oac-demo" - member_ids = data.guance_members.demo.items[*].id + name = "oac-demo2" + account_uuids = data.guance_members.demo.members[*].uuid +} + +output "member" { + value = data.guance_members.demo.members } diff --git a/examples/membergroup/provider.tf b/examples/membergroup/provider.tf index 8d3b1ad..75a0cdf 100644 --- a/examples/membergroup/provider.tf +++ b/examples/membergroup/provider.tf @@ -1,13 +1,14 @@ terraform { - required_version = ">=0.12" + required_version = ">=0.12" - required_providers { - guance = { - source = "GuanceCloud/guance" - } - } + required_providers { + guance = { + source = "GuanceCloud/guance" + } + } } provider "guance" { + region = "hangzhou" } diff --git a/examples/monitor/README.md b/examples/monitor/README.md deleted file mode 100644 index d487d5b..0000000 --- a/examples/monitor/README.md +++ /dev/null @@ -1,76 +0,0 @@ -# Monitor - -A monitor is a set of checks that you can run against your data. A monitor watches your data over time and alerts you -when certain conditions are met. For example, you can create a monitor that watches the average response time of your -website and alerts you when the response time is greater than 1 second. - -Monitors are made up of one or more checks. A check is a single test that you can run against your data. For example, -you can create a check that watches the average response time of your website. You can also create a check that watches -the percentage of 5xx errors in your logs. - -Guance Cloud supports defining monitors, users can customize the configuration of detection rules and trigger -conditions, and open the monitors to receive related alarm events triggered by the detection rules. - -Relationships: - -```mermaid -graph LR - -A[Monitor] --> B[Alert Policy] --> C[Notification] -``` - -## Create - -The first let me create a resource. We will send the create operation to the resource management service - -```terraform -variable "email" { - type = string -} - -data "guance_members" "demo" { - filters = [ - { - name = "email" - values = [var.email] - } - ] -} - -resource "guance_membergroup" "demo" { - name = "oac-demo" - member_ids = data.guance_members.demo.items[*].id -} - -resource "guance_alertpolicy" "demo" { - name = "oac-demo" - silent_timeout = "1h" - - statuses = [ - "critical", - "error", - "warning", - "info", - "ok", - "nodata", - "nodata_ok", - "nodata_as_ok", - ] - - alert_targets = [ - { - type = "member_group" - member_group = { - id = guance_membergroup.demo.id - } - }, - ] -} - -resource "guance_monitor" "demo" { - manifest = file("${path.module}/monitor.json") - alert_policy = { - id = guance_alertpolicy.demo.id - } -} -``` diff --git a/examples/monitor/main.tf b/examples/monitor/main.tf deleted file mode 100644 index 3fa9532..0000000 --- a/examples/monitor/main.tf +++ /dev/null @@ -1,49 +0,0 @@ -variable "email" { - type = string -} - -data "guance_members" "demo" { - filters = [ - { - name = "email" - values = [var.email] - } - ] -} - -resource "guance_membergroup" "demo" { - name = "oac-demo" - member_ids = data.guance_members.demo.items[*].id -} - -resource "guance_alertpolicy" "demo" { - name = "oac-demo" - silent_timeout = "1h" - - statuses = [ - "critical", - "error", - "warning", - "info", - "ok", - "nodata", - "nodata_ok", - "nodata_as_ok", - ] - - alert_targets = [ - { - type = "member_group" - member_group = { - id = guance_membergroup.demo.id - } - }, - ] -} - -resource "guance_monitor" "demo" { - manifest = file("${path.module}/monitor.json") - alert_policy = { - id = guance_alertpolicy.demo.id - } -} diff --git a/examples/monitor/monitor.json b/examples/monitor/monitor.json deleted file mode 100644 index ce3b431..0000000 --- a/examples/monitor/monitor.json +++ /dev/null @@ -1,140 +0,0 @@ -{ - "extend": { - "funcName": "", - "querylist": [ - { - "datasource": "dataflux", - "qtype": "dql", - "query": { - "children": [ - { - "alias": "", - "code": "A", - "dataSource": "aerospike", - "field": "namespace_memory_free_pct", - "fieldFunc": "last", - "fieldType": "float", - "groupBy": [ - "ns" - ], - "groupByTime": "", - "namespace": "metric", - "q": "M::`aerospike`:(LAST(`namespace_memory_free_pct`)) BY `ns`", - "type": "simple" - } - ], - "code": "Result", - "expression": "100-A", - "funcList": [], - "q": "eval(100-A, A=\"M::`aerospike`:(LAST(`namespace_memory_free_pct`)) BY `ns`\")", - "type": "expression" - }, - "uuid": "19cf2077-8b02-4e0e-b5f8-6a4af19b8ffc" - } - ], - "rules": [ - { - "conditionLogic": "and", - "conditions": [ - { - "alias": "Result", - "operands": [ - "85" - ], - "operator": ">=" - } - ], - "status": "critical" - }, - { - "conditionLogic": "and", - "conditions": [ - { - "alias": "Result", - "operands": [ - "80" - ], - "operator": ">=" - } - ], - "status": "error" - }, - { - "conditionLogic": "and", - "conditions": [ - { - "alias": "Result", - "operands": [ - "60" - ], - "operator": ">=" - } - ], - "status": "warning" - } - ] - }, - "is_disable": false, - "jsonScript": { - "checkerOpt": { - "rules": [ - { - "conditionLogic": "and", - "conditions": [ - { - "alias": "Result", - "operands": [ - "85" - ], - "operator": ">=" - } - ], - "status": "critical" - }, - { - "conditionLogic": "and", - "conditions": [ - { - "alias": "Result", - "operands": [ - "80" - ], - "operator": ">=" - } - ], - "status": "error" - }, - { - "conditionLogic": "and", - "conditions": [ - { - "alias": "Result", - "operands": [ - "60" - ], - "operator": ">=" - } - ], - "status": "warning" - } - ] - }, - "every": "1m", - "groupBy": [ - "ns" - ], - "interval": 300, - "message": ">等级:{{df_status}} \n>集群:{{cluster_name}} \n>空间:{{ns}} \n{% if df_status != 'ok' %}>状态:告警发生\n>内容:Aerospike 集群【{{cluster_name}}】 空间【 {{ ns }}】的 Memory 使用率过高,当前使用率为: {{ Result }} %。\n {% else %}>状态:告警恢复\n>内容:Aerospike 集群【{{cluster_name}}】 空间【 {{ ns }}】的 Memory 告警恢复,当前使用率为: {{ Result }} %。\n{% endif %}", - "recoverNeedPeriodCount": 5, - "targets": [ - { - "alias": "Result", - "dql": "eval(100-A, A=\"M::`aerospike`:(LAST(`namespace_memory_free_pct`)) BY `ns`\")" - } - ], - "title": "Aerospike 集群【{{cluster_name}}】空间【{{ ns }}】 的 Memory 使用率过高", - "type": "simpleCheck" - }, - "monitorName": "默认分组" -} - diff --git a/examples/monitor/provider.tf b/examples/monitor/provider.tf deleted file mode 100644 index 8d3b1ad..0000000 --- a/examples/monitor/provider.tf +++ /dev/null @@ -1,13 +0,0 @@ - -terraform { - required_version = ">=0.12" - - required_providers { - guance = { - source = "GuanceCloud/guance" - } - } -} - -provider "guance" { -} diff --git a/examples/mute/.terraform.lock.hcl b/examples/mute/.terraform.lock.hcl deleted file mode 100644 index 590bf60..0000000 --- a/examples/mute/.terraform.lock.hcl +++ /dev/null @@ -1,24 +0,0 @@ -# This file is maintained automatically by "terraform init". -# Manual edits may be lost in future updates. - -provider "registry.terraform.io/guancecloud/guance" { - version = "0.0.3" - hashes = [ - "h1:ktsr/yAbJ0smNKxFo541ICG30yi57oiiVO7shzN6iiE=", - "zh:0b5cce1ce6178851af1210cdd59db4ac244dcd9f43fa22dd84e9738779a4e5c9", - "zh:0fb228b88c3d5de5b9a86697e36411df2339e2995a495287cbcae06f785e5024", - "zh:2805245d5c113146b450c99c9044e9c6262557c5610438e2c4bc608805a0a99b", - "zh:4428b5b09cbf3d3ac5a131f52e41914a3c7e6034a3c3a62b5992a12f5ac7dbd6", - "zh:4930d1af6f288099306f1603f612bda272ae19c0ea55f6b5f3865d415e1e66db", - "zh:5e151c456aa0f6f8e6ad39799ec116e96d4c61227e40cb6a43e5ff06a5e641f5", - "zh:6d4c1d64fc1cc0cfac68197193f806f5c51e2630023ce29514279475499d5de3", - "zh:6dfc5c6d2a89a6ca3e760d2cca269a2d92a2b6a00f615573716bf5b0aa4c12d0", - "zh:791430b33ba76bef79b185eec55a603b54015942971efc645fce6ba4435f8823", - "zh:890df766e9b839623b1f0437355032a3c006226a6c200cd911e15ee1a9014e9f", - "zh:949e331f05c15fc5469e9334d05598a26a580e32b83b2bf5a5478c42dc21eea5", - "zh:9902a214c1f27effb813221fc793c804958a5a7d35f6def68b3f34e31a7a9a29", - "zh:b72f74aff05da1086bb79fa68e8071f0f154e6a092f44c0d784919183e14f9f1", - "zh:dd26785f6d8a5913351c2906e236156bbbd54a514dbb9b1c0c2356546432418d", - "zh:f7453f2db7bfdb2be9619dbaf63f38de228e939022a68ad75aef2ab71b4106da", - ] -} diff --git a/examples/mute/README.md b/examples/mute/README.md deleted file mode 100644 index 636a14f..0000000 --- a/examples/mute/README.md +++ /dev/null @@ -1,155 +0,0 @@ -# Mute Rule - -Mute rule is a feature that allows you to temporarily stop receiving notifications for a specific alert. You can use -mute rules to temporarily silence alerts that are not relevant to you, or to silence alerts that you are already aware -of. - -Guance Cloud supports the management of all mute rules in the current workspace. It supports muting different monitors, -smart inspections, self-built inspections, SLOs, and alert policies, so that the muted objects do not send any alert -notifications to any alert notification objects during the mute time. - -Relationships: - -```mermaid -graph LR - A[Mute Rule] --> B[Alert Policy] -``` - -## Create - -The first let me create a resource. We will send the create operation to the resource management service - -```terraform -variable "ding_talk_webhook" { - type = string -} - -variable "ding_talk_secret" { - type = string -} - -variable "email" { - type = string -} - -data "guance_members" "demo" { - filters = [ - { - name = "email" - values = [var.email] - } - ] -} - -resource "guance_membergroup" "demo" { - name = "oac-demo" - member_ids = data.guance_members.demo.items[*].id -} - -resource "guance_notification" "demo" { - name = "oac-demo" - type = "ding_talk_robot" - ding_talk_robot = { - webhook = var.ding_talk_webhook - secret = var.ding_talk_secret - } -} - -resource "guance_alertpolicy" "demo" { - name = "oac-demo" - silent_timeout = "1h" - - statuses = [ - "critical", - "error", - "warning", - "info", - "ok", - "nodata", - "nodata_ok", - "nodata_as_ok", - ] - - alert_targets = [ - { - type = "member_group" - member_group = { - id = guance_membergroup.demo.id - } - }, - { - type = "notification" - notification = { - id = guance_notification.demo.id - } - } - ] -} - -resource "guance_mute" "demo" { - // mute ranges - mute_ranges = [ - { - type = "alert_policy" - - alert_policy = { - id = guance_alertpolicy.demo.id - } - } - ] - - // notify options - notify = { - message = < B[Alert Policy] --> C[Notification] -``` - -## Create - -The first let me create a resource. We will send the create operation to the resource management service - -```terraform -variable "ding_talk_webhook" { - type = string -} - -variable "ding_talk_secret" { - type = string -} - -resource "guance_notification" "demo" { - name = "oac-demo" - type = "ding_talk_robot" - ding_talk_robot = { - webhook = var.ding_talk_webhook - secret = var.ding_talk_secret - } -} -``` diff --git a/examples/notification/main.tf b/examples/notification/main.tf deleted file mode 100644 index 7ae9a51..0000000 --- a/examples/notification/main.tf +++ /dev/null @@ -1,16 +0,0 @@ -variable "ding_talk_webhook" { - type = string -} - -variable "ding_talk_secret" { - type = string -} - -resource "guance_notification" "demo" { - name = "oac-demo" - type = "ding_talk_robot" - ding_talk_robot = { - webhook = var.ding_talk_webhook - secret = var.ding_talk_secret - } -} diff --git a/examples/notification/provider.tf b/examples/notification/provider.tf deleted file mode 100644 index 8d3b1ad..0000000 --- a/examples/notification/provider.tf +++ /dev/null @@ -1,13 +0,0 @@ - -terraform { - required_version = ">=0.12" - - required_providers { - guance = { - source = "GuanceCloud/guance" - } - } -} - -provider "guance" { -} diff --git a/examples/pipeline/README.md b/examples/pipeline/README.md index 4948cb9..8ae69a2 100644 --- a/examples/pipeline/README.md +++ b/examples/pipeline/README.md @@ -5,59 +5,4 @@ formats of log data. By writing a pipeline script, you can customize the structure of the log and use the cut fields as attributes. -By cutting out the attribute fields, we can quickly filter the relevant logs and perform data association analysis to -help us quickly locate and solve problems. - -## Create - -The first let me create a resource. We will send the create operation to the resource management service - -```terraform -resource "guance_pipeline" "demo" { - name = "oac-demo" - category = "logging" - source = [ - "nginx" - ] - is_default = false - is_force = false - - content = < B[Member] +``` + +## Example Usage + +```terraform +variable "email" { + type = string +} + +data "guance_members" "demo" { + search = var.email +} + +output "member" { + value = data.guance_members.demo.members +} ``` \ No newline at end of file diff --git a/internal/datasources/members/datasource.go b/internal/datasources/members/datasource.go index eccbccf..4315e6c 100644 --- a/internal/datasources/members/datasource.go +++ b/internal/datasources/members/datasource.go @@ -1,5 +1,3 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - package members import ( @@ -7,13 +5,11 @@ import ( _ "embed" "fmt" - "github.com/hashicorp/go-multierror" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" - "github.com/GuanceCloud/terraform-provider-guance/internal/consts" - "github.com/GuanceCloud/terraform-provider-guance/internal/helpers/tfcodec" - "github.com/GuanceCloud/terraform-provider-guance/internal/sdk" + "github.com/GuanceCloud/terraform-provider-guance/internal/api" ) //go:embed README.md @@ -32,7 +28,7 @@ func NewMembersDataSource() datasource.DataSource { // membersDataSource is the data source implementation. type membersDataSource struct { - client *sdk.Client[sdk.Resource] + client *api.Client } // Metadata returns the data source type name. @@ -51,22 +47,20 @@ func (d *membersDataSource) Configure(_ context.Context, req datasource.Configur return } - d.client = req.ProviderData.(*sdk.Client[sdk.Resource]) + d.client = req.ProviderData.(*api.Client) } // Read refreshes the Terraform state with the latest data. func (d *membersDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { var state memberDataSourceModel + diags := req.Config.Get(ctx, &state) resp.Diagnostics.Append(diags...) if resp.Diagnostics.HasError() { return } - results, err := d.client.List(ctx, &sdk.ListOptions{ - MaxResults: state.MaxResults.ValueInt64(), - TypeName: consts.TypeNameMember, - }) + results, err := d.client.ReadMember(state.Search.ValueString()) if err != nil { resp.Diagnostics.AddError( "Unable to List", @@ -75,32 +69,25 @@ func (d *membersDataSource) Read(ctx context.Context, req datasource.ReadRequest return } - var mErr error - var items []*memberResourceModel - for _, rd := range results.ResourceDescriptions { - if !sdk.FilterAllSuccess(rd.Properties, state.Filters...) { - continue - } + state.Members = make([]memberResourceModel, 0) - item := &memberResourceModel{} - if err := tfcodec.DecodeJSON([]byte(rd.Properties), item); err != nil { - mErr = multierror.Append(mErr, fmt.Errorf("unable to decode properties: %w", err)) - continue + for _, member := range results { + m := memberResourceModel{ + CreateAt: types.StringValue(fmt.Sprintf("%d", member.CreateAt)), + Email: types.StringValue(member.Email), + Name: types.StringValue(member.Name), + UUID: types.StringValue(member.UUID), } - item.SetId(rd.Identifier) - item.SetCreatedAt(rd.CreatedAt) - items = append(items, item) - } - if mErr != nil { - resp.Diagnostics.AddError( - "Unable to List resources", - mErr.Error(), - ) - return + for _, r := range member.Roles { + m.Roles = append(m.Roles, roleModel{ + Name: types.StringValue(r.Name), + UUID: types.StringValue(r.UUID), + }) + } + tflog.Info(ctx, "member", map[string]interface{}{"member": member}) + state.Members = append(state.Members, m) } - state.Items = items - state.ID = types.StringValue("placeholder") // Set state diags = resp.State.Set(ctx, &state) diff --git a/internal/datasources/members/model.go b/internal/datasources/members/model.go index 19bba5d..77da5c5 100644 --- a/internal/datasources/members/model.go +++ b/internal/datasources/members/model.go @@ -1,44 +1,26 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - package members import ( "github.com/hashicorp/terraform-plugin-framework/types" - - "github.com/GuanceCloud/terraform-provider-guance/internal/consts" - "github.com/GuanceCloud/terraform-provider-guance/internal/sdk" ) // memberResourceModel maps the resource schema data. type memberResourceModel struct { - ID types.String `tfsdk:"id"` - CreatedAt types.String `tfsdk:"created_at"` - Email types.String `tfsdk:"email"` - Role types.String `tfsdk:"role"` -} - -// GetId returns the ID of the resource. -func (m *memberResourceModel) GetId() string { - return m.ID.ValueString() -} - -// SetId sets the ID of the resource. -func (m *memberResourceModel) SetId(id string) { - m.ID = types.StringValue(id) + ID types.String `tfsdk:"id"` + UUID types.String `tfsdk:"uuid"` + CreateAt types.String `tfsdk:"create_at"` + Email types.String `tfsdk:"email"` + Roles []roleModel `tfsdk:"roles"` + Name types.String `tfsdk:"name"` } -// GetResourceType returns the type of the resource. -func (m *memberResourceModel) GetResourceType() string { - return consts.TypeNameMember +type roleModel struct { + Name types.String `tfsdk:"name"` + UUID types.String `tfsdk:"uuid"` } -// SetCreatedAt sets the creation time of the resource. -func (m *memberResourceModel) SetCreatedAt(t string) { - m.CreatedAt = types.StringValue(t) -} // memberDataSourceModel maps the resource schema data. +// memberDataSourceModel maps the resource schema data. type memberDataSourceModel struct { - Items []*memberResourceModel `tfsdk:"items"` - Filters []*sdk.Filter `tfsdk:"filters"` - MaxResults types.Int64 `tfsdk:"max_results"` - ID types.String `tfsdk:"id"` + Members []memberResourceModel `tfsdk:"members"` + Search types.String `tfsdk:"search"` } diff --git a/internal/datasources/members/schema.go b/internal/datasources/members/schema.go index 3d259f5..989e00d 100644 --- a/internal/datasources/members/schema.go +++ b/internal/datasources/members/schema.go @@ -1,59 +1,29 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - package members import ( - "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" - "github.com/hashicorp/terraform-plugin-framework/schema/validator" - "github.com/hashicorp/terraform-plugin-framework/types" ) var dataSourceSchema = schema.Schema{ Description: "Workspace Member", MarkdownDescription: resourceDocument, Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Description: "The hasd id of the resource.", - Computed: true, - }, - - "max_results": schema.Int64Attribute{ - Description: "The max results count of the resource will be returned.", + "search": schema.StringAttribute{ + Description: "Search the member by email or name.", Optional: true, }, - - "filters": schema.ListNestedAttribute{ - Description: "The list of the resource", - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: map[string]schema.Attribute{ - "name": schema.StringAttribute{ - Description: "The filter path, represent as json path.", - Required: true, - }, - - "values": schema.ListAttribute{ - ElementType: types.StringType, - Required: true, - Description: "The filter values", - }, - }, - }, - }, - - "items": schema.ListNestedAttribute{ - Description: "The list of the resource", + "members": schema.ListNestedAttribute{ + Description: "The list of the members.", Computed: true, NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Description: "The Guance Resource Name (GRN) of cloud resource.", + "uuid": schema.StringAttribute{ + Description: "The uuid of the member.", Computed: true, }, - "created_at": schema.StringAttribute{ - Description: "The RFC3339/ISO8601 time string of resource created at.", + "create_at": schema.StringAttribute{ + Description: "The unix timestamp in seconds of the member creation.", Computed: true, }, @@ -62,22 +32,35 @@ var dataSourceSchema = schema.Schema{ Optional: true, }, - - "role": schema.StringAttribute{ - Description: "Role", - - MarkdownDescription: ` - Role, value must be one of: *owner*, *wsAdmin*, *general*, *readOnly*, other value will be ignored. - `, + "name": schema.StringAttribute{ + Description: "User name", Optional: true, - - Validators: []validator.String{ - stringvalidator.OneOf("owner", "wsAdmin", "general", "readOnly"), - }, }, + "roles": roleAttribute, }, }, }, }, } + +var roleAttribute = schema.ListNestedAttribute{ + Description: "Role", + + MarkdownDescription: ` + Role, value must be one of: *owner*, *wsAdmin*, *general*, *readOnly*, other value will be ignored. + `, + Optional: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "name": schema.StringAttribute{ + Optional: true, + Description: "The name of the role.", + }, + "uuid": schema.StringAttribute{ + Optional: true, + Description: "The UUID of the role.", + }, + }, + }, +} diff --git a/internal/datasources/permissions/README.md b/internal/datasources/permissions/README.md new file mode 100644 index 0000000..5957349 --- /dev/null +++ b/internal/datasources/permissions/README.md @@ -0,0 +1,15 @@ +A role permission is defined to grant a user permission to perform a specific action on a specific resource. + +Guance Cloud supports a number of different role permissions, and you can create new roles for users and assign permission scopes to roles to meet the permission needs of your organization. + + +## Example Usage + +```terraform +data "guance_permissions" "demo" { +} + +output "permissions" { + value = data.guance_permissions.demo +} +``` \ No newline at end of file diff --git a/internal/datasources/permissions/datasource.go b/internal/datasources/permissions/datasource.go new file mode 100644 index 0000000..b74f7ca --- /dev/null +++ b/internal/datasources/permissions/datasource.go @@ -0,0 +1,110 @@ +package permissions + +import ( + "context" + _ "embed" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/types" + + "github.com/GuanceCloud/terraform-provider-guance/internal/api" +) + +//go:embed README.md +var resourceDocument string + +// Ensure the implementation satisfies the expected interfaces. +var ( + _ datasource.DataSource = &permissionsDataSource{} + _ datasource.DataSourceWithConfigure = &permissionsDataSource{} +) + +// NewPermissionsDataSource is a helper function to simplify the provider implementation. +func NewPermissionsDataSource() datasource.DataSource { + return &permissionsDataSource{} +} + +// permissionsDataSource is the data source implementation. +type permissionsDataSource struct { + client *api.Client +} + +// Metadata returns the data source type name. +func (d *permissionsDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_permissions" +} + +// Schema defines the schema for the data source. +func (d *permissionsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = dataSourceSchema +} + +// Configure adds the provider configured client to the data source. +func (d *permissionsDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, _ *datasource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + + d.client = req.ProviderData.(*api.Client) +} + +// Read refreshes the Terraform state with the latest data. +func (d *permissionsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var state permissionDataSourceModel + + diags := req.Config.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + results, err := d.client.ReadPermission(state.IsSupportCustomRole.ValueBool()) + if err != nil { + resp.Diagnostics.AddError( + "Unable to List", + err.Error(), + ) + return + } + + state.Permissions = make([]permissionResourceModel, 0) + + for _, p := range results { + m := permissionResourceModel{ + Desc: types.StringValue(p.Desc), + Disabled: types.Int64Value(int64(p.Disabled)), + IsSupportCustomRole: types.Int64Value(int64(p.IsSupportCustomRole)), + IsSupportGeneral: types.Int64Value(int64(p.IsSupportGeneral)), + IsSupportOwner: types.Int64Value(int64(p.IsSupportOwner)), + IsSupportReadOnly: types.Int64Value(int64(p.IsSupportReadOnly)), + IsSupportWsAdmin: types.Int64Value(int64(p.IsSupportWsAdmin)), + Key: types.StringValue(p.Key), + Name: types.StringValue(p.Name), + } + m.Subs = make([]*permissionSubResourceModel, 0) + + for _, s := range p.Subs { + sub := permissionSubResourceModel{ + Desc: types.StringValue(s.Desc), + Disabled: types.Int64Value(int64(s.Disabled)), + IsSupportCustomRole: types.Int64Value(int64(s.IsSupportCustomRole)), + IsSupportGeneral: types.Int64Value(int64(s.IsSupportGeneral)), + IsSupportOwner: types.Int64Value(int64(s.IsSupportOwner)), + IsSupportReadOnly: types.Int64Value(int64(s.IsSupportReadOnly)), + IsSupportWsAdmin: types.Int64Value(int64(s.IsSupportWsAdmin)), + Key: types.StringValue(s.Key), + Name: types.StringValue(s.Name), + } + m.Subs = append(m.Subs, &sub) + } + + state.Permissions = append(state.Permissions, m) + } + + // Set state + diags = resp.State.Set(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } +} diff --git a/internal/datasources/permissions/model.go b/internal/datasources/permissions/model.go new file mode 100644 index 0000000..3ad6438 --- /dev/null +++ b/internal/datasources/permissions/model.go @@ -0,0 +1,37 @@ +package permissions + +import ( + "github.com/hashicorp/terraform-plugin-framework/types" +) + +type permissionSubResourceModel struct { + Desc types.String `tfsdk:"desc"` + Disabled types.Int64 `tfsdk:"disabled"` + IsSupportCustomRole types.Int64 `tfsdk:"is_support_custom_role"` + IsSupportGeneral types.Int64 `tfsdk:"is_support_general"` + IsSupportOwner types.Int64 `tfsdk:"is_support_owner"` + IsSupportReadOnly types.Int64 `tfsdk:"is_support_read_only"` + IsSupportWsAdmin types.Int64 `tfsdk:"is_support_ws_admin"` + Key types.String `tfsdk:"key"` + Name types.String `tfsdk:"name"` +} + +// permissionResourceModel maps the resource schema data. +type permissionResourceModel struct { + Desc types.String `tfsdk:"desc"` + Disabled types.Int64 `tfsdk:"disabled"` + IsSupportCustomRole types.Int64 `tfsdk:"is_support_custom_role"` + IsSupportGeneral types.Int64 `tfsdk:"is_support_general"` + IsSupportOwner types.Int64 `tfsdk:"is_support_owner"` + IsSupportReadOnly types.Int64 `tfsdk:"is_support_read_only"` + IsSupportWsAdmin types.Int64 `tfsdk:"is_support_ws_admin"` + Key types.String `tfsdk:"key"` + Name types.String `tfsdk:"name"` + Subs []*permissionSubResourceModel `tfsdk:"subs"` +} + +// permissionDataSourceModel maps the resource schema data. +type permissionDataSourceModel struct { + Permissions []permissionResourceModel `tfsdk:"permissions"` + IsSupportCustomRole types.Bool `tfsdk:"is_support_custom_role"` +} diff --git a/internal/datasources/permissions/schema.go b/internal/datasources/permissions/schema.go new file mode 100644 index 0000000..8650ff6 --- /dev/null +++ b/internal/datasources/permissions/schema.go @@ -0,0 +1,107 @@ +package permissions + +import ( + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" +) + +var dataSourceSchema = schema.Schema{ + Description: "Role permissions", + MarkdownDescription: resourceDocument, + Attributes: map[string]schema.Attribute{ + "is_support_custom_role": schema.BoolAttribute{ + Description: "Filter the permission list that supports custom role.", + Optional: true, + }, + "permissions": schema.ListNestedAttribute{ + Description: "The list of the permissions.", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: permissionAttribute, + }, + }, + }, +} + +var permissionAttribute = map[string]schema.Attribute{ + "desc": schema.StringAttribute{ + Description: "The description of the permission.", + Computed: true, + }, + "disabled": schema.Int64Attribute{ + Description: "The disabled status of the permission.", + Computed: true, + }, + + "is_support_custom_role": schema.Int64Attribute{ + Description: "Whether support custom role.", + Computed: true, + }, + "is_support_general": schema.Int64Attribute{ + Description: "Whether support general.", + Computed: true, + }, + "is_support_owner": schema.Int64Attribute{ + Description: "Whether support owner.", + Computed: true, + }, + "is_support_read_only": schema.Int64Attribute{ + Description: "Whether support readonly.", + Computed: true, + }, + "is_support_ws_admin": schema.Int64Attribute{ + Description: "Whether support WsAdmin.", + Computed: true, + }, + "key": schema.StringAttribute{ + Description: "The key of the permission.", + Computed: true, + }, + "name": schema.StringAttribute{ + Description: "The name of the permission.", + Computed: true, + }, + "subs": schema.ListNestedAttribute{ + Description: "The list of the sub permissions.", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "desc": schema.StringAttribute{ + Description: "The description of the permission.", + Computed: true, + }, + "disabled": schema.Int64Attribute{ + Description: "The disabled status of the permission.", + Computed: true, + }, + "is_support_custom_role": schema.Int64Attribute{ + Description: "Whether support custom role.", + Computed: true, + }, + "is_support_general": schema.Int64Attribute{ + Description: "Whether support general.", + Computed: true, + }, + "is_support_owner": schema.Int64Attribute{ + Description: "Whether support owner.", + Computed: true, + }, + "is_support_read_only": schema.Int64Attribute{ + Description: "Whether support readonly.", + Computed: true, + }, + "is_support_ws_admin": schema.Int64Attribute{ + Description: "Whether support WsAdmin.", + Computed: true, + }, + "key": schema.StringAttribute{ + Description: "The key of the permission.", + Computed: true, + }, + "name": schema.StringAttribute{ + Description: "The name of the permission.", + Computed: true, + }, + }, + }, + }, +} diff --git a/internal/resources/alertpolicy/README.md b/internal/resources/alertpolicy/README.md deleted file mode 100644 index 859bb3f..0000000 --- a/internal/resources/alertpolicy/README.md +++ /dev/null @@ -1,94 +0,0 @@ -# Alert Policy - -Alert policy is a set of rules that define when to trigger an alert. You can create alert policies for your data -sources, and set up alert targets to receive alerts. - -Guance Cloud supports alert policy management for the results of monitor checks, by sending alert notification emails or -group message notifications, so that you can know about the abnormal data situation of the monitoring in time, find -problems, and solve problems. - -Relationships: - -```mermaid -graph LR - -A[Monitor] --> B[Alert Policy] --> C[Notification] -``` - -Notes: - -1. When a monitor is created, an alert policy must be selected, and the default is selected by default; -2. When a certain alert policy is deleted, the monitor under the deleted alert policy will automatically be classified - into the default. - -## Create - -The first let me create a resource. We will send the create operation to the resource management service - -```terraform -variable "ding_talk_webhook" { - type = string -} - -variable "ding_talk_secret" { - type = string -} - -variable "email" { - type = string -} - -data "guance_members" "demo" { - filters = [ - { - name = "email" - values = [var.email] - } - ] -} - -resource "guance_membergroup" "demo" { - name = "oac-demo" - member_ids = data.guance_members.demo.items[*].id -} - -resource "guance_notification" "demo" { - name = "oac-demo" - type = "ding_talk_robot" - ding_talk_robot = { - webhook = var.ding_talk_webhook - secret = var.ding_talk_secret - } -} - -resource "guance_alertpolicy" "demo" { - name = "oac-demo" - silent_timeout = "1h" - - statuses = [ - "critical", - "error", - "warning", - "info", - "ok", - "nodata", - "nodata_ok", - "nodata_as_ok", - ] - - alert_targets = [ - { - type = "member_group" - member_group = { - id = guance_membergroup.demo.id - } - }, - { - type = "notification" - notification = { - id = guance_notification.demo.id - } - } - ] -} -``` diff --git a/internal/resources/alertpolicy/model.go b/internal/resources/alertpolicy/model.go deleted file mode 100644 index 143ada3..0000000 --- a/internal/resources/alertpolicy/model.go +++ /dev/null @@ -1,56 +0,0 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - -package alertpolicy - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" - - "github.com/GuanceCloud/terraform-provider-guance/internal/consts" -) - -// alertPolicyResourceModel maps the resource schema data. -type alertPolicyResourceModel struct { - ID types.String `tfsdk:"id"` - CreatedAt types.String `tfsdk:"created_at"` - Name types.String `tfsdk:"name"` - SilentTimeout types.String `tfsdk:"silent_timeout"` - Statuses []types.String `tfsdk:"statuses"` - AlertTargets []*AlertTarget `tfsdk:"alert_targets"` -} - -// GetId returns the ID of the resource. -func (m *alertPolicyResourceModel) GetId() string { - return m.ID.ValueString() -} - -// SetId sets the ID of the resource. -func (m *alertPolicyResourceModel) SetId(id string) { - m.ID = types.StringValue(id) -} - -// GetResourceType returns the type of the resource. -func (m *alertPolicyResourceModel) GetResourceType() string { - return consts.TypeNameAlertPolicy -} - -// SetCreatedAt sets the creation time of the resource. -func (m *alertPolicyResourceModel) SetCreatedAt(t string) { - m.CreatedAt = types.StringValue(t) -} - -// AlertTarget maps the resource schema data. -type AlertTarget struct { - Type types.String `tfsdk:"type"` - Notification *TargetNotification `tfsdk:"notification"` - MemberGroup *TargetMemberGroup `tfsdk:"member_group"` -} - -// TargetMemberGroup maps the resource schema data. -type TargetMemberGroup struct { - Id types.String `tfsdk:"id"` -} - -// TargetNotification maps the resource schema data. -type TargetNotification struct { - Id types.String `tfsdk:"id"` -} diff --git a/internal/resources/alertpolicy/resource.go b/internal/resources/alertpolicy/resource.go deleted file mode 100644 index 27f3368..0000000 --- a/internal/resources/alertpolicy/resource.go +++ /dev/null @@ -1,162 +0,0 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - -package alertpolicy - -import ( - "context" - _ "embed" - - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/resource" - - "github.com/GuanceCloud/terraform-provider-guance/internal/sdk" -) - -//go:embed README.md -var resourceDocument string - -// Ensure the implementation satisfies the expected interfaces. -var ( - _ resource.Resource = &alertPolicyResource{} - _ resource.ResourceWithConfigure = &alertPolicyResource{} - _ resource.ResourceWithImportState = &alertPolicyResource{} -) - -// NewAlertPolicyResource is -func NewAlertPolicyResource() resource.Resource { - return &alertPolicyResource{} -} - -// alertPolicyResource is the resource implementation. -type alertPolicyResource struct { - client *sdk.Client[sdk.Resource] -} - -// Schema defines the schema for the data source. -func (r *alertPolicyResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { - resp.Schema = resourceSchema -} - -// Configure adds the provider configured client to the data source. -func (r *alertPolicyResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { - if req.ProviderData == nil { - return - } - r.client = req.ProviderData.(*sdk.Client[sdk.Resource]) -} - -// Metadata returns the data source type name. -func (r *alertPolicyResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_alertpolicy" -} - -// Create creates the resource and sets the initial Terraform state. -func (r *alertPolicyResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - // Retrieve values from plan - var plan alertPolicyResourceModel - diags := req.Plan.Get(ctx, &plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - if err := r.client.Create(ctx, &plan); err != nil { - resp.Diagnostics.AddError( - "Error creating alertPolicy", - "Could not create alertPolicy, unexpected error: "+err.Error(), - ) - return - } - - if err := r.client.Read(ctx, &plan); err != nil { - resp.Diagnostics.AddError( - "Error creating alertPolicy", - "Could not create alertPolicy, unexpected error: "+err.Error(), - ) - return - } - - // Set state to fully populated data - diags = resp.State.Set(ctx, plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } -} - -// Read refreshes the Terraform state with the latest data. -func (r *alertPolicyResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - // Get current state - var state alertPolicyResourceModel - diags := req.State.Get(ctx, &state) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - if err := r.client.Read(ctx, &state); err != nil { - resp.Diagnostics.AddError( - "Error reading alertPolicy", - "Could not read alertPolicy, unexpected error: "+err.Error(), - ) - return - } - - // Set refreshed state - diags = resp.State.Set(ctx, &state) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } -} - -// Update updates the resource and sets the updated Terraform state on success. -func (r *alertPolicyResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - // Retrieve values from plan - var plan alertPolicyResourceModel - diags := req.Plan.Get(ctx, &plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - if err := r.client.Read(ctx, &plan); err != nil { - resp.Diagnostics.AddError( - "Error creating alertPolicy", - "Could not create alertPolicy, unexpected error: "+err.Error(), - ) - return - } - - // Set state to fully populated data - diags = resp.State.Set(ctx, plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } -} - -// Delete deletes the resource and removes the Terraform state on success. -func (r *alertPolicyResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - // Retrieve values from state - var state alertPolicyResourceModel - diags := req.State.Get(ctx, &state) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - // Delete existing alertPolicy - if err := r.client.Delete(ctx, &state); err != nil { - resp.Diagnostics.AddError( - "Error deleting alertPolicy", - "Could not delete alertPolicy, unexpected error: "+err.Error(), - ) - return - } -} - -func (r *alertPolicyResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - // Retrieve import ID and save to id attribute - resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) -} diff --git a/internal/resources/alertpolicy/schema.go b/internal/resources/alertpolicy/schema.go deleted file mode 100644 index 03a622c..0000000 --- a/internal/resources/alertpolicy/schema.go +++ /dev/null @@ -1,125 +0,0 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - -package alertpolicy - -import ( - "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/schema/validator" - "github.com/hashicorp/terraform-plugin-framework/types" -) - -var resourceSchema = schema.Schema{ - Description: "Alert Policy", - MarkdownDescription: resourceDocument, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Description: "The Guance Resource Name (GRN) of cloud resource.", - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, - }, - - "created_at": schema.StringAttribute{ - Description: "The RFC3339/ISO8601 time string of resource created at.", - Computed: true, - }, - - "name": schema.StringAttribute{ - Description: "Alert Policy Name", - - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - - "silent_timeout": schema.StringAttribute{ - Description: "Silent timeout timestamp", - - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - - "statuses": schema.ListAttribute{ - Description: "The status value of the event to be sent", - - Required: true, - ElementType: types.StringType, - PlanModifiers: []planmodifier.List{ - listplanmodifier.RequiresReplace(), - }, - }, - - "alert_targets": schema.ListNestedAttribute{ - Description: "Alert Action", - - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: schemaAlertTarget, - }, - }, - }, -} - -// schemaAlertTarget maps the resource schema data. -var schemaAlertTarget = map[string]schema.Attribute{ - "type": schema.StringAttribute{ - Description: "Alert type", - - MarkdownDescription: ` - Alert type, value must be one of: *member_group*, *notification*, other value will be ignored. - `, - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Validators: []validator.String{ - stringvalidator.OneOf("member_group", "notification"), - }, - }, - - "notification": schema.SingleNestedAttribute{ - Description: "Notification", - - Optional: true, - Attributes: schemaTargetNotification, - }, - - "member_group": schema.SingleNestedAttribute{ - Description: "Member Group", - - Optional: true, - Attributes: schemaTargetMemberGroup, - }, -} - -// schemaTargetMemberGroup maps the resource schema data. -var schemaTargetMemberGroup = map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Description: "Member Group", - - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, -} - -// schemaTargetNotification maps the resource schema data. -var schemaTargetNotification = map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Description: "Notification", - - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, -} diff --git a/internal/resources/blacklist/README.md b/internal/resources/blacklist/README.md index b68231b..83f2e7d 100644 --- a/internal/resources/blacklist/README.md +++ b/internal/resources/blacklist/README.md @@ -5,24 +5,20 @@ Guance Cloud supports filtering data that meets the conditions by setting a blac After configuring the blacklist, the data that meets the conditions will no longer be reported to the Guance Cloud workspace, helping you save data storage costs. -## Create - -The first let me create a resource. We will send the create operation to the resource management service +## Example Usage ```terraform resource "guance_blacklist" "demo" { - source = { - type = "logging" - name = "nginx" - } + type = "logging" + source = "mysql" - filter_rules = [ + filters = [ { - name = "foo" + name = "foo1" operation = "in" condition = "and" values = ["oac-*"] } ] } -``` +``` \ No newline at end of file diff --git a/internal/resources/blacklist/model.go b/internal/resources/blacklist/model.go index 7b1457d..953ac1e 100644 --- a/internal/resources/blacklist/model.go +++ b/internal/resources/blacklist/model.go @@ -1,51 +1,22 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - package blacklist import ( "github.com/hashicorp/terraform-plugin-framework/types" - - "github.com/GuanceCloud/terraform-provider-guance/internal/consts" ) // blackListResourceModel maps the resource schema data. type blackListResourceModel struct { - ID types.String `tfsdk:"id"` - CreatedAt types.String `tfsdk:"created_at"` - Source *Source `tfsdk:"source"` - FilterRules []*Filter `tfsdk:"filter_rules"` -} - -// GetId returns the ID of the resource. -func (m *blackListResourceModel) GetId() string { - return m.ID.ValueString() -} - -// SetId sets the ID of the resource. -func (m *blackListResourceModel) SetId(id string) { - m.ID = types.StringValue(id) + UUID types.String `tfsdk:"uuid"` + CreatedAt types.String `tfsdk:"created_at"` + Source types.String `tfsdk:"source"` + Type types.String `tfsdk:"type"` + Filters []*filter `tfsdk:"filters"` } -// GetResourceType returns the type of the resource. -func (m *blackListResourceModel) GetResourceType() string { - return consts.TypeNameBlackList -} - -// SetCreatedAt sets the creation time of the resource. -func (m *blackListResourceModel) SetCreatedAt(t string) { - m.CreatedAt = types.StringValue(t) -} - -// Filter maps the resource schema data. -type Filter struct { +// filter maps the resource schema data. +type filter struct { Name types.String `tfsdk:"name"` Operation types.String `tfsdk:"operation"` Condition types.String `tfsdk:"condition"` Values []types.String `tfsdk:"values"` } - -// Source maps the resource schema data. -type Source struct { - Type types.String `tfsdk:"type"` - Name types.String `tfsdk:"name"` -} diff --git a/internal/resources/blacklist/resource.go b/internal/resources/blacklist/resource.go index a398d69..8b86b31 100644 --- a/internal/resources/blacklist/resource.go +++ b/internal/resources/blacklist/resource.go @@ -1,15 +1,16 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - package blacklist import ( "context" _ "embed" + "fmt" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/GuanceCloud/terraform-provider-guance/internal/sdk" + "github.com/GuanceCloud/terraform-provider-guance/internal/api" + "github.com/GuanceCloud/terraform-provider-guance/internal/consts" ) //go:embed README.md @@ -29,7 +30,7 @@ func NewBlackListResource() resource.Resource { // blackListResource is the resource implementation. type blackListResource struct { - client *sdk.Client[sdk.Resource] + client *api.Client } // Schema defines the schema for the data source. @@ -42,7 +43,7 @@ func (r *blackListResource) Configure(_ context.Context, req resource.ConfigureR if req.ProviderData == nil { return } - r.client = req.ProviderData.(*sdk.Client[sdk.Resource]) + r.client = req.ProviderData.(*api.Client) } // Metadata returns the data source type name. @@ -60,7 +61,10 @@ func (r *blackListResource) Create(ctx context.Context, req resource.CreateReque return } - if err := r.client.Create(ctx, &plan); err != nil { + item := r.getBlacklistFromPlan(&plan) + content := &api.Blacklist{} + err := r.client.Create(consts.TypeNameBlackList, item, content) + if err != nil { resp.Diagnostics.AddError( "Error creating blackList", "Could not create blackList, unexpected error: "+err.Error(), @@ -68,13 +72,8 @@ func (r *blackListResource) Create(ctx context.Context, req resource.CreateReque return } - if err := r.client.Read(ctx, &plan); err != nil { - resp.Diagnostics.AddError( - "Error creating blackList", - "Could not create blackList, unexpected error: "+err.Error(), - ) - return - } + plan.UUID = types.StringValue(content.UUID) + plan.CreatedAt = types.StringValue(fmt.Sprintf("%d", content.CreateAt)) // Set state to fully populated data diags = resp.State.Set(ctx, plan) @@ -94,14 +93,39 @@ func (r *blackListResource) Read(ctx context.Context, req resource.ReadRequest, return } - if err := r.client.Read(ctx, &state); err != nil { + content := &api.Blacklist{} + err := r.client.Read(consts.TypeNameBlackList, state.UUID.ValueString(), content) + if err != nil { + if err == api.Error404 { + resp.State.RemoveResource(ctx) + return + } resp.Diagnostics.AddError( - "Error reading blackList", - "Could not read blackList, unexpected error: "+err.Error(), + "Error reading blacklist", + "Could not read blacklist, unexpected error: "+err.Error(), ) return } + state.CreatedAt = types.StringValue(fmt.Sprintf("%d", content.CreateAt)) + state.UUID = types.StringValue(content.UUID) + state.Source = types.StringValue(content.Source) + state.Type = types.StringValue(content.Type) + state.Filters = make([]*filter, 0) + for _, item := range content.Filters { + f := &filter{ + Name: types.StringValue(item.Name), + Condition: types.StringValue(item.Condition), + Operation: types.StringValue(item.Operation), + } + + for _, value := range item.Value { + f.Values = append(f.Values, types.StringValue(value)) + } + + state.Filters = append(state.Filters, f) + } + // Set refreshed state diags = resp.State.Set(ctx, &state) resp.Diagnostics.Append(diags...) @@ -120,10 +144,15 @@ func (r *blackListResource) Update(ctx context.Context, req resource.UpdateReque return } - if err := r.client.Read(ctx, &plan); err != nil { + item := r.getBlacklistFromPlan(&plan) + item.UUID = plan.UUID.ValueString() + body := &api.Blacklist{} + err := r.client.Update(consts.TypeNameBlackList, item.UUID, item, body) + + if err != nil { resp.Diagnostics.AddError( - "Error creating blackList", - "Could not create blackList, unexpected error: "+err.Error(), + "Error updating blacklist", + "Could not update blacklist, unexpected error: "+err.Error(), ) return } @@ -146,8 +175,8 @@ func (r *blackListResource) Delete(ctx context.Context, req resource.DeleteReque return } - // Delete existing blackList - if err := r.client.Delete(ctx, &state); err != nil { + //Delete existing blackList + if err := r.client.Delete(consts.TypeNameBlackList, state.UUID.ValueString()); err != nil { resp.Diagnostics.AddError( "Error deleting blackList", "Could not delete blackList, unexpected error: "+err.Error(), @@ -158,5 +187,32 @@ func (r *blackListResource) Delete(ctx context.Context, req resource.DeleteReque func (r *blackListResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { // Retrieve import ID and save to id attribute - resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + resource.ImportStatePassthroughID(ctx, path.Root("uuid"), req, resp) +} + +func (r *blackListResource) getBlacklistFromPlan(plan *blackListResourceModel) *api.Blacklist { + item := &api.Blacklist{ + Type: plan.Type.ValueString(), + Source: plan.Source.ValueString(), + } + + if len(plan.Filters) > 0 { + filters := []api.Filter{} + for _, filter := range plan.Filters { + f := api.Filter{ + Name: filter.Name.ValueString(), + Condition: filter.Condition.ValueString(), + Operation: filter.Operation.ValueString(), + } + + for _, value := range filter.Values { + f.Value = append(f.Value, value.ValueString()) + } + + filters = append(filters, f) + } + item.Filters = filters + } + + return item } diff --git a/internal/resources/blacklist/schema.go b/internal/resources/blacklist/schema.go index c3cdcfb..6c51d0b 100644 --- a/internal/resources/blacklist/schema.go +++ b/internal/resources/blacklist/schema.go @@ -1,5 +1,3 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - package blacklist import ( @@ -16,8 +14,8 @@ var resourceSchema = schema.Schema{ Description: "BlackList", MarkdownDescription: resourceDocument, Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Description: "The Guance Resource Name (GRN) of cloud resource.", + "uuid": schema.StringAttribute{ + Description: "The uuid of resource.", Computed: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), @@ -25,21 +23,24 @@ var resourceSchema = schema.Schema{ }, "created_at": schema.StringAttribute{ - Description: "The RFC3339/ISO8601 time string of resource created at.", + Description: "The timestamp seconds of the resource created at.", Computed: true, }, - "source": schema.SingleNestedAttribute{ - Description: "Source", - - Required: true, - Attributes: schemaSource, + "source": schema.StringAttribute{ + Description: "The source of the resource.", + Required: true, }, - - "filter_rules": schema.ListNestedAttribute{ - Description: "Filters", - - Optional: true, + "type": schema.StringAttribute{ + Description: "The type of the resource.", + Required: true, + Validators: []validator.String{ + stringvalidator.OneOf("object", "custom_object", "logging", "keyevent", "tracing", "rum", "network", "security", "profiling", "metric"), + }, + }, + "filters": schema.ListNestedAttribute{ + Description: "The filters of the resource.", + Optional: true, NestedObject: schema.NestedAttributeObject{ Attributes: schemaFilter, }, @@ -50,7 +51,7 @@ var resourceSchema = schema.Schema{ // schemaFilter maps the resource schema data. var schemaFilter = map[string]schema.Attribute{ "name": schema.StringAttribute{ - Description: "Name", + Description: "The name of the filter.", Required: true, PlanModifiers: []planmodifier.String{ @@ -59,8 +60,7 @@ var schemaFilter = map[string]schema.Attribute{ }, "operation": schema.StringAttribute{ - Description: "Operation", - + Description: "The operation of the filter.", MarkdownDescription: ` Operation, value must be one of: *in*, *not in*, *match*, *not match*, other value will be ignored. `, @@ -74,17 +74,15 @@ var schemaFilter = map[string]schema.Attribute{ }, "condition": schema.StringAttribute{ - Description: "Condition, represented by DQL", - - Required: true, + Description: "The condition of the filter.", + Required: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplace(), }, }, "values": schema.ListAttribute{ - Description: "Values", - + Description: "The values of the filter.", Optional: true, ElementType: types.StringType, PlanModifiers: []planmodifier.List{ @@ -92,30 +90,3 @@ var schemaFilter = map[string]schema.Attribute{ }, }, } - -// schemaSource maps the resource schema data. -var schemaSource = map[string]schema.Attribute{ - "type": schema.StringAttribute{ - Description: "Source Type", - - MarkdownDescription: ` - Source Type, value must be one of: *logging*, *object*, *custom_object*, *network*, *tracing*, *rum*, *security*, *keyevent*, *metric*, other value will be ignored. - `, - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Validators: []validator.String{ - stringvalidator.OneOf("logging", "object", "custom_object", "network", "tracing", "rum", "security", "keyevent", "metric"), - }, - }, - - "name": schema.StringAttribute{ - Description: "Source", - - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, -} diff --git a/internal/resources/dashboard/README.md b/internal/resources/dashboard/README.md deleted file mode 100644 index 476445b..0000000 --- a/internal/resources/dashboard/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# Dashboard - -A dashboard is a collection of visualizations that you can use to monitor the health of your systems and applications. -Dashboards are made up of one or more panels, which are the visualizations themselves. Each panel displays a single -metric or a single aggregation of metrics. - -Dashboards are a great way to visualize your data and monitor your systems. You can use them to track metrics over time, -and to quickly see how your systems are performing. You can also use them to compare metrics from different systems and -applications. - -Guance Cloud's dashboard is used to clearly show the range in which the metric data values are located. It is suitable -for slicing messy data into points. - -## Create - -The first let me create a resource. We will send the create operation to the resource management service - -```terraform -resource "guance_dashboard" "demo" { - name = "oac-demo" - manifest = file("${path.module}/dashboard.json") -} -``` diff --git a/internal/resources/dashboard/model.go b/internal/resources/dashboard/model.go deleted file mode 100644 index 4a8af1f..0000000 --- a/internal/resources/dashboard/model.go +++ /dev/null @@ -1,37 +0,0 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - -package dashboard - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" - - "github.com/GuanceCloud/terraform-provider-guance/internal/consts" -) - -// dashboardResourceModel maps the resource schema data. -type dashboardResourceModel struct { - ID types.String `tfsdk:"id"` - CreatedAt types.String `tfsdk:"created_at"` - Name types.String `tfsdk:"name"` - Manifest types.String `tfsdk:"manifest"` -} - -// GetId returns the ID of the resource. -func (m *dashboardResourceModel) GetId() string { - return m.ID.ValueString() -} - -// SetId sets the ID of the resource. -func (m *dashboardResourceModel) SetId(id string) { - m.ID = types.StringValue(id) -} - -// GetResourceType returns the type of the resource. -func (m *dashboardResourceModel) GetResourceType() string { - return consts.TypeNameDashboard -} - -// SetCreatedAt sets the creation time of the resource. -func (m *dashboardResourceModel) SetCreatedAt(t string) { - m.CreatedAt = types.StringValue(t) -} diff --git a/internal/resources/dashboard/resource.go b/internal/resources/dashboard/resource.go deleted file mode 100644 index b918e05..0000000 --- a/internal/resources/dashboard/resource.go +++ /dev/null @@ -1,162 +0,0 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - -package dashboard - -import ( - "context" - _ "embed" - - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/resource" - - "github.com/GuanceCloud/terraform-provider-guance/internal/sdk" -) - -//go:embed README.md -var resourceDocument string - -// Ensure the implementation satisfies the expected interfaces. -var ( - _ resource.Resource = &dashboardResource{} - _ resource.ResourceWithConfigure = &dashboardResource{} - _ resource.ResourceWithImportState = &dashboardResource{} -) - -// NewDashboardResource is -func NewDashboardResource() resource.Resource { - return &dashboardResource{} -} - -// dashboardResource is the resource implementation. -type dashboardResource struct { - client *sdk.Client[sdk.Resource] -} - -// Schema defines the schema for the data source. -func (r *dashboardResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { - resp.Schema = resourceSchema -} - -// Configure adds the provider configured client to the data source. -func (r *dashboardResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { - if req.ProviderData == nil { - return - } - r.client = req.ProviderData.(*sdk.Client[sdk.Resource]) -} - -// Metadata returns the data source type name. -func (r *dashboardResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_dashboard" -} - -// Create creates the resource and sets the initial Terraform state. -func (r *dashboardResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - // Retrieve values from plan - var plan dashboardResourceModel - diags := req.Plan.Get(ctx, &plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - if err := r.client.Create(ctx, &plan); err != nil { - resp.Diagnostics.AddError( - "Error creating dashboard", - "Could not create dashboard, unexpected error: "+err.Error(), - ) - return - } - - if err := r.client.Read(ctx, &plan); err != nil { - resp.Diagnostics.AddError( - "Error creating dashboard", - "Could not create dashboard, unexpected error: "+err.Error(), - ) - return - } - - // Set state to fully populated data - diags = resp.State.Set(ctx, plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } -} - -// Read refreshes the Terraform state with the latest data. -func (r *dashboardResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - // Get current state - var state dashboardResourceModel - diags := req.State.Get(ctx, &state) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - if err := r.client.Read(ctx, &state); err != nil { - resp.Diagnostics.AddError( - "Error reading dashboard", - "Could not read dashboard, unexpected error: "+err.Error(), - ) - return - } - - // Set refreshed state - diags = resp.State.Set(ctx, &state) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } -} - -// Update updates the resource and sets the updated Terraform state on success. -func (r *dashboardResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - // Retrieve values from plan - var plan dashboardResourceModel - diags := req.Plan.Get(ctx, &plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - if err := r.client.Read(ctx, &plan); err != nil { - resp.Diagnostics.AddError( - "Error creating dashboard", - "Could not create dashboard, unexpected error: "+err.Error(), - ) - return - } - - // Set state to fully populated data - diags = resp.State.Set(ctx, plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } -} - -// Delete deletes the resource and removes the Terraform state on success. -func (r *dashboardResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - // Retrieve values from state - var state dashboardResourceModel - diags := req.State.Get(ctx, &state) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - // Delete existing dashboard - if err := r.client.Delete(ctx, &state); err != nil { - resp.Diagnostics.AddError( - "Error deleting dashboard", - "Could not delete dashboard, unexpected error: "+err.Error(), - ) - return - } -} - -func (r *dashboardResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - // Retrieve import ID and save to id attribute - resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) -} diff --git a/internal/resources/dashboard/schema.go b/internal/resources/dashboard/schema.go deleted file mode 100644 index d1c564e..0000000 --- a/internal/resources/dashboard/schema.go +++ /dev/null @@ -1,46 +0,0 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - -package dashboard - -import ( - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" -) - -var resourceSchema = schema.Schema{ - Description: "Dashboard", - MarkdownDescription: resourceDocument, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Description: "The Guance Resource Name (GRN) of cloud resource.", - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, - }, - - "created_at": schema.StringAttribute{ - Description: "The RFC3339/ISO8601 time string of resource created at.", - Computed: true, - }, - - "name": schema.StringAttribute{ - Description: "Dashboard Name", - - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - - "manifest": schema.StringAttribute{ - Description: "Dashboard Manifest", - - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - }, -} diff --git a/internal/resources/membergroup/README.md b/internal/resources/membergroup/README.md index 681a2d5..d8bb0d1 100644 --- a/internal/resources/membergroup/README.md +++ b/internal/resources/membergroup/README.md @@ -1,7 +1,6 @@ # Member Group -Member group is a collection of members in a workspace, and member groups can be authorized to access the resources in -the workspace. +Member group is a collection of members in a workspace, and member groups can be authorized to access the resources in the workspace. Member group is an abstract concept, it can be a team, or a department, it can help us build a reasonable organizational structure, optimize the management efficiency and user experience of the observability platform. @@ -15,9 +14,7 @@ A[Workspace] --> B[Member] A --> C[MemberGroup] ``` -## Create - -The first let me create a resource. We will send the create operation to the resource management service +## Example Usage ```terraform variable "email" { @@ -25,16 +22,15 @@ variable "email" { } data "guance_members" "demo" { - filters = [ - { - name = "email" - values = [var.email] - } - ] + search = var.email } resource "guance_membergroup" "demo" { - name = "oac-demo" - member_ids = data.guance_members.demo.items[*].id + name = "oac-demo2" + account_uuids = data.guance_members.demo.members[*].uuid +} + +output "member" { + value = data.guance_members.demo.members } ``` diff --git a/internal/resources/membergroup/model.go b/internal/resources/membergroup/model.go index 74e84d5..c549151 100644 --- a/internal/resources/membergroup/model.go +++ b/internal/resources/membergroup/model.go @@ -1,37 +1,12 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - package membergroup import ( "github.com/hashicorp/terraform-plugin-framework/types" - - "github.com/GuanceCloud/terraform-provider-guance/internal/consts" ) // memberGroupResourceModel maps the resource schema data. type memberGroupResourceModel struct { - ID types.String `tfsdk:"id"` - CreatedAt types.String `tfsdk:"created_at"` - Name types.String `tfsdk:"name"` - MemberIds []types.String `tfsdk:"member_ids"` -} - -// GetId returns the ID of the resource. -func (m *memberGroupResourceModel) GetId() string { - return m.ID.ValueString() -} - -// SetId sets the ID of the resource. -func (m *memberGroupResourceModel) SetId(id string) { - m.ID = types.StringValue(id) -} - -// GetResourceType returns the type of the resource. -func (m *memberGroupResourceModel) GetResourceType() string { - return consts.TypeNameMemberGroup -} - -// SetCreatedAt sets the creation time of the resource. -func (m *memberGroupResourceModel) SetCreatedAt(t string) { - m.CreatedAt = types.StringValue(t) + UUID types.String `tfsdk:"uuid"` + Name types.String `tfsdk:"name"` + AccountUUIDs []types.String `tfsdk:"account_uuids"` } diff --git a/internal/resources/membergroup/resource.go b/internal/resources/membergroup/resource.go index 375b911..7063986 100644 --- a/internal/resources/membergroup/resource.go +++ b/internal/resources/membergroup/resource.go @@ -1,5 +1,3 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - package membergroup import ( @@ -8,8 +6,11 @@ import ( "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "github.com/GuanceCloud/terraform-provider-guance/internal/sdk" + "github.com/GuanceCloud/terraform-provider-guance/internal/api" + "github.com/GuanceCloud/terraform-provider-guance/internal/consts" ) //go:embed README.md @@ -29,7 +30,7 @@ func NewMemberGroupResource() resource.Resource { // memberGroupResource is the resource implementation. type memberGroupResource struct { - client *sdk.Client[sdk.Resource] + client *api.Client } // Schema defines the schema for the data source. @@ -42,7 +43,7 @@ func (r *memberGroupResource) Configure(_ context.Context, req resource.Configur if req.ProviderData == nil { return } - r.client = req.ProviderData.(*sdk.Client[sdk.Resource]) + r.client = req.ProviderData.(*api.Client) } // Metadata returns the data source type name. @@ -60,21 +61,18 @@ func (r *memberGroupResource) Create(ctx context.Context, req resource.CreateReq return } - if err := r.client.Create(ctx, &plan); err != nil { + item := r.getMembergroupFromPlan(&plan) + content := &api.MembergroupContent{} + err := r.client.Create(consts.TypeNameMemberGroup, item, content) + if err != nil { resp.Diagnostics.AddError( - "Error creating memberGroup", - "Could not create memberGroup, unexpected error: "+err.Error(), + "Error creating membergroup", + "Could not create membergroup, unexpected error: "+err.Error(), ) return } - if err := r.client.Read(ctx, &plan); err != nil { - resp.Diagnostics.AddError( - "Error creating memberGroup", - "Could not create memberGroup, unexpected error: "+err.Error(), - ) - return - } + plan.UUID = types.StringValue(content.UUID) // Set state to fully populated data diags = resp.State.Set(ctx, plan) @@ -94,7 +92,14 @@ func (r *memberGroupResource) Read(ctx context.Context, req resource.ReadRequest return } - if err := r.client.Read(ctx, &state); err != nil { + content := &api.MembergroupReadContent{} + if err := r.client.Read(consts.TypeNameMemberGroup, state.UUID.ValueString(), content); err != nil { + + if err == api.Error404 { + resp.State.RemoveResource(ctx) + return + } + resp.Diagnostics.AddError( "Error reading memberGroup", "Could not read memberGroup, unexpected error: "+err.Error(), @@ -102,6 +107,11 @@ func (r *memberGroupResource) Read(ctx context.Context, req resource.ReadRequest return } + state.AccountUUIDs = make([]basetypes.StringValue, 0) + for _, v := range content.GroupMembers { + state.AccountUUIDs = append(state.AccountUUIDs, types.StringValue(v.UUID)) + } + // Set refreshed state diags = resp.State.Set(ctx, &state) resp.Diagnostics.Append(diags...) @@ -120,10 +130,13 @@ func (r *memberGroupResource) Update(ctx context.Context, req resource.UpdateReq return } - if err := r.client.Read(ctx, &plan); err != nil { + item := r.getMembergroupFromPlan(&plan) + item.UUID = "" // set empty to avoid update failure + content := false + if err := r.client.Update(consts.TypeNameMemberGroup, plan.UUID.ValueString(), item, &content); err != nil { resp.Diagnostics.AddError( - "Error creating memberGroup", - "Could not create memberGroup, unexpected error: "+err.Error(), + "Error updating memberGroup", + "Could not update memberGroup, unexpected error: "+err.Error(), ) return } @@ -147,7 +160,7 @@ func (r *memberGroupResource) Delete(ctx context.Context, req resource.DeleteReq } // Delete existing memberGroup - if err := r.client.Delete(ctx, &state); err != nil { + if err := r.client.Delete(consts.TypeNameMemberGroup, state.UUID.ValueString()); err != nil { resp.Diagnostics.AddError( "Error deleting memberGroup", "Could not delete memberGroup, unexpected error: "+err.Error(), @@ -158,5 +171,20 @@ func (r *memberGroupResource) Delete(ctx context.Context, req resource.DeleteReq func (r *memberGroupResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { // Retrieve import ID and save to id attribute - resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + resource.ImportStatePassthroughID(ctx, path.Root("uuid"), req, resp) +} + +func (r *memberGroupResource) getMembergroupFromPlan(plan *memberGroupResourceModel) *api.Membergroup { + + g := &api.Membergroup{ + UUID: plan.UUID.ValueString(), + Name: plan.Name.ValueString(), + } + + g.AccountUUIDs = make([]string, 0) + for _, v := range plan.AccountUUIDs { + g.AccountUUIDs = append(g.AccountUUIDs, v.ValueString()) + } + + return g } diff --git a/internal/resources/membergroup/schema.go b/internal/resources/membergroup/schema.go index 20b7185..7458714 100644 --- a/internal/resources/membergroup/schema.go +++ b/internal/resources/membergroup/schema.go @@ -1,10 +1,7 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - package membergroup import ( "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/types" @@ -14,36 +11,23 @@ var resourceSchema = schema.Schema{ Description: "Member Group", MarkdownDescription: resourceDocument, Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Description: "The Guance Resource Name (GRN) of cloud resource.", + "uuid": schema.StringAttribute{ + Description: "The UUID of resource.", Computed: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, - "created_at": schema.StringAttribute{ - Description: "The RFC3339/ISO8601 time string of resource created at.", - Computed: true, - }, - "name": schema.StringAttribute{ - Description: "Name", - - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, + Description: "The name of resource.", + Required: true, }, - "member_ids": schema.ListAttribute{ - Description: "Member id list", - + "account_uuids": schema.ListAttribute{ + Description: "Member uuid list", Optional: true, ElementType: types.StringType, - PlanModifiers: []planmodifier.List{ - listplanmodifier.RequiresReplace(), - }, }, }, } diff --git a/internal/resources/monitor/README.md b/internal/resources/monitor/README.md deleted file mode 100644 index d487d5b..0000000 --- a/internal/resources/monitor/README.md +++ /dev/null @@ -1,76 +0,0 @@ -# Monitor - -A monitor is a set of checks that you can run against your data. A monitor watches your data over time and alerts you -when certain conditions are met. For example, you can create a monitor that watches the average response time of your -website and alerts you when the response time is greater than 1 second. - -Monitors are made up of one or more checks. A check is a single test that you can run against your data. For example, -you can create a check that watches the average response time of your website. You can also create a check that watches -the percentage of 5xx errors in your logs. - -Guance Cloud supports defining monitors, users can customize the configuration of detection rules and trigger -conditions, and open the monitors to receive related alarm events triggered by the detection rules. - -Relationships: - -```mermaid -graph LR - -A[Monitor] --> B[Alert Policy] --> C[Notification] -``` - -## Create - -The first let me create a resource. We will send the create operation to the resource management service - -```terraform -variable "email" { - type = string -} - -data "guance_members" "demo" { - filters = [ - { - name = "email" - values = [var.email] - } - ] -} - -resource "guance_membergroup" "demo" { - name = "oac-demo" - member_ids = data.guance_members.demo.items[*].id -} - -resource "guance_alertpolicy" "demo" { - name = "oac-demo" - silent_timeout = "1h" - - statuses = [ - "critical", - "error", - "warning", - "info", - "ok", - "nodata", - "nodata_ok", - "nodata_as_ok", - ] - - alert_targets = [ - { - type = "member_group" - member_group = { - id = guance_membergroup.demo.id - } - }, - ] -} - -resource "guance_monitor" "demo" { - manifest = file("${path.module}/monitor.json") - alert_policy = { - id = guance_alertpolicy.demo.id - } -} -``` diff --git a/internal/resources/monitor/model.go b/internal/resources/monitor/model.go deleted file mode 100644 index 3f0a04c..0000000 --- a/internal/resources/monitor/model.go +++ /dev/null @@ -1,48 +0,0 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - -package monitor - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" - - "github.com/GuanceCloud/terraform-provider-guance/internal/consts" -) - -// monitorResourceModel maps the resource schema data. -type monitorResourceModel struct { - ID types.String `tfsdk:"id"` - CreatedAt types.String `tfsdk:"created_at"` - Manifest types.String `tfsdk:"manifest"` - AlertPolicy *AlertPolicy `tfsdk:"alert_policy"` - Dashboard *Dashboard `tfsdk:"dashboard"` -} - -// GetId returns the ID of the resource. -func (m *monitorResourceModel) GetId() string { - return m.ID.ValueString() -} - -// SetId sets the ID of the resource. -func (m *monitorResourceModel) SetId(id string) { - m.ID = types.StringValue(id) -} - -// GetResourceType returns the type of the resource. -func (m *monitorResourceModel) GetResourceType() string { - return consts.TypeNameMonitor -} - -// SetCreatedAt sets the creation time of the resource. -func (m *monitorResourceModel) SetCreatedAt(t string) { - m.CreatedAt = types.StringValue(t) -} - -// AlertPolicy maps the resource schema data. -type AlertPolicy struct { - Id types.String `tfsdk:"id"` -} - -// Dashboard maps the resource schema data. -type Dashboard struct { - Id types.String `tfsdk:"id"` -} diff --git a/internal/resources/monitor/resource.go b/internal/resources/monitor/resource.go deleted file mode 100644 index a359e63..0000000 --- a/internal/resources/monitor/resource.go +++ /dev/null @@ -1,162 +0,0 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - -package monitor - -import ( - "context" - _ "embed" - - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/resource" - - "github.com/GuanceCloud/terraform-provider-guance/internal/sdk" -) - -//go:embed README.md -var resourceDocument string - -// Ensure the implementation satisfies the expected interfaces. -var ( - _ resource.Resource = &monitorResource{} - _ resource.ResourceWithConfigure = &monitorResource{} - _ resource.ResourceWithImportState = &monitorResource{} -) - -// NewMonitorResource is -func NewMonitorResource() resource.Resource { - return &monitorResource{} -} - -// monitorResource is the resource implementation. -type monitorResource struct { - client *sdk.Client[sdk.Resource] -} - -// Schema defines the schema for the data source. -func (r *monitorResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { - resp.Schema = resourceSchema -} - -// Configure adds the provider configured client to the data source. -func (r *monitorResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { - if req.ProviderData == nil { - return - } - r.client = req.ProviderData.(*sdk.Client[sdk.Resource]) -} - -// Metadata returns the data source type name. -func (r *monitorResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_monitor" -} - -// Create creates the resource and sets the initial Terraform state. -func (r *monitorResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - // Retrieve values from plan - var plan monitorResourceModel - diags := req.Plan.Get(ctx, &plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - if err := r.client.Create(ctx, &plan); err != nil { - resp.Diagnostics.AddError( - "Error creating monitor", - "Could not create monitor, unexpected error: "+err.Error(), - ) - return - } - - if err := r.client.Read(ctx, &plan); err != nil { - resp.Diagnostics.AddError( - "Error creating monitor", - "Could not create monitor, unexpected error: "+err.Error(), - ) - return - } - - // Set state to fully populated data - diags = resp.State.Set(ctx, plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } -} - -// Read refreshes the Terraform state with the latest data. -func (r *monitorResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - // Get current state - var state monitorResourceModel - diags := req.State.Get(ctx, &state) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - if err := r.client.Read(ctx, &state); err != nil { - resp.Diagnostics.AddError( - "Error reading monitor", - "Could not read monitor, unexpected error: "+err.Error(), - ) - return - } - - // Set refreshed state - diags = resp.State.Set(ctx, &state) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } -} - -// Update updates the resource and sets the updated Terraform state on success. -func (r *monitorResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - // Retrieve values from plan - var plan monitorResourceModel - diags := req.Plan.Get(ctx, &plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - if err := r.client.Read(ctx, &plan); err != nil { - resp.Diagnostics.AddError( - "Error creating monitor", - "Could not create monitor, unexpected error: "+err.Error(), - ) - return - } - - // Set state to fully populated data - diags = resp.State.Set(ctx, plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } -} - -// Delete deletes the resource and removes the Terraform state on success. -func (r *monitorResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - // Retrieve values from state - var state monitorResourceModel - diags := req.State.Get(ctx, &state) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - // Delete existing monitor - if err := r.client.Delete(ctx, &state); err != nil { - resp.Diagnostics.AddError( - "Error deleting monitor", - "Could not delete monitor, unexpected error: "+err.Error(), - ) - return - } -} - -func (r *monitorResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - // Retrieve import ID and save to id attribute - resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) -} diff --git a/internal/resources/monitor/schema.go b/internal/resources/monitor/schema.go deleted file mode 100644 index ba52927..0000000 --- a/internal/resources/monitor/schema.go +++ /dev/null @@ -1,75 +0,0 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - -package monitor - -import ( - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" -) - -var resourceSchema = schema.Schema{ - Description: "Monitor", - MarkdownDescription: resourceDocument, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Description: "The Guance Resource Name (GRN) of cloud resource.", - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, - }, - - "created_at": schema.StringAttribute{ - Description: "The RFC3339/ISO8601 time string of resource created at.", - Computed: true, - }, - - "manifest": schema.StringAttribute{ - Description: "Monitor Configuration", - - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - - "alert_policy": schema.SingleNestedAttribute{ - Description: "Alert Policy Configuration", - - Required: true, - Attributes: schemaAlertPolicy, - }, - - "dashboard": schema.SingleNestedAttribute{ - Description: "Dashboard Configuration", - - Optional: true, - Attributes: schemaDashboard, - }, - }, -} - -// schemaAlertPolicy maps the resource schema data. -var schemaAlertPolicy = map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Description: "Alert Policy ID", - - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, -} - -// schemaDashboard maps the resource schema data. -var schemaDashboard = map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Description: "Dashboard ID", - - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, -} diff --git a/internal/resources/mute/README.md b/internal/resources/mute/README.md deleted file mode 100644 index 636a14f..0000000 --- a/internal/resources/mute/README.md +++ /dev/null @@ -1,155 +0,0 @@ -# Mute Rule - -Mute rule is a feature that allows you to temporarily stop receiving notifications for a specific alert. You can use -mute rules to temporarily silence alerts that are not relevant to you, or to silence alerts that you are already aware -of. - -Guance Cloud supports the management of all mute rules in the current workspace. It supports muting different monitors, -smart inspections, self-built inspections, SLOs, and alert policies, so that the muted objects do not send any alert -notifications to any alert notification objects during the mute time. - -Relationships: - -```mermaid -graph LR - A[Mute Rule] --> B[Alert Policy] -``` - -## Create - -The first let me create a resource. We will send the create operation to the resource management service - -```terraform -variable "ding_talk_webhook" { - type = string -} - -variable "ding_talk_secret" { - type = string -} - -variable "email" { - type = string -} - -data "guance_members" "demo" { - filters = [ - { - name = "email" - values = [var.email] - } - ] -} - -resource "guance_membergroup" "demo" { - name = "oac-demo" - member_ids = data.guance_members.demo.items[*].id -} - -resource "guance_notification" "demo" { - name = "oac-demo" - type = "ding_talk_robot" - ding_talk_robot = { - webhook = var.ding_talk_webhook - secret = var.ding_talk_secret - } -} - -resource "guance_alertpolicy" "demo" { - name = "oac-demo" - silent_timeout = "1h" - - statuses = [ - "critical", - "error", - "warning", - "info", - "ok", - "nodata", - "nodata_ok", - "nodata_as_ok", - ] - - alert_targets = [ - { - type = "member_group" - member_group = { - id = guance_membergroup.demo.id - } - }, - { - type = "notification" - notification = { - id = guance_notification.demo.id - } - } - ] -} - -resource "guance_mute" "demo" { - // mute ranges - mute_ranges = [ - { - type = "alert_policy" - - alert_policy = { - id = guance_alertpolicy.demo.id - } - } - ] - - // notify options - notify = { - message = < -func NewMuteResource() resource.Resource { - return &muteResource{} -} - -// muteResource is the resource implementation. -type muteResource struct { - client *sdk.Client[sdk.Resource] -} - -// Schema defines the schema for the data source. -func (r *muteResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { - resp.Schema = resourceSchema -} - -// Configure adds the provider configured client to the data source. -func (r *muteResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { - if req.ProviderData == nil { - return - } - r.client = req.ProviderData.(*sdk.Client[sdk.Resource]) -} - -// Metadata returns the data source type name. -func (r *muteResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_mute" -} - -// Create creates the resource and sets the initial Terraform state. -func (r *muteResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - // Retrieve values from plan - var plan muteResourceModel - diags := req.Plan.Get(ctx, &plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - if err := r.client.Create(ctx, &plan); err != nil { - resp.Diagnostics.AddError( - "Error creating mute", - "Could not create mute, unexpected error: "+err.Error(), - ) - return - } - - if err := r.client.Read(ctx, &plan); err != nil { - resp.Diagnostics.AddError( - "Error creating mute", - "Could not create mute, unexpected error: "+err.Error(), - ) - return - } - - // Set state to fully populated data - diags = resp.State.Set(ctx, plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } -} - -// Read refreshes the Terraform state with the latest data. -func (r *muteResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - // Get current state - var state muteResourceModel - diags := req.State.Get(ctx, &state) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - if err := r.client.Read(ctx, &state); err != nil { - resp.Diagnostics.AddError( - "Error reading mute", - "Could not read mute, unexpected error: "+err.Error(), - ) - return - } - - // Set refreshed state - diags = resp.State.Set(ctx, &state) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } -} - -// Update updates the resource and sets the updated Terraform state on success. -func (r *muteResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - // Retrieve values from plan - var plan muteResourceModel - diags := req.Plan.Get(ctx, &plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - if err := r.client.Read(ctx, &plan); err != nil { - resp.Diagnostics.AddError( - "Error creating mute", - "Could not create mute, unexpected error: "+err.Error(), - ) - return - } - - // Set state to fully populated data - diags = resp.State.Set(ctx, plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } -} - -// Delete deletes the resource and removes the Terraform state on success. -func (r *muteResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - // Retrieve values from state - var state muteResourceModel - diags := req.State.Get(ctx, &state) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - // Delete existing mute - if err := r.client.Delete(ctx, &state); err != nil { - resp.Diagnostics.AddError( - "Error deleting mute", - "Could not delete mute, unexpected error: "+err.Error(), - ) - return - } -} - -func (r *muteResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - // Retrieve import ID and save to id attribute - resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) -} diff --git a/internal/resources/mute/schema.go b/internal/resources/mute/schema.go deleted file mode 100644 index 326a487..0000000 --- a/internal/resources/mute/schema.go +++ /dev/null @@ -1,347 +0,0 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - -package mute - -import ( - "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/schema/validator" -) - -var resourceSchema = schema.Schema{ - Description: "Mute Rule", - MarkdownDescription: resourceDocument, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Description: "The Guance Resource Name (GRN) of cloud resource.", - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, - }, - - "created_at": schema.StringAttribute{ - Description: "The RFC3339/ISO8601 time string of resource created at.", - Computed: true, - }, - - "mute_ranges": schema.ListNestedAttribute{ - Description: "Mute Ranges", - - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: schemaMuteRange, - }, - }, - - "notify": schema.SingleNestedAttribute{ - Description: "Notify Options", - - Optional: true, - Attributes: schemaNotifyOptions, - }, - - "notify_targets": schema.ListNestedAttribute{ - Description: "Notify targets", - - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: schemaNotifyTarget, - }, - }, - - "onetime": schema.SingleNestedAttribute{ - Description: "Onetime", - - Optional: true, - Attributes: schemaOnetimeOptions, - }, - - "repeat": schema.SingleNestedAttribute{ - Description: "Repeat", - - Optional: true, - Attributes: schemaRepeatOptions, - }, - - "mute_tags": schema.ListNestedAttribute{ - Description: "Tags", - - Optional: true, - NestedObject: schema.NestedAttributeObject{ - Attributes: schemaTag, - }, - }, - }, -} - -// schemaMuteRange maps the resource schema data. -var schemaMuteRange = map[string]schema.Attribute{ - "type": schema.StringAttribute{ - Description: "Mute Range Type", - - MarkdownDescription: ` - Mute Range Type, value must be one of: *monitor*, *alert_policy*, other value will be ignored. - `, - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Validators: []validator.String{ - stringvalidator.OneOf("monitor", "alert_policy"), - }, - }, - - "monitor": schema.SingleNestedAttribute{ - Description: "Monitor configuration", - - Optional: true, - Attributes: schemaMuteRangeMonitor, - }, - - "alert_policy": schema.SingleNestedAttribute{ - Description: "Alert Policy configuration", - - Optional: true, - Attributes: schemaMuteRangeAlertPolicy, - }, -} - -// schemaMuteRangeAlertPolicy maps the resource schema data. -var schemaMuteRangeAlertPolicy = map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Description: "Alert Policy ID", - - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, -} - -// schemaMuteRangeMonitor maps the resource schema data. -var schemaMuteRangeMonitor = map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Description: "Monitor ID", - - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, -} - -// schemaNotifyOptions maps the resource schema data. -var schemaNotifyOptions = map[string]schema.Attribute{ - "message": schema.StringAttribute{ - Description: "Notify Message", - - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - - "before_time": schema.StringAttribute{ - Description: "Notify Time", - - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, -} - -// schemaNotifyTarget maps the resource schema data. -var schemaNotifyTarget = map[string]schema.Attribute{ - "type": schema.StringAttribute{ - Description: "Notify Type", - - MarkdownDescription: ` - Notify Type, value must be one of: *member_group*, *notification*, other value will be ignored. - `, - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Validators: []validator.String{ - stringvalidator.OneOf("member_group", "notification"), - }, - }, - - "member_group": schema.SingleNestedAttribute{ - Description: "MemberGroup", - - Optional: true, - Attributes: schemaNotifyTargetMemberGroup, - }, - - "notification": schema.SingleNestedAttribute{ - Description: "Notification", - - Optional: true, - Attributes: schemaNotifyTargetNotification, - }, -} - -// schemaNotifyTargetMemberGroup maps the resource schema data. -var schemaNotifyTargetMemberGroup = map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Description: "MemberGroup ID", - - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, -} - -// schemaNotifyTargetNotification maps the resource schema data. -var schemaNotifyTargetNotification = map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Description: "Notification ID", - - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, -} - -// schemaOnetimeOptions maps the resource schema data. -var schemaOnetimeOptions = map[string]schema.Attribute{ - "start": schema.StringAttribute{ - Description: "Start", - - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - - "end": schema.StringAttribute{ - Description: "End", - - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, -} - -// schemaRepeatCrontabSet maps the resource schema data. -var schemaRepeatCrontabSet = map[string]schema.Attribute{ - "min": schema.StringAttribute{ - Description: "Min", - - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - - "hour": schema.StringAttribute{ - Description: "Hour", - - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - - "day": schema.StringAttribute{ - Description: "Day", - - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - - "month": schema.StringAttribute{ - Description: "Month", - - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - - "week": schema.StringAttribute{ - Description: "Week", - - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, -} - -// schemaRepeatOptions maps the resource schema data. -var schemaRepeatOptions = map[string]schema.Attribute{ - "start": schema.StringAttribute{ - Description: "Start", - - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - - "end": schema.StringAttribute{ - Description: "End", - - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - - "crontab_duration": schema.StringAttribute{ - Description: "Crontab Duration", - - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - - "expire": schema.StringAttribute{ - Description: "Repeat Expire", - - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - - "crontab": schema.SingleNestedAttribute{ - Description: "Crontab configuration", - - Optional: true, - Attributes: schemaRepeatCrontabSet, - }, -} - -// schemaTag maps the resource schema data. -var schemaTag = map[string]schema.Attribute{ - "key": schema.StringAttribute{ - Description: "Tag", - - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - - "value": schema.StringAttribute{ - Description: "Tag Value", - - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, -} diff --git a/internal/resources/notification/README.md b/internal/resources/notification/README.md deleted file mode 100644 index 31aa47e..0000000 --- a/internal/resources/notification/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# Notification - -Notification is a feature that allows you to receive alerts when an event occurs. - -Guance Cloud supports setting the notification object for the alert event. When the alert event occurs, the alert -information will be sent to the notification object. - -Guance Cloud supports multiple different notification methods. You can refer to the documentation to learn more. - -Relationships: - -```mermaid -graph LR - -A[Monitor] --> B[Alert Policy] --> C[Notification] -``` - -## Create - -The first let me create a resource. We will send the create operation to the resource management service - -```terraform -variable "ding_talk_webhook" { - type = string -} - -variable "ding_talk_secret" { - type = string -} - -resource "guance_notification" "demo" { - name = "oac-demo" - type = "ding_talk_robot" - ding_talk_robot = { - webhook = var.ding_talk_webhook - secret = var.ding_talk_secret - } -} -``` diff --git a/internal/resources/notification/model.go b/internal/resources/notification/model.go deleted file mode 100644 index 3fba8fa..0000000 --- a/internal/resources/notification/model.go +++ /dev/null @@ -1,75 +0,0 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - -package notification - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" - - "github.com/GuanceCloud/terraform-provider-guance/internal/consts" -) - -// notificationResourceModel maps the resource schema data. -type notificationResourceModel struct { - ID types.String `tfsdk:"id"` - CreatedAt types.String `tfsdk:"created_at"` - Name types.String `tfsdk:"name"` - Type types.String `tfsdk:"type"` - DingTalkRobot *DingTalkRobot `tfsdk:"ding_talk_robot"` - HttpRequest *HTTPRequest `tfsdk:"http_request"` - WechatRobot *WeChatRobot `tfsdk:"wechat_robot"` - MailGroup *MailGroup `tfsdk:"mail_group"` - FeishuRobot *FeishuRobot `tfsdk:"feishu_robot"` - Sms *SMS `tfsdk:"sms"` -} - -// GetId returns the ID of the resource. -func (m *notificationResourceModel) GetId() string { - return m.ID.ValueString() -} - -// SetId sets the ID of the resource. -func (m *notificationResourceModel) SetId(id string) { - m.ID = types.StringValue(id) -} - -// GetResourceType returns the type of the resource. -func (m *notificationResourceModel) GetResourceType() string { - return consts.TypeNameNotification -} - -// SetCreatedAt sets the creation time of the resource. -func (m *notificationResourceModel) SetCreatedAt(t string) { - m.CreatedAt = types.StringValue(t) -} - -// DingTalkRobot maps the resource schema data. -type DingTalkRobot struct { - Webhook types.String `tfsdk:"webhook"` - Secret types.String `tfsdk:"secret"` -} - -// FeishuRobot maps the resource schema data. -type FeishuRobot struct { - Webhook types.String `tfsdk:"webhook"` - Secret types.String `tfsdk:"secret"` -} - -// HTTPRequest maps the resource schema data. -type HTTPRequest struct { - Url types.String `tfsdk:"url"` -} - -// MailGroup maps the resource schema data. -type MailGroup struct { - To []types.String `tfsdk:"to"` -} - -// SMS maps the resource schema data. -type SMS struct { - To []types.String `tfsdk:"to"` -} - -// WeChatRobot maps the resource schema data. -type WeChatRobot struct { - Webhook types.String `tfsdk:"webhook"` -} diff --git a/internal/resources/notification/resource.go b/internal/resources/notification/resource.go deleted file mode 100644 index bffdeaf..0000000 --- a/internal/resources/notification/resource.go +++ /dev/null @@ -1,162 +0,0 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - -package notification - -import ( - "context" - _ "embed" - - "github.com/hashicorp/terraform-plugin-framework/path" - "github.com/hashicorp/terraform-plugin-framework/resource" - - "github.com/GuanceCloud/terraform-provider-guance/internal/sdk" -) - -//go:embed README.md -var resourceDocument string - -// Ensure the implementation satisfies the expected interfaces. -var ( - _ resource.Resource = ¬ificationResource{} - _ resource.ResourceWithConfigure = ¬ificationResource{} - _ resource.ResourceWithImportState = ¬ificationResource{} -) - -// NewNotificationResource is -func NewNotificationResource() resource.Resource { - return ¬ificationResource{} -} - -// notificationResource is the resource implementation. -type notificationResource struct { - client *sdk.Client[sdk.Resource] -} - -// Schema defines the schema for the data source. -func (r *notificationResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { - resp.Schema = resourceSchema -} - -// Configure adds the provider configured client to the data source. -func (r *notificationResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { - if req.ProviderData == nil { - return - } - r.client = req.ProviderData.(*sdk.Client[sdk.Resource]) -} - -// Metadata returns the data source type name. -func (r *notificationResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_notification" -} - -// Create creates the resource and sets the initial Terraform state. -func (r *notificationResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - // Retrieve values from plan - var plan notificationResourceModel - diags := req.Plan.Get(ctx, &plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - if err := r.client.Create(ctx, &plan); err != nil { - resp.Diagnostics.AddError( - "Error creating notification", - "Could not create notification, unexpected error: "+err.Error(), - ) - return - } - - if err := r.client.Read(ctx, &plan); err != nil { - resp.Diagnostics.AddError( - "Error creating notification", - "Could not create notification, unexpected error: "+err.Error(), - ) - return - } - - // Set state to fully populated data - diags = resp.State.Set(ctx, plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } -} - -// Read refreshes the Terraform state with the latest data. -func (r *notificationResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - // Get current state - var state notificationResourceModel - diags := req.State.Get(ctx, &state) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - if err := r.client.Read(ctx, &state); err != nil { - resp.Diagnostics.AddError( - "Error reading notification", - "Could not read notification, unexpected error: "+err.Error(), - ) - return - } - - // Set refreshed state - diags = resp.State.Set(ctx, &state) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } -} - -// Update updates the resource and sets the updated Terraform state on success. -func (r *notificationResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - // Retrieve values from plan - var plan notificationResourceModel - diags := req.Plan.Get(ctx, &plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - if err := r.client.Read(ctx, &plan); err != nil { - resp.Diagnostics.AddError( - "Error creating notification", - "Could not create notification, unexpected error: "+err.Error(), - ) - return - } - - // Set state to fully populated data - diags = resp.State.Set(ctx, plan) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } -} - -// Delete deletes the resource and removes the Terraform state on success. -func (r *notificationResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - // Retrieve values from state - var state notificationResourceModel - diags := req.State.Get(ctx, &state) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - // Delete existing notification - if err := r.client.Delete(ctx, &state); err != nil { - resp.Diagnostics.AddError( - "Error deleting notification", - "Could not delete notification, unexpected error: "+err.Error(), - ) - return - } -} - -func (r *notificationResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - // Retrieve import ID and save to id attribute - resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) -} diff --git a/internal/resources/notification/schema.go b/internal/resources/notification/schema.go deleted file mode 100644 index b0b3d79..0000000 --- a/internal/resources/notification/schema.go +++ /dev/null @@ -1,190 +0,0 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - -package notification - -import ( - "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" - "github.com/hashicorp/terraform-plugin-framework/resource/schema" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/schema/validator" - "github.com/hashicorp/terraform-plugin-framework/types" -) - -var resourceSchema = schema.Schema{ - Description: "Notification", - MarkdownDescription: resourceDocument, - Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Description: "The Guance Resource Name (GRN) of cloud resource.", - Computed: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.UseStateForUnknown(), - }, - }, - - "created_at": schema.StringAttribute{ - Description: "The RFC3339/ISO8601 time string of resource created at.", - Computed: true, - }, - - "name": schema.StringAttribute{ - Description: "Notification object name", - - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - - "type": schema.StringAttribute{ - Description: "Trigger rule type", - - MarkdownDescription: ` - Trigger rule type, value must be one of: *ding_talk_robot*, *http_request*, *wechat_robot*, *mail_group*, *feishu_robot*, *sms*, other value will be ignored. - `, - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - Validators: []validator.String{ - stringvalidator.OneOf("ding_talk_robot", "http_request", "wechat_robot", "mail_group", "feishu_robot", "sms"), - }, - }, - - "ding_talk_robot": schema.SingleNestedAttribute{ - Description: "DingTalk Robot", - - Optional: true, - Attributes: schemaDingTalkRobot, - }, - - "http_request": schema.SingleNestedAttribute{ - Description: "HTTP Request", - - Optional: true, - Attributes: schemaHTTPRequest, - }, - - "wechat_robot": schema.SingleNestedAttribute{ - Description: "WeChat Robot", - - Optional: true, - Attributes: schemaWeChatRobot, - }, - - "mail_group": schema.SingleNestedAttribute{ - Description: "Mail Group", - - Optional: true, - Attributes: schemaMailGroup, - }, - - "feishu_robot": schema.SingleNestedAttribute{ - Description: "Feishu Robot", - - Optional: true, - Attributes: schemaFeishuRobot, - }, - - "sms": schema.SingleNestedAttribute{ - Description: "SMS", - - Optional: true, - Attributes: schemaSMS, - }, - }, -} - -// schemaDingTalkRobot maps the resource schema data. -var schemaDingTalkRobot = map[string]schema.Attribute{ - "webhook": schema.StringAttribute{ - Description: "DingTalk Robot Call Address", - - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - - "secret": schema.StringAttribute{ - Description: "DingTalk Robot Call Secret", - - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, -} - -// schemaFeishuRobot maps the resource schema data. -var schemaFeishuRobot = map[string]schema.Attribute{ - "webhook": schema.StringAttribute{ - Description: "Feishu Robot Call Address", - - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, - - "secret": schema.StringAttribute{ - Description: "Feishu Robot Call Secret", - - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, -} - -// schemaHTTPRequest maps the resource schema data. -var schemaHTTPRequest = map[string]schema.Attribute{ - "url": schema.StringAttribute{ - Description: "HTTP Call Address", - - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, -} - -// schemaMailGroup maps the resource schema data. -var schemaMailGroup = map[string]schema.Attribute{ - "to": schema.ListAttribute{ - Description: "Member Account List", - - Required: true, - ElementType: types.StringType, - PlanModifiers: []planmodifier.List{ - listplanmodifier.RequiresReplace(), - }, - }, -} - -// schemaSMS maps the resource schema data. -var schemaSMS = map[string]schema.Attribute{ - "to": schema.ListAttribute{ - Description: "Phone Number List", - - Required: true, - ElementType: types.StringType, - PlanModifiers: []planmodifier.List{ - listplanmodifier.RequiresReplace(), - }, - }, -} - -// schemaWeChatRobot maps the resource schema data. -var schemaWeChatRobot = map[string]schema.Attribute{ - "webhook": schema.StringAttribute{ - Description: "Robot Call Address", - - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, - }, -} diff --git a/internal/resources/pipeline/README.md b/internal/resources/pipeline/README.md index 4948cb9..55a5486 100644 --- a/internal/resources/pipeline/README.md +++ b/internal/resources/pipeline/README.md @@ -8,9 +8,7 @@ By writing a pipeline script, you can customize the structure of the log and use By cutting out the attribute fields, we can quickly filter the relevant logs and perform data association analysis to help us quickly locate and solve problems. -## Create - -The first let me create a resource. We will send the create operation to the resource management service +## Example Usage ```terraform resource "guance_pipeline" "demo" { diff --git a/internal/resources/pipeline/model.go b/internal/resources/pipeline/model.go deleted file mode 100644 index e237e64..0000000 --- a/internal/resources/pipeline/model.go +++ /dev/null @@ -1,42 +0,0 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - -package pipeline - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" - - "github.com/GuanceCloud/terraform-provider-guance/internal/consts" -) - -// pipelineResourceModel maps the resource schema data. -type pipelineResourceModel struct { - ID types.String `tfsdk:"id"` - CreatedAt types.String `tfsdk:"created_at"` - Name types.String `tfsdk:"name"` - Source []types.String `tfsdk:"source"` - Content types.String `tfsdk:"content"` - TestData types.String `tfsdk:"test_data"` - IsForce types.Bool `tfsdk:"is_force"` - Category types.String `tfsdk:"category"` - IsDefault types.Bool `tfsdk:"is_default"` -} - -// GetId returns the ID of the resource. -func (m *pipelineResourceModel) GetId() string { - return m.ID.ValueString() -} - -// SetId sets the ID of the resource. -func (m *pipelineResourceModel) SetId(id string) { - m.ID = types.StringValue(id) -} - -// GetResourceType returns the type of the resource. -func (m *pipelineResourceModel) GetResourceType() string { - return consts.TypeNamePipeline -} - -// SetCreatedAt sets the creation time of the resource. -func (m *pipelineResourceModel) SetCreatedAt(t string) { - m.CreatedAt = types.StringValue(t) -} diff --git a/internal/resources/pipeline/resource.go b/internal/resources/pipeline/resource.go index 7937b24..53cebb5 100644 --- a/internal/resources/pipeline/resource.go +++ b/internal/resources/pipeline/resource.go @@ -1,15 +1,18 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - package pipeline import ( "context" _ "embed" + "encoding/base64" + "fmt" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" - "github.com/GuanceCloud/terraform-provider-guance/internal/sdk" + "github.com/GuanceCloud/terraform-provider-guance/internal/api" + "github.com/GuanceCloud/terraform-provider-guance/internal/consts" ) //go:embed README.md @@ -29,7 +32,7 @@ func NewPipelineResource() resource.Resource { // pipelineResource is the resource implementation. type pipelineResource struct { - client *sdk.Client[sdk.Resource] + client *api.Client } // Schema defines the schema for the data source. @@ -42,7 +45,7 @@ func (r *pipelineResource) Configure(_ context.Context, req resource.ConfigureRe if req.ProviderData == nil { return } - r.client = req.ProviderData.(*sdk.Client[sdk.Resource]) + r.client = req.ProviderData.(*api.Client) } // Metadata returns the data source type name. @@ -60,7 +63,10 @@ func (r *pipelineResource) Create(ctx context.Context, req resource.CreateReques return } - if err := r.client.Create(ctx, &plan); err != nil { + item := r.getPipelineFromPlan(&plan) + content := &api.Pipeline{} + err := r.client.Create(consts.TypeNamePipeline, item, content) + if err != nil { resp.Diagnostics.AddError( "Error creating pipeline", "Could not create pipeline, unexpected error: "+err.Error(), @@ -68,13 +74,8 @@ func (r *pipelineResource) Create(ctx context.Context, req resource.CreateReques return } - if err := r.client.Read(ctx, &plan); err != nil { - resp.Diagnostics.AddError( - "Error creating pipeline", - "Could not create pipeline, unexpected error: "+err.Error(), - ) - return - } + plan.UUID = types.StringValue(content.UUID) + plan.CreateAt = types.StringValue(fmt.Sprintf("%d", content.CreateAt)) // Set state to fully populated data diags = resp.State.Set(ctx, plan) @@ -94,7 +95,36 @@ func (r *pipelineResource) Read(ctx context.Context, req resource.ReadRequest, r return } - if err := r.client.Read(ctx, &state); err != nil { + pl := &api.Pipeline{} + err := r.client.Read(consts.TypeNamePipeline, state.UUID.ValueString(), pl) + if err != nil { + if err == api.Error404 { + resp.State.RemoveResource(ctx) + return + } + resp.Diagnostics.AddError( + "Error reading pipeline", + "Could not read pipeline, unexpected error: "+err.Error(), + ) + return + } + + state.AsDefault = types.Int64Value(pl.AsDefault) + state.Category = types.StringValue(pl.Category) + + // only set extend when it's not nil + if pl.Extend != nil && (pl.Extend.AppID != nil || pl.Extend.Measurement != nil) { + state.Extend = &pipelineExtend{} + for _, id := range pl.Extend.AppID { + state.Extend.AppID = append(state.Extend.AppID, types.StringValue(id)) + } + for _, m := range pl.Extend.Measurement { + state.Extend.Measurement = append(state.Extend.Measurement, types.StringValue(m)) + } + } + + content, err := base64.StdEncoding.DecodeString(pl.Content) + if err != nil { resp.Diagnostics.AddError( "Error reading pipeline", "Could not read pipeline, unexpected error: "+err.Error(), @@ -102,6 +132,29 @@ func (r *pipelineResource) Read(ctx context.Context, req resource.ReadRequest, r return } + state.Content = types.StringValue(string(content)) + + state.CreateAt = types.StringValue(fmt.Sprintf("%d", pl.CreateAt)) + state.IsForce = types.BoolValue(pl.IsForce) + + testData, err := base64.StdEncoding.DecodeString(pl.TestData) + if err != nil { + resp.Diagnostics.AddError( + "Error reading pipeline", + "Could not read pipeline, unexpected error: "+err.Error(), + ) + return + } + state.TestData = types.StringValue(string(testData)) + + state.Name = types.StringValue(pl.Name) + state.Source = make([]basetypes.StringValue, 0) + for _, s := range pl.Source { + state.Source = append(state.Source, types.StringValue(s)) + } + + state.Type = types.StringValue(pl.Type) + // Set refreshed state diags = resp.State.Set(ctx, &state) resp.Diagnostics.Append(diags...) @@ -119,11 +172,15 @@ func (r *pipelineResource) Update(ctx context.Context, req resource.UpdateReques if resp.Diagnostics.HasError() { return } + item := r.getPipelineFromPlan(&plan) + item.UUID = plan.UUID.ValueString() - if err := r.client.Read(ctx, &plan); err != nil { + content := &api.Pipeline{} + err := r.client.Update(consts.TypeNamePipeline, item.UUID, item, content) + if err != nil { resp.Diagnostics.AddError( - "Error creating pipeline", - "Could not create pipeline, unexpected error: "+err.Error(), + "Error updating pipeline", + "Could not update pipeline, unexpected error: "+err.Error(), ) return } @@ -146,17 +203,65 @@ func (r *pipelineResource) Delete(ctx context.Context, req resource.DeleteReques return } - // Delete existing pipeline - if err := r.client.Delete(ctx, &state); err != nil { + err := r.client.Delete(consts.TypeNamePipeline, state.UUID.ValueString()) + if err != nil { resp.Diagnostics.AddError( "Error deleting pipeline", "Could not delete pipeline, unexpected error: "+err.Error(), ) return } + } func (r *pipelineResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { // Retrieve import ID and save to id attribute - resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) + resource.ImportStatePassthroughID(ctx, path.Root("uuid"), req, resp) +} + +func (r *pipelineResource) getPipelineFromPlan(plan *pipelineResourceModel) *api.Pipeline { + item := &api.Pipeline{ + Name: plan.Name.ValueString(), + Category: plan.Category.ValueString(), + Content: base64.StdEncoding.EncodeToString([]byte(plan.Content.ValueString())), + TestData: base64.StdEncoding.EncodeToString([]byte(plan.TestData.ValueString())), + Type: plan.Type.ValueString(), + UUID: plan.UUID.ValueString(), + AsDefault: plan.AsDefault.ValueInt64(), + IsForce: plan.IsForce.ValueBool(), + } + + if len(plan.Source) > 0 { + source := []string{} + for _, s := range plan.Source { + source = append(source, s.ValueString()) + } + + item.Source = source + } + + if plan.Extend != nil { + item.Extend = &api.PipelineExtend{} + if len(plan.Extend.AppID) > 0 { + appID := []string{} + for _, s := range plan.Extend.AppID { + appID = append(appID, s.ValueString()) + } + item.Extend.AppID = appID + } + + if len(plan.Extend.Measurement) > 0 { + measurement := []string{} + for _, s := range plan.Extend.Measurement { + measurement = append(measurement, s.ValueString()) + } + item.Extend.Measurement = measurement + } + } + // set is_force to true when as_default is set to 1 + if item.AsDefault == 1 { + item.IsForce = true + } + + return item } diff --git a/internal/resources/pipeline/schema.go b/internal/resources/pipeline/schema.go index aa3032a..4d06823 100644 --- a/internal/resources/pipeline/schema.go +++ b/internal/resources/pipeline/schema.go @@ -1,102 +1,116 @@ -// Code generated by Guance Cloud Code Generation Pipeline. DO NOT EDIT. - package pipeline import ( "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier" - "github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" ) +type pipelineResourceModel struct { + CreateAt types.String `tfsdk:"create_at"` + Name types.String `tfsdk:"name"` + Source []types.String `tfsdk:"source"` + Content types.String `tfsdk:"content"` + TestData types.String `tfsdk:"test_data"` + IsForce types.Bool `tfsdk:"is_force"` + Category types.String `tfsdk:"category"` + AsDefault types.Int64 `tfsdk:"as_default"` + Type types.String `tfsdk:"type"` + UUID types.String `tfsdk:"uuid"` + Extend *pipelineExtend `tfsdk:"extend"` +} + +type pipelineExtend struct { + AppID []types.String `tfsdk:"app_id"` + Measurement []types.String `tfsdk:"measurement"` +} + var resourceSchema = schema.Schema{ Description: "Pipeline", MarkdownDescription: resourceDocument, Attributes: map[string]schema.Attribute{ - "id": schema.StringAttribute{ - Description: "The Guance Resource Name (GRN) of cloud resource.", + "uuid": schema.StringAttribute{ + Description: "The uuid of the pipeline.", Computed: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, - - "created_at": schema.StringAttribute{ - Description: "The RFC3339/ISO8601 time string of resource created at.", - Computed: true, - }, - "name": schema.StringAttribute{ - Description: "Name", - - Required: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), + Description: "The name of the pipeline.", + Required: true, + }, + "type": schema.StringAttribute{ + MarkdownDescription: "The type of the pipeline.Valid value: `local`, `central`", + Required: true, + Validators: []validator.String{ + stringvalidator.OneOf("local", "central"), }, }, - "source": schema.ListAttribute{ Description: "Data source list", - - Optional: true, + Required: true, ElementType: types.StringType, - PlanModifiers: []planmodifier.List{ - listplanmodifier.RequiresReplace(), - }, }, - "content": schema.StringAttribute{ Description: "Pipeline file content", - - Required: true, + Required: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplace(), }, }, - "test_data": schema.StringAttribute{ Description: "Test data", - - Optional: true, - PlanModifiers: []planmodifier.String{ - stringplanmodifier.RequiresReplace(), - }, + Required: true, }, - "is_force": schema.BoolAttribute{ - Description: "Is Force Overwrite", - - Optional: true, + MarkdownDescription: "Is Force Overwrite. If the field `as_default` is true, `is_force` will be set to be true automatically.", + Required: true, PlanModifiers: []planmodifier.Bool{ boolplanmodifier.RequiresReplace(), }, }, - "category": schema.StringAttribute{ Description: "Category", MarkdownDescription: ` - Category, value must be one of: *logging*, *object*, *custom_object*, *network*, *tracing*, *rum*, *security*, *keyevent*, *metric*, other value will be ignored. + Category, value must be one of: *logging*, *object*, *custom_object*, *network*, *tracing*, *rum*, *security*, *keyevent*, *metric*, *profiling*, other value will be ignored. `, Required: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplace(), }, Validators: []validator.String{ - stringvalidator.OneOf("logging", "object", "custom_object", "network", "tracing", "rum", "security", "keyevent", "metric"), + stringvalidator.OneOf("logging", "object", "custom_object", "network", "tracing", "rum", "security", "keyevent", "metric", "profiling"), }, }, - - "is_default": schema.BoolAttribute{ + "as_default": schema.Int64Attribute{ Description: "Is Default Pipeline", - + Required: true, + PlanModifiers: []planmodifier.Int64{ + int64planmodifier.RequiresReplace(), + }, + }, + "create_at": schema.StringAttribute{ + Description: "The creation time of the resource, in seconds as a timestamp.", + Computed: true, + }, + "extend": schema.SingleNestedAttribute{ Optional: true, - PlanModifiers: []planmodifier.Bool{ - boolplanmodifier.RequiresReplace(), + Attributes: map[string]schema.Attribute{ + "app_id": schema.ListAttribute{ + Optional: true, + ElementType: types.StringType, + }, + "measurement": schema.ListAttribute{ + Optional: true, + ElementType: types.StringType, + }, }, }, }, diff --git a/internal/resources/role/README.md b/internal/resources/role/README.md new file mode 100644 index 0000000..61472f1 --- /dev/null +++ b/internal/resources/role/README.md @@ -0,0 +1,13 @@ +# Role + +Guance Cloud supports creating roles to manage the permissions of users. Role management provides users with an intuitive entry for permission management, supporting the flexible adjustment of the permission scope corresponding to different roles, creating new roles for users, and assigning permission scopes to roles to meet the permission needs of different users. + +## Example Usage + +```terraform +resource "guance_role" "role" { + name = "tf-test-role1" + desc = "test role" + keys = ["snapshot.delete", "workspace.readMember"] +} +``` diff --git a/internal/resources/role/model.go b/internal/resources/role/model.go new file mode 100644 index 0000000..84d0d7c --- /dev/null +++ b/internal/resources/role/model.go @@ -0,0 +1,13 @@ +package role + +import ( + "github.com/hashicorp/terraform-plugin-framework/types" +) + +// roleResourceModel maps the resource schema data. +type roleResourceModel struct { + UUID types.String `tfsdk:"uuid"` + Name types.String `tfsdk:"name"` + Desc types.String `tfsdk:"desc"` + Keys []types.String `tfsdk:"keys"` +} diff --git a/internal/resources/role/resource.go b/internal/resources/role/resource.go new file mode 100644 index 0000000..e8665f4 --- /dev/null +++ b/internal/resources/role/resource.go @@ -0,0 +1,205 @@ +package role + +import ( + "context" + _ "embed" + + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-framework/types/basetypes" + "github.com/hashicorp/terraform-plugin-log/tflog" + + "github.com/GuanceCloud/terraform-provider-guance/internal/api" + "github.com/GuanceCloud/terraform-provider-guance/internal/consts" +) + +//go:embed README.md +var resourceDocument string + +// Ensure the implementation satisfies the expected interfaces. +var ( + _ resource.Resource = &roleResource{} + _ resource.ResourceWithConfigure = &roleResource{} + _ resource.ResourceWithImportState = &roleResource{} +) + +// NewRoleResource is +func NewRoleResource() resource.Resource { + return &roleResource{} +} + +// roleResource is the resource implementation. +type roleResource struct { + client *api.Client +} + +// Schema defines the schema for the data source. +func (r *roleResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { + resp.Schema = resourceSchema +} + +// Configure adds the provider configured client to the data source. +func (r *roleResource) Configure(_ context.Context, req resource.ConfigureRequest, _ *resource.ConfigureResponse) { + if req.ProviderData == nil { + return + } + r.client = req.ProviderData.(*api.Client) +} + +// Metadata returns the data source type name. +func (r *roleResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_role" +} + +// Create creates the resource and sets the initial Terraform state. +func (r *roleResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + // Retrieve values from plan + var plan roleResourceModel + diags := req.Plan.Get(ctx, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + item := r.getRoleFromPlan(&plan) + content := &api.Role{} + err := r.client.Create(consts.TypeNameRole, item, content) + if err != nil { + resp.Diagnostics.AddError( + "Error creating role", + "Could not create role, unexpected error: "+err.Error(), + ) + return + } + + plan.UUID = types.StringValue(content.UUID) + + // Set state to fully populated data + diags = resp.State.Set(ctx, plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } +} + +// Read refreshes the Terraform state with the latest data. +func (r *roleResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + // Get current state + var state roleResourceModel + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + content := &api.Role{} + if err := r.client.Read(consts.TypeNameRole, state.UUID.ValueString(), content); err != nil { + if err == api.Error404 { + resp.State.RemoveResource(ctx) + return + } + + resp.Diagnostics.AddError( + "Error reading role", + "Could not read role, unexpected error: "+err.Error(), + ) + return + } + + hasDefault := false + for _, p := range state.Keys { + if p.ValueString() == "routine.defaultAccess" { + hasDefault = true + break + } + } + + state.Name = types.StringValue(content.Name) + state.Desc = types.StringValue(content.Desc) + state.Keys = make([]basetypes.StringValue, 0) + for _, permission := range content.Permissions { + if permission == "routine.defaultAccess" && !hasDefault { //hack: skip defaultAccess + continue + } + state.Keys = append(state.Keys, types.StringValue(permission)) + } + + // Set refreshed state + diags = resp.State.Set(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } +} + +// Update updates the resource and sets the updated Terraform state on success. +func (r *roleResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + // Retrieve values from plan + var plan roleResourceModel + diags := req.Plan.Get(ctx, &plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + item := r.getRoleFromPlan(&plan) + item.UUID = "" + content := false + + tflog.Info(ctx, "Updating role", map[string]interface{}{ + "item": item, + }) + if err := r.client.Update(consts.TypeNameRole, plan.UUID.ValueString(), item, &content); err != nil { + resp.Diagnostics.AddError( + "Error updating role", + "Could not update role, unexpected error: "+err.Error(), + ) + return + } + + // Set state to fully populated data + diags = resp.State.Set(ctx, plan) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } +} + +// Delete deletes the resource and removes the Terraform state on success. +func (r *roleResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + // Retrieve values from state + var state roleResourceModel + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + err := r.client.DeleteRole(state.UUID.ValueString()) + if err != nil { + resp.Diagnostics.AddError( + "Error deleting role", + "Could not delete role, unexpected error: "+err.Error(), + ) + return + } + +} + +func (r *roleResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + // Retrieve import ID and save to id attribute + resource.ImportStatePassthroughID(ctx, path.Root("uuid"), req, resp) +} + +func (r *roleResource) getRoleFromPlan(plan *roleResourceModel) *api.Role { + item := &api.Role{ + Name: plan.Name.ValueString(), + Desc: plan.Desc.ValueString(), + } + item.Keys = make([]string, 0) + for _, key := range plan.Keys { + item.Keys = append(item.Keys, key.ValueString()) + } + return item +} diff --git a/internal/resources/role/schema.go b/internal/resources/role/schema.go new file mode 100644 index 0000000..0c3a006 --- /dev/null +++ b/internal/resources/role/schema.go @@ -0,0 +1,38 @@ +package role + +import ( + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" +) + +var resourceSchema = schema.Schema{ + Description: "Role is a set of permissions that can be assigned to a user or a group of users.", + MarkdownDescription: resourceDocument, + Attributes: map[string]schema.Attribute{ + "uuid": schema.StringAttribute{ + Description: "The UUID of the role.", + Computed: true, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.UseStateForUnknown(), + }, + }, + "name": schema.StringAttribute{ + Description: "The name of the role.", + Required: true, + }, + + "desc": schema.StringAttribute{ + Description: "The description of the role.", + Computed: true, + Optional: true, + }, + + "keys": schema.ListAttribute{ + Description: "The permission keys.", + Required: true, + ElementType: types.StringType, + }, + }, +} diff --git a/internal/sdk/api/cloudcontrol/v1/client.go b/internal/sdk/api/cloudcontrol/v1/client.go deleted file mode 100644 index ded6f46..0000000 --- a/internal/sdk/api/cloudcontrol/v1/client.go +++ /dev/null @@ -1,335 +0,0 @@ -package v1 - -import ( - "bytes" - "context" - "encoding/json" - "fmt" - "io" - "net/http" - "strings" - - "github.com/avast/retry-go" - "github.com/go-kratos/kratos/v2/errors" - "github.com/hashicorp/go-multierror" - "google.golang.org/protobuf/encoding/protojson" - "google.golang.org/protobuf/proto" - - "github.com/GuanceCloud/terraform-provider-guance/internal/sdk/types" -) - -type Client interface { - CreateResource(ctx context.Context, req *CreateResourceRequest, opts ...Option) (rsp *CreateResourceResponse, err error) - DeleteResource(ctx context.Context, req *DeleteResourceRequest, opts ...Option) (rsp *DeleteResourceResponse, err error) - GetResource(ctx context.Context, req *GetResourceRequest, opts ...Option) (rsp *GetResourceResponse, err error) - ListResources(ctx context.Context, req *ListResourcesRequest, opts ...Option) (rsp *ListResourcesResponse, err error) - UpdateResource(ctx context.Context, req *UpdateResourceRequest, opts ...Option) (rsp *UpdateResourceResponse, err error) -} - -type Option func(Client) error - -func NewClient(options ...Option) (Client, error) { - c := &client{} - var mErr error - for _, option := range options { - err := option(c) - if err != nil { - mErr = multierror.Append(mErr, err) - } - } - return c, mErr -} - -type client struct { - token string - region string - endpoint string - wait bool - maxRetries int - nonIdempotentRetried bool -} - -// WithEndpoint is an option to set the endpoint of the service. -func WithEndpoint(endpoint string) Option { - return func(c Client) error { - c.(*client).endpoint = endpoint - return nil - } -} - -// WithWait is an option to set if need to wait the request is completed. -func WithWait(wait bool) Option { - return func(c Client) error { - c.(*client).wait = wait - return nil - } -} - -// WithRegion is an option to set the region of the service. -func WithRegion(region string) Option { - return func(c Client) error { - c.(*client).region = region - c.(*client).endpoint = "https://api.guance.io" - // c.(*client).endpoint = "http://localhost:8000" - return nil - } -} - -// WithAccessToken is an option to set the access token of the service. -func WithAccessToken(token string) Option { - return func(c Client) error { - c.(*client).token = token - return nil - } -} - -// WithMaxRetries is an option to set the max retries of the request. -func WithMaxRetries(maxRetries int) Option { - return func(c Client) error { - c.(*client).maxRetries = maxRetries - return nil - } -} - -// WithNonIdempotentRetried is an option to set if need to retry the non idempotent request. -func WithNonIdempotentRetried(nonIdempotentRetried bool) Option { - return func(c Client) error { - c.(*client).nonIdempotentRetried = nonIdempotentRetried - return nil - } -} - -func (c client) clone() client { - return client{ - token: c.token, - region: c.region, - endpoint: c.endpoint, - wait: c.wait, - maxRetries: c.maxRetries, - nonIdempotentRetried: c.nonIdempotentRetried, - } -} - -func (c client) withOptions(opts ...Option) (*client, error) { - var mErr error - cc := c.clone() - for _, opt := range opts { - if err := opt(&cc); err != nil { - mErr = multierror.Append(mErr, err) - } - } - return &cc, mErr -} - -func (c client) CreateResource(ctx context.Context, req *CreateResourceRequest, opts ...Option) (rsp *CreateResourceResponse, err error) { - if !c.nonIdempotentRetried { - opts = append(opts, WithMaxRetries(0)) - } - - cc, err := c.withOptions(opts...) - if err != nil { - return nil, err - } - - req.Region = cc.region - req.AccessToken = cc.token - - // request to create resource - rsp = &CreateResourceResponse{} - err = cc.invoke(ctx, "/cloud-control/create-resource", req, rsp) - if err != nil { - return nil, err - } - - if !cc.wait { - return rsp, nil - } - - if err := c.Wait(ctx, WaitOptions{RequestId: rsp.ProgressEvent.RequestToken}); err != nil { - return nil, fmt.Errorf("failed when retring to create resource: %w", err) - } - return rsp, nil -} - -func (c client) DeleteResource(ctx context.Context, req *DeleteResourceRequest, opts ...Option) (rsp *DeleteResourceResponse, err error) { - if !c.nonIdempotentRetried { - opts = append(opts, WithMaxRetries(0)) - } - - cc, err := c.withOptions(opts...) - if err != nil { - return nil, err - } - - req.AccessToken = cc.token - - // request to create resource - rsp = &DeleteResourceResponse{} - err = cc.invoke(ctx, "/cloud-control/delete-resource", req, rsp) - if err != nil { - return nil, err - } - - if !cc.wait { - return rsp, nil - } - - if err := c.Wait(ctx, WaitOptions{RequestId: rsp.ProgressEvent.RequestToken}); err != nil { - return nil, fmt.Errorf("failed when retring to create resource: %w", err) - } - return rsp, nil -} - -func (c client) GetResource(ctx context.Context, req *GetResourceRequest, opts ...Option) (rsp *GetResourceResponse, err error) { - cc, err := c.withOptions(opts...) - if err != nil { - return nil, err - } - - req.AccessToken = cc.token - - // request to create resource - rsp = &GetResourceResponse{} - err = cc.invoke(ctx, "/cloud-control/get-resource", req, rsp) - if err != nil { - return nil, err - } - return rsp, nil -} - -func (c client) ListResources(ctx context.Context, req *ListResourcesRequest, opts ...Option) (rsp *ListResourcesResponse, err error) { - cc, err := c.withOptions(opts...) - if err != nil { - return nil, err - } - - req.Region = cc.region - req.AccessToken = cc.token - - // request to create resource - rsp = &ListResourcesResponse{} - err = cc.invoke(ctx, "/cloud-control/list-resources", req, rsp) - if err != nil { - return nil, err - } - return rsp, nil -} - -func (c client) UpdateResource(ctx context.Context, req *UpdateResourceRequest, opts ...Option) (rsp *UpdateResourceResponse, err error) { - if !c.nonIdempotentRetried { - opts = append(opts, WithMaxRetries(0)) - } - - cc, err := c.withOptions(opts...) - if err != nil { - return nil, err - } - - req.AccessToken = cc.token - - // request to create resource - rsp = &UpdateResourceResponse{} - err = cc.invoke(ctx, "/cloud-control/update-resource", req, rsp) - if err != nil { - return nil, err - } - - if !cc.wait { - return rsp, nil - } - - if err := c.Wait(ctx, WaitOptions{RequestId: rsp.ProgressEvent.RequestToken}); err != nil { - return nil, fmt.Errorf("failed when retring to create resource: %w", err) - } - return rsp, nil -} - -func (c client) invoke(ctx context.Context, path string, in interface{}, out proto.Message) error { - reqBytes, err := json.Marshal(in) - if err != nil { - return err - } - - httpClient := &http.Client{} - - // Send request - resp, err := httpClient.Post( - fmt.Sprintf("%s/%s", strings.Trim(c.endpoint, "/"), strings.Trim(path, "/")), - "application/json", - bytes.NewBuffer(reqBytes), - ) - if err != nil { - return err - } - - // Got errors - if resp.StatusCode >= 400 { - respBytes, err := io.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("read response body failed with status code %d", resp.StatusCode) - } - fmt.Println("[Got]", path, string(respBytes)) - outErr := &errors.Error{} - if err := protojson.Unmarshal(respBytes, outErr); err != nil { - return fmt.Errorf("unmarshal failed with status code %d: %s", resp.StatusCode, string(respBytes)) - } - return outErr - } - - // Got response - respBytes, err := io.ReadAll(resp.Body) - if err != nil { - return err - } - fmt.Println("[Got]", path, string(respBytes)) - if err := protojson.Unmarshal(respBytes, out); err != nil { - return err - } - return nil -} - -type WaitOptions struct { - RequestId string -} - -func (c client) Wait(ctx context.Context, opts WaitOptions) error { - return retry.Do( - func() error { - // wait for the request is completed - r, err := c.getResourceRequestStatus(ctx, &GetResourceRequestStatusRequest{ - RequestToken: opts.RequestId, - }) - if err != nil { - return err - } - - fmt.Printf("Waiting for request to be completed, current status: %s\n", r.ProgressEvent.OperationStatus) - - switch r.ProgressEvent.OperationStatus { - case types.RequestStatusPending, - types.RequestStatusInProgress, - types.RequestStatusCancelInProgress: - return fmt.Errorf("request is not completed") - case types.RequestStatusSuccess, - types.RequestStatusCancelComplete: - return nil - case types.RequestStatusFailed: - return fmt.Errorf("failed: %s", r.ProgressEvent.StatusMessage) - default: - return fmt.Errorf("unknown status %s", r.ProgressEvent.OperationStatus) - } - }, - retry.RetryIf(func(err error) bool { - return strings.Contains(err.Error(), "request is not completed") - }), - ) -} - -func (c client) getResourceRequestStatus(ctx context.Context, g *GetResourceRequestStatusRequest) (*GetResourceRequestStatusResponse, error) { - rsp := &GetResourceRequestStatusResponse{} - err := c.invoke(ctx, "/cloud-control/get-resource-request-status", g, rsp) - if err != nil { - return nil, err - } - return rsp, nil -} diff --git a/internal/sdk/api/cloudcontrol/v1/cloudcontrol.pb.go b/internal/sdk/api/cloudcontrol/v1/cloudcontrol.pb.go deleted file mode 100644 index d4579ec..0000000 --- a/internal/sdk/api/cloudcontrol/v1/cloudcontrol.pb.go +++ /dev/null @@ -1,1841 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc (unknown) -// source: api/cloudcontrol/v1/cloudcontrol.proto - -package v1 - -import ( - reflect "reflect" - sync "sync" - - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// The request message of resource creating. -type CreateResourceRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The region of the resource. - Region string `protobuf:"bytes,1,opt,name=region,proto3" json:"region,omitempty"` - // The name of the resource type. - TypeName string `protobuf:"bytes,2,opt,name=type_name,json=typeName,proto3" json:"type_name,omitempty"` - // Structured data format representing the desired state of the resource, - // consisting of that resource's properties and their desired values. - // - // Specify the desired state is a JSON blob. - DesiredState string `protobuf:"bytes,3,opt,name=desired_state,json=desiredState,proto3" json:"desired_state,omitempty"` - // The access token of request - AccessToken string `protobuf:"bytes,4,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` -} - -func (x *CreateResourceRequest) Reset() { - *x = CreateResourceRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreateResourceRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateResourceRequest) ProtoMessage() {} - -func (x *CreateResourceRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CreateResourceRequest.ProtoReflect.Descriptor instead. -func (*CreateResourceRequest) Descriptor() ([]byte, []int) { - return file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescGZIP(), []int{0} -} - -func (x *CreateResourceRequest) GetRegion() string { - if x != nil { - return x.Region - } - return "" -} - -func (x *CreateResourceRequest) GetTypeName() string { - if x != nil { - return x.TypeName - } - return "" -} - -func (x *CreateResourceRequest) GetDesiredState() string { - if x != nil { - return x.DesiredState - } - return "" -} - -func (x *CreateResourceRequest) GetAccessToken() string { - if x != nil { - return x.AccessToken - } - return "" -} - -// The response message of resource creating. -type CreateResourceResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Represents the current status of the resource creating request. - ProgressEvent *ProgressEvent `protobuf:"bytes,1,opt,name=progress_event,json=progressEvent,proto3" json:"progress_event,omitempty"` -} - -func (x *CreateResourceResponse) Reset() { - *x = CreateResourceResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreateResourceResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateResourceResponse) ProtoMessage() {} - -func (x *CreateResourceResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CreateResourceResponse.ProtoReflect.Descriptor instead. -func (*CreateResourceResponse) Descriptor() ([]byte, []int) { - return file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescGZIP(), []int{1} -} - -func (x *CreateResourceResponse) GetProgressEvent() *ProgressEvent { - if x != nil { - return x.ProgressEvent - } - return nil -} - -// The request message of resource getting. -type GetResourceRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The identifier for the resource. - Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"` - // The access token of request - AccessToken string `protobuf:"bytes,2,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` -} - -func (x *GetResourceRequest) Reset() { - *x = GetResourceRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetResourceRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetResourceRequest) ProtoMessage() {} - -func (x *GetResourceRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetResourceRequest.ProtoReflect.Descriptor instead. -func (*GetResourceRequest) Descriptor() ([]byte, []int) { - return file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescGZIP(), []int{2} -} - -func (x *GetResourceRequest) GetIdentifier() string { - if x != nil { - return x.Identifier - } - return "" -} - -func (x *GetResourceRequest) GetAccessToken() string { - if x != nil { - return x.AccessToken - } - return "" -} - -// The response message of resource getting. -type GetResourceResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Represents information about a provisioned resource. - ResourceDescription *ResourceDescription `protobuf:"bytes,1,opt,name=resource_description,json=resourceDescription,proto3" json:"resource_description,omitempty"` - // The name of the resource type. - TypeName string `protobuf:"bytes,2,opt,name=type_name,json=typeName,proto3" json:"type_name,omitempty"` -} - -func (x *GetResourceResponse) Reset() { - *x = GetResourceResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetResourceResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetResourceResponse) ProtoMessage() {} - -func (x *GetResourceResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetResourceResponse.ProtoReflect.Descriptor instead. -func (*GetResourceResponse) Descriptor() ([]byte, []int) { - return file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescGZIP(), []int{3} -} - -func (x *GetResourceResponse) GetResourceDescription() *ResourceDescription { - if x != nil { - return x.ResourceDescription - } - return nil -} - -func (x *GetResourceResponse) GetTypeName() string { - if x != nil { - return x.TypeName - } - return "" -} - -// The request message of resource deleting. -type DeleteResourceRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The identifier for the resource. - Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"` - // The access token of request - AccessToken string `protobuf:"bytes,2,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` -} - -func (x *DeleteResourceRequest) Reset() { - *x = DeleteResourceRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DeleteResourceRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteResourceRequest) ProtoMessage() {} - -func (x *DeleteResourceRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DeleteResourceRequest.ProtoReflect.Descriptor instead. -func (*DeleteResourceRequest) Descriptor() ([]byte, []int) { - return file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescGZIP(), []int{4} -} - -func (x *DeleteResourceRequest) GetIdentifier() string { - if x != nil { - return x.Identifier - } - return "" -} - -func (x *DeleteResourceRequest) GetAccessToken() string { - if x != nil { - return x.AccessToken - } - return "" -} - -// The response message of resource deleting. -type DeleteResourceResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Represents the current status of the resource deletion request. - ProgressEvent *ProgressEvent `protobuf:"bytes,1,opt,name=progress_event,json=progressEvent,proto3" json:"progress_event,omitempty"` -} - -func (x *DeleteResourceResponse) Reset() { - *x = DeleteResourceResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DeleteResourceResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteResourceResponse) ProtoMessage() {} - -func (x *DeleteResourceResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DeleteResourceResponse.ProtoReflect.Descriptor instead. -func (*DeleteResourceResponse) Descriptor() ([]byte, []int) { - return file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescGZIP(), []int{5} -} - -func (x *DeleteResourceResponse) GetProgressEvent() *ProgressEvent { - if x != nil { - return x.ProgressEvent - } - return nil -} - -// The request message of resource listing. -type ListResourcesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Count of reserved records. - MaxResults int64 `protobuf:"varint,1,opt,name=max_results,json=maxResults,proto3" json:"max_results,omitempty"` - // The region of the resource. - Region string `protobuf:"bytes,2,opt,name=region,proto3" json:"region,omitempty"` - // The name of the resource type. - TypeName string `protobuf:"bytes,3,opt,name=type_name,json=typeName,proto3" json:"type_name,omitempty"` - // The access token of request - AccessToken string `protobuf:"bytes,4,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` -} - -func (x *ListResourcesRequest) Reset() { - *x = ListResourcesRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListResourcesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListResourcesRequest) ProtoMessage() {} - -func (x *ListResourcesRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListResourcesRequest.ProtoReflect.Descriptor instead. -func (*ListResourcesRequest) Descriptor() ([]byte, []int) { - return file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescGZIP(), []int{6} -} - -func (x *ListResourcesRequest) GetMaxResults() int64 { - if x != nil { - return x.MaxResults - } - return 0 -} - -func (x *ListResourcesRequest) GetRegion() string { - if x != nil { - return x.Region - } - return "" -} - -func (x *ListResourcesRequest) GetTypeName() string { - if x != nil { - return x.TypeName - } - return "" -} - -func (x *ListResourcesRequest) GetAccessToken() string { - if x != nil { - return x.AccessToken - } - return "" -} - -// The response message of resource listing. -type ListResourcesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // If the request doesn't return all of the remaining results, NextToken is set to a token. - // To retrieve the next set of results, call ListResources again and assign that token to the request object's NextToken parameter. - // If the request returns all results, NextToken is set to null. - NextToken string `protobuf:"bytes,1,opt,name=next_token,json=nextToken,proto3" json:"next_token,omitempty"` - // A list of resource descriptions. - ResourceDescriptions []*ResourceDescription `protobuf:"bytes,2,rep,name=resource_descriptions,json=resourceDescriptions,proto3" json:"resource_descriptions,omitempty"` - // The name of the resource type. - TypeName string `protobuf:"bytes,3,opt,name=type_name,json=typeName,proto3" json:"type_name,omitempty"` -} - -func (x *ListResourcesResponse) Reset() { - *x = ListResourcesResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListResourcesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListResourcesResponse) ProtoMessage() {} - -func (x *ListResourcesResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListResourcesResponse.ProtoReflect.Descriptor instead. -func (*ListResourcesResponse) Descriptor() ([]byte, []int) { - return file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescGZIP(), []int{7} -} - -func (x *ListResourcesResponse) GetNextToken() string { - if x != nil { - return x.NextToken - } - return "" -} - -func (x *ListResourcesResponse) GetResourceDescriptions() []*ResourceDescription { - if x != nil { - return x.ResourceDescriptions - } - return nil -} - -func (x *ListResourcesResponse) GetTypeName() string { - if x != nil { - return x.TypeName - } - return "" -} - -// The request message of resource updating. -type UpdateResourceRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The identifier for the resource. - Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"` - // A JavaScript Object Notation (JSON) document listing the patch operations that represent the updates to apply to the current resource properties. - PatchDocument string `protobuf:"bytes,2,opt,name=patch_document,json=patchDocument,proto3" json:"patch_document,omitempty"` - // The access token of request - AccessToken string `protobuf:"bytes,3,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` -} - -func (x *UpdateResourceRequest) Reset() { - *x = UpdateResourceRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UpdateResourceRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateResourceRequest) ProtoMessage() {} - -func (x *UpdateResourceRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UpdateResourceRequest.ProtoReflect.Descriptor instead. -func (*UpdateResourceRequest) Descriptor() ([]byte, []int) { - return file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescGZIP(), []int{8} -} - -func (x *UpdateResourceRequest) GetIdentifier() string { - if x != nil { - return x.Identifier - } - return "" -} - -func (x *UpdateResourceRequest) GetPatchDocument() string { - if x != nil { - return x.PatchDocument - } - return "" -} - -func (x *UpdateResourceRequest) GetAccessToken() string { - if x != nil { - return x.AccessToken - } - return "" -} - -// The response message of resource updating. -type UpdateResourceResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Represents the current status of the resource update request. - ProgressEvent *ProgressEvent `protobuf:"bytes,1,opt,name=progress_event,json=progressEvent,proto3" json:"progress_event,omitempty"` -} - -func (x *UpdateResourceResponse) Reset() { - *x = UpdateResourceResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UpdateResourceResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateResourceResponse) ProtoMessage() {} - -func (x *UpdateResourceResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UpdateResourceResponse.ProtoReflect.Descriptor instead. -func (*UpdateResourceResponse) Descriptor() ([]byte, []int) { - return file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescGZIP(), []int{9} -} - -func (x *UpdateResourceResponse) GetProgressEvent() *ProgressEvent { - if x != nil { - return x.ProgressEvent - } - return nil -} - -// The request message of resource request canceling. -type CancelResourceRequestRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The RequestToken of the ProgressEvent object returned by the resource operation request. - RequestToken string `protobuf:"bytes,1,opt,name=request_token,json=requestToken,proto3" json:"request_token,omitempty"` -} - -func (x *CancelResourceRequestRequest) Reset() { - *x = CancelResourceRequestRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CancelResourceRequestRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CancelResourceRequestRequest) ProtoMessage() {} - -func (x *CancelResourceRequestRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[10] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CancelResourceRequestRequest.ProtoReflect.Descriptor instead. -func (*CancelResourceRequestRequest) Descriptor() ([]byte, []int) { - return file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescGZIP(), []int{10} -} - -func (x *CancelResourceRequestRequest) GetRequestToken() string { - if x != nil { - return x.RequestToken - } - return "" -} - -// The response message of resource request canceling. -type CancelResourceRequestResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Represents the current status of the resource update request. - ProgressEvent *ProgressEvent `protobuf:"bytes,1,opt,name=progress_event,json=progressEvent,proto3" json:"progress_event,omitempty"` -} - -func (x *CancelResourceRequestResponse) Reset() { - *x = CancelResourceRequestResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CancelResourceRequestResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CancelResourceRequestResponse) ProtoMessage() {} - -func (x *CancelResourceRequestResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[11] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CancelResourceRequestResponse.ProtoReflect.Descriptor instead. -func (*CancelResourceRequestResponse) Descriptor() ([]byte, []int) { - return file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescGZIP(), []int{11} -} - -func (x *CancelResourceRequestResponse) GetProgressEvent() *ProgressEvent { - if x != nil { - return x.ProgressEvent - } - return nil -} - -// The request message of resource request status getting. -type GetResourceRequestStatusRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The RequestToken of the ProgressEvent object returned by the resource operation request. - RequestToken string `protobuf:"bytes,1,opt,name=request_token,json=requestToken,proto3" json:"request_token,omitempty"` -} - -func (x *GetResourceRequestStatusRequest) Reset() { - *x = GetResourceRequestStatusRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetResourceRequestStatusRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetResourceRequestStatusRequest) ProtoMessage() {} - -func (x *GetResourceRequestStatusRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[12] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetResourceRequestStatusRequest.ProtoReflect.Descriptor instead. -func (*GetResourceRequestStatusRequest) Descriptor() ([]byte, []int) { - return file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescGZIP(), []int{12} -} - -func (x *GetResourceRequestStatusRequest) GetRequestToken() string { - if x != nil { - return x.RequestToken - } - return "" -} - -// The response message of resource request status getting. -type GetResourceRequestStatusResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Represents the current status of the resource update request. - ProgressEvent *ProgressEvent `protobuf:"bytes,1,opt,name=progress_event,json=progressEvent,proto3" json:"progress_event,omitempty"` -} - -func (x *GetResourceRequestStatusResponse) Reset() { - *x = GetResourceRequestStatusResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetResourceRequestStatusResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetResourceRequestStatusResponse) ProtoMessage() {} - -func (x *GetResourceRequestStatusResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[13] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetResourceRequestStatusResponse.ProtoReflect.Descriptor instead. -func (*GetResourceRequestStatusResponse) Descriptor() ([]byte, []int) { - return file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescGZIP(), []int{13} -} - -func (x *GetResourceRequestStatusResponse) GetProgressEvent() *ProgressEvent { - if x != nil { - return x.ProgressEvent - } - return nil -} - -// The request message of resource requests listing. -type ListResourceRequestsRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Count of reserved records. - MaxResults int64 `protobuf:"varint,1,opt,name=max_results,json=maxResults,proto3" json:"max_results,omitempty"` - // If the previous paginated request didn't return all of the remaining results, - // the response object's NextToken parameter value is set to a token. - // To retrieve the next set of results, call this action again and assign that token to the request object's NextToken parameter. - // If there are no remaining results, the previous response object's NextToken parameter is set to null. - NextToken string `protobuf:"bytes,2,opt,name=next_token,json=nextToken,proto3" json:"next_token,omitempty"` - // The filter criteria to apply to the requests returned. - ResourceRequestStatusFilter *ResourceRequestStatusFilter `protobuf:"bytes,3,opt,name=resource_request_status_filter,json=resourceRequestStatusFilter,proto3" json:"resource_request_status_filter,omitempty"` -} - -func (x *ListResourceRequestsRequest) Reset() { - *x = ListResourceRequestsRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListResourceRequestsRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListResourceRequestsRequest) ProtoMessage() {} - -func (x *ListResourceRequestsRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[14] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListResourceRequestsRequest.ProtoReflect.Descriptor instead. -func (*ListResourceRequestsRequest) Descriptor() ([]byte, []int) { - return file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescGZIP(), []int{14} -} - -func (x *ListResourceRequestsRequest) GetMaxResults() int64 { - if x != nil { - return x.MaxResults - } - return 0 -} - -func (x *ListResourceRequestsRequest) GetNextToken() string { - if x != nil { - return x.NextToken - } - return "" -} - -func (x *ListResourceRequestsRequest) GetResourceRequestStatusFilter() *ResourceRequestStatusFilter { - if x != nil { - return x.ResourceRequestStatusFilter - } - return nil -} - -// The response message of resource requests listing. -type ListResourceRequestsResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // If the request doesn't return all of the remaining results, NextToken is set to a token. - // To retrieve the next set of results, call ListResourceRequests again and assign that token to the request object's NextToken parameter. - // If the request returns all results, NextToken is set to null. - NextToken string `protobuf:"bytes,1,opt,name=next_token,json=nextToken,proto3" json:"next_token,omitempty"` - // A list of resource requests. - ResourceRequestStatusSummaries []*ProgressEvent `protobuf:"bytes,2,rep,name=resource_request_status_summaries,json=resourceRequestStatusSummaries,proto3" json:"resource_request_status_summaries,omitempty"` -} - -func (x *ListResourceRequestsResponse) Reset() { - *x = ListResourceRequestsResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ListResourceRequestsResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListResourceRequestsResponse) ProtoMessage() {} - -func (x *ListResourceRequestsResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[15] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListResourceRequestsResponse.ProtoReflect.Descriptor instead. -func (*ListResourceRequestsResponse) Descriptor() ([]byte, []int) { - return file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescGZIP(), []int{15} -} - -func (x *ListResourceRequestsResponse) GetNextToken() string { - if x != nil { - return x.NextToken - } - return "" -} - -func (x *ListResourceRequestsResponse) GetResourceRequestStatusSummaries() []*ProgressEvent { - if x != nil { - return x.ResourceRequestStatusSummaries - } - return nil -} - -// The current status of a resource operation request. -type ProgressEvent struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // For requests with a status of FAILED, the associated error code. - // - // Valid Values: - // NotUpdatable - // | InvalidRequest - // | AccessDenied - // | InvalidCredentials - // | AlreadyExists - // | NotFound - // | ResourceConflict - // | Throttling - // | ServiceLimitExceeded - // | NotStabilized - // | GeneralServiceException - // | ServiceInternalError - // | ServiceTimeout - // | NetworkFailure - // | InternalFailure - ErrorCode string `protobuf:"bytes,1,opt,name=error_code,json=errorCode,proto3" json:"error_code,omitempty"` - // When the resource operation request was initiated. - EventTime int64 `protobuf:"varint,2,opt,name=event_time,json=eventTime,proto3" json:"event_time,omitempty"` - // The primary identifier for the resource. - Identifier string `protobuf:"bytes,3,opt,name=identifier,proto3" json:"identifier,omitempty"` - // The resource operation type. - // - // Valid Values: - // CREATE - // | DELETE - // | UPDATE - Operation string `protobuf:"bytes,4,opt,name=operation,proto3" json:"operation,omitempty"` - // The current status of the resource operation request. - // - // PENDING: The resource operation hasn't yet started. - // IN_PROGRESS: The resource operation is currently in progress. - // SUCCESS: The resource operation has successfully completed. - // FAILED: The resource operation has failed. Refer to the error code and status message for more information. - // CANCEL_IN_PROGRESS: The resource operation is in the process of being canceled. - // CANCEL_COMPLETE: The resource operation has been canceled. - OperationStatus string `protobuf:"bytes,5,opt,name=operation_status,json=operationStatus,proto3" json:"operation_status,omitempty"` - // The unique token representing this resource operation request. - // Use the RequestToken with GetResourceRequestStatus to return the current status of a resource operation request. - RequestToken string `protobuf:"bytes,6,opt,name=request_token,json=requestToken,proto3" json:"request_token,omitempty"` - // A JSON string containing the resource model, - // consisting of each resource property and its current value. - ResourceModel string `protobuf:"bytes,7,opt,name=resource_model,json=resourceModel,proto3" json:"resource_model,omitempty"` - // When to next request the status of this resource operation request. - RetryAfter int64 `protobuf:"varint,8,opt,name=retry_after,json=retryAfter,proto3" json:"retry_after,omitempty"` - // Any message explaining the current status. - StatusMessage string `protobuf:"bytes,9,opt,name=status_message,json=statusMessage,proto3" json:"status_message,omitempty"` - // The name of the resource type used in the operation. - TypeName string `protobuf:"bytes,10,opt,name=type_name,json=typeName,proto3" json:"type_name,omitempty"` -} - -func (x *ProgressEvent) Reset() { - *x = ProgressEvent{} - if protoimpl.UnsafeEnabled { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[16] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ProgressEvent) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ProgressEvent) ProtoMessage() {} - -func (x *ProgressEvent) ProtoReflect() protoreflect.Message { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[16] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ProgressEvent.ProtoReflect.Descriptor instead. -func (*ProgressEvent) Descriptor() ([]byte, []int) { - return file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescGZIP(), []int{16} -} - -func (x *ProgressEvent) GetErrorCode() string { - if x != nil { - return x.ErrorCode - } - return "" -} - -func (x *ProgressEvent) GetEventTime() int64 { - if x != nil { - return x.EventTime - } - return 0 -} - -func (x *ProgressEvent) GetIdentifier() string { - if x != nil { - return x.Identifier - } - return "" -} - -func (x *ProgressEvent) GetOperation() string { - if x != nil { - return x.Operation - } - return "" -} - -func (x *ProgressEvent) GetOperationStatus() string { - if x != nil { - return x.OperationStatus - } - return "" -} - -func (x *ProgressEvent) GetRequestToken() string { - if x != nil { - return x.RequestToken - } - return "" -} - -func (x *ProgressEvent) GetResourceModel() string { - if x != nil { - return x.ResourceModel - } - return "" -} - -func (x *ProgressEvent) GetRetryAfter() int64 { - if x != nil { - return x.RetryAfter - } - return 0 -} - -func (x *ProgressEvent) GetStatusMessage() string { - if x != nil { - return x.StatusMessage - } - return "" -} - -func (x *ProgressEvent) GetTypeName() string { - if x != nil { - return x.TypeName - } - return "" -} - -// Information about the specified resources, including primary identifier and resource model. -type ResourceDescription struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The identifier for the resource. - Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"` - // A list of the resource properties and their current values. - // It is a JSON blob. - Properties string `protobuf:"bytes,2,opt,name=properties,proto3" json:"properties,omitempty"` - // The time when the resource was created. - CreatedAt string `protobuf:"bytes,3,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` -} - -func (x *ResourceDescription) Reset() { - *x = ResourceDescription{} - if protoimpl.UnsafeEnabled { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ResourceDescription) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ResourceDescription) ProtoMessage() {} - -func (x *ResourceDescription) ProtoReflect() protoreflect.Message { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[17] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ResourceDescription.ProtoReflect.Descriptor instead. -func (*ResourceDescription) Descriptor() ([]byte, []int) { - return file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescGZIP(), []int{17} -} - -func (x *ResourceDescription) GetIdentifier() string { - if x != nil { - return x.Identifier - } - return "" -} - -func (x *ResourceDescription) GetProperties() string { - if x != nil { - return x.Properties - } - return "" -} - -func (x *ResourceDescription) GetCreatedAt() string { - if x != nil { - return x.CreatedAt - } - return "" -} - -// The filter criteria to use in determining the requests returned. -type ResourceRequestStatusFilter struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The operation types to include in the filter. - // - // Valid Values: - // CREATE - // | DELETE - // | UPDATE - Operations []string `protobuf:"bytes,1,rep,name=operations,proto3" json:"operations,omitempty"` - // The resource operation request status types to include in the filter. - // - // Valid Values: - // PENDING - // | IN_PROGRESS - // | SUCCESS - // | FAILED - // | CANCEL_IN_PROGRESS - // | CANCEL_COMPLETE - OperationStatuses []string `protobuf:"bytes,2,rep,name=operation_statuses,json=operationStatuses,proto3" json:"operation_statuses,omitempty"` -} - -func (x *ResourceRequestStatusFilter) Reset() { - *x = ResourceRequestStatusFilter{} - if protoimpl.UnsafeEnabled { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[18] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ResourceRequestStatusFilter) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ResourceRequestStatusFilter) ProtoMessage() {} - -func (x *ResourceRequestStatusFilter) ProtoReflect() protoreflect.Message { - mi := &file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[18] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ResourceRequestStatusFilter.ProtoReflect.Descriptor instead. -func (*ResourceRequestStatusFilter) Descriptor() ([]byte, []int) { - return file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescGZIP(), []int{18} -} - -func (x *ResourceRequestStatusFilter) GetOperations() []string { - if x != nil { - return x.Operations - } - return nil -} - -func (x *ResourceRequestStatusFilter) GetOperationStatuses() []string { - if x != nil { - return x.OperationStatuses - } - return nil -} - -var File_api_cloudcontrol_v1_cloudcontrol_proto protoreflect.FileDescriptor - -var file_api_cloudcontrol_v1_cloudcontrol_proto_rawDesc = []byte{ - 0x0a, 0x26, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x13, 0x61, 0x70, 0x69, 0x2e, 0x63, 0x6c, - 0x6f, 0x75, 0x64, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x1a, 0x1c, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x94, 0x01, 0x0a, 0x15, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, - 0x09, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x74, 0x79, 0x70, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x64, 0x65, - 0x73, 0x69, 0x72, 0x65, 0x64, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0c, 0x64, 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, - 0x21, 0x0a, 0x0c, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, - 0x65, 0x6e, 0x22, 0x63, 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x49, 0x0a, 0x0e, - 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, - 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x67, 0x72, - 0x65, 0x73, 0x73, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, - 0x73, 0x73, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x57, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x52, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a, - 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x21, 0x0a, - 0x0c, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, - 0x22, 0x8f, 0x01, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5b, 0x0a, 0x14, 0x72, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x5f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x63, 0x6c, 0x6f, - 0x75, 0x64, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x52, 0x13, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x79, 0x70, 0x65, 0x4e, 0x61, - 0x6d, 0x65, 0x22, 0x5a, 0x0a, 0x15, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x69, - 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x21, 0x0a, 0x0c, 0x61, - 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x63, - 0x0a, 0x16, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x49, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x67, - 0x72, 0x65, 0x73, 0x73, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x63, 0x6f, 0x6e, 0x74, - 0x72, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x45, - 0x76, 0x65, 0x6e, 0x74, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x45, 0x76, - 0x65, 0x6e, 0x74, 0x22, 0x8f, 0x01, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, - 0x6d, 0x61, 0x78, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x0a, 0x6d, 0x61, 0x78, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x12, 0x16, 0x0a, - 0x06, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, - 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x79, 0x70, 0x65, 0x4e, 0x61, - 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, - 0x65, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, - 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0xb2, 0x01, 0x0a, 0x15, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x1d, 0x0a, 0x0a, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x5d, - 0x0a, 0x15, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x64, 0x65, 0x73, 0x63, 0x72, - 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x44, 0x65, 0x73, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x14, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1b, 0x0a, - 0x09, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x74, 0x79, 0x70, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x81, 0x01, 0x0a, 0x15, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, - 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, - 0x66, 0x69, 0x65, 0x72, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x64, 0x6f, - 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x70, 0x61, - 0x74, 0x63, 0x68, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x61, - 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x63, - 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x49, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x67, - 0x72, 0x65, 0x73, 0x73, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x63, 0x6f, 0x6e, 0x74, - 0x72, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x45, - 0x76, 0x65, 0x6e, 0x74, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x45, 0x76, - 0x65, 0x6e, 0x74, 0x22, 0x43, 0x0a, 0x1c, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x52, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x74, - 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x6a, 0x0a, 0x1d, 0x43, 0x61, 0x6e, 0x63, - 0x65, 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x49, 0x0a, 0x0e, 0x70, 0x72, 0x6f, - 0x67, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x63, 0x6f, 0x6e, - 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, - 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x45, - 0x76, 0x65, 0x6e, 0x74, 0x22, 0x46, 0x0a, 0x1f, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, - 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x6d, 0x0a, 0x20, - 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x49, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x65, 0x76, 0x65, - 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x63, - 0x6c, 0x6f, 0x75, 0x64, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, - 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x0d, 0x70, 0x72, - 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x22, 0xd4, 0x01, 0x0a, 0x1b, - 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x6d, - 0x61, 0x78, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x0a, 0x6d, 0x61, 0x78, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x12, 0x1d, 0x0a, 0x0a, - 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x75, 0x0a, 0x1e, 0x72, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x63, - 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x46, - 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x1b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x46, 0x69, 0x6c, 0x74, - 0x65, 0x72, 0x22, 0xac, 0x01, 0x0a, 0x1c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x6f, 0x6b, 0x65, - 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x6f, 0x6b, - 0x65, 0x6e, 0x12, 0x6d, 0x0a, 0x21, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x72, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x73, 0x75, - 0x6d, 0x6d, 0x61, 0x72, 0x69, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x45, 0x76, 0x65, 0x6e, - 0x74, 0x52, 0x1e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x69, 0x65, - 0x73, 0x22, 0xe7, 0x02, 0x0a, 0x0d, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x45, 0x76, - 0x65, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, - 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, - 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, - 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x29, 0x0a, 0x10, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6f, 0x70, 0x65, 0x72, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0c, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, - 0x25, 0x0a, 0x0e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x6f, 0x64, 0x65, - 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x74, 0x72, 0x79, 0x5f, - 0x61, 0x66, 0x74, 0x65, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x72, 0x65, 0x74, - 0x72, 0x79, 0x41, 0x66, 0x74, 0x65, 0x72, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1b, - 0x0a, 0x09, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x74, 0x79, 0x70, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x74, 0x0a, 0x13, 0x52, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, - 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, - 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, - 0x74, 0x22, 0x6c, 0x0a, 0x1b, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, - 0x12, 0x1e, 0x0a, 0x0a, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x12, 0x2d, 0x0a, 0x12, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, 0x6f, 0x70, - 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x65, 0x73, 0x32, - 0x9d, 0x0a, 0x0a, 0x13, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x94, 0x01, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x2a, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x76, 0x31, - 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x63, 0x6c, 0x6f, - 0x75, 0x64, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x29, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x23, 0x3a, 0x01, 0x2a, 0x22, 0x1e, - 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2f, 0x63, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x2d, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x88, - 0x01, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x27, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, - 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x63, 0x6c, - 0x6f, 0x75, 0x64, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, - 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x26, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x20, 0x3a, 0x01, 0x2a, 0x22, 0x1b, 0x2f, 0x63, - 0x6c, 0x6f, 0x75, 0x64, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2f, 0x67, 0x65, 0x74, - 0x2d, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x94, 0x01, 0x0a, 0x0e, 0x44, 0x65, - 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x2a, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, - 0x76, 0x31, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x63, - 0x6c, 0x6f, 0x75, 0x64, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x44, - 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x23, 0x3a, 0x01, 0x2a, - 0x22, 0x1e, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x2f, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x2d, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x12, 0x90, 0x01, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x73, 0x12, 0x29, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x28, 0x82, 0xd3, 0xe4, 0x93, 0x02, - 0x22, 0x3a, 0x01, 0x2a, 0x22, 0x1d, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2d, 0x63, 0x6f, 0x6e, - 0x74, 0x72, 0x6f, 0x6c, 0x2f, 0x6c, 0x69, 0x73, 0x74, 0x2d, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x73, 0x12, 0x94, 0x01, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x63, 0x6c, 0x6f, - 0x75, 0x64, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x29, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x23, 0x3a, 0x01, 0x2a, 0x22, 0x1e, 0x2f, 0x63, 0x6c, 0x6f, - 0x75, 0x64, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2f, 0x75, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x2d, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0xb1, 0x01, 0x0a, 0x15, 0x43, - 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x31, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, - 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x61, 0x6e, 0x63, 0x65, - 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x32, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x63, 0x6c, - 0x6f, 0x75, 0x64, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x61, - 0x6e, 0x63, 0x65, 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x31, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x2b, 0x3a, 0x01, 0x2a, 0x22, 0x26, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2d, 0x63, - 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2f, 0x63, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x2d, 0x72, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2d, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0xbe, - 0x01, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x34, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x76, - 0x31, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x35, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x63, 0x6f, 0x6e, - 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x35, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2f, - 0x3a, 0x01, 0x2a, 0x22, 0x2a, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2d, 0x63, 0x6f, 0x6e, 0x74, - 0x72, 0x6f, 0x6c, 0x2f, 0x67, 0x65, 0x74, 0x2d, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x2d, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, - 0xad, 0x01, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x12, 0x30, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x63, - 0x6c, 0x6f, 0x75, 0x64, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x4c, - 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x76, 0x31, - 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x30, 0x82, - 0xd3, 0xe4, 0x93, 0x02, 0x2a, 0x3a, 0x01, 0x2a, 0x22, 0x25, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, - 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2f, 0x6c, 0x69, 0x73, 0x74, 0x2d, 0x72, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2d, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x42, - 0x37, 0x5a, 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x47, 0x75, - 0x61, 0x6e, 0x63, 0x65, 0x43, 0x6c, 0x6f, 0x75, 0x64, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, - 0x69, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescOnce sync.Once - file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescData = file_api_cloudcontrol_v1_cloudcontrol_proto_rawDesc -) - -func file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescGZIP() []byte { - file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescOnce.Do(func() { - file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescData = protoimpl.X.CompressGZIP(file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescData) - }) - return file_api_cloudcontrol_v1_cloudcontrol_proto_rawDescData -} - -var file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes = make([]protoimpl.MessageInfo, 19) -var file_api_cloudcontrol_v1_cloudcontrol_proto_goTypes = []interface{}{ - (*CreateResourceRequest)(nil), // 0: api.cloudcontrol.v1.CreateResourceRequest - (*CreateResourceResponse)(nil), // 1: api.cloudcontrol.v1.CreateResourceResponse - (*GetResourceRequest)(nil), // 2: api.cloudcontrol.v1.GetResourceRequest - (*GetResourceResponse)(nil), // 3: api.cloudcontrol.v1.GetResourceResponse - (*DeleteResourceRequest)(nil), // 4: api.cloudcontrol.v1.DeleteResourceRequest - (*DeleteResourceResponse)(nil), // 5: api.cloudcontrol.v1.DeleteResourceResponse - (*ListResourcesRequest)(nil), // 6: api.cloudcontrol.v1.ListResourcesRequest - (*ListResourcesResponse)(nil), // 7: api.cloudcontrol.v1.ListResourcesResponse - (*UpdateResourceRequest)(nil), // 8: api.cloudcontrol.v1.UpdateResourceRequest - (*UpdateResourceResponse)(nil), // 9: api.cloudcontrol.v1.UpdateResourceResponse - (*CancelResourceRequestRequest)(nil), // 10: api.cloudcontrol.v1.CancelResourceRequestRequest - (*CancelResourceRequestResponse)(nil), // 11: api.cloudcontrol.v1.CancelResourceRequestResponse - (*GetResourceRequestStatusRequest)(nil), // 12: api.cloudcontrol.v1.GetResourceRequestStatusRequest - (*GetResourceRequestStatusResponse)(nil), // 13: api.cloudcontrol.v1.GetResourceRequestStatusResponse - (*ListResourceRequestsRequest)(nil), // 14: api.cloudcontrol.v1.ListResourceRequestsRequest - (*ListResourceRequestsResponse)(nil), // 15: api.cloudcontrol.v1.ListResourceRequestsResponse - (*ProgressEvent)(nil), // 16: api.cloudcontrol.v1.ProgressEvent - (*ResourceDescription)(nil), // 17: api.cloudcontrol.v1.ResourceDescription - (*ResourceRequestStatusFilter)(nil), // 18: api.cloudcontrol.v1.ResourceRequestStatusFilter -} -var file_api_cloudcontrol_v1_cloudcontrol_proto_depIdxs = []int32{ - 16, // 0: api.cloudcontrol.v1.CreateResourceResponse.progress_event:type_name -> api.cloudcontrol.v1.ProgressEvent - 17, // 1: api.cloudcontrol.v1.GetResourceResponse.resource_description:type_name -> api.cloudcontrol.v1.ResourceDescription - 16, // 2: api.cloudcontrol.v1.DeleteResourceResponse.progress_event:type_name -> api.cloudcontrol.v1.ProgressEvent - 17, // 3: api.cloudcontrol.v1.ListResourcesResponse.resource_descriptions:type_name -> api.cloudcontrol.v1.ResourceDescription - 16, // 4: api.cloudcontrol.v1.UpdateResourceResponse.progress_event:type_name -> api.cloudcontrol.v1.ProgressEvent - 16, // 5: api.cloudcontrol.v1.CancelResourceRequestResponse.progress_event:type_name -> api.cloudcontrol.v1.ProgressEvent - 16, // 6: api.cloudcontrol.v1.GetResourceRequestStatusResponse.progress_event:type_name -> api.cloudcontrol.v1.ProgressEvent - 18, // 7: api.cloudcontrol.v1.ListResourceRequestsRequest.resource_request_status_filter:type_name -> api.cloudcontrol.v1.ResourceRequestStatusFilter - 16, // 8: api.cloudcontrol.v1.ListResourceRequestsResponse.resource_request_status_summaries:type_name -> api.cloudcontrol.v1.ProgressEvent - 0, // 9: api.cloudcontrol.v1.CloudControlService.CreateResource:input_type -> api.cloudcontrol.v1.CreateResourceRequest - 2, // 10: api.cloudcontrol.v1.CloudControlService.GetResource:input_type -> api.cloudcontrol.v1.GetResourceRequest - 4, // 11: api.cloudcontrol.v1.CloudControlService.DeleteResource:input_type -> api.cloudcontrol.v1.DeleteResourceRequest - 6, // 12: api.cloudcontrol.v1.CloudControlService.ListResources:input_type -> api.cloudcontrol.v1.ListResourcesRequest - 8, // 13: api.cloudcontrol.v1.CloudControlService.UpdateResource:input_type -> api.cloudcontrol.v1.UpdateResourceRequest - 10, // 14: api.cloudcontrol.v1.CloudControlService.CancelResourceRequest:input_type -> api.cloudcontrol.v1.CancelResourceRequestRequest - 12, // 15: api.cloudcontrol.v1.CloudControlService.GetResourceRequestStatus:input_type -> api.cloudcontrol.v1.GetResourceRequestStatusRequest - 14, // 16: api.cloudcontrol.v1.CloudControlService.ListResourceRequests:input_type -> api.cloudcontrol.v1.ListResourceRequestsRequest - 1, // 17: api.cloudcontrol.v1.CloudControlService.CreateResource:output_type -> api.cloudcontrol.v1.CreateResourceResponse - 3, // 18: api.cloudcontrol.v1.CloudControlService.GetResource:output_type -> api.cloudcontrol.v1.GetResourceResponse - 5, // 19: api.cloudcontrol.v1.CloudControlService.DeleteResource:output_type -> api.cloudcontrol.v1.DeleteResourceResponse - 7, // 20: api.cloudcontrol.v1.CloudControlService.ListResources:output_type -> api.cloudcontrol.v1.ListResourcesResponse - 9, // 21: api.cloudcontrol.v1.CloudControlService.UpdateResource:output_type -> api.cloudcontrol.v1.UpdateResourceResponse - 11, // 22: api.cloudcontrol.v1.CloudControlService.CancelResourceRequest:output_type -> api.cloudcontrol.v1.CancelResourceRequestResponse - 13, // 23: api.cloudcontrol.v1.CloudControlService.GetResourceRequestStatus:output_type -> api.cloudcontrol.v1.GetResourceRequestStatusResponse - 15, // 24: api.cloudcontrol.v1.CloudControlService.ListResourceRequests:output_type -> api.cloudcontrol.v1.ListResourceRequestsResponse - 17, // [17:25] is the sub-list for method output_type - 9, // [9:17] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name -} - -func init() { file_api_cloudcontrol_v1_cloudcontrol_proto_init() } -func file_api_cloudcontrol_v1_cloudcontrol_proto_init() { - if File_api_cloudcontrol_v1_cloudcontrol_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateResourceRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateResourceResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetResourceRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetResourceResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteResourceRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteResourceResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListResourcesRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListResourcesResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateResourceRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateResourceResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CancelResourceRequestRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CancelResourceRequestResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetResourceRequestStatusRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetResourceRequestStatusResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListResourceRequestsRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ListResourceRequestsResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ProgressEvent); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ResourceDescription); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ResourceRequestStatusFilter); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_api_cloudcontrol_v1_cloudcontrol_proto_rawDesc, - NumEnums: 0, - NumMessages: 19, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_api_cloudcontrol_v1_cloudcontrol_proto_goTypes, - DependencyIndexes: file_api_cloudcontrol_v1_cloudcontrol_proto_depIdxs, - MessageInfos: file_api_cloudcontrol_v1_cloudcontrol_proto_msgTypes, - }.Build() - File_api_cloudcontrol_v1_cloudcontrol_proto = out.File - file_api_cloudcontrol_v1_cloudcontrol_proto_rawDesc = nil - file_api_cloudcontrol_v1_cloudcontrol_proto_goTypes = nil - file_api_cloudcontrol_v1_cloudcontrol_proto_depIdxs = nil -} diff --git a/internal/sdk/api/cloudcontrol/v1/cloudcontrol.pb.validate.go b/internal/sdk/api/cloudcontrol/v1/cloudcontrol.pb.validate.go deleted file mode 100644 index 5ffbacd..0000000 --- a/internal/sdk/api/cloudcontrol/v1/cloudcontrol.pb.validate.go +++ /dev/null @@ -1,2324 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: api/cloudcontrol/v1/cloudcontrol.proto - -package v1 - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on CreateResourceRequest with the rules -// defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *CreateResourceRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateResourceRequest with the rules -// defined in the proto definition for this message. If any rules are -// violated, the result is a list of violation errors wrapped in -// CreateResourceRequestMultiError, or nil if none found. -func (m *CreateResourceRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateResourceRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Region - - // no validation rules for TypeName - - // no validation rules for DesiredState - - // no validation rules for AccessToken - - if len(errors) > 0 { - return CreateResourceRequestMultiError(errors) - } - - return nil -} - -// CreateResourceRequestMultiError is an error wrapping multiple validation -// errors returned by CreateResourceRequest.ValidateAll() if the designated -// constraints aren't met. -type CreateResourceRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateResourceRequestMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m CreateResourceRequestMultiError) AllErrors() []error { return m } - -// CreateResourceRequestValidationError is the validation error returned by -// CreateResourceRequest.Validate if the designated constraints aren't met. -type CreateResourceRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateResourceRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateResourceRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateResourceRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateResourceRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateResourceRequestValidationError) ErrorName() string { - return "CreateResourceRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateResourceRequestValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sCreateResourceRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateResourceRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateResourceRequestValidationError{} - -// Validate checks the field values on CreateResourceResponse with the rules -// defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *CreateResourceResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateResourceResponse with the rules -// defined in the proto definition for this message. If any rules are -// violated, the result is a list of violation errors wrapped in -// CreateResourceResponseMultiError, or nil if none found. -func (m *CreateResourceResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateResourceResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetProgressEvent()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateResourceResponseValidationError{ - field: "ProgressEvent", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateResourceResponseValidationError{ - field: "ProgressEvent", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetProgressEvent()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateResourceResponseValidationError{ - field: "ProgressEvent", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateResourceResponseMultiError(errors) - } - - return nil -} - -// CreateResourceResponseMultiError is an error wrapping multiple validation -// errors returned by CreateResourceResponse.ValidateAll() if the designated -// constraints aren't met. -type CreateResourceResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateResourceResponseMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m CreateResourceResponseMultiError) AllErrors() []error { return m } - -// CreateResourceResponseValidationError is the validation error returned by -// CreateResourceResponse.Validate if the designated constraints aren't met. -type CreateResourceResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateResourceResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateResourceResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateResourceResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateResourceResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateResourceResponseValidationError) ErrorName() string { - return "CreateResourceResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateResourceResponseValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sCreateResourceResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateResourceResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateResourceResponseValidationError{} - -// Validate checks the field values on GetResourceRequest with the rules -// defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *GetResourceRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetResourceRequest with the rules -// defined in the proto definition for this message. If any rules are -// violated, the result is a list of violation errors wrapped in -// GetResourceRequestMultiError, or nil if none found. -func (m *GetResourceRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *GetResourceRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Identifier - - // no validation rules for AccessToken - - if len(errors) > 0 { - return GetResourceRequestMultiError(errors) - } - - return nil -} - -// GetResourceRequestMultiError is an error wrapping multiple validation errors -// returned by GetResourceRequest.ValidateAll() if the designated constraints -// aren't met. -type GetResourceRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetResourceRequestMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m GetResourceRequestMultiError) AllErrors() []error { return m } - -// GetResourceRequestValidationError is the validation error returned by -// GetResourceRequest.Validate if the designated constraints aren't met. -type GetResourceRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetResourceRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetResourceRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetResourceRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetResourceRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetResourceRequestValidationError) ErrorName() string { - return "GetResourceRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e GetResourceRequestValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sGetResourceRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetResourceRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetResourceRequestValidationError{} - -// Validate checks the field values on GetResourceResponse with the rules -// defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *GetResourceResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetResourceResponse with the rules -// defined in the proto definition for this message. If any rules are -// violated, the result is a list of violation errors wrapped in -// GetResourceResponseMultiError, or nil if none found. -func (m *GetResourceResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *GetResourceResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetResourceDescription()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, GetResourceResponseValidationError{ - field: "ResourceDescription", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, GetResourceResponseValidationError{ - field: "ResourceDescription", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetResourceDescription()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return GetResourceResponseValidationError{ - field: "ResourceDescription", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for TypeName - - if len(errors) > 0 { - return GetResourceResponseMultiError(errors) - } - - return nil -} - -// GetResourceResponseMultiError is an error wrapping multiple validation -// errors returned by GetResourceResponse.ValidateAll() if the designated -// constraints aren't met. -type GetResourceResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetResourceResponseMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m GetResourceResponseMultiError) AllErrors() []error { return m } - -// GetResourceResponseValidationError is the validation error returned by -// GetResourceResponse.Validate if the designated constraints aren't met. -type GetResourceResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetResourceResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetResourceResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetResourceResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetResourceResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetResourceResponseValidationError) ErrorName() string { - return "GetResourceResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e GetResourceResponseValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sGetResourceResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetResourceResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetResourceResponseValidationError{} - -// Validate checks the field values on DeleteResourceRequest with the rules -// defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *DeleteResourceRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteResourceRequest with the rules -// defined in the proto definition for this message. If any rules are -// violated, the result is a list of violation errors wrapped in -// DeleteResourceRequestMultiError, or nil if none found. -func (m *DeleteResourceRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteResourceRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Identifier - - // no validation rules for AccessToken - - if len(errors) > 0 { - return DeleteResourceRequestMultiError(errors) - } - - return nil -} - -// DeleteResourceRequestMultiError is an error wrapping multiple validation -// errors returned by DeleteResourceRequest.ValidateAll() if the designated -// constraints aren't met. -type DeleteResourceRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteResourceRequestMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m DeleteResourceRequestMultiError) AllErrors() []error { return m } - -// DeleteResourceRequestValidationError is the validation error returned by -// DeleteResourceRequest.Validate if the designated constraints aren't met. -type DeleteResourceRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteResourceRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteResourceRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteResourceRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteResourceRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteResourceRequestValidationError) ErrorName() string { - return "DeleteResourceRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteResourceRequestValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sDeleteResourceRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteResourceRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteResourceRequestValidationError{} - -// Validate checks the field values on DeleteResourceResponse with the rules -// defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *DeleteResourceResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteResourceResponse with the rules -// defined in the proto definition for this message. If any rules are -// violated, the result is a list of violation errors wrapped in -// DeleteResourceResponseMultiError, or nil if none found. -func (m *DeleteResourceResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteResourceResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetProgressEvent()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DeleteResourceResponseValidationError{ - field: "ProgressEvent", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DeleteResourceResponseValidationError{ - field: "ProgressEvent", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetProgressEvent()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DeleteResourceResponseValidationError{ - field: "ProgressEvent", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return DeleteResourceResponseMultiError(errors) - } - - return nil -} - -// DeleteResourceResponseMultiError is an error wrapping multiple validation -// errors returned by DeleteResourceResponse.ValidateAll() if the designated -// constraints aren't met. -type DeleteResourceResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteResourceResponseMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m DeleteResourceResponseMultiError) AllErrors() []error { return m } - -// DeleteResourceResponseValidationError is the validation error returned by -// DeleteResourceResponse.Validate if the designated constraints aren't met. -type DeleteResourceResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteResourceResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteResourceResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteResourceResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteResourceResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteResourceResponseValidationError) ErrorName() string { - return "DeleteResourceResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteResourceResponseValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sDeleteResourceResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteResourceResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteResourceResponseValidationError{} - -// Validate checks the field values on ListResourcesRequest with the rules -// defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *ListResourcesRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListResourcesRequest with the rules -// defined in the proto definition for this message. If any rules are -// violated, the result is a list of violation errors wrapped in -// ListResourcesRequestMultiError, or nil if none found. -func (m *ListResourcesRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListResourcesRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for MaxResults - - // no validation rules for Region - - // no validation rules for TypeName - - // no validation rules for AccessToken - - if len(errors) > 0 { - return ListResourcesRequestMultiError(errors) - } - - return nil -} - -// ListResourcesRequestMultiError is an error wrapping multiple validation -// errors returned by ListResourcesRequest.ValidateAll() if the designated -// constraints aren't met. -type ListResourcesRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListResourcesRequestMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m ListResourcesRequestMultiError) AllErrors() []error { return m } - -// ListResourcesRequestValidationError is the validation error returned by -// ListResourcesRequest.Validate if the designated constraints aren't met. -type ListResourcesRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListResourcesRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListResourcesRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListResourcesRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListResourcesRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListResourcesRequestValidationError) ErrorName() string { - return "ListResourcesRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ListResourcesRequestValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sListResourcesRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListResourcesRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListResourcesRequestValidationError{} - -// Validate checks the field values on ListResourcesResponse with the rules -// defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *ListResourcesResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListResourcesResponse with the rules -// defined in the proto definition for this message. If any rules are -// violated, the result is a list of violation errors wrapped in -// ListResourcesResponseMultiError, or nil if none found. -func (m *ListResourcesResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListResourcesResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for NextToken - - for idx, item := range m.GetResourceDescriptions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListResourcesResponseValidationError{ - field: fmt.Sprintf("ResourceDescriptions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListResourcesResponseValidationError{ - field: fmt.Sprintf("ResourceDescriptions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListResourcesResponseValidationError{ - field: fmt.Sprintf("ResourceDescriptions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - // no validation rules for TypeName - - if len(errors) > 0 { - return ListResourcesResponseMultiError(errors) - } - - return nil -} - -// ListResourcesResponseMultiError is an error wrapping multiple validation -// errors returned by ListResourcesResponse.ValidateAll() if the designated -// constraints aren't met. -type ListResourcesResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListResourcesResponseMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m ListResourcesResponseMultiError) AllErrors() []error { return m } - -// ListResourcesResponseValidationError is the validation error returned by -// ListResourcesResponse.Validate if the designated constraints aren't met. -type ListResourcesResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListResourcesResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListResourcesResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListResourcesResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListResourcesResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListResourcesResponseValidationError) ErrorName() string { - return "ListResourcesResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListResourcesResponseValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sListResourcesResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListResourcesResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListResourcesResponseValidationError{} - -// Validate checks the field values on UpdateResourceRequest with the rules -// defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *UpdateResourceRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateResourceRequest with the rules -// defined in the proto definition for this message. If any rules are -// violated, the result is a list of violation errors wrapped in -// UpdateResourceRequestMultiError, or nil if none found. -func (m *UpdateResourceRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateResourceRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Identifier - - // no validation rules for PatchDocument - - // no validation rules for AccessToken - - if len(errors) > 0 { - return UpdateResourceRequestMultiError(errors) - } - - return nil -} - -// UpdateResourceRequestMultiError is an error wrapping multiple validation -// errors returned by UpdateResourceRequest.ValidateAll() if the designated -// constraints aren't met. -type UpdateResourceRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateResourceRequestMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m UpdateResourceRequestMultiError) AllErrors() []error { return m } - -// UpdateResourceRequestValidationError is the validation error returned by -// UpdateResourceRequest.Validate if the designated constraints aren't met. -type UpdateResourceRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateResourceRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateResourceRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateResourceRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateResourceRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateResourceRequestValidationError) ErrorName() string { - return "UpdateResourceRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateResourceRequestValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sUpdateResourceRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateResourceRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateResourceRequestValidationError{} - -// Validate checks the field values on UpdateResourceResponse with the rules -// defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *UpdateResourceResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateResourceResponse with the rules -// defined in the proto definition for this message. If any rules are -// violated, the result is a list of violation errors wrapped in -// UpdateResourceResponseMultiError, or nil if none found. -func (m *UpdateResourceResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateResourceResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetProgressEvent()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateResourceResponseValidationError{ - field: "ProgressEvent", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateResourceResponseValidationError{ - field: "ProgressEvent", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetProgressEvent()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateResourceResponseValidationError{ - field: "ProgressEvent", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateResourceResponseMultiError(errors) - } - - return nil -} - -// UpdateResourceResponseMultiError is an error wrapping multiple validation -// errors returned by UpdateResourceResponse.ValidateAll() if the designated -// constraints aren't met. -type UpdateResourceResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateResourceResponseMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m UpdateResourceResponseMultiError) AllErrors() []error { return m } - -// UpdateResourceResponseValidationError is the validation error returned by -// UpdateResourceResponse.Validate if the designated constraints aren't met. -type UpdateResourceResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateResourceResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateResourceResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateResourceResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateResourceResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateResourceResponseValidationError) ErrorName() string { - return "UpdateResourceResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateResourceResponseValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sUpdateResourceResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateResourceResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateResourceResponseValidationError{} - -// Validate checks the field values on CancelResourceRequestRequest with the -// rules defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *CancelResourceRequestRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CancelResourceRequestRequest with the -// rules defined in the proto definition for this message. If any rules are -// violated, the result is a list of violation errors wrapped in -// CancelResourceRequestRequestMultiError, or nil if none found. -func (m *CancelResourceRequestRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CancelResourceRequestRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for RequestToken - - if len(errors) > 0 { - return CancelResourceRequestRequestMultiError(errors) - } - - return nil -} - -// CancelResourceRequestRequestMultiError is an error wrapping multiple -// validation errors returned by CancelResourceRequestRequest.ValidateAll() if -// the designated constraints aren't met. -type CancelResourceRequestRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CancelResourceRequestRequestMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m CancelResourceRequestRequestMultiError) AllErrors() []error { return m } - -// CancelResourceRequestRequestValidationError is the validation error returned -// by CancelResourceRequestRequest.Validate if the designated constraints -// aren't met. -type CancelResourceRequestRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CancelResourceRequestRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CancelResourceRequestRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CancelResourceRequestRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CancelResourceRequestRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CancelResourceRequestRequestValidationError) ErrorName() string { - return "CancelResourceRequestRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CancelResourceRequestRequestValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sCancelResourceRequestRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CancelResourceRequestRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CancelResourceRequestRequestValidationError{} - -// Validate checks the field values on CancelResourceRequestResponse with the -// rules defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *CancelResourceRequestResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CancelResourceRequestResponse with -// the rules defined in the proto definition for this message. If any rules -// are violated, the result is a list of violation errors wrapped in -// CancelResourceRequestResponseMultiError, or nil if none found. -func (m *CancelResourceRequestResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CancelResourceRequestResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetProgressEvent()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CancelResourceRequestResponseValidationError{ - field: "ProgressEvent", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CancelResourceRequestResponseValidationError{ - field: "ProgressEvent", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetProgressEvent()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CancelResourceRequestResponseValidationError{ - field: "ProgressEvent", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CancelResourceRequestResponseMultiError(errors) - } - - return nil -} - -// CancelResourceRequestResponseMultiError is an error wrapping multiple -// validation errors returned by CancelResourceRequestResponse.ValidateAll() -// if the designated constraints aren't met. -type CancelResourceRequestResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CancelResourceRequestResponseMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m CancelResourceRequestResponseMultiError) AllErrors() []error { return m } - -// CancelResourceRequestResponseValidationError is the validation error -// returned by CancelResourceRequestResponse.Validate if the designated -// constraints aren't met. -type CancelResourceRequestResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CancelResourceRequestResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CancelResourceRequestResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CancelResourceRequestResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CancelResourceRequestResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CancelResourceRequestResponseValidationError) ErrorName() string { - return "CancelResourceRequestResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CancelResourceRequestResponseValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sCancelResourceRequestResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CancelResourceRequestResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CancelResourceRequestResponseValidationError{} - -// Validate checks the field values on GetResourceRequestStatusRequest with the -// rules defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *GetResourceRequestStatusRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetResourceRequestStatusRequest with -// the rules defined in the proto definition for this message. If any rules -// are violated, the result is a list of violation errors wrapped in -// GetResourceRequestStatusRequestMultiError, or nil if none found. -func (m *GetResourceRequestStatusRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *GetResourceRequestStatusRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for RequestToken - - if len(errors) > 0 { - return GetResourceRequestStatusRequestMultiError(errors) - } - - return nil -} - -// GetResourceRequestStatusRequestMultiError is an error wrapping multiple -// validation errors returned by GetResourceRequestStatusRequest.ValidateAll() -// if the designated constraints aren't met. -type GetResourceRequestStatusRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetResourceRequestStatusRequestMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m GetResourceRequestStatusRequestMultiError) AllErrors() []error { return m } - -// GetResourceRequestStatusRequestValidationError is the validation error -// returned by GetResourceRequestStatusRequest.Validate if the designated -// constraints aren't met. -type GetResourceRequestStatusRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetResourceRequestStatusRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetResourceRequestStatusRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetResourceRequestStatusRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetResourceRequestStatusRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetResourceRequestStatusRequestValidationError) ErrorName() string { - return "GetResourceRequestStatusRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e GetResourceRequestStatusRequestValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sGetResourceRequestStatusRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetResourceRequestStatusRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetResourceRequestStatusRequestValidationError{} - -// Validate checks the field values on GetResourceRequestStatusResponse with -// the rules defined in the proto definition for this message. If any rules -// are violated, the first error encountered is returned, or nil if there are -// no violations. -func (m *GetResourceRequestStatusResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetResourceRequestStatusResponse with -// the rules defined in the proto definition for this message. If any rules -// are violated, the result is a list of violation errors wrapped in -// GetResourceRequestStatusResponseMultiError, or nil if none found. -func (m *GetResourceRequestStatusResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *GetResourceRequestStatusResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetProgressEvent()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, GetResourceRequestStatusResponseValidationError{ - field: "ProgressEvent", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, GetResourceRequestStatusResponseValidationError{ - field: "ProgressEvent", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetProgressEvent()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return GetResourceRequestStatusResponseValidationError{ - field: "ProgressEvent", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return GetResourceRequestStatusResponseMultiError(errors) - } - - return nil -} - -// GetResourceRequestStatusResponseMultiError is an error wrapping multiple -// validation errors returned by -// GetResourceRequestStatusResponse.ValidateAll() if the designated -// constraints aren't met. -type GetResourceRequestStatusResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetResourceRequestStatusResponseMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m GetResourceRequestStatusResponseMultiError) AllErrors() []error { return m } - -// GetResourceRequestStatusResponseValidationError is the validation error -// returned by GetResourceRequestStatusResponse.Validate if the designated -// constraints aren't met. -type GetResourceRequestStatusResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetResourceRequestStatusResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetResourceRequestStatusResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetResourceRequestStatusResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetResourceRequestStatusResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetResourceRequestStatusResponseValidationError) ErrorName() string { - return "GetResourceRequestStatusResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e GetResourceRequestStatusResponseValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sGetResourceRequestStatusResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetResourceRequestStatusResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetResourceRequestStatusResponseValidationError{} - -// Validate checks the field values on ListResourceRequestsRequest with the -// rules defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *ListResourceRequestsRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListResourceRequestsRequest with the -// rules defined in the proto definition for this message. If any rules are -// violated, the result is a list of violation errors wrapped in -// ListResourceRequestsRequestMultiError, or nil if none found. -func (m *ListResourceRequestsRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListResourceRequestsRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for MaxResults - - // no validation rules for NextToken - - if all { - switch v := interface{}(m.GetResourceRequestStatusFilter()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListResourceRequestsRequestValidationError{ - field: "ResourceRequestStatusFilter", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListResourceRequestsRequestValidationError{ - field: "ResourceRequestStatusFilter", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetResourceRequestStatusFilter()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListResourceRequestsRequestValidationError{ - field: "ResourceRequestStatusFilter", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return ListResourceRequestsRequestMultiError(errors) - } - - return nil -} - -// ListResourceRequestsRequestMultiError is an error wrapping multiple -// validation errors returned by ListResourceRequestsRequest.ValidateAll() if -// the designated constraints aren't met. -type ListResourceRequestsRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListResourceRequestsRequestMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m ListResourceRequestsRequestMultiError) AllErrors() []error { return m } - -// ListResourceRequestsRequestValidationError is the validation error returned -// by ListResourceRequestsRequest.Validate if the designated constraints -// aren't met. -type ListResourceRequestsRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListResourceRequestsRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListResourceRequestsRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListResourceRequestsRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListResourceRequestsRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListResourceRequestsRequestValidationError) ErrorName() string { - return "ListResourceRequestsRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ListResourceRequestsRequestValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sListResourceRequestsRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListResourceRequestsRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListResourceRequestsRequestValidationError{} - -// Validate checks the field values on ListResourceRequestsResponse with the -// rules defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *ListResourceRequestsResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListResourceRequestsResponse with the -// rules defined in the proto definition for this message. If any rules are -// violated, the result is a list of violation errors wrapped in -// ListResourceRequestsResponseMultiError, or nil if none found. -func (m *ListResourceRequestsResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListResourceRequestsResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for NextToken - - for idx, item := range m.GetResourceRequestStatusSummaries() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListResourceRequestsResponseValidationError{ - field: fmt.Sprintf("ResourceRequestStatusSummaries[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListResourceRequestsResponseValidationError{ - field: fmt.Sprintf("ResourceRequestStatusSummaries[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListResourceRequestsResponseValidationError{ - field: fmt.Sprintf("ResourceRequestStatusSummaries[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return ListResourceRequestsResponseMultiError(errors) - } - - return nil -} - -// ListResourceRequestsResponseMultiError is an error wrapping multiple -// validation errors returned by ListResourceRequestsResponse.ValidateAll() if -// the designated constraints aren't met. -type ListResourceRequestsResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListResourceRequestsResponseMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m ListResourceRequestsResponseMultiError) AllErrors() []error { return m } - -// ListResourceRequestsResponseValidationError is the validation error returned -// by ListResourceRequestsResponse.Validate if the designated constraints -// aren't met. -type ListResourceRequestsResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListResourceRequestsResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListResourceRequestsResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListResourceRequestsResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListResourceRequestsResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListResourceRequestsResponseValidationError) ErrorName() string { - return "ListResourceRequestsResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListResourceRequestsResponseValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sListResourceRequestsResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListResourceRequestsResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListResourceRequestsResponseValidationError{} - -// Validate checks the field values on ProgressEvent with the rules defined in -// the proto definition for this message. If any rules are violated, the first -// error encountered is returned, or nil if there are no violations. -func (m *ProgressEvent) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ProgressEvent with the rules defined -// in the proto definition for this message. If any rules are violated, the -// result is a list of violation errors wrapped in ProgressEventMultiError, or -// nil if none found. -func (m *ProgressEvent) ValidateAll() error { - return m.validate(true) -} - -func (m *ProgressEvent) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for ErrorCode - - // no validation rules for EventTime - - // no validation rules for Identifier - - // no validation rules for Operation - - // no validation rules for OperationStatus - - // no validation rules for RequestToken - - // no validation rules for ResourceModel - - // no validation rules for RetryAfter - - // no validation rules for StatusMessage - - // no validation rules for TypeName - - if len(errors) > 0 { - return ProgressEventMultiError(errors) - } - - return nil -} - -// ProgressEventMultiError is an error wrapping multiple validation errors -// returned by ProgressEvent.ValidateAll() if the designated constraints -// aren't met. -type ProgressEventMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ProgressEventMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m ProgressEventMultiError) AllErrors() []error { return m } - -// ProgressEventValidationError is the validation error returned by -// ProgressEvent.Validate if the designated constraints aren't met. -type ProgressEventValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ProgressEventValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ProgressEventValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ProgressEventValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ProgressEventValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ProgressEventValidationError) ErrorName() string { return "ProgressEventValidationError" } - -// Error satisfies the builtin error interface -func (e ProgressEventValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sProgressEvent.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ProgressEventValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ProgressEventValidationError{} - -// Validate checks the field values on ResourceDescription with the rules -// defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *ResourceDescription) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ResourceDescription with the rules -// defined in the proto definition for this message. If any rules are -// violated, the result is a list of violation errors wrapped in -// ResourceDescriptionMultiError, or nil if none found. -func (m *ResourceDescription) ValidateAll() error { - return m.validate(true) -} - -func (m *ResourceDescription) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Identifier - - // no validation rules for Properties - - // no validation rules for CreatedAt - - if len(errors) > 0 { - return ResourceDescriptionMultiError(errors) - } - - return nil -} - -// ResourceDescriptionMultiError is an error wrapping multiple validation -// errors returned by ResourceDescription.ValidateAll() if the designated -// constraints aren't met. -type ResourceDescriptionMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ResourceDescriptionMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m ResourceDescriptionMultiError) AllErrors() []error { return m } - -// ResourceDescriptionValidationError is the validation error returned by -// ResourceDescription.Validate if the designated constraints aren't met. -type ResourceDescriptionValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ResourceDescriptionValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ResourceDescriptionValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ResourceDescriptionValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ResourceDescriptionValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ResourceDescriptionValidationError) ErrorName() string { - return "ResourceDescriptionValidationError" -} - -// Error satisfies the builtin error interface -func (e ResourceDescriptionValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sResourceDescription.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ResourceDescriptionValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ResourceDescriptionValidationError{} - -// Validate checks the field values on ResourceRequestStatusFilter with the -// rules defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *ResourceRequestStatusFilter) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ResourceRequestStatusFilter with the -// rules defined in the proto definition for this message. If any rules are -// violated, the result is a list of violation errors wrapped in -// ResourceRequestStatusFilterMultiError, or nil if none found. -func (m *ResourceRequestStatusFilter) ValidateAll() error { - return m.validate(true) -} - -func (m *ResourceRequestStatusFilter) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return ResourceRequestStatusFilterMultiError(errors) - } - - return nil -} - -// ResourceRequestStatusFilterMultiError is an error wrapping multiple -// validation errors returned by ResourceRequestStatusFilter.ValidateAll() if -// the designated constraints aren't met. -type ResourceRequestStatusFilterMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ResourceRequestStatusFilterMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m ResourceRequestStatusFilterMultiError) AllErrors() []error { return m } - -// ResourceRequestStatusFilterValidationError is the validation error returned -// by ResourceRequestStatusFilter.Validate if the designated constraints -// aren't met. -type ResourceRequestStatusFilterValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ResourceRequestStatusFilterValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ResourceRequestStatusFilterValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ResourceRequestStatusFilterValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ResourceRequestStatusFilterValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ResourceRequestStatusFilterValidationError) ErrorName() string { - return "ResourceRequestStatusFilterValidationError" -} - -// Error satisfies the builtin error interface -func (e ResourceRequestStatusFilterValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sResourceRequestStatusFilter.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ResourceRequestStatusFilterValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ResourceRequestStatusFilterValidationError{} diff --git a/internal/sdk/api/cloudcontrol/v1/cloudcontrol.proto b/internal/sdk/api/cloudcontrol/v1/cloudcontrol.proto deleted file mode 100644 index 4629f86..0000000 --- a/internal/sdk/api/cloudcontrol/v1/cloudcontrol.proto +++ /dev/null @@ -1,335 +0,0 @@ -syntax = "proto3"; - -package api.cloudcontrol.v1; - -import "google/api/annotations.proto"; - -option go_package = "github.com/GuanceCloud/openapi/api/cloudcontrol/v1;v1"; - -// The cloud control service definition. -// Cloud Control API is a design pattern by AWS, so all the API is defined at AWS documentation. -// See details: https://docs.aws.amazon.com/cloudcontrolapi/latest/APIReference/Welcome.html -service CloudControlService { - // Creates a new resource. - rpc CreateResource(CreateResourceRequest) returns (CreateResourceResponse) { - option (google.api.http) = { - post: "/cloud-control/create-resource" - body: "*" - }; - } - - // Gets the resource by name. - rpc GetResource(GetResourceRequest) returns (GetResourceResponse) { - option (google.api.http) = { - post: "/cloud-control/get-resource" - body: "*" - }; - } - - // Deletes the resource by name. - rpc DeleteResource(DeleteResourceRequest) returns (DeleteResourceResponse) { - option (google.api.http) = { - post: "/cloud-control/delete-resource" - body: "*" - }; - } - - // Lists all resources. - rpc ListResources(ListResourcesRequest) returns (ListResourcesResponse) { - option (google.api.http) = { - post: "/cloud-control/list-resources" - body: "*" - }; - } - - // Updates the resource. - rpc UpdateResource(UpdateResourceRequest) returns (UpdateResourceResponse) { - option (google.api.http) = { - post: "/cloud-control/update-resource" - body: "*" - }; - } - - // Cancels the specified resource request. - rpc CancelResourceRequest(CancelResourceRequestRequest) returns (CancelResourceRequestResponse) { - option (google.api.http) = { - post: "/cloud-control/cancel-resource-request" - body: "*" - }; - } - - // Gets the specified resource request status. - rpc GetResourceRequestStatus(GetResourceRequestStatusRequest) returns (GetResourceRequestStatusResponse) { - option (google.api.http) = { - post: "/cloud-control/get-resource-request-status" - body: "*" - }; - } - - // List resource requests. - rpc ListResourceRequests(ListResourceRequestsRequest) returns (ListResourceRequestsResponse) { - option (google.api.http) = { - post: "/cloud-control/list-resource-requests" - body: "*" - }; - } -} - -// The request message of resource creating. -message CreateResourceRequest { - // The region of the resource. - string region = 1; - - // The name of the resource type. - string type_name = 2; - - /* Structured data format representing the desired state of the resource, - consisting of that resource's properties and their desired values. - - Specify the desired state is a JSON blob. - */ - string desired_state = 3; - - // The access token of request - string access_token = 4; -} - -// The response message of resource creating. -message CreateResourceResponse { - // Represents the current status of the resource creating request. - ProgressEvent progress_event = 1; -} - -// The request message of resource getting. -message GetResourceRequest { - // The identifier for the resource. - string identifier = 1; - - // The access token of request - string access_token = 2; -} - -// The response message of resource getting. -message GetResourceResponse { - // Represents information about a provisioned resource. - ResourceDescription resource_description = 1; - - // The name of the resource type. - string type_name = 2; -} - -// The request message of resource deleting. -message DeleteResourceRequest { - // The identifier for the resource. - string identifier = 1; - - // The access token of request - string access_token = 2; -} - -// The response message of resource deleting. -message DeleteResourceResponse { - // Represents the current status of the resource deletion request. - ProgressEvent progress_event = 1; -} - -// The request message of resource listing. -message ListResourcesRequest { - // Count of reserved records. - int64 max_results = 1; - - // The region of the resource. - string region = 2; - - // The name of the resource type. - string type_name = 3; - - // The access token of request - string access_token = 4; -} - -// The response message of resource listing. -message ListResourcesResponse { - // If the request doesn't return all of the remaining results, NextToken is set to a token. - // To retrieve the next set of results, call ListResources again and assign that token to the request object's NextToken parameter. - // If the request returns all results, NextToken is set to null. - string next_token = 1; - - // A list of resource descriptions. - repeated ResourceDescription resource_descriptions = 2; - - // The name of the resource type. - string type_name = 3; -} - -// The request message of resource updating. -message UpdateResourceRequest { - // The identifier for the resource. - string identifier = 1; - - // A JavaScript Object Notation (JSON) document listing the patch operations that represent the updates to apply to the current resource properties. - string patch_document = 2; - - // The access token of request - string access_token = 3; -} - -// The response message of resource updating. -message UpdateResourceResponse { - // Represents the current status of the resource update request. - ProgressEvent progress_event = 1; -} - -// The request message of resource request canceling. -message CancelResourceRequestRequest { - // The RequestToken of the ProgressEvent object returned by the resource operation request. - string request_token = 1; -} - -// The response message of resource request canceling. -message CancelResourceRequestResponse { - // Represents the current status of the resource update request. - ProgressEvent progress_event = 1; -} - -// The request message of resource request status getting. -message GetResourceRequestStatusRequest { - // The RequestToken of the ProgressEvent object returned by the resource operation request. - string request_token = 1; -} - -// The response message of resource request status getting. -message GetResourceRequestStatusResponse { - // Represents the current status of the resource update request. - ProgressEvent progress_event = 1; -} - -// The request message of resource requests listing. -message ListResourceRequestsRequest { - // Count of reserved records. - int64 max_results = 1; - - // If the previous paginated request didn't return all of the remaining results, - // the response object's NextToken parameter value is set to a token. - // To retrieve the next set of results, call this action again and assign that token to the request object's NextToken parameter. - // If there are no remaining results, the previous response object's NextToken parameter is set to null. - string next_token = 2; - - // The filter criteria to apply to the requests returned. - ResourceRequestStatusFilter resource_request_status_filter = 3; -} - -// The response message of resource requests listing. -message ListResourceRequestsResponse { - // If the request doesn't return all of the remaining results, NextToken is set to a token. - // To retrieve the next set of results, call ListResourceRequests again and assign that token to the request object's NextToken parameter. - // If the request returns all results, NextToken is set to null. - string next_token = 1; - - // A list of resource requests. - repeated ProgressEvent resource_request_status_summaries = 2; -} - -// The current status of a resource operation request. -message ProgressEvent { - /* For requests with a status of FAILED, the associated error code. - - Valid Values: - NotUpdatable - | InvalidRequest - | AccessDenied - | InvalidCredentials - | AlreadyExists - | NotFound - | ResourceConflict - | Throttling - | ServiceLimitExceeded - | NotStabilized - | GeneralServiceException - | ServiceInternalError - | ServiceTimeout - | NetworkFailure - | InternalFailure - */ - string error_code = 1; - - // When the resource operation request was initiated. - int64 event_time = 2; - - // The primary identifier for the resource. - string identifier = 3; - - /* The resource operation type. - - Valid Values: - CREATE - | DELETE - | UPDATE - */ - string operation = 4; - - /* The current status of the resource operation request. - - * PENDING: The resource operation hasn't yet started. - * IN_PROGRESS: The resource operation is currently in progress. - * SUCCESS: The resource operation has successfully completed. - * FAILED: The resource operation has failed. Refer to the error code and status message for more information. - * CANCEL_IN_PROGRESS: The resource operation is in the process of being canceled. - * CANCEL_COMPLETE: The resource operation has been canceled. - */ - string operation_status = 5; - - // The unique token representing this resource operation request. - // Use the RequestToken with GetResourceRequestStatus to return the current status of a resource operation request. - string request_token = 6; - - // A JSON string containing the resource model, - // consisting of each resource property and its current value. - string resource_model = 7; - - // When to next request the status of this resource operation request. - int64 retry_after = 8; - - // Any message explaining the current status. - string status_message = 9; - - // The name of the resource type used in the operation. - string type_name = 10; -} - -// Information about the specified resources, including primary identifier and resource model. -message ResourceDescription { - // The identifier for the resource. - string identifier = 1; - - // A list of the resource properties and their current values. - // It is a JSON blob. - string properties = 2; - - // The time when the resource was created. - string created_at = 3; -} - -// The filter criteria to use in determining the requests returned. -message ResourceRequestStatusFilter { - /* The operation types to include in the filter. - - Valid Values: - CREATE - | DELETE - | UPDATE - */ - repeated string operations = 1; - - /* The resource operation request status types to include in the filter. - - Valid Values: - PENDING - | IN_PROGRESS - | SUCCESS - | FAILED - | CANCEL_IN_PROGRESS - | CANCEL_COMPLETE - */ - repeated string operation_statuses = 2; -} diff --git a/internal/sdk/api/cloudcontrol/v1/cloudcontrol_grpc.pb.go b/internal/sdk/api/cloudcontrol/v1/cloudcontrol_grpc.pb.go deleted file mode 100644 index 8b1dcc2..0000000 --- a/internal/sdk/api/cloudcontrol/v1/cloudcontrol_grpc.pb.go +++ /dev/null @@ -1,385 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.3.0 -// - protoc (unknown) -// source: api/cloudcontrol/v1/cloudcontrol.proto - -package v1 - -import ( - context "context" - - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -const ( - CloudControlService_CreateResource_FullMethodName = "/api.cloudcontrol.v1.CloudControlService/CreateResource" - CloudControlService_GetResource_FullMethodName = "/api.cloudcontrol.v1.CloudControlService/GetResource" - CloudControlService_DeleteResource_FullMethodName = "/api.cloudcontrol.v1.CloudControlService/DeleteResource" - CloudControlService_ListResources_FullMethodName = "/api.cloudcontrol.v1.CloudControlService/ListResources" - CloudControlService_UpdateResource_FullMethodName = "/api.cloudcontrol.v1.CloudControlService/UpdateResource" - CloudControlService_CancelResourceRequest_FullMethodName = "/api.cloudcontrol.v1.CloudControlService/CancelResourceRequest" - CloudControlService_GetResourceRequestStatus_FullMethodName = "/api.cloudcontrol.v1.CloudControlService/GetResourceRequestStatus" - CloudControlService_ListResourceRequests_FullMethodName = "/api.cloudcontrol.v1.CloudControlService/ListResourceRequests" -) - -// CloudControlServiceClient is the client API for CloudControlService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type CloudControlServiceClient interface { - // Creates a new resource. - CreateResource(ctx context.Context, in *CreateResourceRequest, opts ...grpc.CallOption) (*CreateResourceResponse, error) - // Gets the resource by name. - GetResource(ctx context.Context, in *GetResourceRequest, opts ...grpc.CallOption) (*GetResourceResponse, error) - // Deletes the resource by name. - DeleteResource(ctx context.Context, in *DeleteResourceRequest, opts ...grpc.CallOption) (*DeleteResourceResponse, error) - // Lists all resources. - ListResources(ctx context.Context, in *ListResourcesRequest, opts ...grpc.CallOption) (*ListResourcesResponse, error) - // Updates the resource. - UpdateResource(ctx context.Context, in *UpdateResourceRequest, opts ...grpc.CallOption) (*UpdateResourceResponse, error) - // Cancels the specified resource request. - CancelResourceRequest(ctx context.Context, in *CancelResourceRequestRequest, opts ...grpc.CallOption) (*CancelResourceRequestResponse, error) - // Gets the specified resource request status. - GetResourceRequestStatus(ctx context.Context, in *GetResourceRequestStatusRequest, opts ...grpc.CallOption) (*GetResourceRequestStatusResponse, error) - // List resource requests. - ListResourceRequests(ctx context.Context, in *ListResourceRequestsRequest, opts ...grpc.CallOption) (*ListResourceRequestsResponse, error) -} - -type cloudControlServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewCloudControlServiceClient(cc grpc.ClientConnInterface) CloudControlServiceClient { - return &cloudControlServiceClient{cc} -} - -func (c *cloudControlServiceClient) CreateResource(ctx context.Context, in *CreateResourceRequest, opts ...grpc.CallOption) (*CreateResourceResponse, error) { - out := new(CreateResourceResponse) - err := c.cc.Invoke(ctx, CloudControlService_CreateResource_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *cloudControlServiceClient) GetResource(ctx context.Context, in *GetResourceRequest, opts ...grpc.CallOption) (*GetResourceResponse, error) { - out := new(GetResourceResponse) - err := c.cc.Invoke(ctx, CloudControlService_GetResource_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *cloudControlServiceClient) DeleteResource(ctx context.Context, in *DeleteResourceRequest, opts ...grpc.CallOption) (*DeleteResourceResponse, error) { - out := new(DeleteResourceResponse) - err := c.cc.Invoke(ctx, CloudControlService_DeleteResource_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *cloudControlServiceClient) ListResources(ctx context.Context, in *ListResourcesRequest, opts ...grpc.CallOption) (*ListResourcesResponse, error) { - out := new(ListResourcesResponse) - err := c.cc.Invoke(ctx, CloudControlService_ListResources_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *cloudControlServiceClient) UpdateResource(ctx context.Context, in *UpdateResourceRequest, opts ...grpc.CallOption) (*UpdateResourceResponse, error) { - out := new(UpdateResourceResponse) - err := c.cc.Invoke(ctx, CloudControlService_UpdateResource_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *cloudControlServiceClient) CancelResourceRequest(ctx context.Context, in *CancelResourceRequestRequest, opts ...grpc.CallOption) (*CancelResourceRequestResponse, error) { - out := new(CancelResourceRequestResponse) - err := c.cc.Invoke(ctx, CloudControlService_CancelResourceRequest_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *cloudControlServiceClient) GetResourceRequestStatus(ctx context.Context, in *GetResourceRequestStatusRequest, opts ...grpc.CallOption) (*GetResourceRequestStatusResponse, error) { - out := new(GetResourceRequestStatusResponse) - err := c.cc.Invoke(ctx, CloudControlService_GetResourceRequestStatus_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *cloudControlServiceClient) ListResourceRequests(ctx context.Context, in *ListResourceRequestsRequest, opts ...grpc.CallOption) (*ListResourceRequestsResponse, error) { - out := new(ListResourceRequestsResponse) - err := c.cc.Invoke(ctx, CloudControlService_ListResourceRequests_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// CloudControlServiceServer is the server API for CloudControlService service. -// All implementations must embed UnimplementedCloudControlServiceServer -// for forward compatibility -type CloudControlServiceServer interface { - // Creates a new resource. - CreateResource(context.Context, *CreateResourceRequest) (*CreateResourceResponse, error) - // Gets the resource by name. - GetResource(context.Context, *GetResourceRequest) (*GetResourceResponse, error) - // Deletes the resource by name. - DeleteResource(context.Context, *DeleteResourceRequest) (*DeleteResourceResponse, error) - // Lists all resources. - ListResources(context.Context, *ListResourcesRequest) (*ListResourcesResponse, error) - // Updates the resource. - UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error) - // Cancels the specified resource request. - CancelResourceRequest(context.Context, *CancelResourceRequestRequest) (*CancelResourceRequestResponse, error) - // Gets the specified resource request status. - GetResourceRequestStatus(context.Context, *GetResourceRequestStatusRequest) (*GetResourceRequestStatusResponse, error) - // List resource requests. - ListResourceRequests(context.Context, *ListResourceRequestsRequest) (*ListResourceRequestsResponse, error) - mustEmbedUnimplementedCloudControlServiceServer() -} - -// UnimplementedCloudControlServiceServer must be embedded to have forward compatible implementations. -type UnimplementedCloudControlServiceServer struct { -} - -func (UnimplementedCloudControlServiceServer) CreateResource(context.Context, *CreateResourceRequest) (*CreateResourceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateResource not implemented") -} -func (UnimplementedCloudControlServiceServer) GetResource(context.Context, *GetResourceRequest) (*GetResourceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetResource not implemented") -} -func (UnimplementedCloudControlServiceServer) DeleteResource(context.Context, *DeleteResourceRequest) (*DeleteResourceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DeleteResource not implemented") -} -func (UnimplementedCloudControlServiceServer) ListResources(context.Context, *ListResourcesRequest) (*ListResourcesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListResources not implemented") -} -func (UnimplementedCloudControlServiceServer) UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateResource not implemented") -} -func (UnimplementedCloudControlServiceServer) CancelResourceRequest(context.Context, *CancelResourceRequestRequest) (*CancelResourceRequestResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CancelResourceRequest not implemented") -} -func (UnimplementedCloudControlServiceServer) GetResourceRequestStatus(context.Context, *GetResourceRequestStatusRequest) (*GetResourceRequestStatusResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetResourceRequestStatus not implemented") -} -func (UnimplementedCloudControlServiceServer) ListResourceRequests(context.Context, *ListResourceRequestsRequest) (*ListResourceRequestsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListResourceRequests not implemented") -} -func (UnimplementedCloudControlServiceServer) mustEmbedUnimplementedCloudControlServiceServer() {} - -// UnsafeCloudControlServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to CloudControlServiceServer will -// result in compilation errors. -type UnsafeCloudControlServiceServer interface { - mustEmbedUnimplementedCloudControlServiceServer() -} - -func RegisterCloudControlServiceServer(s grpc.ServiceRegistrar, srv CloudControlServiceServer) { - s.RegisterService(&CloudControlService_ServiceDesc, srv) -} - -func _CloudControlService_CreateResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateResourceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CloudControlServiceServer).CreateResource(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: CloudControlService_CreateResource_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CloudControlServiceServer).CreateResource(ctx, req.(*CreateResourceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _CloudControlService_GetResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetResourceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CloudControlServiceServer).GetResource(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: CloudControlService_GetResource_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CloudControlServiceServer).GetResource(ctx, req.(*GetResourceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _CloudControlService_DeleteResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteResourceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CloudControlServiceServer).DeleteResource(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: CloudControlService_DeleteResource_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CloudControlServiceServer).DeleteResource(ctx, req.(*DeleteResourceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _CloudControlService_ListResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListResourcesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CloudControlServiceServer).ListResources(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: CloudControlService_ListResources_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CloudControlServiceServer).ListResources(ctx, req.(*ListResourcesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _CloudControlService_UpdateResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateResourceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CloudControlServiceServer).UpdateResource(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: CloudControlService_UpdateResource_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CloudControlServiceServer).UpdateResource(ctx, req.(*UpdateResourceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _CloudControlService_CancelResourceRequest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CancelResourceRequestRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CloudControlServiceServer).CancelResourceRequest(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: CloudControlService_CancelResourceRequest_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CloudControlServiceServer).CancelResourceRequest(ctx, req.(*CancelResourceRequestRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _CloudControlService_GetResourceRequestStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetResourceRequestStatusRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CloudControlServiceServer).GetResourceRequestStatus(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: CloudControlService_GetResourceRequestStatus_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CloudControlServiceServer).GetResourceRequestStatus(ctx, req.(*GetResourceRequestStatusRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _CloudControlService_ListResourceRequests_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListResourceRequestsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CloudControlServiceServer).ListResourceRequests(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: CloudControlService_ListResourceRequests_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CloudControlServiceServer).ListResourceRequests(ctx, req.(*ListResourceRequestsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// CloudControlService_ServiceDesc is the grpc.ServiceDesc for CloudControlService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var CloudControlService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.cloudcontrol.v1.CloudControlService", - HandlerType: (*CloudControlServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "CreateResource", - Handler: _CloudControlService_CreateResource_Handler, - }, - { - MethodName: "GetResource", - Handler: _CloudControlService_GetResource_Handler, - }, - { - MethodName: "DeleteResource", - Handler: _CloudControlService_DeleteResource_Handler, - }, - { - MethodName: "ListResources", - Handler: _CloudControlService_ListResources_Handler, - }, - { - MethodName: "UpdateResource", - Handler: _CloudControlService_UpdateResource_Handler, - }, - { - MethodName: "CancelResourceRequest", - Handler: _CloudControlService_CancelResourceRequest_Handler, - }, - { - MethodName: "GetResourceRequestStatus", - Handler: _CloudControlService_GetResourceRequestStatus_Handler, - }, - { - MethodName: "ListResourceRequests", - Handler: _CloudControlService_ListResourceRequests_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "api/cloudcontrol/v1/cloudcontrol.proto", -} diff --git a/internal/sdk/api/cloudcontrol/v1/cloudcontrol_http.pb.go b/internal/sdk/api/cloudcontrol/v1/cloudcontrol_http.pb.go deleted file mode 100644 index f8e0475..0000000 --- a/internal/sdk/api/cloudcontrol/v1/cloudcontrol_http.pb.go +++ /dev/null @@ -1,336 +0,0 @@ -// Code generated by protoc-gen-go-http. DO NOT EDIT. -// versions: -// - protoc-gen-go-http v2.5.3 -// - protoc (unknown) -// source: api/cloudcontrol/v1/cloudcontrol.proto - -package v1 - -import ( - context "context" - - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 - -const OperationCloudControlServiceCancelResourceRequest = "/api.cloudcontrol.v1.CloudControlService/CancelResourceRequest" -const OperationCloudControlServiceCreateResource = "/api.cloudcontrol.v1.CloudControlService/CreateResource" -const OperationCloudControlServiceDeleteResource = "/api.cloudcontrol.v1.CloudControlService/DeleteResource" -const OperationCloudControlServiceGetResource = "/api.cloudcontrol.v1.CloudControlService/GetResource" -const OperationCloudControlServiceGetResourceRequestStatus = "/api.cloudcontrol.v1.CloudControlService/GetResourceRequestStatus" -const OperationCloudControlServiceListResourceRequests = "/api.cloudcontrol.v1.CloudControlService/ListResourceRequests" -const OperationCloudControlServiceListResources = "/api.cloudcontrol.v1.CloudControlService/ListResources" -const OperationCloudControlServiceUpdateResource = "/api.cloudcontrol.v1.CloudControlService/UpdateResource" - -type CloudControlServiceHTTPServer interface { - // CancelResourceRequest Cancels the specified resource request. - CancelResourceRequest(context.Context, *CancelResourceRequestRequest) (*CancelResourceRequestResponse, error) - // CreateResource Creates a new resource. - CreateResource(context.Context, *CreateResourceRequest) (*CreateResourceResponse, error) - // DeleteResource Deletes the resource by name. - DeleteResource(context.Context, *DeleteResourceRequest) (*DeleteResourceResponse, error) - // GetResource Gets the resource by name. - GetResource(context.Context, *GetResourceRequest) (*GetResourceResponse, error) - // GetResourceRequestStatus Gets the specified resource request status. - GetResourceRequestStatus(context.Context, *GetResourceRequestStatusRequest) (*GetResourceRequestStatusResponse, error) - // ListResourceRequests List resource requests. - ListResourceRequests(context.Context, *ListResourceRequestsRequest) (*ListResourceRequestsResponse, error) - // ListResources Lists all resources. - ListResources(context.Context, *ListResourcesRequest) (*ListResourcesResponse, error) - // UpdateResource Updates the resource. - UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error) -} - -func RegisterCloudControlServiceHTTPServer(s *http.Server, srv CloudControlServiceHTTPServer) { - r := s.Route("/") - r.POST("/cloud-control/create-resource", _CloudControlService_CreateResource0_HTTP_Handler(srv)) - r.POST("/cloud-control/get-resource", _CloudControlService_GetResource0_HTTP_Handler(srv)) - r.POST("/cloud-control/delete-resource", _CloudControlService_DeleteResource0_HTTP_Handler(srv)) - r.POST("/cloud-control/list-resources", _CloudControlService_ListResources0_HTTP_Handler(srv)) - r.POST("/cloud-control/update-resource", _CloudControlService_UpdateResource0_HTTP_Handler(srv)) - r.POST("/cloud-control/cancel-resource-request", _CloudControlService_CancelResourceRequest0_HTTP_Handler(srv)) - r.POST("/cloud-control/get-resource-request-status", _CloudControlService_GetResourceRequestStatus0_HTTP_Handler(srv)) - r.POST("/cloud-control/list-resource-requests", _CloudControlService_ListResourceRequests0_HTTP_Handler(srv)) -} - -func _CloudControlService_CreateResource0_HTTP_Handler(srv CloudControlServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CreateResourceRequest - if err := ctx.Bind(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationCloudControlServiceCreateResource) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreateResource(ctx, req.(*CreateResourceRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*CreateResourceResponse) - return ctx.Result(200, reply) - } -} - -func _CloudControlService_GetResource0_HTTP_Handler(srv CloudControlServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetResourceRequest - if err := ctx.Bind(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationCloudControlServiceGetResource) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetResource(ctx, req.(*GetResourceRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*GetResourceResponse) - return ctx.Result(200, reply) - } -} - -func _CloudControlService_DeleteResource0_HTTP_Handler(srv CloudControlServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in DeleteResourceRequest - if err := ctx.Bind(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationCloudControlServiceDeleteResource) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DeleteResource(ctx, req.(*DeleteResourceRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*DeleteResourceResponse) - return ctx.Result(200, reply) - } -} - -func _CloudControlService_ListResources0_HTTP_Handler(srv CloudControlServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListResourcesRequest - if err := ctx.Bind(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationCloudControlServiceListResources) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListResources(ctx, req.(*ListResourcesRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListResourcesResponse) - return ctx.Result(200, reply) - } -} - -func _CloudControlService_UpdateResource0_HTTP_Handler(srv CloudControlServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdateResourceRequest - if err := ctx.Bind(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationCloudControlServiceUpdateResource) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdateResource(ctx, req.(*UpdateResourceRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdateResourceResponse) - return ctx.Result(200, reply) - } -} - -func _CloudControlService_CancelResourceRequest0_HTTP_Handler(srv CloudControlServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CancelResourceRequestRequest - if err := ctx.Bind(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationCloudControlServiceCancelResourceRequest) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CancelResourceRequest(ctx, req.(*CancelResourceRequestRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*CancelResourceRequestResponse) - return ctx.Result(200, reply) - } -} - -func _CloudControlService_GetResourceRequestStatus0_HTTP_Handler(srv CloudControlServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetResourceRequestStatusRequest - if err := ctx.Bind(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationCloudControlServiceGetResourceRequestStatus) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetResourceRequestStatus(ctx, req.(*GetResourceRequestStatusRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*GetResourceRequestStatusResponse) - return ctx.Result(200, reply) - } -} - -func _CloudControlService_ListResourceRequests0_HTTP_Handler(srv CloudControlServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListResourceRequestsRequest - if err := ctx.Bind(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationCloudControlServiceListResourceRequests) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListResourceRequests(ctx, req.(*ListResourceRequestsRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListResourceRequestsResponse) - return ctx.Result(200, reply) - } -} - -type CloudControlServiceHTTPClient interface { - CancelResourceRequest(ctx context.Context, req *CancelResourceRequestRequest, opts ...http.CallOption) (rsp *CancelResourceRequestResponse, err error) - CreateResource(ctx context.Context, req *CreateResourceRequest, opts ...http.CallOption) (rsp *CreateResourceResponse, err error) - DeleteResource(ctx context.Context, req *DeleteResourceRequest, opts ...http.CallOption) (rsp *DeleteResourceResponse, err error) - GetResource(ctx context.Context, req *GetResourceRequest, opts ...http.CallOption) (rsp *GetResourceResponse, err error) - GetResourceRequestStatus(ctx context.Context, req *GetResourceRequestStatusRequest, opts ...http.CallOption) (rsp *GetResourceRequestStatusResponse, err error) - ListResourceRequests(ctx context.Context, req *ListResourceRequestsRequest, opts ...http.CallOption) (rsp *ListResourceRequestsResponse, err error) - ListResources(ctx context.Context, req *ListResourcesRequest, opts ...http.CallOption) (rsp *ListResourcesResponse, err error) - UpdateResource(ctx context.Context, req *UpdateResourceRequest, opts ...http.CallOption) (rsp *UpdateResourceResponse, err error) -} - -type CloudControlServiceHTTPClientImpl struct { - cc *http.Client -} - -func NewCloudControlServiceHTTPClient(client *http.Client) CloudControlServiceHTTPClient { - return &CloudControlServiceHTTPClientImpl{client} -} - -func (c *CloudControlServiceHTTPClientImpl) CancelResourceRequest(ctx context.Context, in *CancelResourceRequestRequest, opts ...http.CallOption) (*CancelResourceRequestResponse, error) { - var out CancelResourceRequestResponse - pattern := "/cloud-control/cancel-resource-request" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationCloudControlServiceCancelResourceRequest)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) - if err != nil { - return nil, err - } - return &out, err -} - -func (c *CloudControlServiceHTTPClientImpl) CreateResource(ctx context.Context, in *CreateResourceRequest, opts ...http.CallOption) (*CreateResourceResponse, error) { - var out CreateResourceResponse - pattern := "/cloud-control/create-resource" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationCloudControlServiceCreateResource)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) - if err != nil { - return nil, err - } - return &out, err -} - -func (c *CloudControlServiceHTTPClientImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest, opts ...http.CallOption) (*DeleteResourceResponse, error) { - var out DeleteResourceResponse - pattern := "/cloud-control/delete-resource" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationCloudControlServiceDeleteResource)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) - if err != nil { - return nil, err - } - return &out, err -} - -func (c *CloudControlServiceHTTPClientImpl) GetResource(ctx context.Context, in *GetResourceRequest, opts ...http.CallOption) (*GetResourceResponse, error) { - var out GetResourceResponse - pattern := "/cloud-control/get-resource" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationCloudControlServiceGetResource)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) - if err != nil { - return nil, err - } - return &out, err -} - -func (c *CloudControlServiceHTTPClientImpl) GetResourceRequestStatus(ctx context.Context, in *GetResourceRequestStatusRequest, opts ...http.CallOption) (*GetResourceRequestStatusResponse, error) { - var out GetResourceRequestStatusResponse - pattern := "/cloud-control/get-resource-request-status" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationCloudControlServiceGetResourceRequestStatus)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) - if err != nil { - return nil, err - } - return &out, err -} - -func (c *CloudControlServiceHTTPClientImpl) ListResourceRequests(ctx context.Context, in *ListResourceRequestsRequest, opts ...http.CallOption) (*ListResourceRequestsResponse, error) { - var out ListResourceRequestsResponse - pattern := "/cloud-control/list-resource-requests" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationCloudControlServiceListResourceRequests)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) - if err != nil { - return nil, err - } - return &out, err -} - -func (c *CloudControlServiceHTTPClientImpl) ListResources(ctx context.Context, in *ListResourcesRequest, opts ...http.CallOption) (*ListResourcesResponse, error) { - var out ListResourcesResponse - pattern := "/cloud-control/list-resources" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationCloudControlServiceListResources)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) - if err != nil { - return nil, err - } - return &out, err -} - -func (c *CloudControlServiceHTTPClientImpl) UpdateResource(ctx context.Context, in *UpdateResourceRequest, opts ...http.CallOption) (*UpdateResourceResponse, error) { - var out UpdateResourceResponse - pattern := "/cloud-control/update-resource" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationCloudControlServiceUpdateResource)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) - if err != nil { - return nil, err - } - return &out, err -} diff --git a/internal/sdk/client.go b/internal/sdk/client.go deleted file mode 100644 index 0f1189f..0000000 --- a/internal/sdk/client.go +++ /dev/null @@ -1,103 +0,0 @@ -package sdk - -import ( - "context" - "encoding/json" - "fmt" - - "github.com/hashicorp/terraform-plugin-log/tflog" - - "github.com/GuanceCloud/terraform-provider-guance/internal/helpers/tfcodec" - ccv1 "github.com/GuanceCloud/terraform-provider-guance/internal/sdk/api/cloudcontrol/v1" -) - -// Resource is the interface that all Guance Cloud resources must implement. -type Resource interface { - // GetResourceType returns the type of the resource. - GetResourceType() string - - // GetId returns the ID of the resource. - GetId() string - - // SetId sets the ID of the resource. - SetId(s string) - - // SetCreatedAt sets the creation time of the resource. - SetCreatedAt(time string) -} - -// ListOptions are the options for listing resources. -type ListOptions struct { - // Count of reserved records. - MaxResults int64 - - // The name of the resource type. - TypeName string -} - -// Client is a Client for the Guance Cloud API. -type Client[T Resource] struct { - Client ccv1.Client -} - -// Create creates a resource. -func (c *Client[T]) Create(ctx context.Context, plan T) error { - desiredState, err := json.Marshal(tfcodec.Encode(plan)) - if err != nil { - return err - } - tflog.Info(ctx, fmt.Sprintf("[DESIRED STATE]: %+v", string(desiredState))) - resp, err := c.Client.CreateResource(ctx, &ccv1.CreateResourceRequest{ - TypeName: plan.GetResourceType(), - DesiredState: string(desiredState), - }) - tflog.Info(ctx, fmt.Sprintf("[RESP]: %+v; [ERROR] %+v;", resp, err)) - if err != nil { - return err - } - plan.SetId(resp.ProgressEvent.Identifier) - return nil -} - -// Delete deletes a resource. -func (c *Client[T]) Delete(ctx context.Context, plan T) error { - _, err := c.Client.DeleteResource(ctx, &ccv1.DeleteResourceRequest{ - Identifier: plan.GetId(), - }) - if err != nil { - return err - } - return nil -} - -// Update updates a resource. -func (c *Client[T]) Update(ctx context.Context, plan T) error { - return nil -} - -// Read reads a resource. -func (c *Client[T]) Read(ctx context.Context, out T) error { - id := out.GetId() - rsResp, err := c.Client.GetResource(ctx, &ccv1.GetResourceRequest{ - Identifier: id, - }) - if err != nil { - return fmt.Errorf("failed to get resource: %w", err) - } - - // Map response body to schema and populate Computed attribute values - if err := tfcodec.DecodeJSON([]byte(rsResp.ResourceDescription.Properties), out); err != nil { - return fmt.Errorf("failed to decode properties: %w", err) - } - out.SetId(rsResp.ResourceDescription.Identifier) - out.SetCreatedAt(rsResp.ResourceDescription.CreatedAt) - return nil -} - -// List lists resources. -func (c *Client[T]) List(ctx context.Context, options *ListOptions) (*ccv1.ListResourcesResponse, error) { - return c.Client.ListResources(ctx, &ccv1.ListResourcesRequest{ - TypeName: options.TypeName, - MaxResults: options.MaxResults, - }) -} diff --git a/internal/sdk/filter.go b/internal/sdk/filter.go deleted file mode 100644 index 9e79e75..0000000 --- a/internal/sdk/filter.go +++ /dev/null @@ -1,29 +0,0 @@ -package sdk - -import ( - "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/tidwall/gjson" -) - -type Filter struct { - Name types.String `tfsdk:"name"` - Values []types.String `tfsdk:"values"` -} - -func (f *Filter) IsOK(state string) bool { - for _, value := range f.Values { - if gjson.Get(state, f.Name.ValueString()).String() == value.ValueString() { - return true - } - } - return false -} - -func FilterAllSuccess(state string, filters ...*Filter) bool { - for _, filter := range filters { - if !filter.IsOK(state) { - return false - } - } - return true -} diff --git a/internal/sdk/types/error.go b/internal/sdk/types/error.go deleted file mode 100644 index 86fdbf1..0000000 --- a/internal/sdk/types/error.go +++ /dev/null @@ -1,7 +0,0 @@ -package types - -type Error struct { - Code int - Message string - Metadata map[string]string -} diff --git a/internal/sdk/types/identifier.go b/internal/sdk/types/identifier.go deleted file mode 100644 index 6e7d0df..0000000 --- a/internal/sdk/types/identifier.go +++ /dev/null @@ -1,29 +0,0 @@ -package types - -import ( - "fmt" - "strings" -) - -// Identifier is a resource identifier. -type Identifier struct { - ResourceType string - PrimaryId string -} - -// String returns the identifier as a string. -func (i Identifier) String() string { - return i.ResourceType + "/" + i.PrimaryId -} - -// ParseIdentifier parses an identifier from a string. -func ParseIdentifier(id string) (Identifier, error) { - tokens := strings.Split(id, "/") - if len(tokens) != 2 { - return Identifier{}, fmt.Errorf("invalid identifier: %s", id) - } - return Identifier{ - ResourceType: tokens[0], - PrimaryId: tokens[1], - }, nil -} diff --git a/internal/sdk/types/request.go b/internal/sdk/types/request.go deleted file mode 100644 index e47a17d..0000000 --- a/internal/sdk/types/request.go +++ /dev/null @@ -1,118 +0,0 @@ -package types - -import ( - "time" - - "github.com/google/uuid" -) - -const ( - // RequestOperationCreate is the operation type for create. - RequestOperationCreate = "CREATE" - - // RequestOperationDelete is the operation type for delete. - RequestOperationDelete = "DELETE" - - // RequestOperationUpdate is the operation type for update. - RequestOperationUpdate = "UPDATE" -) - -const ( - // RequestStatusPending is the status for pending. - RequestStatusPending = "PENDING" - - // RequestStatusInProgress is the status for in progress. - RequestStatusInProgress = "IN_PROGRESS" - - // RequestStatusSuccess is the status for success. - RequestStatusSuccess = "SUCCESS" - - // RequestStatusFailed is the status for failed. - RequestStatusFailed = "FAILED" - - // RequestStatusCancelInProgress is the status for cancel in progress. - RequestStatusCancelInProgress = "CANCEL_IN_PROGRESS" - - // RequestStatusCancelComplete is the status for cancel complete. - RequestStatusCancelComplete = "CANCEL_COMPLETE" -) - -// Request is the current status of a resource operation request. -type Request struct { - // For requests with a status of FAILED, the associated error code. - // - // Valid Values: - // NotUpdatable - // | InvalidRequest - // | AccessDenied - // | InvalidCredentials - // | AlreadyExists - // | NotFound - // | ResourceConflict - // | Throttling - // | ServiceLimitExceeded - // | NotStabilized - // | GeneralServiceException - // | ServiceInternalError - // | ServiceTimeout - // | NetworkFailure - // | InternalFailure - ErrorCode string - - // When the resource operation request was initiated. - RequestTime int64 - - // The primary identifier for the resource. - Identifier Identifier - - // The resource operation type. - // - // Valid Values: - // CREATE - // | DELETE - // | UPDATE - Operation string - - // The current status of the resource operation request. - // - // PENDING: The resource operation hasn't yet started. - // IN_PROGRESS: The resource operation is currently in progress. - // SUCCESS: The resource operation has successfully completed. - // FAILED: The resource operation has failed. Refer to the error code and status message for more information. - // CANCEL_IN_PROGRESS: The resource operation is in the process of being canceled. - // CANCEL_COMPLETE: The resource operation has been canceled. - OperationStatus string - - // The unique token representing this resource operation request. - // Use the RequestToken with GetResourceRequestStatus to return the current status of a resource operation request. - Id string - - // A JSON string containing the resource model, - // consisting of each resource property and its current value. - DesiredState string - - // When to next request the status of this resource operation request. - RetryAfter int64 - - // Any message explaining the current status. - StatusMessage string -} - -func (r *Request) DesiredResource() *Resource { - return &Resource{ - Identifier: r.Identifier, - State: r.DesiredState, - TypeName: r.Identifier.ResourceType, - } -} - -func NewRequest(rs *Resource, op string) *Request { - return &Request{ - Id: uuid.New().String(), - Identifier: rs.Identifier, - DesiredState: rs.State, - Operation: op, - OperationStatus: RequestStatusPending, - RequestTime: time.Now().UnixNano(), - } -} diff --git a/internal/sdk/types/requestquery.go b/internal/sdk/types/requestquery.go deleted file mode 100644 index 6619f21..0000000 --- a/internal/sdk/types/requestquery.go +++ /dev/null @@ -1,6 +0,0 @@ -package types - -type RequestQuery struct { - TypeName string - MaxResults int -} diff --git a/internal/sdk/types/resource.go b/internal/sdk/types/resource.go deleted file mode 100644 index 830d4f7..0000000 --- a/internal/sdk/types/resource.go +++ /dev/null @@ -1,8 +0,0 @@ -package types - -// Resource is the actual representation of a resource. -type Resource struct { - Identifier Identifier - State string - TypeName string -} diff --git a/internal/sdk/types/resourcepatch.go b/internal/sdk/types/resourcepatch.go deleted file mode 100644 index c86c3c2..0000000 --- a/internal/sdk/types/resourcepatch.go +++ /dev/null @@ -1,42 +0,0 @@ -package types - -import ( - "encoding/json" - "fmt" - - jsonpatch "github.com/evanphx/json-patch" -) - -// ResourcePatch is the actual representation of a resource patch. -type ResourcePatch struct { - // Id is the identifier of the resource to be patched. - Id Identifier - - // Patches is a list of JSON patches. - Patches json.RawMessage -} - -// Apply applies the patch to the resource. -func (g *ResourcePatch) Apply(rs *Resource) (*Resource, error) { - patch, err := jsonpatch.DecodePatch(g.Patches) - if err != nil { - return nil, fmt.Errorf("failed to decode patch: %w", err) - } - - state := stateWrapper{Attributes: json.RawMessage(rs.State)} - rsBytes, err := json.Marshal(state) - if err != nil { - return nil, fmt.Errorf("failed to marshal resource: %w", err) - } - - result, err := patch.ApplyIndent(rsBytes, " ") - if err != nil { - return nil, fmt.Errorf("failed to apply patch: %w", err) - } - rs.State = string(result) - return rs, nil -} - -type stateWrapper struct { - Attributes json.RawMessage `json:"attributes"` -} diff --git a/internal/sdk/types/resourcequery.go b/internal/sdk/types/resourcequery.go deleted file mode 100644 index eef64db..0000000 --- a/internal/sdk/types/resourcequery.go +++ /dev/null @@ -1,6 +0,0 @@ -package types - -type ResourceQuery struct { - TypeName string - MaxResults int -}