From b6ed7f6a7f6a294d3b82af648aef40316118c2a8 Mon Sep 17 00:00:00 2001 From: ngrok release bot Date: Wed, 21 May 2025 15:21:32 +0000 Subject: [PATCH] Update generated files --- CHANGELOG.md | 3 + docs/resources/kubernetes_operator.md | 93 ++ .../ngrok_kubernetes_operator/resource.tf | 15 + ngrok/flatten_expand.go | 1022 +++++++++++++++-- ngrok/provider.go | 1 + ngrok/resource_kubernetes_operator.go | 310 +++++ ngrok/resource_kubernetes_operator_test.go | 103 ++ restapi/methods.go | 238 ++++ restapi/resources.go | 195 +++- 9 files changed, 1825 insertions(+), 155 deletions(-) create mode 100644 docs/resources/kubernetes_operator.md create mode 100644 examples/resources/ngrok_kubernetes_operator/resource.tf create mode 100644 ngrok/resource_kubernetes_operator.go create mode 100644 ngrok/resource_kubernetes_operator_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 04af9ea..254ed4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,10 @@ +## 0.5.0 +* Renamed `upstream_proto` to `upstream_protocol` for `endpoint` resources ## 0.4.0 * Added support for Cloud Endpoints (currently in private beta). +* Renamed `principal_id` to `principal` for `endpoint` resources ## 0.3.0 diff --git a/docs/resources/kubernetes_operator.md b/docs/resources/kubernetes_operator.md new file mode 100644 index 0000000..b371c1d --- /dev/null +++ b/docs/resources/kubernetes_operator.md @@ -0,0 +1,93 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "ngrok_kubernetes_operator Resource - terraform-provider-ngrok" +subcategory: "" +description: |- + KubernetesOperators is used by the Kubernetes Operator to register and + manage its own resource, as well as for users to see active kubernetes + clusters. +--- + +# ngrok_kubernetes_operator (Resource) + +KubernetesOperators is used by the Kubernetes Operator to register and + manage its own resource, as well as for users to see active kubernetes + clusters. + +## Example Usage + +```terraform +# Code generated for API Clients. DO NOT EDIT. + + +resource "ngrok_kubernetes_operator" "example" { + deployment { + name = "ngrok-operator" + namespace = "ngrok-operator" + version = "0.12.2" + } + description = "Created by ngrok-operator" + enabled_features = [ "Ingress", "Bindings" ] + metadata = "{\"namespace.uid\":\"9663c1aa-10e4-4933-8576-398a49a5caf6\",\"owned-by\":\"ngrok-operator\"}" + region = "global" +} +``` + + +## Schema + +### Optional + +- **binding** (Block Set) information about the Bindings feature of this Kubernetes Operator, if enabled (see [below for nested schema](#nestedblock--binding)) +- **deployment** (Block Set) information about the deployment of this Kubernetes Operator (see [below for nested schema](#nestedblock--deployment)) +- **description** (String) human-readable description of this Kubernetes Operator. optional, max 255 bytes. +- **enabled_features** (List of String) features enabled for this Kubernetes Operator. a subset of "bindings", "ingress", and "gateway" +- **metadata** (String) arbitrary user-defined machine-readable data of this Kubernetes Operator. optional, max 4096 bytes. +- **region** (String) the ngrok region in which the ingress for this operator is served. defaults to "global" + +### Read-Only + +- **id** (String) unique identifier for this Kubernetes Operator +- **principal** (Set of Object) the principal who created this Kubernetes Operator (see [below for nested schema](#nestedatt--principal)) + + +### Nested Schema for `binding` + +Optional: + +- **endpoint_selectors** (List of String) the list of cel expressions that filter the k8s bound endpoints for this operator +- **ingress_endpoint** (String) the public ingress endpoint for this Kubernetes Operator + +Read-Only: + +- **cert** (Set of Object) the binding certificate information (see [below for nested schema](#nestedatt--binding--cert)) + + +### Nested Schema for `binding.cert` + +Read-Only: + +- **cert** (String) + + + + +### Nested Schema for `deployment` + +Optional: + +- **cluster_name** (String) user-given name for the cluster the Kubernetes Operator is deployed to +- **name** (String) the deployment name +- **namespace** (String) the namespace this Kubernetes Operator is deployed to +- **version** (String) the version of this Kubernetes Operator + + + +### Nested Schema for `principal` + +Read-Only: + +- **id** (String) +- **uri** (String) + + diff --git a/examples/resources/ngrok_kubernetes_operator/resource.tf b/examples/resources/ngrok_kubernetes_operator/resource.tf new file mode 100644 index 0000000..1666912 --- /dev/null +++ b/examples/resources/ngrok_kubernetes_operator/resource.tf @@ -0,0 +1,15 @@ +# Code generated for API Clients. DO NOT EDIT. + + +resource "ngrok_kubernetes_operator" "example" { + deployment { + name = "ngrok-operator" + namespace = "ngrok-operator" + version = "0.12.2" + } + description = "Created by ngrok-operator" + enabled_features = [ "Ingress", "Bindings" ] + metadata = "{\"namespace.uid\":\"9663c1aa-10e4-4933-8576-398a49a5caf6\",\"owned-by\":\"ngrok-operator\"}" + region = "global" +} + diff --git a/ngrok/flatten_expand.go b/ngrok/flatten_expand.go index b1e4fad..57697e5 100644 --- a/ngrok/flatten_expand.go +++ b/ngrok/flatten_expand.go @@ -142,6 +142,62 @@ func expandPagingSlice(in interface{}) *[]restapi.Paging { return &out } +func flattenItemPaging(obj *restapi.ItemPaging) interface{} { + if obj == nil { + return nil + } + + m := make(map[string]interface{}) + m["id"] = obj.ID + m["before_id"] = obj.BeforeID + m["limit"] = obj.Limit + + return []interface{}{m} +} + +func flattenItemPagingSlice(objs *[]restapi.ItemPaging) (sl []interface{}) { + if objs == nil { + return nil + } + + for _, v := range *objs { + sl = append(sl, flattenItemPaging(&v)) + } + return sl +} + +func expandItemPaging(in interface{}) *restapi.ItemPaging { + if in == nil { + return nil + } + v := in.(*schema.Set) + + if v.Len() == 0 { + return nil + } + + m := v.List()[0].(map[string]interface{}) + var obj restapi.ItemPaging + if v, ok := m["id"]; ok { + obj.ID = *expandString(v) + } + if v, ok := m["before_id"]; ok { + obj.BeforeID = expandString(v) + } + if v, ok := m["limit"]; ok { + obj.Limit = expandString(v) + } + return &obj +} + +func expandItemPagingSlice(in interface{}) *[]restapi.ItemPaging { + var out []restapi.ItemPaging + for _, v := range in.([]interface{}) { + out = append(out, *expandItemPaging(v)) + } + return &out +} + func flattenError(obj *restapi.Error) interface{} { if obj == nil { return nil @@ -9282,15 +9338,15 @@ func flattenEndpoint(obj *restapi.Endpoint) interface{} { m["tunnel"] = flattenRef(obj.Tunnel) m["edge"] = flattenRef(obj.Edge) m["upstream_url"] = obj.UpstreamURL - m["upstream_proto"] = obj.UpstreamProto + m["upstream_protocol"] = obj.UpstreamProtocol m["url"] = obj.URL m["principal"] = flattenRef(obj.Principal) - m["principal_id"] = flattenRef(obj.PrincipalID) m["traffic_policy"] = obj.TrafficPolicy m["bindings"] = obj.Bindings m["tunnel_session"] = flattenRef(obj.TunnelSession) m["uri"] = obj.URI m["name"] = obj.Name + m["pooling_enabled"] = obj.PoolingEnabled return []interface{}{m} } @@ -9372,8 +9428,8 @@ func expandEndpoint(in interface{}) *restapi.Endpoint { if v, ok := m["upstream_url"]; ok { obj.UpstreamURL = *expandString(v) } - if v, ok := m["upstream_proto"]; ok { - obj.UpstreamProto = *expandString(v) + if v, ok := m["upstream_protocol"]; ok { + obj.UpstreamProtocol = *expandString(v) } if v, ok := m["url"]; ok { obj.URL = *expandString(v) @@ -9381,9 +9437,6 @@ func expandEndpoint(in interface{}) *restapi.Endpoint { if v, ok := m["principal"]; ok { obj.Principal = expandRef(v) } - if v, ok := m["principal_id"]; ok { - obj.PrincipalID = expandRef(v) - } if v, ok := m["traffic_policy"]; ok { obj.TrafficPolicy = *expandString(v) } @@ -9399,6 +9452,9 @@ func expandEndpoint(in interface{}) *restapi.Endpoint { if v, ok := m["name"]; ok { obj.Name = *expandString(v) } + if v, ok := m["pooling_enabled"]; ok { + obj.PoolingEnabled = *expandBool(v) + } return &obj } @@ -9478,6 +9534,7 @@ func flattenEndpointCreate(obj *restapi.EndpointCreate) interface{} { m["description"] = obj.Description m["metadata"] = obj.Metadata m["bindings"] = obj.Bindings + m["pooling_enabled"] = obj.PoolingEnabled return []interface{}{m} } @@ -9523,6 +9580,9 @@ func expandEndpointCreate(in interface{}) *restapi.EndpointCreate { if v, ok := m["bindings"]; ok { obj.Bindings = expandStringSlice(v) } + if v, ok := m["pooling_enabled"]; ok { + obj.PoolingEnabled = *expandBool(v) + } return &obj } @@ -9546,6 +9606,7 @@ func flattenEndpointUpdate(obj *restapi.EndpointUpdate) interface{} { m["description"] = obj.Description m["metadata"] = obj.Metadata m["bindings"] = obj.Bindings + m["pooling_enabled"] = obj.PoolingEnabled return []interface{}{m} } @@ -9591,6 +9652,9 @@ func expandEndpointUpdate(in interface{}) *restapi.EndpointUpdate { if v, ok := m["bindings"]; ok { obj.Bindings = expandStringSlice(v) } + if v, ok := m["pooling_enabled"]; ok { + obj.PoolingEnabled = *expandBool(v) + } return &obj } @@ -12164,8 +12228,7 @@ func flattenKubernetesOperatorBindingCreate(obj *restapi.KubernetesOperatorBindi } m := make(map[string]interface{}) - m["name"] = obj.Name - m["allowed_urls"] = obj.AllowedURLs + m["endpoint_selectors"] = obj.EndpointSelectors m["csr"] = obj.CSR m["ingress_endpoint"] = obj.IngressEndpoint @@ -12195,11 +12258,8 @@ func expandKubernetesOperatorBindingCreate(in interface{}) *restapi.KubernetesOp m := v.List()[0].(map[string]interface{}) var obj restapi.KubernetesOperatorBindingCreate - if v, ok := m["name"]; ok { - obj.Name = *expandString(v) - } - if v, ok := m["allowed_urls"]; ok { - obj.AllowedURLs = *expandStringSlice(v) + if v, ok := m["endpoint_selectors"]; ok { + obj.EndpointSelectors = *expandStringSlice(v) } if v, ok := m["csr"]; ok { obj.CSR = *expandString(v) @@ -12230,6 +12290,7 @@ func flattenKubernetesOperatorUpdate(obj *restapi.KubernetesOperatorUpdate) inte m["enabled_features"] = obj.EnabledFeatures m["region"] = obj.Region m["binding"] = flattenKubernetesOperatorBindingUpdate(obj.Binding) + m["deployment"] = flattenKubernetesOperatorDeploymentUpdate(obj.Deployment) return []interface{}{m} } @@ -12275,6 +12336,9 @@ func expandKubernetesOperatorUpdate(in interface{}) *restapi.KubernetesOperatorU if v, ok := m["binding"]; ok { obj.Binding = expandKubernetesOperatorBindingUpdate(v) } + if v, ok := m["deployment"]; ok { + obj.Deployment = expandKubernetesOperatorDeploymentUpdate(v) + } return &obj } @@ -12292,8 +12356,7 @@ func flattenKubernetesOperatorBindingUpdate(obj *restapi.KubernetesOperatorBindi } m := make(map[string]interface{}) - m["name"] = obj.Name - m["allowed_urls"] = obj.AllowedURLs + m["endpoint_selectors"] = obj.EndpointSelectors m["csr"] = obj.CSR m["ingress_endpoint"] = obj.IngressEndpoint @@ -12323,11 +12386,8 @@ func expandKubernetesOperatorBindingUpdate(in interface{}) *restapi.KubernetesOp m := v.List()[0].(map[string]interface{}) var obj restapi.KubernetesOperatorBindingUpdate - if v, ok := m["name"]; ok { - obj.Name = expandString(v) - } - if v, ok := m["allowed_urls"]; ok { - obj.AllowedURLs = expandStringSlice(v) + if v, ok := m["endpoint_selectors"]; ok { + obj.EndpointSelectors = expandStringSlice(v) } if v, ok := m["csr"]; ok { obj.CSR = expandString(v) @@ -12346,6 +12406,58 @@ func expandKubernetesOperatorBindingUpdateSlice(in interface{}) *[]restapi.Kuber return &out } +func flattenKubernetesOperatorDeploymentUpdate(obj *restapi.KubernetesOperatorDeploymentUpdate) interface{} { + if obj == nil { + return nil + } + + m := make(map[string]interface{}) + m["name"] = obj.Name + m["version"] = obj.Version + + return []interface{}{m} +} + +func flattenKubernetesOperatorDeploymentUpdateSlice(objs *[]restapi.KubernetesOperatorDeploymentUpdate) (sl []interface{}) { + if objs == nil { + return nil + } + + for _, v := range *objs { + sl = append(sl, flattenKubernetesOperatorDeploymentUpdate(&v)) + } + return sl +} + +func expandKubernetesOperatorDeploymentUpdate(in interface{}) *restapi.KubernetesOperatorDeploymentUpdate { + if in == nil { + return nil + } + v := in.(*schema.Set) + + if v.Len() == 0 { + return nil + } + + m := v.List()[0].(map[string]interface{}) + var obj restapi.KubernetesOperatorDeploymentUpdate + if v, ok := m["name"]; ok { + obj.Name = expandString(v) + } + if v, ok := m["version"]; ok { + obj.Version = expandString(v) + } + return &obj +} + +func expandKubernetesOperatorDeploymentUpdateSlice(in interface{}) *[]restapi.KubernetesOperatorDeploymentUpdate { + var out []restapi.KubernetesOperatorDeploymentUpdate + for _, v := range in.([]interface{}) { + out = append(out, *expandKubernetesOperatorDeploymentUpdate(v)) + } + return &out +} + func flattenKubernetesOperator(obj *restapi.KubernetesOperator) interface{} { if obj == nil { return nil @@ -12443,6 +12555,7 @@ func flattenKubernetesOperatorDeployment(obj *restapi.KubernetesOperatorDeployme m["name"] = obj.Name m["namespace"] = obj.Namespace m["version"] = obj.Version + m["cluster_name"] = obj.ClusterName return []interface{}{m} } @@ -12479,6 +12592,9 @@ func expandKubernetesOperatorDeployment(in interface{}) *restapi.KubernetesOpera if v, ok := m["version"]; ok { obj.Version = *expandString(v) } + if v, ok := m["cluster_name"]; ok { + obj.ClusterName = *expandString(v) + } return &obj } @@ -12552,8 +12668,7 @@ func flattenKubernetesOperatorBinding(obj *restapi.KubernetesOperatorBinding) in } m := make(map[string]interface{}) - m["name"] = obj.Name - m["allowed_urls"] = obj.AllowedURLs + m["endpoint_selectors"] = obj.EndpointSelectors m["cert"] = flattenKubernetesOperatorCert(&obj.Cert) m["ingress_endpoint"] = obj.IngressEndpoint @@ -12583,11 +12698,8 @@ func expandKubernetesOperatorBinding(in interface{}) *restapi.KubernetesOperator m := v.List()[0].(map[string]interface{}) var obj restapi.KubernetesOperatorBinding - if v, ok := m["name"]; ok { - obj.Name = *expandString(v) - } - if v, ok := m["allowed_urls"]; ok { - obj.AllowedURLs = *expandStringSlice(v) + if v, ok := m["endpoint_selectors"]; ok { + obj.EndpointSelectors = *expandStringSlice(v) } if v, ok := m["cert"]; ok { obj.Cert = *expandKubernetesOperatorCert(v) @@ -14130,33 +14242,31 @@ func expandRootResponseSlice(in interface{}) *[]restapi.RootResponse { return &out } -func flattenSSHCertificateAuthorityCreate(obj *restapi.SSHCertificateAuthorityCreate) interface{} { +func flattenSelfResponse(obj *restapi.SelfResponse) interface{} { if obj == nil { return nil } m := make(map[string]interface{}) - m["description"] = obj.Description - m["metadata"] = obj.Metadata - m["private_key_type"] = obj.PrivateKeyType - m["elliptic_curve"] = obj.EllipticCurve - m["key_size"] = obj.KeySize + m["api_key"] = flattenAPIKey(&obj.ApiKey) + m["account"] = flattenAccount(&obj.Account) + m["user"] = obj.User return []interface{}{m} } -func flattenSSHCertificateAuthorityCreateSlice(objs *[]restapi.SSHCertificateAuthorityCreate) (sl []interface{}) { +func flattenSelfResponseSlice(objs *[]restapi.SelfResponse) (sl []interface{}) { if objs == nil { return nil } for _, v := range *objs { - sl = append(sl, flattenSSHCertificateAuthorityCreate(&v)) + sl = append(sl, flattenSelfResponse(&v)) } return sl } -func expandSSHCertificateAuthorityCreate(in interface{}) *restapi.SSHCertificateAuthorityCreate { +func expandSelfResponse(in interface{}) *restapi.SelfResponse { if in == nil { return nil } @@ -14167,58 +14277,58 @@ func expandSSHCertificateAuthorityCreate(in interface{}) *restapi.SSHCertificate } m := v.List()[0].(map[string]interface{}) - var obj restapi.SSHCertificateAuthorityCreate - if v, ok := m["description"]; ok { - obj.Description = *expandString(v) - } - if v, ok := m["metadata"]; ok { - obj.Metadata = *expandString(v) - } - if v, ok := m["private_key_type"]; ok { - obj.PrivateKeyType = *expandString(v) + var obj restapi.SelfResponse + if v, ok := m["api_key"]; ok { + obj.ApiKey = *expandAPIKey(v) } - if v, ok := m["elliptic_curve"]; ok { - obj.EllipticCurve = *expandString(v) + if v, ok := m["account"]; ok { + obj.Account = *expandAccount(v) } - if v, ok := m["key_size"]; ok { - obj.KeySize = *expandInt64(v) + if v, ok := m["user"]; ok { + obj.User = *expandString(v) } return &obj } -func expandSSHCertificateAuthorityCreateSlice(in interface{}) *[]restapi.SSHCertificateAuthorityCreate { - var out []restapi.SSHCertificateAuthorityCreate +func expandSelfResponseSlice(in interface{}) *[]restapi.SelfResponse { + var out []restapi.SelfResponse for _, v := range in.([]interface{}) { - out = append(out, *expandSSHCertificateAuthorityCreate(v)) + out = append(out, *expandSelfResponse(v)) } return &out } -func flattenSSHCertificateAuthorityUpdate(obj *restapi.SSHCertificateAuthorityUpdate) interface{} { +func flattenAccount(obj *restapi.Account) interface{} { if obj == nil { return nil } m := make(map[string]interface{}) m["id"] = obj.ID - m["description"] = obj.Description - m["metadata"] = obj.Metadata + m["name"] = obj.Name + m["created_at"] = obj.CreatedAt + m["suspended"] = obj.Suspended + m["enforce_sso"] = obj.EnforceSSO + m["min_api_version"] = obj.MinApiVersion + m["min_agent_version"] = obj.MinAgentVersion + m["user_mfa_required"] = obj.UserMfaRequired + m["traffic_full_capture"] = obj.TrafficFullCapture return []interface{}{m} } -func flattenSSHCertificateAuthorityUpdateSlice(objs *[]restapi.SSHCertificateAuthorityUpdate) (sl []interface{}) { +func flattenAccountSlice(objs *[]restapi.Account) (sl []interface{}) { if objs == nil { return nil } for _, v := range *objs { - sl = append(sl, flattenSSHCertificateAuthorityUpdate(&v)) + sl = append(sl, flattenAccount(&v)) } return sl } -func expandSSHCertificateAuthorityUpdate(in interface{}) *restapi.SSHCertificateAuthorityUpdate { +func expandAccount(in interface{}) *restapi.Account { if in == nil { return nil } @@ -14229,56 +14339,72 @@ func expandSSHCertificateAuthorityUpdate(in interface{}) *restapi.SSHCertificate } m := v.List()[0].(map[string]interface{}) - var obj restapi.SSHCertificateAuthorityUpdate + var obj restapi.Account if v, ok := m["id"]; ok { obj.ID = *expandString(v) } - if v, ok := m["description"]; ok { - obj.Description = expandString(v) + if v, ok := m["name"]; ok { + obj.Name = *expandString(v) } - if v, ok := m["metadata"]; ok { - obj.Metadata = expandString(v) + if v, ok := m["created_at"]; ok { + obj.CreatedAt = *expandString(v) + } + if v, ok := m["suspended"]; ok { + obj.Suspended = *expandBool(v) + } + if v, ok := m["enforce_sso"]; ok { + obj.EnforceSSO = *expandBool(v) + } + if v, ok := m["min_api_version"]; ok { + obj.MinApiVersion = *expandInt64(v) + } + if v, ok := m["min_agent_version"]; ok { + obj.MinAgentVersion = *expandString(v) + } + if v, ok := m["user_mfa_required"]; ok { + obj.UserMfaRequired = *expandBool(v) + } + if v, ok := m["traffic_full_capture"]; ok { + obj.TrafficFullCapture = *expandBool(v) } return &obj } -func expandSSHCertificateAuthorityUpdateSlice(in interface{}) *[]restapi.SSHCertificateAuthorityUpdate { - var out []restapi.SSHCertificateAuthorityUpdate +func expandAccountSlice(in interface{}) *[]restapi.Account { + var out []restapi.Account for _, v := range in.([]interface{}) { - out = append(out, *expandSSHCertificateAuthorityUpdate(v)) + out = append(out, *expandAccount(v)) } return &out } -func flattenSSHCertificateAuthority(obj *restapi.SSHCertificateAuthority) interface{} { +func flattenSecretCreate(obj *restapi.SecretCreate) interface{} { if obj == nil { return nil } m := make(map[string]interface{}) - m["id"] = obj.ID - m["uri"] = obj.URI - m["created_at"] = obj.CreatedAt - m["description"] = obj.Description + m["name"] = obj.Name + m["value"] = obj.Value m["metadata"] = obj.Metadata - m["public_key"] = obj.PublicKey - m["key_type"] = obj.KeyType + m["description"] = obj.Description + m["vault_id"] = obj.VaultID return []interface{}{m} } -func flattenSSHCertificateAuthoritySlice(objs *[]restapi.SSHCertificateAuthority) (sl []interface{}) { +func flattenSecretCreateSlice(objs *[]restapi.SecretCreate) (sl []interface{}) { if objs == nil { return nil } for _, v := range *objs { - sl = append(sl, flattenSSHCertificateAuthority(&v)) + sl = append(sl, flattenSecretCreate(&v)) } return sl } -func expandSSHCertificateAuthority(in interface{}) *restapi.SSHCertificateAuthority { +func expandSecretCreate(in interface{}) *restapi.SecretCreate { if in == nil { return nil } @@ -14289,64 +14415,60 @@ func expandSSHCertificateAuthority(in interface{}) *restapi.SSHCertificateAuthor } m := v.List()[0].(map[string]interface{}) - var obj restapi.SSHCertificateAuthority - if v, ok := m["id"]; ok { - obj.ID = *expandString(v) - } - if v, ok := m["uri"]; ok { - obj.URI = *expandString(v) - } - if v, ok := m["created_at"]; ok { - obj.CreatedAt = *expandString(v) + var obj restapi.SecretCreate + if v, ok := m["name"]; ok { + obj.Name = *expandString(v) } - if v, ok := m["description"]; ok { - obj.Description = *expandString(v) + if v, ok := m["value"]; ok { + obj.Value = *expandString(v) } if v, ok := m["metadata"]; ok { obj.Metadata = *expandString(v) } - if v, ok := m["public_key"]; ok { - obj.PublicKey = *expandString(v) + if v, ok := m["description"]; ok { + obj.Description = *expandString(v) } - if v, ok := m["key_type"]; ok { - obj.KeyType = *expandString(v) + if v, ok := m["vault_id"]; ok { + obj.VaultID = *expandString(v) } return &obj } -func expandSSHCertificateAuthoritySlice(in interface{}) *[]restapi.SSHCertificateAuthority { - var out []restapi.SSHCertificateAuthority +func expandSecretCreateSlice(in interface{}) *[]restapi.SecretCreate { + var out []restapi.SecretCreate for _, v := range in.([]interface{}) { - out = append(out, *expandSSHCertificateAuthority(v)) + out = append(out, *expandSecretCreate(v)) } return &out } -func flattenSSHCertificateAuthorityList(obj *restapi.SSHCertificateAuthorityList) interface{} { +func flattenSecretUpdate(obj *restapi.SecretUpdate) interface{} { if obj == nil { return nil } m := make(map[string]interface{}) - m["ssh_certificate_authorities"] = flattenSSHCertificateAuthoritySlice(&obj.SSHCertificateAuthorities) - m["uri"] = obj.URI - m["next_page_uri"] = obj.NextPageURI + m["id"] = obj.ID + m["name"] = obj.Name + m["value"] = obj.Value + m["metadata"] = obj.Metadata + m["description"] = obj.Description return []interface{}{m} } -func flattenSSHCertificateAuthorityListSlice(objs *[]restapi.SSHCertificateAuthorityList) (sl []interface{}) { +func flattenSecretUpdateSlice(objs *[]restapi.SecretUpdate) (sl []interface{}) { if objs == nil { return nil } for _, v := range *objs { - sl = append(sl, flattenSSHCertificateAuthorityList(&v)) + sl = append(sl, flattenSecretUpdate(&v)) } return sl } -func expandSSHCertificateAuthorityList(in interface{}) *restapi.SSHCertificateAuthorityList { +func expandSecretUpdate(in interface{}) *restapi.SecretUpdate { if in == nil { return nil } @@ -14357,55 +14479,65 @@ func expandSSHCertificateAuthorityList(in interface{}) *restapi.SSHCertificateAu } m := v.List()[0].(map[string]interface{}) - var obj restapi.SSHCertificateAuthorityList - if v, ok := m["ssh_certificate_authorities"]; ok { - obj.SSHCertificateAuthorities = *expandSSHCertificateAuthoritySlice(v) + var obj restapi.SecretUpdate + if v, ok := m["id"]; ok { + obj.ID = *expandString(v) } - if v, ok := m["uri"]; ok { - obj.URI = *expandString(v) + if v, ok := m["name"]; ok { + obj.Name = expandString(v) } - if v, ok := m["next_page_uri"]; ok { - obj.NextPageURI = expandString(v) + if v, ok := m["value"]; ok { + obj.Value = expandString(v) + } + if v, ok := m["metadata"]; ok { + obj.Metadata = expandString(v) + } + if v, ok := m["description"]; ok { + obj.Description = expandString(v) } return &obj } -func expandSSHCertificateAuthorityListSlice(in interface{}) *[]restapi.SSHCertificateAuthorityList { - var out []restapi.SSHCertificateAuthorityList +func expandSecretUpdateSlice(in interface{}) *[]restapi.SecretUpdate { + var out []restapi.SecretUpdate for _, v := range in.([]interface{}) { - out = append(out, *expandSSHCertificateAuthorityList(v)) + out = append(out, *expandSecretUpdate(v)) } return &out } -func flattenSSHCredentialCreate(obj *restapi.SSHCredentialCreate) interface{} { +func flattenSecret(obj *restapi.Secret) interface{} { if obj == nil { return nil } m := make(map[string]interface{}) + m["id"] = obj.ID + m["uri"] = obj.URI + m["created_at"] = obj.CreatedAt + m["updated_at"] = obj.UpdatedAt + m["name"] = obj.Name m["description"] = obj.Description m["metadata"] = obj.Metadata - m["acl"] = obj.ACL - m["public_key"] = obj.PublicKey - m["owner_id"] = obj.OwnerID - m["owner_email"] = obj.OwnerEmail + m["created_by"] = flattenRef(&obj.CreatedBy) + m["last_updated_by"] = flattenRef(&obj.LastUpdatedBy) + m["vault"] = flattenRef(&obj.Vault) return []interface{}{m} } -func flattenSSHCredentialCreateSlice(objs *[]restapi.SSHCredentialCreate) (sl []interface{}) { +func flattenSecretSlice(objs *[]restapi.Secret) (sl []interface{}) { if objs == nil { return nil } for _, v := range *objs { - sl = append(sl, flattenSSHCredentialCreate(&v)) + sl = append(sl, flattenSecret(&v)) } return sl } -func expandSSHCredentialCreate(in interface{}) *restapi.SSHCredentialCreate { +func expandSecret(in interface{}) *restapi.Secret { if in == nil { return nil } @@ -14416,15 +14548,399 @@ func expandSSHCredentialCreate(in interface{}) *restapi.SSHCredentialCreate { } m := v.List()[0].(map[string]interface{}) - var obj restapi.SSHCredentialCreate - if v, ok := m["description"]; ok { - obj.Description = *expandString(v) + var obj restapi.Secret + if v, ok := m["id"]; ok { + obj.ID = *expandString(v) } - if v, ok := m["metadata"]; ok { - obj.Metadata = *expandString(v) + if v, ok := m["uri"]; ok { + obj.URI = *expandString(v) } - if v, ok := m["acl"]; ok { - obj.ACL = *expandStringSlice(v) + if v, ok := m["created_at"]; ok { + obj.CreatedAt = *expandString(v) + } + if v, ok := m["updated_at"]; ok { + obj.UpdatedAt = *expandString(v) + } + if v, ok := m["name"]; ok { + obj.Name = *expandString(v) + } + if v, ok := m["description"]; ok { + obj.Description = *expandString(v) + } + if v, ok := m["metadata"]; ok { + obj.Metadata = *expandString(v) + } + if v, ok := m["created_by"]; ok { + obj.CreatedBy = *expandRef(v) + } + if v, ok := m["last_updated_by"]; ok { + obj.LastUpdatedBy = *expandRef(v) + } + if v, ok := m["vault"]; ok { + obj.Vault = *expandRef(v) + } + return &obj +} + +func expandSecretSlice(in interface{}) *[]restapi.Secret { + var out []restapi.Secret + for _, v := range in.([]interface{}) { + out = append(out, *expandSecret(v)) + } + return &out +} + +func flattenSecretList(obj *restapi.SecretList) interface{} { + if obj == nil { + return nil + } + + m := make(map[string]interface{}) + m["secrets"] = flattenSecretSlice(&obj.Secrets) + m["uri"] = obj.URI + m["next_page_uri"] = obj.NextPageURI + + return []interface{}{m} +} + +func flattenSecretListSlice(objs *[]restapi.SecretList) (sl []interface{}) { + if objs == nil { + return nil + } + + for _, v := range *objs { + sl = append(sl, flattenSecretList(&v)) + } + return sl +} + +func expandSecretList(in interface{}) *restapi.SecretList { + if in == nil { + return nil + } + v := in.(*schema.Set) + + if v.Len() == 0 { + return nil + } + + m := v.List()[0].(map[string]interface{}) + var obj restapi.SecretList + if v, ok := m["secrets"]; ok { + obj.Secrets = *expandSecretSlice(v) + } + if v, ok := m["uri"]; ok { + obj.URI = *expandString(v) + } + if v, ok := m["next_page_uri"]; ok { + obj.NextPageURI = expandString(v) + } + return &obj +} + +func expandSecretListSlice(in interface{}) *[]restapi.SecretList { + var out []restapi.SecretList + for _, v := range in.([]interface{}) { + out = append(out, *expandSecretList(v)) + } + return &out +} + +func flattenSSHCertificateAuthorityCreate(obj *restapi.SSHCertificateAuthorityCreate) interface{} { + if obj == nil { + return nil + } + + m := make(map[string]interface{}) + m["description"] = obj.Description + m["metadata"] = obj.Metadata + m["private_key_type"] = obj.PrivateKeyType + m["elliptic_curve"] = obj.EllipticCurve + m["key_size"] = obj.KeySize + + return []interface{}{m} +} + +func flattenSSHCertificateAuthorityCreateSlice(objs *[]restapi.SSHCertificateAuthorityCreate) (sl []interface{}) { + if objs == nil { + return nil + } + + for _, v := range *objs { + sl = append(sl, flattenSSHCertificateAuthorityCreate(&v)) + } + return sl +} + +func expandSSHCertificateAuthorityCreate(in interface{}) *restapi.SSHCertificateAuthorityCreate { + if in == nil { + return nil + } + v := in.(*schema.Set) + + if v.Len() == 0 { + return nil + } + + m := v.List()[0].(map[string]interface{}) + var obj restapi.SSHCertificateAuthorityCreate + if v, ok := m["description"]; ok { + obj.Description = *expandString(v) + } + if v, ok := m["metadata"]; ok { + obj.Metadata = *expandString(v) + } + if v, ok := m["private_key_type"]; ok { + obj.PrivateKeyType = *expandString(v) + } + if v, ok := m["elliptic_curve"]; ok { + obj.EllipticCurve = *expandString(v) + } + if v, ok := m["key_size"]; ok { + obj.KeySize = *expandInt64(v) + } + return &obj +} + +func expandSSHCertificateAuthorityCreateSlice(in interface{}) *[]restapi.SSHCertificateAuthorityCreate { + var out []restapi.SSHCertificateAuthorityCreate + for _, v := range in.([]interface{}) { + out = append(out, *expandSSHCertificateAuthorityCreate(v)) + } + return &out +} + +func flattenSSHCertificateAuthorityUpdate(obj *restapi.SSHCertificateAuthorityUpdate) interface{} { + if obj == nil { + return nil + } + + m := make(map[string]interface{}) + m["id"] = obj.ID + m["description"] = obj.Description + m["metadata"] = obj.Metadata + + return []interface{}{m} +} + +func flattenSSHCertificateAuthorityUpdateSlice(objs *[]restapi.SSHCertificateAuthorityUpdate) (sl []interface{}) { + if objs == nil { + return nil + } + + for _, v := range *objs { + sl = append(sl, flattenSSHCertificateAuthorityUpdate(&v)) + } + return sl +} + +func expandSSHCertificateAuthorityUpdate(in interface{}) *restapi.SSHCertificateAuthorityUpdate { + if in == nil { + return nil + } + v := in.(*schema.Set) + + if v.Len() == 0 { + return nil + } + + m := v.List()[0].(map[string]interface{}) + var obj restapi.SSHCertificateAuthorityUpdate + if v, ok := m["id"]; ok { + obj.ID = *expandString(v) + } + if v, ok := m["description"]; ok { + obj.Description = expandString(v) + } + if v, ok := m["metadata"]; ok { + obj.Metadata = expandString(v) + } + return &obj +} + +func expandSSHCertificateAuthorityUpdateSlice(in interface{}) *[]restapi.SSHCertificateAuthorityUpdate { + var out []restapi.SSHCertificateAuthorityUpdate + for _, v := range in.([]interface{}) { + out = append(out, *expandSSHCertificateAuthorityUpdate(v)) + } + return &out +} + +func flattenSSHCertificateAuthority(obj *restapi.SSHCertificateAuthority) interface{} { + if obj == nil { + return nil + } + + m := make(map[string]interface{}) + m["id"] = obj.ID + m["uri"] = obj.URI + m["created_at"] = obj.CreatedAt + m["description"] = obj.Description + m["metadata"] = obj.Metadata + m["public_key"] = obj.PublicKey + m["key_type"] = obj.KeyType + + return []interface{}{m} +} + +func flattenSSHCertificateAuthoritySlice(objs *[]restapi.SSHCertificateAuthority) (sl []interface{}) { + if objs == nil { + return nil + } + + for _, v := range *objs { + sl = append(sl, flattenSSHCertificateAuthority(&v)) + } + return sl +} + +func expandSSHCertificateAuthority(in interface{}) *restapi.SSHCertificateAuthority { + if in == nil { + return nil + } + v := in.(*schema.Set) + + if v.Len() == 0 { + return nil + } + + m := v.List()[0].(map[string]interface{}) + var obj restapi.SSHCertificateAuthority + if v, ok := m["id"]; ok { + obj.ID = *expandString(v) + } + if v, ok := m["uri"]; ok { + obj.URI = *expandString(v) + } + if v, ok := m["created_at"]; ok { + obj.CreatedAt = *expandString(v) + } + if v, ok := m["description"]; ok { + obj.Description = *expandString(v) + } + if v, ok := m["metadata"]; ok { + obj.Metadata = *expandString(v) + } + if v, ok := m["public_key"]; ok { + obj.PublicKey = *expandString(v) + } + if v, ok := m["key_type"]; ok { + obj.KeyType = *expandString(v) + } + return &obj +} + +func expandSSHCertificateAuthoritySlice(in interface{}) *[]restapi.SSHCertificateAuthority { + var out []restapi.SSHCertificateAuthority + for _, v := range in.([]interface{}) { + out = append(out, *expandSSHCertificateAuthority(v)) + } + return &out +} + +func flattenSSHCertificateAuthorityList(obj *restapi.SSHCertificateAuthorityList) interface{} { + if obj == nil { + return nil + } + + m := make(map[string]interface{}) + m["ssh_certificate_authorities"] = flattenSSHCertificateAuthoritySlice(&obj.SSHCertificateAuthorities) + m["uri"] = obj.URI + m["next_page_uri"] = obj.NextPageURI + + return []interface{}{m} +} + +func flattenSSHCertificateAuthorityListSlice(objs *[]restapi.SSHCertificateAuthorityList) (sl []interface{}) { + if objs == nil { + return nil + } + + for _, v := range *objs { + sl = append(sl, flattenSSHCertificateAuthorityList(&v)) + } + return sl +} + +func expandSSHCertificateAuthorityList(in interface{}) *restapi.SSHCertificateAuthorityList { + if in == nil { + return nil + } + v := in.(*schema.Set) + + if v.Len() == 0 { + return nil + } + + m := v.List()[0].(map[string]interface{}) + var obj restapi.SSHCertificateAuthorityList + if v, ok := m["ssh_certificate_authorities"]; ok { + obj.SSHCertificateAuthorities = *expandSSHCertificateAuthoritySlice(v) + } + if v, ok := m["uri"]; ok { + obj.URI = *expandString(v) + } + if v, ok := m["next_page_uri"]; ok { + obj.NextPageURI = expandString(v) + } + return &obj +} + +func expandSSHCertificateAuthorityListSlice(in interface{}) *[]restapi.SSHCertificateAuthorityList { + var out []restapi.SSHCertificateAuthorityList + for _, v := range in.([]interface{}) { + out = append(out, *expandSSHCertificateAuthorityList(v)) + } + return &out +} + +func flattenSSHCredentialCreate(obj *restapi.SSHCredentialCreate) interface{} { + if obj == nil { + return nil + } + + m := make(map[string]interface{}) + m["description"] = obj.Description + m["metadata"] = obj.Metadata + m["acl"] = obj.ACL + m["public_key"] = obj.PublicKey + m["owner_id"] = obj.OwnerID + m["owner_email"] = obj.OwnerEmail + + return []interface{}{m} +} + +func flattenSSHCredentialCreateSlice(objs *[]restapi.SSHCredentialCreate) (sl []interface{}) { + if objs == nil { + return nil + } + + for _, v := range *objs { + sl = append(sl, flattenSSHCredentialCreate(&v)) + } + return sl +} + +func expandSSHCredentialCreate(in interface{}) *restapi.SSHCredentialCreate { + if in == nil { + return nil + } + v := in.(*schema.Set) + + if v.Len() == 0 { + return nil + } + + m := v.List()[0].(map[string]interface{}) + var obj restapi.SSHCredentialCreate + if v, ok := m["description"]; ok { + obj.Description = *expandString(v) + } + if v, ok := m["metadata"]; ok { + obj.Metadata = *expandString(v) + } + if v, ok := m["acl"]; ok { + obj.ACL = *expandStringSlice(v) } if v, ok := m["public_key"]; ok { obj.PublicKey = *expandString(v) @@ -15702,6 +16218,258 @@ func expandTunnelListSlice(in interface{}) *[]restapi.TunnelList { return &out } +func flattenVaultCreate(obj *restapi.VaultCreate) interface{} { + if obj == nil { + return nil + } + + m := make(map[string]interface{}) + m["name"] = obj.Name + m["metadata"] = obj.Metadata + m["description"] = obj.Description + + return []interface{}{m} +} + +func flattenVaultCreateSlice(objs *[]restapi.VaultCreate) (sl []interface{}) { + if objs == nil { + return nil + } + + for _, v := range *objs { + sl = append(sl, flattenVaultCreate(&v)) + } + return sl +} + +func expandVaultCreate(in interface{}) *restapi.VaultCreate { + if in == nil { + return nil + } + v := in.(*schema.Set) + + if v.Len() == 0 { + return nil + } + + m := v.List()[0].(map[string]interface{}) + var obj restapi.VaultCreate + if v, ok := m["name"]; ok { + obj.Name = *expandString(v) + } + if v, ok := m["metadata"]; ok { + obj.Metadata = *expandString(v) + } + if v, ok := m["description"]; ok { + obj.Description = *expandString(v) + } + return &obj +} + +func expandVaultCreateSlice(in interface{}) *[]restapi.VaultCreate { + var out []restapi.VaultCreate + for _, v := range in.([]interface{}) { + out = append(out, *expandVaultCreate(v)) + } + return &out +} + +func flattenVaultUpdate(obj *restapi.VaultUpdate) interface{} { + if obj == nil { + return nil + } + + m := make(map[string]interface{}) + m["id"] = obj.ID + m["name"] = obj.Name + m["metadata"] = obj.Metadata + m["description"] = obj.Description + + return []interface{}{m} +} + +func flattenVaultUpdateSlice(objs *[]restapi.VaultUpdate) (sl []interface{}) { + if objs == nil { + return nil + } + + for _, v := range *objs { + sl = append(sl, flattenVaultUpdate(&v)) + } + return sl +} + +func expandVaultUpdate(in interface{}) *restapi.VaultUpdate { + if in == nil { + return nil + } + v := in.(*schema.Set) + + if v.Len() == 0 { + return nil + } + + m := v.List()[0].(map[string]interface{}) + var obj restapi.VaultUpdate + if v, ok := m["id"]; ok { + obj.ID = *expandString(v) + } + if v, ok := m["name"]; ok { + obj.Name = expandString(v) + } + if v, ok := m["metadata"]; ok { + obj.Metadata = expandString(v) + } + if v, ok := m["description"]; ok { + obj.Description = expandString(v) + } + return &obj +} + +func expandVaultUpdateSlice(in interface{}) *[]restapi.VaultUpdate { + var out []restapi.VaultUpdate + for _, v := range in.([]interface{}) { + out = append(out, *expandVaultUpdate(v)) + } + return &out +} + +func flattenVault(obj *restapi.Vault) interface{} { + if obj == nil { + return nil + } + + m := make(map[string]interface{}) + m["id"] = obj.ID + m["uri"] = obj.URI + m["created_at"] = obj.CreatedAt + m["updated_at"] = obj.UpdatedAt + m["name"] = obj.Name + m["description"] = obj.Description + m["metadata"] = obj.Metadata + m["created_by"] = obj.CreatedBy + m["last_updated_by"] = obj.LastUpdatedBy + + return []interface{}{m} +} + +func flattenVaultSlice(objs *[]restapi.Vault) (sl []interface{}) { + if objs == nil { + return nil + } + + for _, v := range *objs { + sl = append(sl, flattenVault(&v)) + } + return sl +} + +func expandVault(in interface{}) *restapi.Vault { + if in == nil { + return nil + } + v := in.(*schema.Set) + + if v.Len() == 0 { + return nil + } + + m := v.List()[0].(map[string]interface{}) + var obj restapi.Vault + if v, ok := m["id"]; ok { + obj.ID = *expandString(v) + } + if v, ok := m["uri"]; ok { + obj.URI = *expandString(v) + } + if v, ok := m["created_at"]; ok { + obj.CreatedAt = *expandString(v) + } + if v, ok := m["updated_at"]; ok { + obj.UpdatedAt = *expandString(v) + } + if v, ok := m["name"]; ok { + obj.Name = *expandString(v) + } + if v, ok := m["description"]; ok { + obj.Description = *expandString(v) + } + if v, ok := m["metadata"]; ok { + obj.Metadata = *expandString(v) + } + if v, ok := m["created_by"]; ok { + obj.CreatedBy = *expandString(v) + } + if v, ok := m["last_updated_by"]; ok { + obj.LastUpdatedBy = *expandString(v) + } + return &obj +} + +func expandVaultSlice(in interface{}) *[]restapi.Vault { + var out []restapi.Vault + for _, v := range in.([]interface{}) { + out = append(out, *expandVault(v)) + } + return &out +} + +func flattenVaultList(obj *restapi.VaultList) interface{} { + if obj == nil { + return nil + } + + m := make(map[string]interface{}) + m["vaults"] = flattenVaultSlice(&obj.Vaults) + m["uri"] = obj.URI + m["next_page_uri"] = obj.NextPageURI + + return []interface{}{m} +} + +func flattenVaultListSlice(objs *[]restapi.VaultList) (sl []interface{}) { + if objs == nil { + return nil + } + + for _, v := range *objs { + sl = append(sl, flattenVaultList(&v)) + } + return sl +} + +func expandVaultList(in interface{}) *restapi.VaultList { + if in == nil { + return nil + } + v := in.(*schema.Set) + + if v.Len() == 0 { + return nil + } + + m := v.List()[0].(map[string]interface{}) + var obj restapi.VaultList + if v, ok := m["vaults"]; ok { + obj.Vaults = *expandVaultSlice(v) + } + if v, ok := m["uri"]; ok { + obj.URI = *expandString(v) + } + if v, ok := m["next_page_uri"]; ok { + obj.NextPageURI = expandString(v) + } + return &obj +} + +func expandVaultListSlice(in interface{}) *[]restapi.VaultList { + var out []restapi.VaultList + for _, v := range in.([]interface{}) { + out = append(out, *expandVaultList(v)) + } + return &out +} + func expandString(v interface{}) *string { x := v.(string) return &x diff --git a/ngrok/provider.go b/ngrok/provider.go index 0081bb1..53202e3 100644 --- a/ngrok/provider.go +++ b/ngrok/provider.go @@ -39,6 +39,7 @@ func Provider() *schema.Provider { "ngrok_ip_policy": resourceIPPolicies(), "ngrok_ip_policy_rule": resourceIPPolicyRules(), "ngrok_ip_restriction": resourceIPRestrictions(), + "ngrok_kubernetes_operator": resourceKubernetesOperators(), "ngrok_reserved_addr": resourceReservedAddrs(), "ngrok_reserved_domain": resourceReservedDomains(), "ngrok_ssh_certificate_authority": resourceSSHCertificateAuthorities(), diff --git a/ngrok/resource_kubernetes_operator.go b/ngrok/resource_kubernetes_operator.go new file mode 100644 index 0000000..a92d2ab --- /dev/null +++ b/ngrok/resource_kubernetes_operator.go @@ -0,0 +1,310 @@ +package ngrok + +import ( + "context" + "log" + "net/http" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + restapi "github.com/ngrok/terraform-provider-ngrok/restapi" +) + +func resourceKubernetesOperators() *schema.Resource { + return &schema.Resource{ + Create: resourceKubernetesOperatorsCreate, + Read: resourceKubernetesOperatorsGet, + Update: resourceKubernetesOperatorsUpdate, + Delete: resourceKubernetesOperatorsDelete, + Description: "KubernetesOperators is used by the Kubernetes Operator to register and\n manage its own resource, as well as for users to see active kubernetes\n clusters.", + Schema: map[string]*schema.Schema{ + "binding": { + Type: schema.TypeSet, + Required: false, + Computed: false, + Optional: true, + Sensitive: false, + ForceNew: false, + Description: "information about the Bindings feature of this Kubernetes Operator, if enabled", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "endpoint_selectors": { + Type: schema.TypeList, + Required: false, + Computed: false, + Optional: true, + Sensitive: false, + ForceNew: false, + Description: "the list of cel expressions that filter the k8s bound endpoints for this operator", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "cert": { + Type: schema.TypeSet, + Required: false, + Computed: true, + Optional: false, + Sensitive: false, + ForceNew: true, + Description: "the binding certificate information", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cert": { + Type: schema.TypeString, + Required: false, + Computed: true, + Optional: false, + Sensitive: false, + ForceNew: true, + Description: "the public client certificate generated for this Kubernetes Operator from the CSR supplied when enabling the Bindings feature", + }, + }, + }, + }, + "ingress_endpoint": { + Type: schema.TypeString, + Required: false, + Computed: false, + Optional: true, + Sensitive: false, + ForceNew: false, + Description: "the public ingress endpoint for this Kubernetes Operator", + }, + }, + }, + }, + "deployment": { + Type: schema.TypeSet, + Required: false, + Computed: false, + Optional: true, + Sensitive: false, + ForceNew: false, + Description: "information about the deployment of this Kubernetes Operator", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: false, + Computed: false, + Optional: true, + Sensitive: false, + ForceNew: false, + Description: "the deployment name", + }, + "namespace": { + Type: schema.TypeString, + Required: false, + Computed: false, + Optional: true, + Sensitive: false, + ForceNew: true, + Description: "the namespace this Kubernetes Operator is deployed to", + }, + "version": { + Type: schema.TypeString, + Required: false, + Computed: false, + Optional: true, + Sensitive: false, + ForceNew: false, + Description: "the version of this Kubernetes Operator", + }, + "cluster_name": { + Type: schema.TypeString, + Required: false, + Computed: false, + Optional: true, + Sensitive: false, + ForceNew: true, + Description: "user-given name for the cluster the Kubernetes Operator is deployed to", + }, + }, + }, + }, + "description": { + Type: schema.TypeString, + Required: false, + Computed: false, + Optional: true, + Sensitive: false, + ForceNew: false, + Description: "human-readable description of this Kubernetes Operator. optional, max 255 bytes.", + }, + "enabled_features": { + Type: schema.TypeList, + Required: false, + Computed: false, + Optional: true, + Sensitive: false, + ForceNew: false, + Description: "features enabled for this Kubernetes Operator. a subset of \"bindings\", \"ingress\", and \"gateway\"", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "id": { + Type: schema.TypeString, + Required: false, + Computed: true, + Optional: false, + Sensitive: false, + ForceNew: false, + Description: "unique identifier for this Kubernetes Operator", + }, + "metadata": { + Type: schema.TypeString, + Required: false, + Computed: false, + Optional: true, + Sensitive: false, + ForceNew: false, + Description: "arbitrary user-defined machine-readable data of this Kubernetes Operator. optional, max 4096 bytes.", + }, + "principal": { + Type: schema.TypeSet, + Required: false, + Computed: true, + Optional: false, + Sensitive: false, + ForceNew: true, + Description: "the principal who created this Kubernetes Operator", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Required: false, + Computed: true, + Optional: false, + Sensitive: false, + ForceNew: false, + Description: "a resource identifier", + }, + "uri": { + Type: schema.TypeString, + Required: false, + Computed: true, + Optional: false, + Sensitive: false, + ForceNew: true, + Description: "a uri for locating a resource", + }, + }, + }, + }, + "region": { + Type: schema.TypeString, + Required: false, + Computed: false, + Optional: true, + Sensitive: false, + ForceNew: false, + Description: "the ngrok region in which the ingress for this operator is served. defaults to \"global\"", + }, + }, + } +} + +func resourceKubernetesOperatorsCreate(d *schema.ResourceData, m interface{}) (err error) { + b := m.(*base) + + var arg restapi.KubernetesOperatorCreate + if v, ok := d.GetOk("description"); ok { + arg.Description = *expandString(v) + } + if v, ok := d.GetOk("metadata"); ok { + arg.Metadata = *expandString(v) + } + if v, ok := d.GetOk("enabled_features"); ok { + arg.EnabledFeatures = *expandStringSlice(v) + } + if v, ok := d.GetOk("region"); ok { + arg.Region = *expandString(v) + } + if v, ok := d.GetOk("deployment"); ok { + arg.Deployment = *expandKubernetesOperatorDeployment(v) + } + if v, ok := d.GetOk("binding"); ok { + arg.Binding = expandKubernetesOperatorBindingCreate(v) + } + + res, _, err := b.client.KubernetesOperatorsCreate(context.Background(), &arg) + if err != nil { + log.Printf("[ERROR] KubernetesOperatorsCreate: %s", err) + return err + } + d.SetId(res.ID) + + return resourceKubernetesOperatorsGet(d, m) +} + +func resourceKubernetesOperatorsGet(d *schema.ResourceData, m interface{}) (err error) { + b := m.(*base) + + res, resp, err := b.client.KubernetesOperatorsGet(context.Background(), &restapi.Item{ + ID: d.Id(), + }) + return resourceKubernetesOperatorsGetDecode(d, res, resp, err) +} + +func resourceKubernetesOperatorsGetDecode(d *schema.ResourceData, res *restapi.KubernetesOperator, resp *http.Response, err error) error { + switch { + case resp != nil && resp.StatusCode == 404: + d.SetId("") + case err != nil: + log.Printf("[ERROR] KubernetesOperatorsGet: %s", err) + return err + default: + d.Set("binding", flattenKubernetesOperatorBinding(res.Binding)) + d.Set("deployment", flattenKubernetesOperatorDeployment(&res.Deployment)) + d.Set("description", res.Description) + d.Set("enabled_features", res.EnabledFeatures) + d.Set("id", res.ID) + d.Set("metadata", res.Metadata) + d.Set("principal", flattenRef(&res.Principal)) + d.Set("region", res.Region) + } + return nil +} + +func resourceKubernetesOperatorsUpdate(d *schema.ResourceData, m interface{}) (err error) { + b := m.(*base) + + var arg restapi.KubernetesOperatorUpdate + arg.ID = d.Id() + if v, ok := d.GetOk("id"); ok { + arg.ID = *expandString(v) + } + if v, ok := d.GetOk("description"); ok { + arg.Description = expandString(v) + } + if v, ok := d.GetOk("metadata"); ok { + arg.Metadata = expandString(v) + } + if v, ok := d.GetOk("enabled_features"); ok { + arg.EnabledFeatures = expandStringSlice(v) + } + if v, ok := d.GetOk("region"); ok { + arg.Region = expandString(v) + } + if v, ok := d.GetOk("binding"); ok { + arg.Binding = expandKubernetesOperatorBindingUpdate(v) + } + if v, ok := d.GetOk("deployment"); ok { + arg.Deployment = expandKubernetesOperatorDeploymentUpdate(v) + } + + res, _, err := b.client.KubernetesOperatorsUpdate(context.Background(), &arg) + if err != nil { + log.Printf("[ERROR] KubernetesOperatorsUpdate: %s", err) + return err + } + d.SetId(res.ID) + + return resourceKubernetesOperatorsGet(d, m) +} + +func resourceKubernetesOperatorsDelete(d *schema.ResourceData, m interface{}) (err error) { + b := m.(*base) + _, _, err = b.client.KubernetesOperatorsDelete(context.Background(), &restapi.Item{ID: d.Id()}) + if err != nil { + log.Printf("[ERROR] KubernetesOperatorsDelete: %s", err) + } + return err +} diff --git a/ngrok/resource_kubernetes_operator_test.go b/ngrok/resource_kubernetes_operator_test.go new file mode 100644 index 0000000..59b9989 --- /dev/null +++ b/ngrok/resource_kubernetes_operator_test.go @@ -0,0 +1,103 @@ +package ngrok + +import ( + "context" + "fmt" + "log" + "reflect" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + restapi "github.com/ngrok/terraform-provider-ngrok/restapi" +) + +var ( + resourceKubernetesOperators_createConfig = `resource "ngrok_kubernetes_operator" "example" { + deployment { + name = "ngrok-operator" + namespace = "ngrok-operator" + version = "0.12.2" + } + description = "Created by ngrok-operator" + enabled_features = [ "Ingress", "Bindings" ] + metadata = "{\"namespace.uid\":\"9663c1aa-10e4-4933-8576-398a49a5caf6\",\"owned-by\":\"ngrok-operator\"}" + region = "global" +}` + resourceKubernetesOperators_updateConfig = `resource "ngrok_kubernetes_operator" "example" { + deployment { + cluster_name = "" + name = "ngrok-operator" + namespace = "ngrok-operator" + version = "0.12.2" + } + description = "Created by ngrok-operator" + enabled_features = [ "Ingress", "Bindings" ] + metadata = "{\"namespace.uid\":\"9663c1aa-10e4-4933-8576-398a49a5caf6\",\"owned-by\":\"ngrok-operator\"}" + region = "global" +}` +) + +func init() { + resource.AddTestSweepers("kubernetes_operators", &resource.Sweeper{ + Name: "kubernetes_operators", + F: func(region string) error { + ctx := context.Background() + client, err := sharedClientForRegion(region) + if err != nil { + return fmt.Errorf("Error getting client: %s", err) + } + conn := client.(*restapi.Client) + + list, _, err := conn.KubernetesOperatorsList(ctx, &restapi.Paging{}) + if err != nil { + return fmt.Errorf("Error getting list of items: %s", err) + } + + for _, item := range list.Operators { + // Assume items with empty Description or Metadata are system defined + // (i.e. API Keys) so do not sweep them for cleanup. + // However, not all items have Description and Metadata fields, so need to reflect. + iv := reflect.ValueOf(item) + dv := iv.FieldByName("Description") + mv := iv.FieldByName("Metadata") + shouldKeep := (dv.IsValid() && dv.IsZero()) || (mv.IsValid() && mv.IsZero()) + if !shouldKeep { + _, _, err := conn.KubernetesOperatorsDelete(ctx, &restapi.Item{ID: item.ID}) + + if err != nil { + log.Printf("Error destroying id %s during sweep: %s", item.ID, err) + } + } + } + + return nil + }, + }) +} + +func TestAccResourceKubernetesOperators(t *testing.T) { + + resource.Test(t, resource.TestCase{ + Providers: testAccProviders, + PreCheck: func() { testAccPreCheck(t) }, + CheckDestroy: testAccCheckDestroyKubernetesOperators, + Steps: []resource.TestStep{ + { + Config: resourceKubernetesOperators_createConfig, + // Check: resource.ComposeAggregateTestCheckFunc( + // testAccCheckCreateKubernetesOperators, + // ), + }, + }, + }) +} + +func testAccCheckDestroyKubernetesOperators(s *terraform.State) (err error) { + return err +} + +func testAccCheckCreateKubernetesOperators(s *terraform.State) (err error) { + fmt.Sprintf("state=%#v", s) + return err +} diff --git a/restapi/methods.go b/restapi/methods.go index a8325de..b1ae68d 100644 --- a/restapi/methods.go +++ b/restapi/methods.go @@ -3745,6 +3745,36 @@ func (c *Client) KubernetesOperatorsList(ctx context.Context, arg *Paging) (*Kub return &res, resp, err } +// List Endpoints bound to a Kubernetes Operator +func (c *Client) KubernetesOperatorsGetBoundEndpoints(ctx context.Context, arg *ItemPaging) (*EndpointList, *http.Response, error) { + var res EndpointList + var path bytes.Buffer + if err := template.Must(template.New("").Parse("/kubernetes_operators/{{ .ID }}/bound_endpoints")).Execute(&path, arg); err != nil { + panic(err) + } + uri := path.String() + pathUrl, err := url.Parse(uri) + if err != nil { + panic(err) + } + params := url.Values{} + if arg.BeforeID != nil { + params.Add("before_id", *arg.BeforeID) + } + if arg.Limit != nil { + params.Add("limit", *arg.Limit) + } + pathUrl.RawQuery = params.Encode() + uri = pathUrl.String() + arg.ID = "" + + resp, err := c.Get(ctx, uri, &res) + if errors.Is(err, io.EOF) && resp != nil && resp.StatusCode == 204 { + err = nil + } + return &res, resp, err +} + func (c *Client) EndpointBasicAuthModuleReplace(ctx context.Context, arg *EndpointBasicAuthReplace) (*EndpointBasicAuth, *http.Response, error) { var res EndpointBasicAuth var path bytes.Buffer @@ -4661,6 +4691,118 @@ func (c *Client) RootGet(ctx context.Context, arg *Empty) (*RootResponse, *http. return &res, resp, err } +// Get the details of the data used in this current request +func (c *Client) RootSelf(ctx context.Context, arg *Empty) (*SelfResponse, *http.Response, error) { + var res SelfResponse + var path bytes.Buffer + if err := template.Must(template.New("").Parse("/self")).Execute(&path, arg); err != nil { + panic(err) + } + uri := path.String() + + resp, err := c.Get(ctx, uri, &res) + if errors.Is(err, io.EOF) && resp != nil && resp.StatusCode == 204 { + err = nil + } + return &res, resp, err +} + +// Create a new Secret +func (c *Client) SecretsCreate(ctx context.Context, arg *SecretCreate) (*Secret, *http.Response, error) { + var res Secret + var path bytes.Buffer + if err := template.Must(template.New("").Parse("/vault-secrets")).Execute(&path, arg); err != nil { + panic(err) + } + uri := path.String() + + resp, err := c.Post(ctx, uri, arg, &res) + if errors.Is(err, io.EOF) && resp != nil && resp.StatusCode == 204 { + err = nil + } + return &res, resp, err +} + +// Update an existing Secret by ID +func (c *Client) SecretsUpdate(ctx context.Context, arg *SecretUpdate) (*Secret, *http.Response, error) { + var res Secret + var path bytes.Buffer + if err := template.Must(template.New("").Parse("/vault-secrets/{{ .ID }}")).Execute(&path, arg); err != nil { + panic(err) + } + uri := path.String() + arg.ID = "" + + resp, err := c.Patch(ctx, uri, arg, &res) + if errors.Is(err, io.EOF) && resp != nil && resp.StatusCode == 204 { + err = nil + } + return &res, resp, err +} + +// Delete a Secret +func (c *Client) SecretsDelete(ctx context.Context, arg *Item) (*Empty, *http.Response, error) { + var res Empty + var path bytes.Buffer + if err := template.Must(template.New("").Parse("/vault-secrets/{{ .ID }}")).Execute(&path, arg); err != nil { + panic(err) + } + uri := path.String() + arg.ID = "" + + resp, err := c.Delete(ctx, uri, &res) + if errors.Is(err, io.EOF) && resp != nil && resp.StatusCode == 204 { + err = nil + } + return &res, resp, err +} + +// Get a Secret by ID +func (c *Client) SecretsGet(ctx context.Context, arg *Item) (*Secret, *http.Response, error) { + var res Secret + var path bytes.Buffer + if err := template.Must(template.New("").Parse("/vault-secrets/{{ .ID }}")).Execute(&path, arg); err != nil { + panic(err) + } + uri := path.String() + arg.ID = "" + + resp, err := c.Get(ctx, uri, &res) + if errors.Is(err, io.EOF) && resp != nil && resp.StatusCode == 204 { + err = nil + } + return &res, resp, err +} + +// List all Secrets owned by account +func (c *Client) SecretsList(ctx context.Context, arg *Paging) (*SecretList, *http.Response, error) { + var res SecretList + var path bytes.Buffer + if err := template.Must(template.New("").Parse("/vault-secrets")).Execute(&path, arg); err != nil { + panic(err) + } + uri := path.String() + pathUrl, err := url.Parse(uri) + if err != nil { + panic(err) + } + params := url.Values{} + if arg.BeforeID != nil { + params.Add("before_id", *arg.BeforeID) + } + if arg.Limit != nil { + params.Add("limit", *arg.Limit) + } + pathUrl.RawQuery = params.Encode() + uri = pathUrl.String() + + resp, err := c.Get(ctx, uri, &res) + if errors.Is(err, io.EOF) && resp != nil && resp.StatusCode == 204 { + err = nil + } + return &res, resp, err +} + // Create a new SSH Certificate Authority func (c *Client) SSHCertificateAuthoritiesCreate(ctx context.Context, arg *SSHCertificateAuthorityCreate) (*SSHCertificateAuthority, *http.Response, error) { var res SSHCertificateAuthority @@ -5186,3 +5328,99 @@ func (c *Client) TunnelsGet(ctx context.Context, arg *Item) (*Tunnel, *http.Resp } return &res, resp, err } + +// Create a new Vault +func (c *Client) VaultsCreate(ctx context.Context, arg *VaultCreate) (*Vault, *http.Response, error) { + var res Vault + var path bytes.Buffer + if err := template.Must(template.New("").Parse("/vaults")).Execute(&path, arg); err != nil { + panic(err) + } + uri := path.String() + + resp, err := c.Post(ctx, uri, arg, &res) + if errors.Is(err, io.EOF) && resp != nil && resp.StatusCode == 204 { + err = nil + } + return &res, resp, err +} + +// Update an existing Vault by ID +func (c *Client) VaultsUpdate(ctx context.Context, arg *VaultUpdate) (*Vault, *http.Response, error) { + var res Vault + var path bytes.Buffer + if err := template.Must(template.New("").Parse("/vaults/{{ .ID }}")).Execute(&path, arg); err != nil { + panic(err) + } + uri := path.String() + arg.ID = "" + + resp, err := c.Patch(ctx, uri, arg, &res) + if errors.Is(err, io.EOF) && resp != nil && resp.StatusCode == 204 { + err = nil + } + return &res, resp, err +} + +// Delete a Vault +func (c *Client) VaultsDelete(ctx context.Context, arg *Item) (*Empty, *http.Response, error) { + var res Empty + var path bytes.Buffer + if err := template.Must(template.New("").Parse("/vaults/{{ .ID }}")).Execute(&path, arg); err != nil { + panic(err) + } + uri := path.String() + arg.ID = "" + + resp, err := c.Delete(ctx, uri, &res) + if errors.Is(err, io.EOF) && resp != nil && resp.StatusCode == 204 { + err = nil + } + return &res, resp, err +} + +// Get a Vault by ID +func (c *Client) VaultsGet(ctx context.Context, arg *Item) (*Vault, *http.Response, error) { + var res Vault + var path bytes.Buffer + if err := template.Must(template.New("").Parse("/vaults/{{ .ID }}")).Execute(&path, arg); err != nil { + panic(err) + } + uri := path.String() + arg.ID = "" + + resp, err := c.Get(ctx, uri, &res) + if errors.Is(err, io.EOF) && resp != nil && resp.StatusCode == 204 { + err = nil + } + return &res, resp, err +} + +// List all Vaults owned by account +func (c *Client) VaultsList(ctx context.Context, arg *Paging) (*VaultList, *http.Response, error) { + var res VaultList + var path bytes.Buffer + if err := template.Must(template.New("").Parse("/vaults")).Execute(&path, arg); err != nil { + panic(err) + } + uri := path.String() + pathUrl, err := url.Parse(uri) + if err != nil { + panic(err) + } + params := url.Values{} + if arg.BeforeID != nil { + params.Add("before_id", *arg.BeforeID) + } + if arg.Limit != nil { + params.Add("limit", *arg.Limit) + } + pathUrl.RawQuery = params.Encode() + uri = pathUrl.String() + + resp, err := c.Get(ctx, uri, &res) + if errors.Is(err, io.EOF) && resp != nil && resp.StatusCode == 204 { + err = nil + } + return &res, resp, err +} diff --git a/restapi/resources.go b/restapi/resources.go index c4c896e..323db4f 100644 --- a/restapi/resources.go +++ b/restapi/resources.go @@ -15,6 +15,13 @@ type Paging struct { Limit *string `json:"limit,omitempty"` } +type ItemPaging struct { + // a resource identifier + ID string `json:"id,omitempty"` + BeforeID *string `json:"before_id,omitempty"` + Limit *string `json:"limit,omitempty"` +} + type Error struct { ErrorCode string `json:"error_code,omitempty"` StatusCode int32 `json:"status_code,omitempty"` @@ -2039,13 +2046,11 @@ type Endpoint struct { // the local address the tunnel forwards to UpstreamURL string `json:"upstream_url,omitempty"` // the protocol the agent uses to forward with - UpstreamProto string `json:"upstream_proto,omitempty"` + UpstreamProtocol string `json:"upstream_protocol,omitempty"` // the url of the endpoint URL string `json:"url,omitempty"` // The ID of the owner (bot or user) that owns this endpoint Principal *Ref `json:"principal,omitempty"` - // TODO: deprecate me! - PrincipalID *Ref `json:"principal_id,omitempty"` // The traffic policy attached to this endpoint TrafficPolicy string `json:"traffic_policy,omitempty"` // the bindings associated with this endpoint @@ -2056,6 +2061,8 @@ type Endpoint struct { URI string `json:"uri,omitempty"` // user supplied name for the endpoint Name string `json:"name,omitempty"` + // whether the endpoint allows pooling + PoolingEnabled bool `json:"pooling_enabled,omitempty"` } type EndpointList struct { @@ -2070,8 +2077,8 @@ type EndpointList struct { type EndpointCreate struct { // the url of the endpoint URL string `json:"url,omitempty"` - // whether the endpoint is ephemeral (served directly by an agent-initiated tunnel) - // or edge (served by an edge) or cloud (represents a cloud endpoint) + // Type of endpoint. Only 'cloud' is currently supported (represents a cloud + // endpoint). Defaults to 'cloud' if not specified. Type string `json:"type,omitempty"` // The traffic policy attached to this endpoint TrafficPolicy string `json:"traffic_policy,omitempty"` @@ -2080,7 +2087,8 @@ type EndpointCreate struct { // user-supplied metadata of the associated tunnel or edge object Metadata *string `json:"metadata,omitempty"` // the bindings associated with this endpoint - Bindings *[]string `json:"bindings,omitempty"` + Bindings *[]string `json:"bindings,omitempty"` + PoolingEnabled bool `json:"pooling_enabled,omitempty"` } type EndpointUpdate struct { @@ -2095,7 +2103,8 @@ type EndpointUpdate struct { // user-supplied metadata of the associated tunnel or edge object Metadata *string `json:"metadata,omitempty"` // the bindings associated with this endpoint - Bindings *[]string `json:"bindings,omitempty"` + Bindings *[]string `json:"bindings,omitempty"` + PoolingEnabled bool `json:"pooling_enabled,omitempty"` } type AgentSessionEvent struct { @@ -2627,8 +2636,8 @@ type KubernetesOperatorCreate struct { // arbitrary user-defined machine-readable data of this Kubernetes Operator. // optional, max 4096 bytes. Metadata string `json:"metadata,omitempty"` - // features enabled for this Kubernetes Operator. a subset of {"bindings", - // "ingress", and "gateway"} + // features enabled for this Kubernetes Operator. a subset of "bindings", + // "ingress", and "gateway" EnabledFeatures []string `json:"enabled_features,omitempty"` // the ngrok region in which the ingress for this operator is served. defaults to // "global" @@ -2641,11 +2650,9 @@ type KubernetesOperatorCreate struct { } type KubernetesOperatorBindingCreate struct { - // the name by which endpoints can be bound to this Kubernetes Operator. starts - // with "k8s/" - Name string `json:"name,omitempty"` - // the regexes for urls allowed to be bound to this operator - AllowedURLs []string `json:"allowed_urls,omitempty"` + // the list of cel expressions that filter the k8s bound endpoints for this + // operator + EndpointSelectors []string `json:"endpoint_selectors,omitempty"` // CSR is supplied during initial creation to enable creating a mutual TLS secured // connection between ngrok and the operator. This is an internal implementation // detail and subject to change. @@ -2662,8 +2669,8 @@ type KubernetesOperatorUpdate struct { // arbitrary user-defined machine-readable data of this Kubernetes Operator. // optional, max 4096 bytes. Metadata *string `json:"metadata,omitempty"` - // features enabled for this Kubernetes Operator. a subset of {"bindings", - // "ingress", and "gateway"} + // features enabled for this Kubernetes Operator. a subset of "bindings", + // "ingress", and "gateway" EnabledFeatures *[]string `json:"enabled_features,omitempty"` // the ngrok region in which the ingress for this operator is served. defaults to // "global" @@ -2671,14 +2678,14 @@ type KubernetesOperatorUpdate struct { // configuration for the Bindings feature of this Kubernetes Operator. set only if // enabling the "bindings" feature Binding *KubernetesOperatorBindingUpdate `json:"binding,omitempty"` + // configuration for the Deployment info + Deployment *KubernetesOperatorDeploymentUpdate `json:"deployment,omitempty"` } type KubernetesOperatorBindingUpdate struct { - // the name by which endpoints can be bound to this Kubernetes Operator. starts - // with "k8s/" - Name *string `json:"name,omitempty"` - // the regexes for urls allowed to be bound to this operator - AllowedURLs *[]string `json:"allowed_urls,omitempty"` + // the list of cel expressions that filter the k8s bound endpoints for this + // operator + EndpointSelectors *[]string `json:"endpoint_selectors,omitempty"` // CSR is supplied during initial creation to enable creating a mutual TLS secured // connection between ngrok and the operator. This is an internal implementation // detail and subject to change. @@ -2687,6 +2694,13 @@ type KubernetesOperatorBindingUpdate struct { IngressEndpoint *string `json:"ingress_endpoint,omitempty"` } +type KubernetesOperatorDeploymentUpdate struct { + // the deployment name + Name *string `json:"name,omitempty"` + // the version of this Kubernetes Operator + Version *string `json:"version,omitempty"` +} + type KubernetesOperator struct { // unique identifier for this Kubernetes Operator ID string `json:"id,omitempty"` @@ -2703,8 +2717,8 @@ type KubernetesOperator struct { Metadata string `json:"metadata,omitempty"` // the principal who created this Kubernetes Operator Principal Ref `json:"principal,omitempty"` - // features enabled for this Kubernetes Operator. a subset of {"bindings", - // "ingress", and "gateway"} + // features enabled for this Kubernetes Operator. a subset of "bindings", + // "ingress", and "gateway" EnabledFeatures []string `json:"enabled_features,omitempty"` // the ngrok region in which the ingress for this operator is served. defaults to // "global" @@ -2722,6 +2736,8 @@ type KubernetesOperatorDeployment struct { Namespace string `json:"namespace,omitempty"` // the version of this Kubernetes Operator Version string `json:"version,omitempty"` + // user-given name for the cluster the Kubernetes Operator is deployed to + ClusterName string `json:"cluster_name,omitempty"` } type KubernetesOperatorCert struct { @@ -2735,11 +2751,9 @@ type KubernetesOperatorCert struct { } type KubernetesOperatorBinding struct { - // the name by which endpoints can be bound to this Kubernetes Operator. starts - // with "k8s/" - Name string `json:"name,omitempty"` - // the regexes for urls allowed to be bound to this operator - AllowedURLs []string `json:"allowed_urls,omitempty"` + // the list of cel expressions that filter the k8s bound endpoints for this + // operator + EndpointSelectors []string `json:"endpoint_selectors,omitempty"` // the binding certificate information Cert KubernetesOperatorCert `json:"cert,omitempty"` // the public ingress endpoint for this Kubernetes Operator @@ -3032,6 +3046,82 @@ type RootResponse struct { SubresourceURIs map[string]string `json:"subresource_uris,omitempty"` } +type SelfResponse struct { + ApiKey APIKey `json:"api_key,omitempty"` + Account Account `json:"account,omitempty"` + User string `json:"user,omitempty"` +} + +type Account struct { + // unique API key resource identifier + ID string `json:"id,omitempty"` + Name string `json:"name,omitempty"` + CreatedAt string `json:"created_at,omitempty"` + Suspended bool `json:"suspended,omitempty"` + EnforceSSO bool `json:"enforce_sso,omitempty"` + MinApiVersion int64 `json:"min_api_version,omitempty"` + MinAgentVersion string `json:"min_agent_version,omitempty"` + UserMfaRequired bool `json:"user_mfa_required,omitempty"` + TrafficFullCapture bool `json:"traffic_full_capture,omitempty"` +} + +type SecretCreate struct { + // Name of secret + Name string `json:"name,omitempty"` + // Value of secret + Value string `json:"value,omitempty"` + // Arbitrary user-defined metadata for this Secret + Metadata string `json:"metadata,omitempty"` + // description of Secret + Description string `json:"description,omitempty"` + // unique identifier of the referenced vault + VaultID string `json:"vault_id,omitempty"` +} + +type SecretUpdate struct { + // identifier for Secret + ID string `json:"id,omitempty"` + // Name of secret + Name *string `json:"name,omitempty"` + // Value of secret + Value *string `json:"value,omitempty"` + // Arbitrary user-defined metadata for this Secret + Metadata *string `json:"metadata,omitempty"` + // description of Secret + Description *string `json:"description,omitempty"` +} + +type Secret struct { + // identifier for Secret + ID string `json:"id,omitempty"` + // URI of this Secret API resource + URI string `json:"uri,omitempty"` + // Timestamp when the Secret was created (RFC 3339 format) + CreatedAt string `json:"created_at,omitempty"` + // Timestamp when the Secret was last updated (RFC 3339 format) + UpdatedAt string `json:"updated_at,omitempty"` + // Name of secret + Name string `json:"name,omitempty"` + // description of Secret + Description string `json:"description,omitempty"` + // Arbitrary user-defined metadata for this Secret + Metadata string `json:"metadata,omitempty"` + // Reference to who created this Secret + CreatedBy Ref `json:"created_by,omitempty"` + // Reference to who created this Secret + LastUpdatedBy Ref `json:"last_updated_by,omitempty"` + // Reference to the vault the secret is stored in + Vault Ref `json:"vault,omitempty"` +} + +type SecretList struct { + // The list of Secrets for this account + Secrets []Secret `json:"secrets,omitempty"` + URI string `json:"uri,omitempty"` + // URI of the next page of results, or null if there is no next page + NextPageURI *string `json:"next_page_uri,omitempty"` +} + type SSHCertificateAuthorityCreate struct { // human-readable description of this SSH Certificate Authority. optional, max 255 // bytes. @@ -3505,3 +3595,52 @@ type TunnelList struct { // URI of the next page, or null if there is no next page NextPageURI *string `json:"next_page_uri,omitempty"` } + +type VaultCreate struct { + // Name of vault + Name string `json:"name,omitempty"` + // Arbitrary user-defined metadata for this Vault + Metadata string `json:"metadata,omitempty"` + // description of Vault + Description string `json:"description,omitempty"` +} + +type VaultUpdate struct { + // identifier for Vault + ID string `json:"id,omitempty"` + // Name of vault + Name *string `json:"name,omitempty"` + // Arbitrary user-defined metadata for this Vault + Metadata *string `json:"metadata,omitempty"` + // description of Vault + Description *string `json:"description,omitempty"` +} + +type Vault struct { + // identifier for Vault + ID string `json:"id,omitempty"` + // URI of this Vault API resource + URI string `json:"uri,omitempty"` + // Timestamp when the Vault was created (RFC 3339 format) + CreatedAt string `json:"created_at,omitempty"` + // Timestamp when the Vault was last updated (RFC 3339 format) + UpdatedAt string `json:"updated_at,omitempty"` + // Name of vault + Name string `json:"name,omitempty"` + // description of Vault + Description string `json:"description,omitempty"` + // Arbitrary user-defined metadata for this Vault + Metadata string `json:"metadata,omitempty"` + // Reference to who created this Vault + CreatedBy string `json:"created_by,omitempty"` + // Reference to who created this Vault + LastUpdatedBy string `json:"last_updated_by,omitempty"` +} + +type VaultList struct { + // The list of Vaults for this account + Vaults []Vault `json:"vaults,omitempty"` + URI string `json:"uri,omitempty"` + // URI of the next page of results, or null if there is no next page + NextPageURI *string `json:"next_page_uri,omitempty"` +}