From b934835b444b555c298b9cc9086b11ebfbe2b93b Mon Sep 17 00:00:00 2001 From: kend <860620266@qq.com> Date: Fri, 23 Aug 2024 09:40:39 +0800 Subject: [PATCH 01/24] add gatewayapi crd models --- .../gatewayclass/V1GatewayClass.java | 52 ++++++ .../gatewayclass/V1GatewayClassList.java | 50 +++++ .../gatewayclass/V1GatewayClassSpec.java | 42 +++++ .../V1GatewayClassSpecParametersRef.java | 45 +++++ .../gatewayclass/V1GatewayClassStatus.java | 43 +++++ .../V1GatewayClassStatusConditions.java | 108 +++++++++++ .../crd/gatewayapi/gateways/V1Gateway.java | 97 ++++++++++ .../gatewayapi/gateways/V1GatewayList.java | 98 ++++++++++ .../gatewayapi/gateways/V1GatewaySpec.java | 94 ++++++++++ .../gateways/V1GatewaySpecAddresses.java | 79 ++++++++ .../gateways/V1GatewaySpecAllowedRoutes.java | 92 +++++++++ .../V1GatewaySpecAllowedRoutesKinds.java | 78 ++++++++ .../V1GatewaySpecAllowedRoutesNamespaces.java | 129 +++++++++++++ ...aySpecAllowedRoutesNamespacesSelector.java | 100 ++++++++++ ...tesNamespacesSelectorMatchExpressions.java | 95 ++++++++++ .../gateways/V1GatewaySpecListeners.java | 103 +++++++++++ .../gatewayapi/gateways/V1GatewaySpecTls.java | 157 ++++++++++++++++ .../V1GatewaySpecTlsCertificateRefs.java | 90 +++++++++ .../gatewayapi/gateways/V1GatewayStatus.java | 109 +++++++++++ .../gateways/V1GatewayStatusAddresses.java | 78 ++++++++ .../gateways/V1GatewayStatusConditions.java | 159 ++++++++++++++++ .../gateways/V1GatewayStatusListeners.java | 101 ++++++++++ .../crd/gatewayapi/httproute/V1HTTPRoute.java | 97 ++++++++++ .../gatewayapi/httproute/V1HTTPRouteList.java | 98 ++++++++++ .../gatewayapi/httproute/V1HTTPRouteSpec.java | 102 ++++++++++ .../httproute/V1HTTPRouteSpecBackendRefs.java | 118 ++++++++++++ .../V1HTTPRouteSpecExtensionRef.java | 84 +++++++++ .../httproute/V1HTTPRouteSpecFilters.java | 170 +++++++++++++++++ .../httproute/V1HTTPRouteSpecHeaders.java | 136 ++++++++++++++ .../httproute/V1HTTPRouteSpecMatches.java | 175 ++++++++++++++++++ .../httproute/V1HTTPRouteSpecParentRefs.java | 102 ++++++++++ .../httproute/V1HTTPRouteSpecPath.java | 133 +++++++++++++ .../httproute/V1HTTPRouteSpecQueryParams.java | 136 ++++++++++++++ .../V1HTTPRouteSpecRequestHeaderModifier.java | 116 ++++++++++++ ...HTTPRouteSpecRequestHeaderModifierAdd.java | 78 ++++++++ .../V1HTTPRouteSpecRequestMirror.java | 72 +++++++ ...1HTTPRouteSpecRequestMirrorBackendRef.java | 96 ++++++++++ .../V1HTTPRouteSpecRequestRedirect.java | 149 +++++++++++++++ .../V1HTTPRouteSpecRequestRedirectPath.java | 136 ++++++++++++++ ...V1HTTPRouteSpecResponseHeaderModifier.java | 110 +++++++++++ .../httproute/V1HTTPRouteSpecRules.java | 111 +++++++++++ .../httproute/V1HTTPRouteSpecUrlRewrite.java | 79 ++++++++ .../V1HTTPRouteSpecUrlRewritePath.java | 137 ++++++++++++++ .../httproute/V1HTTPRouteStatus.java | 79 ++++++++ .../V1HTTPRouteStatusConditions.java | 157 ++++++++++++++++ .../httproute/V1HTTPRouteStatusParentRef.java | 102 ++++++++++ .../httproute/V1HTTPRouteStatusParents.java | 95 ++++++++++ .../referencegrant/V1beta1ReferenceGrant.java | 92 +++++++++ .../V1beta1ReferenceGrantList.java | 98 ++++++++++ .../V1beta1ReferenceGrantSpec.java | 87 +++++++++ .../V1beta1ReferenceGrantSpecFrom.java | 84 +++++++++ .../V1beta1ReferenceGrantSpecTo.java | 84 +++++++++ 52 files changed, 5312 insertions(+) create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClass.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassList.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassSpec.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassSpecParametersRef.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassStatus.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassStatusConditions.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1Gateway.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayList.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpec.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAddresses.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutes.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesKinds.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespaces.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespacesSelector.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecListeners.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecTls.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecTlsCertificateRefs.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatus.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusAddresses.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusConditions.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusListeners.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRoute.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteList.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpec.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecBackendRefs.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecExtensionRef.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecFilters.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecHeaders.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecMatches.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecParentRefs.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecPath.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecQueryParams.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifier.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifierAdd.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirror.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirrorBackendRef.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirect.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirectPath.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecResponseHeaderModifier.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRules.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewrite.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewritePath.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatus.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusConditions.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParentRef.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParents.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrant.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantList.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpec.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpecFrom.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpecTo.java diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClass.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClass.java new file mode 100644 index 00000000..47986f0c --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClass.java @@ -0,0 +1,52 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gatewayclass; + +import com.google.gson.annotations.SerializedName; +import io.kubernetes.client.openapi.models.V1ObjectMeta; +import lombok.Data; +import java.util.Objects; + + +@Data +public class V1GatewayClass implements io.kubernetes.client.common.KubernetesObject { + public static final String API_GROUP = "gateway.networking.k8s.io"; + public static final String VERSION = "v1"; + public static final String KIND = "GatewayClass"; + public static final String PLURAL = "gatewayclasses"; + public static final String DEFAULT_NAME = "higress-gateway"; + + + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; + @SerializedName(SERIALIZED_NAME_API_VERSION) + private String apiVersion = API_GROUP + "/" + VERSION; + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind = KIND; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + private V1ObjectMeta metadata = null; + + public static final String SERIALIZED_NAME_SPEC = "spec"; + @SerializedName(SERIALIZED_NAME_SPEC) + private V1GatewayClassSpec spec; + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + private V1GatewayClassStatus status; + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassList.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassList.java new file mode 100644 index 00000000..3f3116ac --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassList.java @@ -0,0 +1,50 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gatewayclass; + +import com.google.gson.annotations.SerializedName; +import io.kubernetes.client.openapi.models.V1ListMeta; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * GatewayClassList is a list of GatewayClass + */ +@Data +public class V1GatewayClassList implements io.kubernetes.client.common.KubernetesListObject { + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; + @SerializedName(SERIALIZED_NAME_API_VERSION) + private String apiVersion; + + public static final String SERIALIZED_NAME_ITEMS = "items"; + @SerializedName(SERIALIZED_NAME_ITEMS) + private List items = new ArrayList<>(); + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + private V1ListMeta metadata = null; + + + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassSpec.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassSpec.java new file mode 100644 index 00000000..a809eb02 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassSpec.java @@ -0,0 +1,42 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gatewayclass; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Objects; + +/** + * Spec defines the desired state of GatewayClass. + */ +@Data +public class V1GatewayClassSpec { + public static final String CONTROLLER_NAME = "higress.io/gateway-controller"; + + public static final String SERIALIZED_NAME_CONTROLLER_NAME = "controllerName"; + @SerializedName(SERIALIZED_NAME_CONTROLLER_NAME) + private String controllerName = CONTROLLER_NAME; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + private String description; + + public static final String SERIALIZED_NAME_PARAMETERS_REF = "parametersRef"; + @SerializedName(SERIALIZED_NAME_PARAMETERS_REF) + private V1GatewayClassSpecParametersRef parametersRef; + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassSpecParametersRef.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassSpecParametersRef.java new file mode 100644 index 00000000..75de4943 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassSpecParametersRef.java @@ -0,0 +1,45 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gatewayclass; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Objects; + +/** + * ParametersRef is a reference to a resource that contains the configuration parameters corresponding to the GatewayClass. This is optional if the controller does not require any additional configuration. ParametersRef can reference a standard Kubernetes resource, i.e. ConfigMap, or an implementation-specific custom resource. The resource can be cluster-scoped or namespace-scoped. If the referent cannot be found, refers to an unsupported kind, or when the data within that resource is malformed, the GatewayClass SHOULD be rejected with the \"Accepted\" status condition set to \"False\" and an \"InvalidParameters\" reason. A Gateway for this GatewayClass may provide its own `parametersRef`. When both are specified, the merging behavior is implementation specific. It is generally recommended that GatewayClass provides defaults that can be overridden by a Gateway. Support: Implementation-specific + */ +@Data +public class V1GatewayClassSpecParametersRef { + static final String SERIALIZED_NAME_GROUP = "group"; + @SerializedName(SERIALIZED_NAME_GROUP) + private String group; + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_NAMESPACE = "namespace"; + @SerializedName(SERIALIZED_NAME_NAMESPACE) + private String namespace; + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassStatus.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassStatus.java new file mode 100644 index 00000000..29faa324 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassStatus.java @@ -0,0 +1,43 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gatewayclass; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * Status defines the current state of GatewayClass. Implementations MUST populate status on all GatewayClass resources which specify their controller name. + */ +@Data +public class V1GatewayClassStatus { + + public static final String SERIALIZED_NAME_CONDITIONS = "conditions"; + @SerializedName(SERIALIZED_NAME_CONDITIONS) + private List conditions = null; + + public V1GatewayClassStatus addConditionsItem(V1GatewayClassStatusConditions conditionsItem) { + if (this.conditions == null) { + this.conditions = new ArrayList<>(); + } + this.conditions.add(conditionsItem); + return this; + } +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassStatusConditions.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassStatusConditions.java new file mode 100644 index 00000000..16ef10c2 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassStatusConditions.java @@ -0,0 +1,108 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gatewayclass; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Objects; + +/** + * Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` // other fields } + */ +@Data +public class V1GatewayClassStatusConditions { + + public static final String SERIALIZED_NAME_LAST_TRANSITION_TIME = "lastTransitionTime"; + @SerializedName(SERIALIZED_NAME_LAST_TRANSITION_TIME) + private OffsetDateTime lastTransitionTime; + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + @SerializedName(SERIALIZED_NAME_MESSAGE) + private String message; + + public static final String SERIALIZED_NAME_OBSERVED_GENERATION = "observedGeneration"; + @SerializedName(SERIALIZED_NAME_OBSERVED_GENERATION) + private Long observedGeneration; + + public static final String SERIALIZED_NAME_REASON = "reason"; + @SerializedName(SERIALIZED_NAME_REASON) + private String reason; + + /** + * status of the condition, one of True, False, Unknown. + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + TRUE("True"), + + FALSE("False"), + + UNKNOWN("Unknown"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + private StatusEnum status; + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private String type; +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1Gateway.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1Gateway.java new file mode 100644 index 00000000..678c9ca5 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1Gateway.java @@ -0,0 +1,97 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; + +import com.google.gson.annotations.SerializedName; +import io.kubernetes.client.openapi.models.V1ObjectMeta; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Objects; + +/** + * Gateway represents an instance of a service-traffic handling infrastructure by binding Listeners to a set of IP addresses. + */ +@Data +public class V1Gateway implements io.kubernetes.client.common.KubernetesObject { + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; + @SerializedName(SERIALIZED_NAME_API_VERSION) + private String apiVersion; + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + private V1ObjectMeta metadata = null; + + public static final String SERIALIZED_NAME_SPEC = "spec"; + @SerializedName(SERIALIZED_NAME_SPEC) + private V1GatewaySpec spec; + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + private V1GatewayStatus status; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1Gateway v1Gateway = (V1Gateway) o; + return Objects.equals(this.apiVersion, v1Gateway.apiVersion) && + Objects.equals(this.kind, v1Gateway.kind) && + Objects.equals(this.metadata, v1Gateway.metadata) && + Objects.equals(this.spec, v1Gateway.spec) && + Objects.equals(this.status, v1Gateway.status); + } + + @Override + public int hashCode() { + return Objects.hash(apiVersion, kind, metadata, spec, status); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1beta1Gateway {\n"); + sb.append(" apiVersion: ").append(toIndentedString(apiVersion)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" spec: ").append(toIndentedString(spec)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayList.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayList.java new file mode 100644 index 00000000..c2047c0c --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayList.java @@ -0,0 +1,98 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; + +import com.google.gson.annotations.SerializedName; +import io.kubernetes.client.openapi.models.V1ListMeta; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * GatewayList is a list of Gateway + */ +@Data +public class V1GatewayList implements io.kubernetes.client.common.KubernetesListObject { + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; + @SerializedName(SERIALIZED_NAME_API_VERSION) + private String apiVersion; + + public static final String SERIALIZED_NAME_ITEMS = "items"; + @SerializedName(SERIALIZED_NAME_ITEMS) + private List items = new ArrayList<>(); + + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + private V1ListMeta metadata = null; + + public V1GatewayList addItemsItem(V1Gateway itemsItem) { + this.items.add(itemsItem); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewayList v1GatewayList = (V1GatewayList) o; + return Objects.equals(this.apiVersion, v1GatewayList.apiVersion) && + Objects.equals(this.items, v1GatewayList.items) && + Objects.equals(this.kind, v1GatewayList.kind) && + Objects.equals(this.metadata, v1GatewayList.metadata); + } + + @Override + public int hashCode() { + return Objects.hash(apiVersion, items, kind, metadata); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1beta1GatewayList {\n"); + sb.append(" apiVersion: ").append(toIndentedString(apiVersion)).append("\n"); + sb.append(" items: ").append(toIndentedString(items)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpec.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpec.java new file mode 100644 index 00000000..e326a609 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpec.java @@ -0,0 +1,94 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * Spec defines the desired state of Gateway. + */ +@Data +public class V1GatewaySpec { + public static final String SERIALIZED_NAME_ADDRESSES = "addresses"; + @SerializedName(SERIALIZED_NAME_ADDRESSES) + private List addresses = null; + + public static final String SERIALIZED_NAME_GATEWAY_CLASS_NAME = "gatewayClassName"; + @SerializedName(SERIALIZED_NAME_GATEWAY_CLASS_NAME) + private String gatewayClassName; + + public static final String SERIALIZED_NAME_LISTENERS = "listeners"; + @SerializedName(SERIALIZED_NAME_LISTENERS) + private List listeners = new ArrayList<>(); + + public V1GatewaySpec addAddressesItem(V1GatewaySpecAddresses addressesItem) { + if (this.addresses == null) { + this.addresses = new ArrayList<>(); + } + this.addresses.add(addressesItem); + return this; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewaySpec v1GatewaySpec = (V1GatewaySpec) o; + return Objects.equals(this.addresses, v1GatewaySpec.addresses) && + Objects.equals(this.gatewayClassName, v1GatewaySpec.gatewayClassName) && + Objects.equals(this.listeners, v1GatewaySpec.listeners); + } + + @Override + public int hashCode() { + return Objects.hash(addresses, gatewayClassName, listeners); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1beta1GatewaySpec {\n"); + sb.append(" addresses: ").append(toIndentedString(addresses)).append("\n"); + sb.append(" gatewayClassName: ").append(toIndentedString(gatewayClassName)).append("\n"); + sb.append(" listeners: ").append(toIndentedString(listeners)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAddresses.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAddresses.java new file mode 100644 index 00000000..59bfb0fc --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAddresses.java @@ -0,0 +1,79 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Objects; + +/** + * GatewayAddress describes an address that can be bound to a Gateway. + */ +@Data +public class V1GatewaySpecAddresses { + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private String type; + + + public static final String SERIALIZED_NAME_VALUE = "value"; + @SerializedName(SERIALIZED_NAME_VALUE) + private String value; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewaySpecAddresses v1GatewaySpecAddresses = (V1GatewaySpecAddresses) o; + return Objects.equals(this.type, v1GatewaySpecAddresses.type) && + Objects.equals(this.value, v1GatewaySpecAddresses.value); + } + + @Override + public int hashCode() { + return Objects.hash(type, value); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1beta1GatewaySpecAddresses {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutes.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutes.java new file mode 100644 index 00000000..8b5f9654 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutes.java @@ -0,0 +1,92 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * AllowedRoutes defines the types of routes that MAY be attached to a Listener and the trusted namespaces where those Route resources MAY be present. Although a client request may match multiple route rules, only one rule may ultimately receive the request. Matching precedence MUST be determined in order of the following criteria: * The most specific match as defined by the Route type. * The oldest Route based on creation timestamp. For example, a Route with a creation timestamp of \"2020-09-08 01:02:03\" is given precedence over a Route with a creation timestamp of \"2020-09-08 01:02:04\". * If everything else is equivalent, the Route appearing first in alphabetical order (namespace/name) should be given precedence. For example, foo/bar is given precedence over foo/baz. All valid rules within a Route attached to this Listener should be implemented. Invalid Route rules can be ignored (sometimes that will mean the full Route). If a Route rule transitions from valid to invalid, support for that Route rule should be dropped to ensure consistency. For example, even if a filter specified by a Route rule is invalid, the rest of the rules within that Route should still be supported. Support: Core + */ +@Data +public class V1GatewaySpecAllowedRoutes { + public static final String SERIALIZED_NAME_KINDS = "kinds"; + @SerializedName(SERIALIZED_NAME_KINDS) + private List kinds = null; + + + public static final String SERIALIZED_NAME_NAMESPACES = "namespaces"; + @SerializedName(SERIALIZED_NAME_NAMESPACES) + private V1GatewaySpecAllowedRoutesNamespaces namespaces; + + + public V1GatewaySpecAllowedRoutes addKindsItem(V1GatewaySpecAllowedRoutesKinds kindsItem) { + if (this.kinds == null) { + this.kinds = new ArrayList<>(); + } + this.kinds.add(kindsItem); + return this; + } + + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewaySpecAllowedRoutes v1GatewaySpecAllowedRoutes = (V1GatewaySpecAllowedRoutes) o; + return Objects.equals(this.kinds, v1GatewaySpecAllowedRoutes.kinds) && + Objects.equals(this.namespaces, v1GatewaySpecAllowedRoutes.namespaces); + } + + @Override + public int hashCode() { + return Objects.hash(kinds, namespaces); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1beta1GatewaySpecAllowedRoutes {\n"); + sb.append(" kinds: ").append(toIndentedString(kinds)).append("\n"); + sb.append(" namespaces: ").append(toIndentedString(namespaces)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesKinds.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesKinds.java new file mode 100644 index 00000000..6fa9cbb3 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesKinds.java @@ -0,0 +1,78 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Objects; + +/** + * RouteGroupKind indicates the group and kind of a Route resource. + */ +@Data +public class V1GatewaySpecAllowedRoutesKinds { + public static final String SERIALIZED_NAME_GROUP = "group"; + @SerializedName(SERIALIZED_NAME_GROUP) + private String group; + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewaySpecAllowedRoutesKinds v1GatewaySpecAllowedRoutesKinds = (V1GatewaySpecAllowedRoutesKinds) o; + return Objects.equals(this.group, v1GatewaySpecAllowedRoutesKinds.group) && + Objects.equals(this.kind, v1GatewaySpecAllowedRoutesKinds.kind); + } + + @Override + public int hashCode() { + return Objects.hash(group, kind); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1beta1GatewaySpecAllowedRoutesKinds {\n"); + sb.append(" group: ").append(toIndentedString(group)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespaces.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespaces.java new file mode 100644 index 00000000..5212524c --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespaces.java @@ -0,0 +1,129 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.IOException; +import java.util.Objects; + +/** + * Namespaces indicates namespaces from which Routes may be attached to this Listener. This is restricted to the namespace of this Gateway by default. Support: Core + */ +@Data +public class V1GatewaySpecAllowedRoutesNamespaces { + /** + * From indicates where Routes will be selected for this Gateway. Possible values are: * All: Routes in all namespaces may be used by this Gateway. * Selector: Routes in namespaces selected by the selector may be used by this Gateway. * Same: Only Routes in the same namespace may be used by this Gateway. Support: Core + */ + @JsonAdapter(FromEnum.Adapter.class) + public enum FromEnum { + ALL("All"), + SELECTOR("Selector"), + SAME("Same"); + private String value; + + FromEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static FromEnum fromValue(String value) { + for (FromEnum b : FromEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final FromEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public FromEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return FromEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_FROM = "from"; + @SerializedName(SERIALIZED_NAME_FROM) + private FromEnum from; + + + public static final String SERIALIZED_NAME_SELECTOR = "selector"; + @SerializedName(SERIALIZED_NAME_SELECTOR) + private V1GatewaySpecAllowedRoutesNamespacesSelector selector; + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewaySpecAllowedRoutesNamespaces v1GatewaySpecAllowedRoutesNamespaces = (V1GatewaySpecAllowedRoutesNamespaces) o; + return Objects.equals(this.from, v1GatewaySpecAllowedRoutesNamespaces.from) && + Objects.equals(this.selector, v1GatewaySpecAllowedRoutesNamespaces.selector); + } + + @Override + public int hashCode() { + return Objects.hash(from, selector); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1beta1GatewaySpecAllowedRoutesNamespaces {\n"); + sb.append(" from: ").append(toIndentedString(from)).append("\n"); + sb.append(" selector: ").append(toIndentedString(selector)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespacesSelector.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespacesSelector.java new file mode 100644 index 00000000..5f75b738 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespacesSelector.java @@ -0,0 +1,100 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.*; + +/** + * Selector must be specified when From is set to \"Selector\". In that case, only Routes in Namespaces matching this Selector will be selected by this Gateway. This field is ignored for other values of \"From\". Support: Core + */ +@Data +public class V1GatewaySpecAllowedRoutesNamespacesSelector { + public static final String SERIALIZED_NAME_MATCH_EXPRESSIONS = "matchExpressions"; + @SerializedName(SERIALIZED_NAME_MATCH_EXPRESSIONS) + private List matchExpressions = null; + + public static final String SERIALIZED_NAME_MATCH_LABELS = "matchLabels"; + @SerializedName(SERIALIZED_NAME_MATCH_LABELS) + private Map matchLabels = null; + + + public V1GatewaySpecAllowedRoutesNamespacesSelector addMatchExpressionsItem(V1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions matchExpressionsItem) { + if (this.matchExpressions == null) { + this.matchExpressions = new ArrayList<>(); + } + this.matchExpressions.add(matchExpressionsItem); + return this; + } + + /** + * matchExpressions is a list of label selector requirements. The requirements are ANDed. + * @return matchExpressions + **/ + + public V1GatewaySpecAllowedRoutesNamespacesSelector putMatchLabelsItem(String key, String matchLabelsItem) { + if (this.matchLabels == null) { + this.matchLabels = new HashMap<>(); + } + this.matchLabels.put(key, matchLabelsItem); + return this; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewaySpecAllowedRoutesNamespacesSelector v1GatewaySpecAllowedRoutesNamespacesSelector = (V1GatewaySpecAllowedRoutesNamespacesSelector) o; + return Objects.equals(this.matchExpressions, v1GatewaySpecAllowedRoutesNamespacesSelector.matchExpressions) && + Objects.equals(this.matchLabels, v1GatewaySpecAllowedRoutesNamespacesSelector.matchLabels); + } + + @Override + public int hashCode() { + return Objects.hash(matchExpressions, matchLabels); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1beta1GatewaySpecAllowedRoutesNamespacesSelector {\n"); + sb.append(" matchExpressions: ").append(toIndentedString(matchExpressions)).append("\n"); + sb.append(" matchLabels: ").append(toIndentedString(matchLabels)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions.java new file mode 100644 index 00000000..e8d0ffcf --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions.java @@ -0,0 +1,95 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values. + */ +@Data +public class V1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions { + public static final String SERIALIZED_NAME_KEY = "key"; + @SerializedName(SERIALIZED_NAME_KEY) + private String key; + + public static final String SERIALIZED_NAME_OPERATOR = "operator"; + @SerializedName(SERIALIZED_NAME_OPERATOR) + private String operator; + + public static final String SERIALIZED_NAME_VALUES = "values"; + @SerializedName(SERIALIZED_NAME_VALUES) + private List values = null; + + + public V1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions addValuesItem(String valuesItem) { + if (this.values == null) { + this.values = new ArrayList<>(); + } + this.values.add(valuesItem); + return this; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions v1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions = (V1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions) o; + return Objects.equals(this.key, v1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions.key) && + Objects.equals(this.operator, v1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions.operator) && + Objects.equals(this.values, v1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions.values); + } + + @Override + public int hashCode() { + return Objects.hash(key, operator, values); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1beta1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions {\n"); + sb.append(" key: ").append(toIndentedString(key)).append("\n"); + sb.append(" operator: ").append(toIndentedString(operator)).append("\n"); + sb.append(" values: ").append(toIndentedString(values)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecListeners.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecListeners.java new file mode 100644 index 00000000..452926cd --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecListeners.java @@ -0,0 +1,103 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Objects; + +/** + * Listener embodies the concept of a logical endpoint where a Gateway accepts network connections. + */ +@Data +public class V1GatewaySpecListeners { + public static final String SERIALIZED_NAME_ALLOWED_ROUTES = "allowedRoutes"; + @SerializedName(SERIALIZED_NAME_ALLOWED_ROUTES) + private V1GatewaySpecAllowedRoutes allowedRoutes; + + + public static final String SERIALIZED_NAME_HOSTNAME = "hostname"; + @SerializedName(SERIALIZED_NAME_HOSTNAME) + private String hostname; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_PORT = "port"; + @SerializedName(SERIALIZED_NAME_PORT) + private Integer port; + + public static final String SERIALIZED_NAME_PROTOCOL = "protocol"; + @SerializedName(SERIALIZED_NAME_PROTOCOL) + private String protocol; + + public static final String SERIALIZED_NAME_TLS = "tls"; + @SerializedName(SERIALIZED_NAME_TLS) + private V1GatewaySpecTls tls; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewaySpecListeners v1GatewaySpecListeners = (V1GatewaySpecListeners) o; + return Objects.equals(this.allowedRoutes, v1GatewaySpecListeners.allowedRoutes) && + Objects.equals(this.hostname, v1GatewaySpecListeners.hostname) && + Objects.equals(this.name, v1GatewaySpecListeners.name) && + Objects.equals(this.port, v1GatewaySpecListeners.port) && + Objects.equals(this.protocol, v1GatewaySpecListeners.protocol) && + Objects.equals(this.tls, v1GatewaySpecListeners.tls); + } + + @Override + public int hashCode() { + return Objects.hash(allowedRoutes, hostname, name, port, protocol, tls); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1beta1GatewaySpecListeners {\n"); + sb.append(" allowedRoutes: ").append(toIndentedString(allowedRoutes)).append("\n"); + sb.append(" hostname: ").append(toIndentedString(hostname)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" port: ").append(toIndentedString(port)).append("\n"); + sb.append(" protocol: ").append(toIndentedString(protocol)).append("\n"); + sb.append(" tls: ").append(toIndentedString(tls)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecTls.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecTls.java new file mode 100644 index 00000000..b3c4d9a9 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecTls.java @@ -0,0 +1,157 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.IOException; +import java.util.*; + +/** + * TLS is the TLS configuration for the Listener. This field is required if the Protocol field is \"HTTPS\" or \"TLS\". It is invalid to set this field if the Protocol field is \"HTTP\", \"TCP\", or \"UDP\". The association of SNIs to Certificate defined in GatewayTLSConfig is defined based on the Hostname field for this listener. The GatewayClass MUST use the longest matching SNI out of all available certificates for any TLS handshake. Support: Core + */ +@Data +public class V1GatewaySpecTls { + public static final String SERIALIZED_NAME_CERTIFICATE_REFS = "certificateRefs"; + @SerializedName(SERIALIZED_NAME_CERTIFICATE_REFS) + private List certificateRefs = null; + + /** + * Mode defines the TLS behavior for the TLS session initiated by the client. There are two possible modes: - Terminate: The TLS session between the downstream client and the Gateway is terminated at the Gateway. This mode requires certificates to be specified in some way, such as populating the certificateRefs field. - Passthrough: The TLS session is NOT terminated by the Gateway. This implies that the Gateway can't decipher the TLS stream except for the ClientHello message of the TLS protocol. The certificateRefs field is ignored in this mode. Support: Core + */ + @JsonAdapter(ModeEnum.Adapter.class) + public enum ModeEnum { + TERMINATE("Terminate"), + PASSTHROUGH("Passthrough"); + + private String value; + + ModeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ModeEnum fromValue(String value) { + for (ModeEnum b : ModeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final ModeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ModeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return ModeEnum.fromValue(value); + } + } + } + + + public static final String SERIALIZED_NAME_MODE = "mode"; + @SerializedName(SERIALIZED_NAME_MODE) + private ModeEnum mode; + + public static final String SERIALIZED_NAME_OPTIONS = "options"; + @SerializedName(SERIALIZED_NAME_OPTIONS) + private Map options = null; + + + public V1GatewaySpecTls addCertificateRefsItem(V1GatewaySpecTlsCertificateRefs certificateRefsItem) { + if (this.certificateRefs == null) { + this.certificateRefs = new ArrayList<>(); + } + this.certificateRefs.add(certificateRefsItem); + return this; + } + + /** + * CertificateRefs contains a series of references to Kubernetes objects that contains TLS certificates and private keys. These certificates are used to establish a TLS handshake for requests that match the hostname of the associated listener. A single CertificateRef to a Kubernetes Secret has \"Core\" support. Implementations MAY choose to support attaching multiple certificates to a Listener, but this behavior is implementation-specific. References to a resource in different namespace are invalid UNLESS there is a ReferenceGrant in the target namespace that allows the certificate to be attached. If a ReferenceGrant does not allow this reference, the \"ResolvedRefs\" condition MUST be set to False for this listener with the \"RefNotPermitted\" reason. This field is required to have at least one element when the mode is set to \"Terminate\" (default) and is optional otherwise. CertificateRefs can reference to standard Kubernetes resources, i.e. Secret, or implementation-specific custom resources. Support: Core - A single reference to a Kubernetes Secret of type kubernetes.io/tls Support: Implementation-specific (More than one reference or other resource types) + * @return certificateRefs + **/ + + public V1GatewaySpecTls putOptionsItem(String key, String optionsItem) { + if (this.options == null) { + this.options = new HashMap<>(); + } + this.options.put(key, optionsItem); + return this; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewaySpecTls v1GatewaySpecTls = (V1GatewaySpecTls) o; + return Objects.equals(this.certificateRefs, v1GatewaySpecTls.certificateRefs) && + Objects.equals(this.mode, v1GatewaySpecTls.mode) && + Objects.equals(this.options, v1GatewaySpecTls.options); + } + + @Override + public int hashCode() { + return Objects.hash(certificateRefs, mode, options); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1beta1GatewaySpecTls {\n"); + sb.append(" certificateRefs: ").append(toIndentedString(certificateRefs)).append("\n"); + sb.append(" mode: ").append(toIndentedString(mode)).append("\n"); + sb.append(" options: ").append(toIndentedString(options)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecTlsCertificateRefs.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecTlsCertificateRefs.java new file mode 100644 index 00000000..cb1c5e8a --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecTlsCertificateRefs.java @@ -0,0 +1,90 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Objects; + +/** + * SecretObjectReference identifies an API object including its namespace, defaulting to Secret. The API object must be valid in the cluster; the Group and Kind must be registered in the cluster for this reference to be valid. References to objects with invalid Group and Kind are not valid, and must be rejected by the implementation, with appropriate Conditions set on the containing object. + */ +@Data +public class V1GatewaySpecTlsCertificateRefs { + + public static final String SERIALIZED_NAME_GROUP = "group"; + @SerializedName(SERIALIZED_NAME_GROUP) + private String group; + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_NAMESPACE = "namespace"; + @SerializedName(SERIALIZED_NAME_NAMESPACE) + private String namespace; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewaySpecTlsCertificateRefs v1GatewaySpecTlsCertificateRefs = (V1GatewaySpecTlsCertificateRefs) o; + return Objects.equals(this.group, v1GatewaySpecTlsCertificateRefs.group) && + Objects.equals(this.kind, v1GatewaySpecTlsCertificateRefs.kind) && + Objects.equals(this.name, v1GatewaySpecTlsCertificateRefs.name) && + Objects.equals(this.namespace, v1GatewaySpecTlsCertificateRefs.namespace); + } + + @Override + public int hashCode() { + return Objects.hash(group, kind, name, namespace); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1beta1GatewaySpecTlsCertificateRefs {\n"); + sb.append(" group: ").append(toIndentedString(group)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatus.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatus.java new file mode 100644 index 00000000..e1241c73 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatus.java @@ -0,0 +1,109 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * Status defines the current state of Gateway. + */ +@Data +public class V1GatewayStatus { + public static final String SERIALIZED_NAME_ADDRESSES = "addresses"; + @SerializedName(SERIALIZED_NAME_ADDRESSES) + private List addresses = null; + + public static final String SERIALIZED_NAME_CONDITIONS = "conditions"; + @SerializedName(SERIALIZED_NAME_CONDITIONS) + private List conditions = null; + + public static final String SERIALIZED_NAME_LISTENERS = "listeners"; + @SerializedName(SERIALIZED_NAME_LISTENERS) + private List listeners = null; + + public V1GatewayStatus addAddressesItem(V1GatewayStatusAddresses addressesItem) { + if (this.addresses == null) { + this.addresses = new ArrayList<>(); + } + this.addresses.add(addressesItem); + return this; + } + + public V1GatewayStatus addConditionsItem(V1GatewayStatusConditions conditionsItem) { + if (this.conditions == null) { + this.conditions = new ArrayList<>(); + } + this.conditions.add(conditionsItem); + return this; + } + + public V1GatewayStatus addListenersItem(V1GatewayStatusListeners listenersItem) { + if (this.listeners == null) { + this.listeners = new ArrayList<>(); + } + this.listeners.add(listenersItem); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewayStatus v1GatewayStatus = (V1GatewayStatus) o; + return Objects.equals(this.addresses, v1GatewayStatus.addresses) && + Objects.equals(this.conditions, v1GatewayStatus.conditions) && + Objects.equals(this.listeners, v1GatewayStatus.listeners); + } + + @Override + public int hashCode() { + return Objects.hash(addresses, conditions, listeners); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1beta1GatewayStatus {\n"); + sb.append(" addresses: ").append(toIndentedString(addresses)).append("\n"); + sb.append(" conditions: ").append(toIndentedString(conditions)).append("\n"); + sb.append(" listeners: ").append(toIndentedString(listeners)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusAddresses.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusAddresses.java new file mode 100644 index 00000000..bdfbc1a0 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusAddresses.java @@ -0,0 +1,78 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Objects; + +/** + * GatewayStatusAddress describes a network address that is bound to a Gateway. + */ +@Data +public class V1GatewayStatusAddresses { + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private String type; + + public static final String SERIALIZED_NAME_VALUE = "value"; + @SerializedName(SERIALIZED_NAME_VALUE) + private String value; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewayStatusAddresses v1GatewayStatusAddresses = (V1GatewayStatusAddresses) o; + return Objects.equals(this.type, v1GatewayStatusAddresses.type) && + Objects.equals(this.value, v1GatewayStatusAddresses.value); + } + + @Override + public int hashCode() { + return Objects.hash(type, value); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1beta1GatewayStatusAddresses {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusConditions.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusConditions.java new file mode 100644 index 00000000..6d1c6ab2 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusConditions.java @@ -0,0 +1,159 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Objects; + +/** + * Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` // other fields } + */ +@Data +public class V1GatewayStatusConditions { + public static final String SERIALIZED_NAME_LAST_TRANSITION_TIME = "lastTransitionTime"; + + @SerializedName(SERIALIZED_NAME_LAST_TRANSITION_TIME) + private OffsetDateTime lastTransitionTime; + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + @SerializedName(SERIALIZED_NAME_MESSAGE) + private String message; + + public static final String SERIALIZED_NAME_OBSERVED_GENERATION = "observedGeneration"; + @SerializedName(SERIALIZED_NAME_OBSERVED_GENERATION) + private Long observedGeneration; + + public static final String SERIALIZED_NAME_REASON = "reason"; + @SerializedName(SERIALIZED_NAME_REASON) + private String reason; + + /** + * status of the condition, one of True, False, Unknown. + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + TRUE("True"), + + FALSE("False"), + + UNKNOWN("Unknown"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + } + + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + private StatusEnum status; + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private String type; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewayStatusConditions v1GatewayStatusConditions = (V1GatewayStatusConditions) o; + return Objects.equals(this.lastTransitionTime, v1GatewayStatusConditions.lastTransitionTime) && + Objects.equals(this.message, v1GatewayStatusConditions.message) && + Objects.equals(this.observedGeneration, v1GatewayStatusConditions.observedGeneration) && + Objects.equals(this.reason, v1GatewayStatusConditions.reason) && + Objects.equals(this.status, v1GatewayStatusConditions.status) && + Objects.equals(this.type, v1GatewayStatusConditions.type); + } + + @Override + public int hashCode() { + return Objects.hash(lastTransitionTime, message, observedGeneration, reason, status, type); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1beta1GatewayStatusConditions {\n"); + sb.append(" lastTransitionTime: ").append(toIndentedString(lastTransitionTime)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" observedGeneration: ").append(toIndentedString(observedGeneration)).append("\n"); + sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusListeners.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusListeners.java new file mode 100644 index 00000000..ab89cd86 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusListeners.java @@ -0,0 +1,101 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * ListenerStatus is the status associated with a Listener. + */ +@Data +public class V1GatewayStatusListeners { + public static final String SERIALIZED_NAME_ATTACHED_ROUTES = "attachedRoutes"; + @SerializedName(SERIALIZED_NAME_ATTACHED_ROUTES) + private Integer attachedRoutes; + + public static final String SERIALIZED_NAME_CONDITIONS = "conditions"; + @SerializedName(SERIALIZED_NAME_CONDITIONS) + private List conditions = new ArrayList<>(); + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_SUPPORTED_KINDS = "supportedKinds"; + @SerializedName(SERIALIZED_NAME_SUPPORTED_KINDS) + private List supportedKinds = new ArrayList<>(); + + public V1GatewayStatusListeners addConditionsItem(V1GatewayStatusConditions conditionsItem) { + this.conditions.add(conditionsItem); + return this; + } + + public V1GatewayStatusListeners addSupportedKindsItem(V1GatewaySpecAllowedRoutesKinds supportedKindsItem) { + this.supportedKinds.add(supportedKindsItem); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewayStatusListeners v1GatewayStatusListeners = (V1GatewayStatusListeners) o; + return Objects.equals(this.attachedRoutes, v1GatewayStatusListeners.attachedRoutes) && + Objects.equals(this.conditions, v1GatewayStatusListeners.conditions) && + Objects.equals(this.name, v1GatewayStatusListeners.name) && + Objects.equals(this.supportedKinds, v1GatewayStatusListeners.supportedKinds); + } + + @Override + public int hashCode() { + return Objects.hash(attachedRoutes, conditions, name, supportedKinds); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1beta1GatewayStatusListeners {\n"); + sb.append(" attachedRoutes: ").append(toIndentedString(attachedRoutes)).append("\n"); + sb.append(" conditions: ").append(toIndentedString(conditions)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" supportedKinds: ").append(toIndentedString(supportedKinds)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRoute.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRoute.java new file mode 100644 index 00000000..ba5aa7f6 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRoute.java @@ -0,0 +1,97 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.annotations.SerializedName; +import io.kubernetes.client.openapi.models.V1ObjectMeta; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Objects; + +/** + * HTTPRoute provides a way to route HTTP requests. This includes the capability to match requests by hostname, path, header, or query param. Filters can be used to specify additional processing steps. Backends specify where matching requests should be routed. + */ +@Data +public class V1HTTPRoute implements io.kubernetes.client.common.KubernetesObject { + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; + @SerializedName(SERIALIZED_NAME_API_VERSION) + private String apiVersion; + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + private V1ObjectMeta metadata = null; + + public static final String SERIALIZED_NAME_SPEC = "spec"; + @SerializedName(SERIALIZED_NAME_SPEC) + private V1HTTPRouteSpec spec; + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + private V1HTTPRouteStatus status; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRoute v1HTTPRoute = (V1HTTPRoute) o; + return Objects.equals(this.apiVersion, v1HTTPRoute.apiVersion) && + Objects.equals(this.kind, v1HTTPRoute.kind) && + Objects.equals(this.metadata, v1HTTPRoute.metadata) && + Objects.equals(this.spec, v1HTTPRoute.spec) && + Objects.equals(this.status, v1HTTPRoute.status); + } + + @Override + public int hashCode() { + return Objects.hash(apiVersion, kind, metadata, spec, status); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRoute {\n"); + sb.append(" apiVersion: ").append(toIndentedString(apiVersion)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" spec: ").append(toIndentedString(spec)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteList.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteList.java new file mode 100644 index 00000000..40369f32 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteList.java @@ -0,0 +1,98 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.annotations.SerializedName; +import io.kubernetes.client.openapi.models.V1ListMeta; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * HTTPRouteList is a list of HTTPRoute + */ +@Data +public class V1HTTPRouteList implements io.kubernetes.client.common.KubernetesListObject { + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; + @SerializedName(SERIALIZED_NAME_API_VERSION) + private String apiVersion; + + public static final String SERIALIZED_NAME_ITEMS = "items"; + @SerializedName(SERIALIZED_NAME_ITEMS) + private List items = new ArrayList<>(); + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + private V1ListMeta metadata = null; + + public V1HTTPRouteList addItemsItem(V1HTTPRoute itemsItem) { + this.items.add(itemsItem); + return this; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteList v1HTTPRouteList = (V1HTTPRouteList) o; + return Objects.equals(this.apiVersion, v1HTTPRouteList.apiVersion) && + Objects.equals(this.items, v1HTTPRouteList.items) && + Objects.equals(this.kind, v1HTTPRouteList.kind) && + Objects.equals(this.metadata, v1HTTPRouteList.metadata); + } + + @Override + public int hashCode() { + return Objects.hash(apiVersion, items, kind, metadata); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteList {\n"); + sb.append(" apiVersion: ").append(toIndentedString(apiVersion)).append("\n"); + sb.append(" items: ").append(toIndentedString(items)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpec.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpec.java new file mode 100644 index 00000000..cd444fc0 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpec.java @@ -0,0 +1,102 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * Spec defines the desired state of HTTPRoute. + */ +@Data +public class V1HTTPRouteSpec { + public static final String SERIALIZED_NAME_HOSTNAMES = "hostnames"; + @SerializedName(SERIALIZED_NAME_HOSTNAMES) + private List hostnames = null; + + public static final String SERIALIZED_NAME_PARENT_REFS = "parentRefs"; + @SerializedName(SERIALIZED_NAME_PARENT_REFS) + private List parentRefs = null; + + public static final String SERIALIZED_NAME_RULES = "rules"; + @SerializedName(SERIALIZED_NAME_RULES) + private List rules = null; + + public V1HTTPRouteSpec addHostnamesItem(String hostnamesItem) { + if (this.hostnames == null) { + this.hostnames = new ArrayList<>(); + } + this.hostnames.add(hostnamesItem); + return this; + } + + public V1HTTPRouteSpec addParentRefsItem(V1HTTPRouteSpecParentRefs parentRefsItem) { + if (this.parentRefs == null) { + this.parentRefs = new ArrayList<>(); + } + this.parentRefs.add(parentRefsItem); + return this; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpec v1HTTPRouteSpec = (V1HTTPRouteSpec) o; + return Objects.equals(this.hostnames, v1HTTPRouteSpec.hostnames) && + Objects.equals(this.parentRefs, v1HTTPRouteSpec.parentRefs) && + Objects.equals(this.rules, v1HTTPRouteSpec.rules); + } + + @Override + public int hashCode() { + return Objects.hash(hostnames, parentRefs, rules); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteSpec {\n"); + sb.append(" hostnames: ").append(toIndentedString(hostnames)).append("\n"); + sb.append(" parentRefs: ").append(toIndentedString(parentRefs)).append("\n"); + sb.append(" rules: ").append(toIndentedString(rules)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecBackendRefs.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecBackendRefs.java new file mode 100644 index 00000000..42b27405 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecBackendRefs.java @@ -0,0 +1,118 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * HTTPBackendRef defines how a HTTPRoute forwards a HTTP request. Note that when a namespace different than the local namespace is specified, a ReferenceGrant object is required in the referent namespace to allow that namespace's owner to accept the reference. See the ReferenceGrant documentation for details. <gateway:experimental:description> When the BackendRef points to a Kubernetes Service, implementations SHOULD honor the appProtocol field if it is set for the target Service Port. Implementations supporting appProtocol SHOULD recognize the Kubernetes Standard Application Protocols defined in KEP-3726. If a Service appProtocol isn't specified, an implementation MAY infer the backend protocol through its own means. Implementations MAY infer the protocol from the Route type referring to the backend Service. If a Route is not able to send traffic to the backend using the specified protocol then the backend is considered invalid. Implementations MUST set the \"ResolvedRefs\" condition to \"False\" with the \"UnsupportedProtocol\" reason. </gateway:experimental:description> + */ +@Data +public class V1HTTPRouteSpecBackendRefs { + public static final String SERIALIZED_NAME_FILTERS = "filters"; + @SerializedName(SERIALIZED_NAME_FILTERS) + private List filters = null; + + public static final String SERIALIZED_NAME_GROUP = "group"; + @SerializedName(SERIALIZED_NAME_GROUP) + private String group; + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_NAMESPACE = "namespace"; + @SerializedName(SERIALIZED_NAME_NAMESPACE) + private String namespace; + + public static final String SERIALIZED_NAME_PORT = "port"; + @SerializedName(SERIALIZED_NAME_PORT) + private Integer port; + + public static final String SERIALIZED_NAME_WEIGHT = "weight"; + @SerializedName(SERIALIZED_NAME_WEIGHT) + private Integer weight; + + public V1HTTPRouteSpecBackendRefs addFiltersItem(V1HTTPRouteSpecFilters filtersItem) { + if (this.filters == null) { + this.filters = new ArrayList<>(); + } + this.filters.add(filtersItem); + return this; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecBackendRefs v1HTTPRouteSpecBackendRefs = (V1HTTPRouteSpecBackendRefs) o; + return Objects.equals(this.filters, v1HTTPRouteSpecBackendRefs.filters) && + Objects.equals(this.group, v1HTTPRouteSpecBackendRefs.group) && + Objects.equals(this.kind, v1HTTPRouteSpecBackendRefs.kind) && + Objects.equals(this.name, v1HTTPRouteSpecBackendRefs.name) && + Objects.equals(this.namespace, v1HTTPRouteSpecBackendRefs.namespace) && + Objects.equals(this.port, v1HTTPRouteSpecBackendRefs.port) && + Objects.equals(this.weight, v1HTTPRouteSpecBackendRefs.weight); + } + + @Override + public int hashCode() { + return Objects.hash(filters, group, kind, name, namespace, port, weight); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteSpecBackendRefs {\n"); + sb.append(" filters: ").append(toIndentedString(filters)).append("\n"); + sb.append(" group: ").append(toIndentedString(group)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); + sb.append(" port: ").append(toIndentedString(port)).append("\n"); + sb.append(" weight: ").append(toIndentedString(weight)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecExtensionRef.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecExtensionRef.java new file mode 100644 index 00000000..3a09070f --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecExtensionRef.java @@ -0,0 +1,84 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Objects; + +/** + * ExtensionRef is an optional, implementation-specific extension to the \"filter\" behavior. For example, resource \"myroutefilter\" in group \"networking.example.net\"). ExtensionRef MUST NOT be used for core and extended filters. This filter can be used multiple times within the same rule. Support: Implementation-specific + */ +@Data +public class V1HTTPRouteSpecExtensionRef { + public static final String SERIALIZED_NAME_GROUP = "group"; + @SerializedName(SERIALIZED_NAME_GROUP) + private String group; + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecExtensionRef v1HTTPRouteSpecExtensionRef = (V1HTTPRouteSpecExtensionRef) o; + return Objects.equals(this.group, v1HTTPRouteSpecExtensionRef.group) && + Objects.equals(this.kind, v1HTTPRouteSpecExtensionRef.kind) && + Objects.equals(this.name, v1HTTPRouteSpecExtensionRef.name); + } + + @Override + public int hashCode() { + return Objects.hash(group, kind, name); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteSpecExtensionRef {\n"); + sb.append(" group: ").append(toIndentedString(group)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecFilters.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecFilters.java new file mode 100644 index 00000000..cbf5eaee --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecFilters.java @@ -0,0 +1,170 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.IOException; +import java.util.Objects; + +/** + * HTTPRouteFilter defines processing steps that must be completed during the request or response lifecycle. HTTPRouteFilters are meant as an extension point to express processing that may be done in Gateway implementations. Some examples include request or response modification, implementing authentication strategies, rate-limiting, and traffic shaping. API guarantee/conformance is defined based on the type of the filter. + */ +@Data +public class V1HTTPRouteSpecFilters { + public static final String SERIALIZED_NAME_EXTENSION_REF = "extensionRef"; + @SerializedName(SERIALIZED_NAME_EXTENSION_REF) + private V1HTTPRouteSpecExtensionRef extensionRef; + + + public static final String SERIALIZED_NAME_REQUEST_HEADER_MODIFIER = "requestHeaderModifier"; + @SerializedName(SERIALIZED_NAME_REQUEST_HEADER_MODIFIER) + private V1HTTPRouteSpecRequestHeaderModifier requestHeaderModifier; + + public static final String SERIALIZED_NAME_REQUEST_MIRROR = "requestMirror"; + @SerializedName(SERIALIZED_NAME_REQUEST_MIRROR) + private V1HTTPRouteSpecRequestMirror requestMirror; + + public static final String SERIALIZED_NAME_REQUEST_REDIRECT = "requestRedirect"; + @SerializedName(SERIALIZED_NAME_REQUEST_REDIRECT) + private V1HTTPRouteSpecRequestRedirect requestRedirect; + + public static final String SERIALIZED_NAME_RESPONSE_HEADER_MODIFIER = "responseHeaderModifier"; + @SerializedName(SERIALIZED_NAME_RESPONSE_HEADER_MODIFIER) + private V1HTTPRouteSpecResponseHeaderModifier responseHeaderModifier; + + /** + * Type identifies the type of filter to apply. As with other API fields, types are classified into three conformance levels: - Core: Filter types and their corresponding configuration defined by \"Support: Core\" in this package, e.g. \"RequestHeaderModifier\". All implementations must support core filters. - Extended: Filter types and their corresponding configuration defined by \"Support: Extended\" in this package, e.g. \"RequestMirror\". Implementers are encouraged to support extended filters. - Implementation-specific: Filters that are defined and supported by specific vendors. In the future, filters showing convergence in behavior across multiple implementations will be considered for inclusion in extended or core conformance levels. Filter-specific configuration for such filters is specified using the ExtensionRef field. `Type` should be set to \"ExtensionRef\" for custom filters. Implementers are encouraged to define custom implementation types to extend the core API with implementation-specific behavior. If a reference to a custom filter type cannot be resolved, the filter MUST NOT be skipped. Instead, requests that would have been processed by that filter MUST receive a HTTP error response. Note that values may be added to this enum, implementations must ensure that unknown values will not cause a crash. Unknown values here must result in the implementation setting the Accepted Condition for the Route to `status: False`, with a Reason of `UnsupportedValue`. + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + REQUESTHEADERMODIFIER("RequestHeaderModifier"), + + RESPONSEHEADERMODIFIER("ResponseHeaderModifier"), + + REQUESTMIRROR("RequestMirror"), + + REQUESTREDIRECT("RequestRedirect"), + + URLREWRITE("URLRewrite"), + + EXTENSIONREF("ExtensionRef"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type; + + public static final String SERIALIZED_NAME_URL_REWRITE = "urlRewrite"; + @SerializedName(SERIALIZED_NAME_URL_REWRITE) + private V1HTTPRouteSpecUrlRewrite urlRewrite; + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecFilters v1HTTPRouteSpecFilters = (V1HTTPRouteSpecFilters) o; + return Objects.equals(this.extensionRef, v1HTTPRouteSpecFilters.extensionRef) && + Objects.equals(this.requestHeaderModifier, v1HTTPRouteSpecFilters.requestHeaderModifier) && + Objects.equals(this.requestMirror, v1HTTPRouteSpecFilters.requestMirror) && + Objects.equals(this.requestRedirect, v1HTTPRouteSpecFilters.requestRedirect) && + Objects.equals(this.responseHeaderModifier, v1HTTPRouteSpecFilters.responseHeaderModifier) && + Objects.equals(this.type, v1HTTPRouteSpecFilters.type) && + Objects.equals(this.urlRewrite, v1HTTPRouteSpecFilters.urlRewrite); + } + + @Override + public int hashCode() { + return Objects.hash(extensionRef, requestHeaderModifier, requestMirror, requestRedirect, responseHeaderModifier, type, urlRewrite); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteSpecFilters {\n"); + sb.append(" extensionRef: ").append(toIndentedString(extensionRef)).append("\n"); + sb.append(" requestHeaderModifier: ").append(toIndentedString(requestHeaderModifier)).append("\n"); + sb.append(" requestMirror: ").append(toIndentedString(requestMirror)).append("\n"); + sb.append(" requestRedirect: ").append(toIndentedString(requestRedirect)).append("\n"); + sb.append(" responseHeaderModifier: ").append(toIndentedString(responseHeaderModifier)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" urlRewrite: ").append(toIndentedString(urlRewrite)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecHeaders.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecHeaders.java new file mode 100644 index 00000000..63c4aac6 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecHeaders.java @@ -0,0 +1,136 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.IOException; +import java.util.Objects; + +/** + * HTTPHeaderMatch describes how to select a HTTP route by matching HTTP request headers. + */ +@Data +public class V1HTTPRouteSpecHeaders { + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + /** + * Type specifies how to match against the value of the header. Support: Core (Exact) Support: Implementation-specific (RegularExpression) Since RegularExpression HeaderMatchType has implementation-specific conformance, implementations can support POSIX, PCRE or any other dialects of regular expressions. Please read the implementation's documentation to determine the supported dialect. + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + EXACT("Exact"), + + REGULAREXPRESSION("RegularExpression"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type; + + public static final String SERIALIZED_NAME_VALUE = "value"; + @SerializedName(SERIALIZED_NAME_VALUE) + private String value; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecHeaders v1HTTPRouteSpecHeaders = (V1HTTPRouteSpecHeaders) o; + return Objects.equals(this.name, v1HTTPRouteSpecHeaders.name) && + Objects.equals(this.type, v1HTTPRouteSpecHeaders.type) && + Objects.equals(this.value, v1HTTPRouteSpecHeaders.value); + } + + @Override + public int hashCode() { + return Objects.hash(name, type, value); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteSpecHeaders {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecMatches.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecMatches.java new file mode 100644 index 00000000..bd9ed0cd --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecMatches.java @@ -0,0 +1,175 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * HTTPRouteMatch defines the predicate used to match requests to a given action. Multiple match types are ANDed together, i.e. the match will evaluate to true only if all conditions are satisfied. For example, the match below will match a HTTP request only if its path starts with `/foo` AND it contains the `version: v1` header: ``` match: path: value: \"/foo\" headers: - name: \"version\" value \"v1\" ``` + */ +@Data +public class V1HTTPRouteSpecMatches { + public static final String SERIALIZED_NAME_HEADERS = "headers"; + @SerializedName(SERIALIZED_NAME_HEADERS) + private List headers = null; + + /** + * Method specifies HTTP method matcher. When specified, this route will be matched only if the request has the specified method. Support: Extended + */ + @JsonAdapter(MethodEnum.Adapter.class) + public enum MethodEnum { + GET("GET"), + + HEAD("HEAD"), + + POST("POST"), + + PUT("PUT"), + + DELETE("DELETE"), + + CONNECT("CONNECT"), + + OPTIONS("OPTIONS"), + + TRACE("TRACE"), + + PATCH("PATCH"); + + private String value; + + MethodEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static MethodEnum fromValue(String value) { + for (MethodEnum b : MethodEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final MethodEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public MethodEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return MethodEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_METHOD = "method"; + @SerializedName(SERIALIZED_NAME_METHOD) + private MethodEnum method; + + public static final String SERIALIZED_NAME_PATH = "path"; + @SerializedName(SERIALIZED_NAME_PATH) + private V1HTTPRouteSpecPath path; + + public static final String SERIALIZED_NAME_QUERY_PARAMS = "queryParams"; + @SerializedName(SERIALIZED_NAME_QUERY_PARAMS) + private List queryParams = null; + + + public V1HTTPRouteSpecMatches addHeadersItem(V1HTTPRouteSpecHeaders headersItem) { + if (this.headers == null) { + this.headers = new ArrayList<>(); + } + this.headers.add(headersItem); + return this; + } + + public V1HTTPRouteSpecMatches addQueryParamsItem(V1HTTPRouteSpecQueryParams queryParamsItem) { + if (this.queryParams == null) { + this.queryParams = new ArrayList<>(); + } + this.queryParams.add(queryParamsItem); + return this; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecMatches v1HTTPRouteSpecMatches = (V1HTTPRouteSpecMatches) o; + return Objects.equals(this.headers, v1HTTPRouteSpecMatches.headers) && + Objects.equals(this.method, v1HTTPRouteSpecMatches.method) && + Objects.equals(this.path, v1HTTPRouteSpecMatches.path) && + Objects.equals(this.queryParams, v1HTTPRouteSpecMatches.queryParams); + } + + @Override + public int hashCode() { + return Objects.hash(headers, method, path, queryParams); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteSpecMatches {\n"); + sb.append(" headers: ").append(toIndentedString(headers)).append("\n"); + sb.append(" method: ").append(toIndentedString(method)).append("\n"); + sb.append(" path: ").append(toIndentedString(path)).append("\n"); + sb.append(" queryParams: ").append(toIndentedString(queryParams)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecParentRefs.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecParentRefs.java new file mode 100644 index 00000000..4c0c54af --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecParentRefs.java @@ -0,0 +1,102 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Objects; + +/** + * ParentReference identifies an API object (usually a Gateway) that can be considered a parent of this resource (usually a route). There are two kinds of parent resources with \"Core\" support: * Gateway (Gateway conformance profile) * Service (Mesh conformance profile, ClusterIP Services only) This API may be extended in the future to support additional kinds of parent resources. The API object must be valid in the cluster; the Group and Kind must be registered in the cluster for this reference to be valid. + */ +@Data +public class V1HTTPRouteSpecParentRefs { + public static final String SERIALIZED_NAME_GROUP = "group"; + @SerializedName(SERIALIZED_NAME_GROUP) + private String group; + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_NAMESPACE = "namespace"; + @SerializedName(SERIALIZED_NAME_NAMESPACE) + private String namespace; + + public static final String SERIALIZED_NAME_PORT = "port"; + @SerializedName(SERIALIZED_NAME_PORT) + private Integer port; + + public static final String SERIALIZED_NAME_SECTION_NAME = "sectionName"; + @SerializedName(SERIALIZED_NAME_SECTION_NAME) + private String sectionName; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecParentRefs v1HTTPRouteSpecParentRefs = (V1HTTPRouteSpecParentRefs) o; + return Objects.equals(this.group, v1HTTPRouteSpecParentRefs.group) && + Objects.equals(this.kind, v1HTTPRouteSpecParentRefs.kind) && + Objects.equals(this.name, v1HTTPRouteSpecParentRefs.name) && + Objects.equals(this.namespace, v1HTTPRouteSpecParentRefs.namespace) && + Objects.equals(this.port, v1HTTPRouteSpecParentRefs.port) && + Objects.equals(this.sectionName, v1HTTPRouteSpecParentRefs.sectionName); + } + + @Override + public int hashCode() { + return Objects.hash(group, kind, name, namespace, port, sectionName); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteSpecParentRefs {\n"); + sb.append(" group: ").append(toIndentedString(group)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); + sb.append(" port: ").append(toIndentedString(port)).append("\n"); + sb.append(" sectionName: ").append(toIndentedString(sectionName)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecPath.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecPath.java new file mode 100644 index 00000000..0cdf57a6 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecPath.java @@ -0,0 +1,133 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.IOException; +import java.util.Objects; + +/** + * Path specifies a HTTP request path matcher. If this field is not specified, a default prefix match on the \"/\" path is provided. + */ +@Data +public class V1HTTPRouteSpecPath { + + /** + * Type specifies how to match against the path Value. Support: Core (Exact, PathPrefix) Support: Implementation-specific (RegularExpression) + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + EXACT("Exact"), + + PATHPREFIX("PathPrefix"), + + REGULAREXPRESSION("RegularExpression"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type; + + public static final String SERIALIZED_NAME_VALUE = "value"; + @SerializedName(SERIALIZED_NAME_VALUE) + private String value; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecPath v1HTTPRouteSpecPath = (V1HTTPRouteSpecPath) o; + return Objects.equals(this.type, v1HTTPRouteSpecPath.type) && + Objects.equals(this.value, v1HTTPRouteSpecPath.value); + } + + @Override + public int hashCode() { + return Objects.hash(type, value); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteSpecPath {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecQueryParams.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecQueryParams.java new file mode 100644 index 00000000..48a832c3 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecQueryParams.java @@ -0,0 +1,136 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.IOException; +import java.util.Objects; + +/** + * HTTPQueryParamMatch describes how to select a HTTP route by matching HTTP query parameters. + */ +@Data +public class V1HTTPRouteSpecQueryParams { + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + /** + * Type specifies how to match against the value of the query parameter. Support: Extended (Exact) Support: Implementation-specific (RegularExpression) Since RegularExpression QueryParamMatchType has Implementation-specific conformance, implementations can support POSIX, PCRE or any other dialects of regular expressions. Please read the implementation's documentation to determine the supported dialect. + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + EXACT("Exact"), + + REGULAREXPRESSION("RegularExpression"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type; + + public static final String SERIALIZED_NAME_VALUE = "value"; + @SerializedName(SERIALIZED_NAME_VALUE) + private String value; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecQueryParams v1HTTPRouteSpecQueryParams = (V1HTTPRouteSpecQueryParams) o; + return Objects.equals(this.name, v1HTTPRouteSpecQueryParams.name) && + Objects.equals(this.type, v1HTTPRouteSpecQueryParams.type) && + Objects.equals(this.value, v1HTTPRouteSpecQueryParams.value); + } + + @Override + public int hashCode() { + return Objects.hash(name, type, value); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteSpecQueryParams {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifier.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifier.java new file mode 100644 index 00000000..9f92b8c0 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifier.java @@ -0,0 +1,116 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * RequestHeaderModifier defines a schema for a filter that modifies request headers. Support: Core + */ +@Data +public class V1HTTPRouteSpecRequestHeaderModifier { + public static final String SERIALIZED_NAME_ADD = "add"; + @SerializedName(SERIALIZED_NAME_ADD) + private List add = null; + + public static final String SERIALIZED_NAME_REMOVE = "remove"; + @SerializedName(SERIALIZED_NAME_REMOVE) + private List remove = null; + + public static final String SERIALIZED_NAME_SET = "set"; + @SerializedName(SERIALIZED_NAME_SET) + private List set = null; + + + public V1HTTPRouteSpecRequestHeaderModifier addAddItem(V1HTTPRouteSpecRequestHeaderModifierAdd addItem) { + if (this.add == null) { + this.add = new ArrayList<>(); + } + this.add.add(addItem); + return this; + } + + /** + * Add adds the given header(s) (name, value) to the request before the action. It appends to any existing values associated with the header name. Input: GET /foo HTTP/1.1 my-header: foo Config: add: - name: \"my-header\" value: \"bar,baz\" Output: GET /foo HTTP/1.1 my-header: foo,bar,baz + * @return add + **/ + + public V1HTTPRouteSpecRequestHeaderModifier addRemoveItem(String removeItem) { + if (this.remove == null) { + this.remove = new ArrayList<>(); + } + this.remove.add(removeItem); + return this; + } + + public V1HTTPRouteSpecRequestHeaderModifier addSetItem(V1HTTPRouteSpecRequestHeaderModifierAdd setItem) { + if (this.set == null) { + this.set = new ArrayList<>(); + } + this.set.add(setItem); + return this; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecRequestHeaderModifier v1HTTPRouteSpecRequestHeaderModifier = (V1HTTPRouteSpecRequestHeaderModifier) o; + return Objects.equals(this.add, v1HTTPRouteSpecRequestHeaderModifier.add) && + Objects.equals(this.remove, v1HTTPRouteSpecRequestHeaderModifier.remove) && + Objects.equals(this.set, v1HTTPRouteSpecRequestHeaderModifier.set); + } + + @Override + public int hashCode() { + return Objects.hash(add, remove, set); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteSpecRequestHeaderModifier {\n"); + sb.append(" add: ").append(toIndentedString(add)).append("\n"); + sb.append(" remove: ").append(toIndentedString(remove)).append("\n"); + sb.append(" set: ").append(toIndentedString(set)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifierAdd.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifierAdd.java new file mode 100644 index 00000000..6d9409f4 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifierAdd.java @@ -0,0 +1,78 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Objects; + +/** + * HTTPHeader represents an HTTP Header name and value as defined by RFC 7230. + */ +@Data +public class V1HTTPRouteSpecRequestHeaderModifierAdd { + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_VALUE = "value"; + @SerializedName(SERIALIZED_NAME_VALUE) + private String value; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecRequestHeaderModifierAdd v1HTTPRouteSpecRequestHeaderModifierAdd = (V1HTTPRouteSpecRequestHeaderModifierAdd) o; + return Objects.equals(this.name, v1HTTPRouteSpecRequestHeaderModifierAdd.name) && + Objects.equals(this.value, v1HTTPRouteSpecRequestHeaderModifierAdd.value); + } + + @Override + public int hashCode() { + return Objects.hash(name, value); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteSpecRequestHeaderModifierAdd {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirror.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirror.java new file mode 100644 index 00000000..389e20d1 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirror.java @@ -0,0 +1,72 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Objects; + +/** + * RequestMirror defines a schema for a filter that mirrors requests. Requests are sent to the specified destination, but responses from that destination are ignored. This filter can be used multiple times within the same rule. Note that not all implementations will be able to support mirroring to multiple backends. Support: Extended + */ +@Data +public class V1HTTPRouteSpecRequestMirror { + public static final String SERIALIZED_NAME_BACKEND_REF = "backendRef"; + @SerializedName(SERIALIZED_NAME_BACKEND_REF) + private V1HTTPRouteSpecRequestMirrorBackendRef backendRef; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecRequestMirror v1HTTPRouteSpecRequestMirror = (V1HTTPRouteSpecRequestMirror) o; + return Objects.equals(this.backendRef, v1HTTPRouteSpecRequestMirror.backendRef); + } + + @Override + public int hashCode() { + return Objects.hash(backendRef); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteSpecRequestMirror {\n"); + sb.append(" backendRef: ").append(toIndentedString(backendRef)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirrorBackendRef.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirrorBackendRef.java new file mode 100644 index 00000000..441d9258 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirrorBackendRef.java @@ -0,0 +1,96 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Objects; + +/** + * BackendRef references a resource where mirrored requests are sent. Mirrored requests must be sent only to a single destination endpoint within this BackendRef, irrespective of how many endpoints are present within this BackendRef. If the referent cannot be found, this BackendRef is invalid and must be dropped from the Gateway. The controller must ensure the \"ResolvedRefs\" condition on the Route status is set to `status: False` and not configure this backend in the underlying implementation. If there is a cross-namespace reference to an *existing* object that is not allowed by a ReferenceGrant, the controller must ensure the \"ResolvedRefs\" condition on the Route is set to `status: False`, with the \"RefNotPermitted\" reason and not configure this backend in the underlying implementation. In either error case, the Message of the `ResolvedRefs` Condition should be used to provide more detail about the problem. Support: Extended for Kubernetes Service Support: Implementation-specific for any other resource + */ +@Data +public class V1HTTPRouteSpecRequestMirrorBackendRef { + public static final String SERIALIZED_NAME_GROUP = "group"; + @SerializedName(SERIALIZED_NAME_GROUP) + private String group; + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_NAMESPACE = "namespace"; + @SerializedName(SERIALIZED_NAME_NAMESPACE) + private String namespace; + + public static final String SERIALIZED_NAME_PORT = "port"; + @SerializedName(SERIALIZED_NAME_PORT) + private Integer port; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecRequestMirrorBackendRef v1HTTPRouteSpecRequestMirrorBackendRef = (V1HTTPRouteSpecRequestMirrorBackendRef) o; + return Objects.equals(this.group, v1HTTPRouteSpecRequestMirrorBackendRef.group) && + Objects.equals(this.kind, v1HTTPRouteSpecRequestMirrorBackendRef.kind) && + Objects.equals(this.name, v1HTTPRouteSpecRequestMirrorBackendRef.name) && + Objects.equals(this.namespace, v1HTTPRouteSpecRequestMirrorBackendRef.namespace) && + Objects.equals(this.port, v1HTTPRouteSpecRequestMirrorBackendRef.port); + } + + @Override + public int hashCode() { + return Objects.hash(group, kind, name, namespace, port); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteSpecRequestMirrorBackendRef {\n"); + sb.append(" group: ").append(toIndentedString(group)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); + sb.append(" port: ").append(toIndentedString(port)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirect.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirect.java new file mode 100644 index 00000000..b2c98e8c --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirect.java @@ -0,0 +1,149 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.IOException; +import java.util.Objects; + +/** + * RequestRedirect defines a schema for a filter that responds to the request with an HTTP redirection. Support: Core + */ +@Data +public class V1HTTPRouteSpecRequestRedirect { + public static final String SERIALIZED_NAME_HOSTNAME = "hostname"; + @SerializedName(SERIALIZED_NAME_HOSTNAME) + private String hostname; + + public static final String SERIALIZED_NAME_PATH = "path"; + @SerializedName(SERIALIZED_NAME_PATH) + private V1HTTPRouteSpecRequestRedirectPath path; + + public static final String SERIALIZED_NAME_PORT = "port"; + @SerializedName(SERIALIZED_NAME_PORT) + private Integer port; + + /** + * Scheme is the scheme to be used in the value of the `Location` header in the response. When empty, the scheme of the request is used. Scheme redirects can affect the port of the redirect, for more information, refer to the documentation for the port field of this filter. Note that values may be added to this enum, implementations must ensure that unknown values will not cause a crash. Unknown values here must result in the implementation setting the Accepted Condition for the Route to `status: False`, with a Reason of `UnsupportedValue`. Support: Extended + */ + @JsonAdapter(SchemeEnum.Adapter.class) + public enum SchemeEnum { + HTTP("http"), + + HTTPS("https"); + + private String value; + + SchemeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static SchemeEnum fromValue(String value) { + for (SchemeEnum b : SchemeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final SchemeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public SchemeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return SchemeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_SCHEME = "scheme"; + @SerializedName(SERIALIZED_NAME_SCHEME) + private SchemeEnum scheme; + + public static final String SERIALIZED_NAME_STATUS_CODE = "statusCode"; + @SerializedName(SERIALIZED_NAME_STATUS_CODE) + private Integer statusCode; + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecRequestRedirect v1HTTPRouteSpecRequestRedirect = (V1HTTPRouteSpecRequestRedirect) o; + return Objects.equals(this.hostname, v1HTTPRouteSpecRequestRedirect.hostname) && + Objects.equals(this.path, v1HTTPRouteSpecRequestRedirect.path) && + Objects.equals(this.port, v1HTTPRouteSpecRequestRedirect.port) && + Objects.equals(this.scheme, v1HTTPRouteSpecRequestRedirect.scheme) && + Objects.equals(this.statusCode, v1HTTPRouteSpecRequestRedirect.statusCode); + } + + @Override + public int hashCode() { + return Objects.hash(hostname, path, port, scheme, statusCode); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteSpecRequestRedirect {\n"); + sb.append(" hostname: ").append(toIndentedString(hostname)).append("\n"); + sb.append(" path: ").append(toIndentedString(path)).append("\n"); + sb.append(" port: ").append(toIndentedString(port)).append("\n"); + sb.append(" scheme: ").append(toIndentedString(scheme)).append("\n"); + sb.append(" statusCode: ").append(toIndentedString(statusCode)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirectPath.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirectPath.java new file mode 100644 index 00000000..1aa32be8 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirectPath.java @@ -0,0 +1,136 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.IOException; +import java.util.Objects; + +/** + * Path defines parameters used to modify the path of the incoming request. The modified path is then used to construct the `Location` header. When empty, the request path is used as-is. Support: Extended + */ +@Data +public class V1HTTPRouteSpecRequestRedirectPath { + public static final String SERIALIZED_NAME_REPLACE_FULL_PATH = "replaceFullPath"; + @SerializedName(SERIALIZED_NAME_REPLACE_FULL_PATH) + private String replaceFullPath; + + public static final String SERIALIZED_NAME_REPLACE_PREFIX_MATCH = "replacePrefixMatch"; + @SerializedName(SERIALIZED_NAME_REPLACE_PREFIX_MATCH) + private String replacePrefixMatch; + + /** + * Type defines the type of path modifier. Additional types may be added in a future release of the API. Note that values may be added to this enum, implementations must ensure that unknown values will not cause a crash. Unknown values here must result in the implementation setting the Accepted Condition for the Route to `status: False`, with a Reason of `UnsupportedValue`. + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + REPLACEFULLPATH("ReplaceFullPath"), + + REPLACEPREFIXMATCH("ReplacePrefixMatch"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecRequestRedirectPath v1HTTPRouteSpecRequestRedirectPath = (V1HTTPRouteSpecRequestRedirectPath) o; + return Objects.equals(this.replaceFullPath, v1HTTPRouteSpecRequestRedirectPath.replaceFullPath) && + Objects.equals(this.replacePrefixMatch, v1HTTPRouteSpecRequestRedirectPath.replacePrefixMatch) && + Objects.equals(this.type, v1HTTPRouteSpecRequestRedirectPath.type); + } + + @Override + public int hashCode() { + return Objects.hash(replaceFullPath, replacePrefixMatch, type); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteSpecRequestRedirectPath {\n"); + sb.append(" replaceFullPath: ").append(toIndentedString(replaceFullPath)).append("\n"); + sb.append(" replacePrefixMatch: ").append(toIndentedString(replacePrefixMatch)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecResponseHeaderModifier.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecResponseHeaderModifier.java new file mode 100644 index 00000000..f4f99308 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecResponseHeaderModifier.java @@ -0,0 +1,110 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * ResponseHeaderModifier defines a schema for a filter that modifies response headers. Support: Extended + */ +@Data +public class V1HTTPRouteSpecResponseHeaderModifier { + public static final String SERIALIZED_NAME_ADD = "add"; + @SerializedName(SERIALIZED_NAME_ADD) + private List add = null; + + public static final String SERIALIZED_NAME_REMOVE = "remove"; + @SerializedName(SERIALIZED_NAME_REMOVE) + private List remove = null; + + public static final String SERIALIZED_NAME_SET = "set"; + @SerializedName(SERIALIZED_NAME_SET) + private List set = null; + + public V1HTTPRouteSpecResponseHeaderModifier addAddItem(V1HTTPRouteSpecRequestHeaderModifierAdd addItem) { + if (this.add == null) { + this.add = new ArrayList<>(); + } + this.add.add(addItem); + return this; + } + + public V1HTTPRouteSpecResponseHeaderModifier addRemoveItem(String removeItem) { + if (this.remove == null) { + this.remove = new ArrayList<>(); + } + this.remove.add(removeItem); + return this; + } + + public V1HTTPRouteSpecResponseHeaderModifier addSetItem(V1HTTPRouteSpecRequestHeaderModifierAdd setItem) { + if (this.set == null) { + this.set = new ArrayList<>(); + } + this.set.add(setItem); + return this; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecResponseHeaderModifier v1HTTPRouteSpecResponseHeaderModifier = (V1HTTPRouteSpecResponseHeaderModifier) o; + return Objects.equals(this.add, v1HTTPRouteSpecResponseHeaderModifier.add) && + Objects.equals(this.remove, v1HTTPRouteSpecResponseHeaderModifier.remove) && + Objects.equals(this.set, v1HTTPRouteSpecResponseHeaderModifier.set); + } + + @Override + public int hashCode() { + return Objects.hash(add, remove, set); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteSpecResponseHeaderModifier {\n"); + sb.append(" add: ").append(toIndentedString(add)).append("\n"); + sb.append(" remove: ").append(toIndentedString(remove)).append("\n"); + sb.append(" set: ").append(toIndentedString(set)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRules.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRules.java new file mode 100644 index 00000000..48a910e4 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRules.java @@ -0,0 +1,111 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * HTTPRouteRule defines semantics for matching an HTTP request based on conditions (matches), processing it (filters), and forwarding the request to an API object (backendRefs). + */ +@Data +public class V1HTTPRouteSpecRules { + public static final String SERIALIZED_NAME_BACKEND_REFS = "backendRefs"; + @SerializedName(SERIALIZED_NAME_BACKEND_REFS) + private List backendRefs = null; + + public static final String SERIALIZED_NAME_FILTERS = "filters"; + @SerializedName(SERIALIZED_NAME_FILTERS) + private List filters = null; + + public static final String SERIALIZED_NAME_MATCHES = "matches"; + @SerializedName(SERIALIZED_NAME_MATCHES) + private List matches = null; + + public V1HTTPRouteSpecRules addBackendRefsItem(V1HTTPRouteSpecBackendRefs backendRefsItem) { + if (this.backendRefs == null) { + this.backendRefs = new ArrayList<>(); + } + this.backendRefs.add(backendRefsItem); + return this; + } + + public V1HTTPRouteSpecRules addFiltersItem(V1HTTPRouteSpecFilters filtersItem) { + if (this.filters == null) { + this.filters = new ArrayList<>(); + } + this.filters.add(filtersItem); + return this; + } + + + public V1HTTPRouteSpecRules addMatchesItem(V1HTTPRouteSpecMatches matchesItem) { + if (this.matches == null) { + this.matches = new ArrayList<>(); + } + this.matches.add(matchesItem); + return this; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecRules v1HTTPRouteSpecRules = (V1HTTPRouteSpecRules) o; + return Objects.equals(this.backendRefs, v1HTTPRouteSpecRules.backendRefs) && + Objects.equals(this.filters, v1HTTPRouteSpecRules.filters) && + Objects.equals(this.matches, v1HTTPRouteSpecRules.matches); + } + + @Override + public int hashCode() { + return Objects.hash(backendRefs, filters, matches); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteSpecRules {\n"); + sb.append(" backendRefs: ").append(toIndentedString(backendRefs)).append("\n"); + sb.append(" filters: ").append(toIndentedString(filters)).append("\n"); + sb.append(" matches: ").append(toIndentedString(matches)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewrite.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewrite.java new file mode 100644 index 00000000..1ad9fe73 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewrite.java @@ -0,0 +1,79 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Objects; + +/** + * URLRewrite defines a schema for a filter that modifies a request during forwarding. Support: Extended + */ +@Data +public class V1HTTPRouteSpecUrlRewrite { + public static final String SERIALIZED_NAME_HOSTNAME = "hostname"; + @SerializedName(SERIALIZED_NAME_HOSTNAME) + private String hostname; + + public static final String SERIALIZED_NAME_PATH = "path"; + @SerializedName(SERIALIZED_NAME_PATH) + private V1HTTPRouteSpecUrlRewritePath path; + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecUrlRewrite v1HTTPRouteSpecUrlRewrite = (V1HTTPRouteSpecUrlRewrite) o; + return Objects.equals(this.hostname, v1HTTPRouteSpecUrlRewrite.hostname) && + Objects.equals(this.path, v1HTTPRouteSpecUrlRewrite.path); + } + + @Override + public int hashCode() { + return Objects.hash(hostname, path); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteSpecUrlRewrite {\n"); + sb.append(" hostname: ").append(toIndentedString(hostname)).append("\n"); + sb.append(" path: ").append(toIndentedString(path)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewritePath.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewritePath.java new file mode 100644 index 00000000..fc98e077 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewritePath.java @@ -0,0 +1,137 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.IOException; +import java.util.Objects; + +/** + * Path defines a path rewrite. Support: Extended + */ +@Data +public class V1HTTPRouteSpecUrlRewritePath { + public static final String SERIALIZED_NAME_REPLACE_FULL_PATH = "replaceFullPath"; + @SerializedName(SERIALIZED_NAME_REPLACE_FULL_PATH) + private String replaceFullPath; + + public static final String SERIALIZED_NAME_REPLACE_PREFIX_MATCH = "replacePrefixMatch"; + @SerializedName(SERIALIZED_NAME_REPLACE_PREFIX_MATCH) + private String replacePrefixMatch; + + /** + * Type defines the type of path modifier. Additional types may be added in a future release of the API. Note that values may be added to this enum, implementations must ensure that unknown values will not cause a crash. Unknown values here must result in the implementation setting the Accepted Condition for the Route to `status: False`, with a Reason of `UnsupportedValue`. + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + REPLACEFULLPATH("ReplaceFullPath"), + + REPLACEPREFIXMATCH("ReplacePrefixMatch"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type; + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecUrlRewritePath v1HTTPRouteSpecUrlRewritePath = (V1HTTPRouteSpecUrlRewritePath) o; + return Objects.equals(this.replaceFullPath, v1HTTPRouteSpecUrlRewritePath.replaceFullPath) && + Objects.equals(this.replacePrefixMatch, v1HTTPRouteSpecUrlRewritePath.replacePrefixMatch) && + Objects.equals(this.type, v1HTTPRouteSpecUrlRewritePath.type); + } + + @Override + public int hashCode() { + return Objects.hash(replaceFullPath, replacePrefixMatch, type); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteSpecUrlRewritePath {\n"); + sb.append(" replaceFullPath: ").append(toIndentedString(replaceFullPath)).append("\n"); + sb.append(" replacePrefixMatch: ").append(toIndentedString(replacePrefixMatch)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatus.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatus.java new file mode 100644 index 00000000..4e5c0b29 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatus.java @@ -0,0 +1,79 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * Status defines the current state of HTTPRoute. + */ +@Data +public class V1HTTPRouteStatus { + public static final String SERIALIZED_NAME_PARENTS = "parents"; + @SerializedName(SERIALIZED_NAME_PARENTS) + private List parents = new ArrayList<>(); + + + public V1HTTPRouteStatus addParentsItem(V1HTTPRouteStatusParents parentsItem) { + this.parents.add(parentsItem); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteStatus v1HTTPRouteStatus = (V1HTTPRouteStatus) o; + return Objects.equals(this.parents, v1HTTPRouteStatus.parents); + } + + @Override + public int hashCode() { + return Objects.hash(parents); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteStatus {\n"); + sb.append(" parents: ").append(toIndentedString(parents)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusConditions.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusConditions.java new file mode 100644 index 00000000..1aa3d909 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusConditions.java @@ -0,0 +1,157 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Objects; + +/** + * Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` // other fields } + */ +@Data +public class V1HTTPRouteStatusConditions { + public static final String SERIALIZED_NAME_LAST_TRANSITION_TIME = "lastTransitionTime"; + @SerializedName(SERIALIZED_NAME_LAST_TRANSITION_TIME) + private OffsetDateTime lastTransitionTime; + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + @SerializedName(SERIALIZED_NAME_MESSAGE) + private String message; + + public static final String SERIALIZED_NAME_OBSERVED_GENERATION = "observedGeneration"; + @SerializedName(SERIALIZED_NAME_OBSERVED_GENERATION) + private Long observedGeneration; + + public static final String SERIALIZED_NAME_REASON = "reason"; + @SerializedName(SERIALIZED_NAME_REASON) + private String reason; + + /** + * status of the condition, one of True, False, Unknown. + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + TRUE("True"), + + FALSE("False"), + + UNKNOWN("Unknown"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + private StatusEnum status; + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private String type; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteStatusConditions v1HTTPRouteStatusConditions = (V1HTTPRouteStatusConditions) o; + return Objects.equals(this.lastTransitionTime, v1HTTPRouteStatusConditions.lastTransitionTime) && + Objects.equals(this.message, v1HTTPRouteStatusConditions.message) && + Objects.equals(this.observedGeneration, v1HTTPRouteStatusConditions.observedGeneration) && + Objects.equals(this.reason, v1HTTPRouteStatusConditions.reason) && + Objects.equals(this.status, v1HTTPRouteStatusConditions.status) && + Objects.equals(this.type, v1HTTPRouteStatusConditions.type); + } + + @Override + public int hashCode() { + return Objects.hash(lastTransitionTime, message, observedGeneration, reason, status, type); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteStatusConditions {\n"); + sb.append(" lastTransitionTime: ").append(toIndentedString(lastTransitionTime)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" observedGeneration: ").append(toIndentedString(observedGeneration)).append("\n"); + sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParentRef.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParentRef.java new file mode 100644 index 00000000..1bd63bbf --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParentRef.java @@ -0,0 +1,102 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Objects; + +/** + * ParentRef corresponds with a ParentRef in the spec that this RouteParentStatus struct describes the status of. + */ +@Data +public class V1HTTPRouteStatusParentRef { + public static final String SERIALIZED_NAME_GROUP = "group"; + @SerializedName(SERIALIZED_NAME_GROUP) + private String group; + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_NAMESPACE = "namespace"; + @SerializedName(SERIALIZED_NAME_NAMESPACE) + private String namespace; + + public static final String SERIALIZED_NAME_PORT = "port"; + @SerializedName(SERIALIZED_NAME_PORT) + private Integer port; + + public static final String SERIALIZED_NAME_SECTION_NAME = "sectionName"; + @SerializedName(SERIALIZED_NAME_SECTION_NAME) + private String sectionName; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteStatusParentRef v1HTTPRouteStatusParentRef = (V1HTTPRouteStatusParentRef) o; + return Objects.equals(this.group, v1HTTPRouteStatusParentRef.group) && + Objects.equals(this.kind, v1HTTPRouteStatusParentRef.kind) && + Objects.equals(this.name, v1HTTPRouteStatusParentRef.name) && + Objects.equals(this.namespace, v1HTTPRouteStatusParentRef.namespace) && + Objects.equals(this.port, v1HTTPRouteStatusParentRef.port) && + Objects.equals(this.sectionName, v1HTTPRouteStatusParentRef.sectionName); + } + + @Override + public int hashCode() { + return Objects.hash(group, kind, name, namespace, port, sectionName); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteStatusParentRef {\n"); + sb.append(" group: ").append(toIndentedString(group)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); + sb.append(" port: ").append(toIndentedString(port)).append("\n"); + sb.append(" sectionName: ").append(toIndentedString(sectionName)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParents.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParents.java new file mode 100644 index 00000000..8d1aacd2 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParents.java @@ -0,0 +1,95 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * RouteParentStatus describes the status of a route with respect to an associated Parent. + */ +@Data +public class V1HTTPRouteStatusParents { + + + public static final String SERIALIZED_NAME_CONDITIONS = "conditions"; + @SerializedName(SERIALIZED_NAME_CONDITIONS) + private List conditions = null; + + public static final String SERIALIZED_NAME_CONTROLLER_NAME = "controllerName"; + @SerializedName(SERIALIZED_NAME_CONTROLLER_NAME) + private String controllerName; + + public static final String SERIALIZED_NAME_PARENT_REF = "parentRef"; + @SerializedName(SERIALIZED_NAME_PARENT_REF) + private V1HTTPRouteStatusParentRef parentRef; + + public V1HTTPRouteStatusParents addConditionsItem(V1HTTPRouteStatusConditions conditionsItem) { + if (this.conditions == null) { + this.conditions = new ArrayList<>(); + } + this.conditions.add(conditionsItem); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteStatusParents v1HTTPRouteStatusParents = (V1HTTPRouteStatusParents) o; + return Objects.equals(this.conditions, v1HTTPRouteStatusParents.conditions) && + Objects.equals(this.controllerName, v1HTTPRouteStatusParents.controllerName) && + Objects.equals(this.parentRef, v1HTTPRouteStatusParents.parentRef); + } + + @Override + public int hashCode() { + return Objects.hash(conditions, controllerName, parentRef); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1HTTPRouteStatusParents {\n"); + sb.append(" conditions: ").append(toIndentedString(conditions)).append("\n"); + sb.append(" controllerName: ").append(toIndentedString(controllerName)).append("\n"); + sb.append(" parentRef: ").append(toIndentedString(parentRef)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrant.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrant.java new file mode 100644 index 00000000..df326d16 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrant.java @@ -0,0 +1,92 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.referencegrant; + +import com.google.gson.annotations.SerializedName; +import io.kubernetes.client.openapi.models.V1ObjectMeta; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Objects; + +/** + * ReferenceGrant identifies kinds of resources in other namespaces that are trusted to reference the specified kinds of resources in the same namespace as the policy. Each ReferenceGrant can be used to represent a unique trust relationship. Additional Reference Grants can be used to add to the set of trusted sources of inbound references for the namespace they are defined within. All cross-namespace references in Gateway API (with the exception of cross-namespace Gateway-route attachment) require a ReferenceGrant. ReferenceGrant is a form of runtime verification allowing users to assert which cross-namespace object references are permitted. Implementations that support ReferenceGrant MUST NOT permit cross-namespace references which have no grant, and MUST respond to the removal of a grant by revoking the access that the grant allowed. + */ + +@Data +public class V1beta1ReferenceGrant implements io.kubernetes.client.common.KubernetesObject { + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; + @SerializedName(SERIALIZED_NAME_API_VERSION) + private String apiVersion; + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + private V1ObjectMeta metadata = null; + + public static final String SERIALIZED_NAME_SPEC = "spec"; + @SerializedName(SERIALIZED_NAME_SPEC) + private V1beta1ReferenceGrantSpec spec; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1beta1ReferenceGrant v1beta1ReferenceGrant = (V1beta1ReferenceGrant) o; + return Objects.equals(this.apiVersion, v1beta1ReferenceGrant.apiVersion) && + Objects.equals(this.kind, v1beta1ReferenceGrant.kind) && + Objects.equals(this.metadata, v1beta1ReferenceGrant.metadata) && + Objects.equals(this.spec, v1beta1ReferenceGrant.spec); + } + + @Override + public int hashCode() { + return Objects.hash(apiVersion, kind, metadata, spec); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1beta1ReferenceGrant {\n"); + sb.append(" apiVersion: ").append(toIndentedString(apiVersion)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" spec: ").append(toIndentedString(spec)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantList.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantList.java new file mode 100644 index 00000000..36c63247 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantList.java @@ -0,0 +1,98 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.referencegrant; + +import com.google.gson.annotations.SerializedName; +import io.kubernetes.client.openapi.models.V1ListMeta; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * ReferenceGrantList is a list of ReferenceGrant + */ +@Data +public class V1beta1ReferenceGrantList implements io.kubernetes.client.common.KubernetesListObject { + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; + @SerializedName(SERIALIZED_NAME_API_VERSION) + private String apiVersion; + + public static final String SERIALIZED_NAME_ITEMS = "items"; + @SerializedName(SERIALIZED_NAME_ITEMS) + private List items = new ArrayList<>(); + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_METADATA) + private V1ListMeta metadata = null; + + + public V1beta1ReferenceGrantList addItemsItem(V1beta1ReferenceGrant itemsItem) { + this.items.add(itemsItem); + return this; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1beta1ReferenceGrantList v1beta1ReferenceGrantList = (V1beta1ReferenceGrantList) o; + return Objects.equals(this.apiVersion, v1beta1ReferenceGrantList.apiVersion) && + Objects.equals(this.items, v1beta1ReferenceGrantList.items) && + Objects.equals(this.kind, v1beta1ReferenceGrantList.kind) && + Objects.equals(this.metadata, v1beta1ReferenceGrantList.metadata); + } + + @Override + public int hashCode() { + return Objects.hash(apiVersion, items, kind, metadata); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1beta1ReferenceGrantList {\n"); + sb.append(" apiVersion: ").append(toIndentedString(apiVersion)).append("\n"); + sb.append(" items: ").append(toIndentedString(items)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpec.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpec.java new file mode 100644 index 00000000..5258a732 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpec.java @@ -0,0 +1,87 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.referencegrant; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * Spec defines the desired state of ReferenceGrant. + */ +@Data +public class V1beta1ReferenceGrantSpec { + public static final String SERIALIZED_NAME_FROM = "from"; + @SerializedName(SERIALIZED_NAME_FROM) + private List from = new ArrayList<>(); + + public static final String SERIALIZED_NAME_TO = "to"; + @SerializedName(SERIALIZED_NAME_TO) + private List to = new ArrayList<>(); + + + public V1beta1ReferenceGrantSpec addToItem(V1beta1ReferenceGrantSpecTo toItem) { + this.to.add(toItem); + return this; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1beta1ReferenceGrantSpec v1beta1ReferenceGrantSpec = (V1beta1ReferenceGrantSpec) o; + return Objects.equals(this.from, v1beta1ReferenceGrantSpec.from) && + Objects.equals(this.to, v1beta1ReferenceGrantSpec.to); + } + + @Override + public int hashCode() { + return Objects.hash(from, to); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1beta1ReferenceGrantSpec {\n"); + sb.append(" from: ").append(toIndentedString(from)).append("\n"); + sb.append(" to: ").append(toIndentedString(to)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpecFrom.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpecFrom.java new file mode 100644 index 00000000..c1cd6b3d --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpecFrom.java @@ -0,0 +1,84 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.referencegrant; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Objects; + +/** + * ReferenceGrantFrom describes trusted namespaces and kinds. + */ +@Data +public class V1beta1ReferenceGrantSpecFrom { + public static final String SERIALIZED_NAME_GROUP = "group"; + @SerializedName(SERIALIZED_NAME_GROUP) + private String group; + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + + public static final String SERIALIZED_NAME_NAMESPACE = "namespace"; + @SerializedName(SERIALIZED_NAME_NAMESPACE) + private String namespace; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1beta1ReferenceGrantSpecFrom v1beta1ReferenceGrantSpecFrom = (V1beta1ReferenceGrantSpecFrom) o; + return Objects.equals(this.group, v1beta1ReferenceGrantSpecFrom.group) && + Objects.equals(this.kind, v1beta1ReferenceGrantSpecFrom.kind) && + Objects.equals(this.namespace, v1beta1ReferenceGrantSpecFrom.namespace); + } + + @Override + public int hashCode() { + return Objects.hash(group, kind, namespace); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1beta1ReferenceGrantSpecFrom {\n"); + sb.append(" group: ").append(toIndentedString(group)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpecTo.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpecTo.java new file mode 100644 index 00000000..02d5f62e --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpecTo.java @@ -0,0 +1,84 @@ +/* + * Kubernetes + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1.21.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.referencegrant; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Objects; + +/** + * ReferenceGrantTo describes what Kinds are allowed as targets of the references. + */ +@Data +public class V1beta1ReferenceGrantSpecTo { + public static final String SERIALIZED_NAME_GROUP = "group"; + @SerializedName(SERIALIZED_NAME_GROUP) + private String group; + + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1beta1ReferenceGrantSpecTo v1beta1ReferenceGrantSpecTo = (V1beta1ReferenceGrantSpecTo) o; + return Objects.equals(this.group, v1beta1ReferenceGrantSpecTo.group) && + Objects.equals(this.kind, v1beta1ReferenceGrantSpecTo.kind) && + Objects.equals(this.name, v1beta1ReferenceGrantSpecTo.name); + } + + @Override + public int hashCode() { + return Objects.hash(group, kind, name); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class V1beta1ReferenceGrantSpecTo {\n"); + sb.append(" group: ").append(toIndentedString(group)).append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + From 13a68f75832bd34745cf295d7425877a1d11a574 Mon Sep 17 00:00:00 2001 From: kend <860620266@qq.com> Date: Fri, 23 Aug 2024 16:28:52 +0800 Subject: [PATCH 02/24] add gatewayclass init & workmode init --- .../sdk/constant/HigressConstants.java | 1 + .../kubernetes/KubernetesClientService.java | 54 +++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/constant/HigressConstants.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/constant/HigressConstants.java index 4235d1b5..80c2fe3f 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/constant/HigressConstants.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/constant/HigressConstants.java @@ -20,4 +20,5 @@ public class HigressConstants { public static final int CONTROLLER_SERVICE_PORT_DEFAULT = 15014; public static final String CONTROLLER_JWT_POLICY_DEFAULT = KubernetesConstants.JwtPolicy.THIRD_PARTY_JWT; public static final String DEFAULT_DOMAIN = "higress-default-domain"; + public static final String DEFAULT_CONFIG = "higress-config"; } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java index fb09fa52..e89a636e 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java @@ -29,6 +29,9 @@ import java.util.Objects; import java.util.Optional; +import com.alibaba.higress.sdk.constant.HigressConstants; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gatewayclass.V1GatewayClass; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gatewayclass.V1GatewayClassSpec; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; @@ -107,6 +110,8 @@ public class KubernetesClientService { private boolean ingressV1Supported; + private String workMode; + public KubernetesClientService(HigressServiceConfig config) throws IOException { validateConfig(config); @@ -132,6 +137,8 @@ public KubernetesClientService(HigressServiceConfig config) throws IOException { } initializeK8sCapabilities(); + initGatewayClass(); + getIngressOrGatewayMode(); } private void initializeK8sCapabilities() { @@ -146,10 +153,57 @@ private void initializeK8sCapabilities() { } } + private void initGatewayClass() { + CustomObjectsApi customObjectsApi = new CustomObjectsApi(client); + + V1GatewayClass gatewayClass = new V1GatewayClass(); + gatewayClass.setMetadata(new V1ObjectMeta()); + gatewayClass.getMetadata().setName(V1GatewayClass.DEFAULT_NAME); + gatewayClass.setSpec(new V1GatewayClassSpec()); + + try { + Object existingGatewayClass = customObjectsApi.getClusterCustomObject(V1GatewayClass.API_GROUP, V1GatewayClass.VERSION, + V1GatewayClass.PLURAL, V1GatewayClass.DEFAULT_NAME); + log.info("GatewayClass already exists: " + existingGatewayClass); + } catch (ApiException e) { + if (e.getCode() == HttpStatus.NOT_FOUND) { // 如果不存在,则创建新的 GatewayClass + try { + Object response = customObjectsApi.createClusterCustomObject(V1GatewayClass.API_GROUP, V1GatewayClass.VERSION, + V1GatewayClass.PLURAL, gatewayClass, null, null, null); + log.info("Created GatewayClass: " + response); + } catch (ApiException ex) { + throw new BusinessException("Failed to create GatewayClass", + ex); + } + } else { + throw new BusinessException("Failed to check if GatewayClass exists", + e); + } + } + } + + private void getIngressOrGatewayMode(){ + // 读取全局配置,看当前是ingress or gateway 模式 + V1ConfigMap higressConfig; + try { + higressConfig = readConfigMap(HigressConstants.DEFAULT_CONFIG); + } catch (ApiException e) { + throw new BusinessException("Error occurs when reading the ConfigMap with name:"+HigressConstants.DEFAULT_CONFIG, + e); + } + Map data = higressConfig.getData(); + workMode = "ingress"; + if (data!=null && data.containsKey("workMode")){ + workMode = data.get("workMode"); + } + } public boolean isIngressV1Supported() { return ingressV1Supported; } + public boolean isIngressWorkMode(){ + return workMode.equals("ingress"); + } public boolean isNamespaceProtected(String namespace) { return KubernetesConstants.KUBE_SYSTEM_NS.equals(namespace) || controllerNamespace.equals(namespace); } From c7b0df19eaa94c171ecc325aee53631db4e8056e Mon Sep 17 00:00:00 2001 From: kend <860620266@qq.com> Date: Fri, 23 Aug 2024 18:11:55 +0800 Subject: [PATCH 03/24] modify domain model to multi-certs --- .../com/alibaba/higress/sdk/model/Domain.java | 4 +++- .../kubernetes/KubernetesModelConverter.java | 20 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/Domain.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/Domain.java index 7acc137e..90ab65e8 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/Domain.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/Domain.java @@ -18,6 +18,8 @@ import lombok.Data; import lombok.NoArgsConstructor; +import java.util.Map; + @Data @Builder @NoArgsConstructor @@ -37,5 +39,5 @@ public static class EnableHttps { private String enableHttps; - private String certIdentifier; + private Map portAndCertMap; } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java index 792946ff..5e0fca2d 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java @@ -37,6 +37,8 @@ import javax.naming.ldap.LdapName; import javax.security.auth.x500.X500Principal; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONException; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.ObjectUtils; @@ -243,7 +245,7 @@ public V1ConfigMap domain2ConfigMap(Domain domain) { Map configMap = new HashMap<>(); configMap.put(CommonKey.DOMAIN, domain.getName()); - configMap.put(KubernetesConstants.K8S_CERT, domain.getCertIdentifier()); + configMap.put(KubernetesConstants.K8S_CERT, JSON.toJSONString(domain.getPortAndCertMap())); configMap.put(KubernetesConstants.K8S_ENABLE_HTTPS, domain.getEnableHttps()); domainConfigMap.data(configMap); @@ -263,7 +265,17 @@ public Domain configMap2Domain(V1ConfigMap configMap) { throw new IllegalArgumentException("The ConfigMap data is illegal"); } domain.setName(configMapData.get(CommonKey.DOMAIN)); - domain.setCertIdentifier(configMapData.get(KubernetesConstants.K8S_CERT)); + String certData = configMapData.get(KubernetesConstants.K8S_CERT); + // + try { + domain.setPortAndCertMap(JSON.parseObject(certData, Map.class)); + }catch(JSONException e){ + // 原先ingress模式下的cert + Map portCertMap = new HashMap<>(); + portCertMap.put(443, certData); + domain.setPortAndCertMap(portCertMap); + } + domain.setEnableHttps(configMapData.get(KubernetesConstants.K8S_ENABLE_HTTPS)); return domain; } @@ -1268,7 +1280,7 @@ private void fillIngressTls(V1ObjectMeta metadata, V1IngressSpec spec, Route rou continue; } - if (StringUtils.isEmpty(domain.getCertIdentifier())) { + if (StringUtils.isEmpty(domain.getPortAndCertMap().get(443))) { continue; } @@ -1276,7 +1288,7 @@ private void fillIngressTls(V1ObjectMeta metadata, V1IngressSpec spec, Route rou if (!HigressConstants.DEFAULT_DOMAIN.equals(domainName)){ tls.setHosts(Collections.singletonList(domainName)); } - tls.setSecretName(domain.getCertIdentifier()); + tls.setSecretName(domain.getPortAndCertMap().get(443)); if (tlses == null) { tlses = new ArrayList<>(); spec.setTls(tlses); From 9f43da683bf1cb7bedc527b73cacc9fdec37e594 Mon Sep 17 00:00:00 2001 From: kend <860620266@qq.com> Date: Sat, 24 Aug 2024 18:43:45 +0800 Subject: [PATCH 04/24] refine gatewayapi crd model definitions --- .../crd/gatewayapi/gateways/V1Gateway.java | 9 +++++-- .../gatewayapi/gateways/V1GatewaySpec.java | 8 +++++++ .../gateways/V1GatewaySpecListeners.java | 24 ++++++++++++++++++- .../crd/gatewayapi/httproute/V1HTTPRoute.java | 9 +++++-- .../referencegrant/V1beta1ReferenceGrant.java | 10 ++++++-- 5 files changed, 53 insertions(+), 7 deletions(-) diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1Gateway.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1Gateway.java index 678c9ca5..6579b367 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1Gateway.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1Gateway.java @@ -26,13 +26,18 @@ */ @Data public class V1Gateway implements io.kubernetes.client.common.KubernetesObject { + public static final String API_GROUP = "gateway.networking.k8s.io"; + public static final String VERSION = "v1"; + public static final String KIND = "Gateway"; + public static final String PLURAL = "gateways"; + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; @SerializedName(SERIALIZED_NAME_API_VERSION) - private String apiVersion; + private String apiVersion = API_GROUP + "/" + VERSION; public static final String SERIALIZED_NAME_KIND = "kind"; @SerializedName(SERIALIZED_NAME_KIND) - private String kind; + private String kind = KIND; public static final String SERIALIZED_NAME_METADATA = "metadata"; @SerializedName(SERIALIZED_NAME_METADATA) diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpec.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpec.java index e326a609..fbe48cd8 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpec.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpec.java @@ -27,6 +27,8 @@ */ @Data public class V1GatewaySpec { + public static final String HIGRESS_GATEWAY_SERVICE = "higress-gateway.higress-system.svc.cluster.local"; + public static final String SERIALIZED_NAME_ADDRESSES = "addresses"; @SerializedName(SERIALIZED_NAME_ADDRESSES) private List addresses = null; @@ -47,6 +49,12 @@ public V1GatewaySpec addAddressesItem(V1GatewaySpecAddresses addressesItem) { return this; } + public V1GatewaySpec addDefaultAddress(){ + V1GatewaySpecAddresses addressesItem = new V1GatewaySpecAddresses(); + addressesItem.setType("Hostname"); + addressesItem.setValue(HIGRESS_GATEWAY_SERVICE); + return addAddressesItem(addressesItem); + } @Override public boolean equals(Object o) { diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecListeners.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecListeners.java index 452926cd..49ede64c 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecListeners.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecListeners.java @@ -17,7 +17,10 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; +import java.util.List; import java.util.Objects; /** @@ -50,7 +53,26 @@ public class V1GatewaySpecListeners { @SerializedName(SERIALIZED_NAME_TLS) private V1GatewaySpecTls tls; - + @NotNull + public static V1GatewaySpecTls getDefaultTls(String cert) { + V1GatewaySpecTls tls = new V1GatewaySpecTls(); + List certificateRefs = new ArrayList<>(); + V1GatewaySpecTlsCertificateRefs certificateRef = new V1GatewaySpecTlsCertificateRefs(); + certificateRef.setKind("Secret"); + certificateRef.setName(cert); + certificateRefs.add(certificateRef); + tls.setCertificateRefs(certificateRefs); + tls.setMode(V1GatewaySpecTls.ModeEnum.TERMINATE); + return tls; + } + @NotNull + public static V1GatewaySpecAllowedRoutes getDefaultAllowedRoutes() { + V1GatewaySpecAllowedRoutes allowedRoute = new V1GatewaySpecAllowedRoutes(); + V1GatewaySpecAllowedRoutesNamespaces ns = new V1GatewaySpecAllowedRoutesNamespaces(); + ns.setFrom(V1GatewaySpecAllowedRoutesNamespaces.FromEnum.ALL); + allowedRoute.setNamespaces(ns); + return allowedRoute; + } @Override public boolean equals(Object o) { if (this == o) { diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRoute.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRoute.java index ba5aa7f6..bc1defcc 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRoute.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRoute.java @@ -26,13 +26,18 @@ */ @Data public class V1HTTPRoute implements io.kubernetes.client.common.KubernetesObject { + public static final String API_GROUP = "gateway.networking.k8s.io"; + public static final String VERSION = "v1"; + public static final String KIND = "HTTPRoute"; + public static final String PLURAL = "httproutes"; + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; @SerializedName(SERIALIZED_NAME_API_VERSION) - private String apiVersion; + private String apiVersion = API_GROUP + "/" + VERSION; public static final String SERIALIZED_NAME_KIND = "kind"; @SerializedName(SERIALIZED_NAME_KIND) - private String kind; + private String kind = KIND; public static final String SERIALIZED_NAME_METADATA = "metadata"; @SerializedName(SERIALIZED_NAME_METADATA) diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrant.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrant.java index df326d16..30a9b72e 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrant.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrant.java @@ -27,13 +27,19 @@ @Data public class V1beta1ReferenceGrant implements io.kubernetes.client.common.KubernetesObject { + public static final String API_GROUP = "gateway.networking.k8s.io"; + public static final String VERSION = "v1"; + public static final String KIND = "ReferenceGrant"; + public static final String PLURAL = "referencegrants"; + + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; @SerializedName(SERIALIZED_NAME_API_VERSION) - private String apiVersion; + private String apiVersion = API_GROUP + "/" + VERSION; public static final String SERIALIZED_NAME_KIND = "kind"; @SerializedName(SERIALIZED_NAME_KIND) - private String kind; + private String kind = KIND; public static final String SERIALIZED_NAME_METADATA = "metadata"; @SerializedName(SERIALIZED_NAME_METADATA) From f4ba7770edec8c458d644c646e18deb3330c1b2c Mon Sep 17 00:00:00 2001 From: kend <860620266@qq.com> Date: Sat, 24 Aug 2024 18:46:33 +0800 Subject: [PATCH 05/24] support gateway functions; modify the service port accordingly --- .../sdk/constant/HigressConstants.java | 1 + .../sdk/service/DomainServiceImpl.java | 29 +++- .../kubernetes/KubernetesClientService.java | 153 ++++++++++++++++-- .../kubernetes/KubernetesModelConverter.java | 68 ++++++++ .../service/kubernetes/KubernetesUtil.java | 1 + 5 files changed, 235 insertions(+), 17 deletions(-) diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/constant/HigressConstants.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/constant/HigressConstants.java index 80c2fe3f..8fab8c91 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/constant/HigressConstants.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/constant/HigressConstants.java @@ -21,4 +21,5 @@ public class HigressConstants { public static final String CONTROLLER_JWT_POLICY_DEFAULT = KubernetesConstants.JwtPolicy.THIRD_PARTY_JWT; public static final String DEFAULT_DOMAIN = "higress-default-domain"; public static final String DEFAULT_CONFIG = "higress-config"; + public static final String PORT_CONFIG = "higress-ports"; } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/DomainServiceImpl.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/DomainServiceImpl.java index 2ddf4e2a..b1279784 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/DomainServiceImpl.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/DomainServiceImpl.java @@ -16,6 +16,7 @@ import java.util.Optional; import java.util.stream.Collectors; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways.V1Gateway; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -67,6 +68,16 @@ public Domain add(Domain domain) { } throw new BusinessException("Error occurs when adding a new domain.", e); } + // if gateway mode, create a gateway named "domain_name" + // TODO: should consider the gateway's spec here. + if(!kubernetesClientService.isIngressWorkMode()){ + V1Gateway gateway = kubernetesModelConverter.domain2Gateway(domain); + try { + kubernetesClientService.createGateway(gateway); + } catch (ApiException e) { + throw new BusinessException("Error occurs when creating a Gateway", e); + } + } return kubernetesModelConverter.configMap2Domain(newDomainConfigMap); } @@ -109,7 +120,15 @@ public void delete(String domainName) { } catch (ApiException e) { throw new BusinessException("Error occurs when deleting the ConfigMap with name: " + configMapName, e); } - + if(!kubernetesClientService.isIngressWorkMode()){ + String gatewayName = kubernetesModelConverter.domainName2GatewayName(domainName); + try { + kubernetesClientService.deleteGateway(gatewayName); + } catch (ApiException e) { + throw new BusinessException("Error occurs when delete a Gateway", e); + } + } + //TODO: should consider delete instance wasm plugins when delete gateway wasmPluginInstanceService.deleteAll(WasmPluginInstanceScope.DOMAIN, domainName); } @@ -140,6 +159,14 @@ public Domain put(Domain domain) { routes.forEach(routeService::update); } + if(!kubernetesClientService.isIngressWorkMode()){ + V1Gateway gateway = kubernetesModelConverter.domain2Gateway(domain); + try { + kubernetesClientService.replaceGateway(gateway); + } catch (ApiException e) { + throw new BusinessException("Error occurs when updating a Gateway", e); + } + } return kubernetesModelConverter.configMap2Domain(updatedConfigMap); } } \ No newline at end of file diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java index e89a636e..b1c6b6e6 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java @@ -21,17 +21,15 @@ import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; +import java.util.*; import com.alibaba.higress.sdk.constant.HigressConstants; import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gatewayclass.V1GatewayClass; import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gatewayclass.V1GatewayClassSpec; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways.V1Gateway; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways.V1GatewayList; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways.V1GatewaySpecListeners; +import io.kubernetes.client.openapi.models.*; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; @@ -58,15 +56,6 @@ import io.kubernetes.client.openapi.apis.CoreV1Api; import io.kubernetes.client.openapi.apis.CustomObjectsApi; import io.kubernetes.client.openapi.apis.NetworkingV1Api; -import io.kubernetes.client.openapi.models.V1APIResource; -import io.kubernetes.client.openapi.models.V1ConfigMap; -import io.kubernetes.client.openapi.models.V1ConfigMapList; -import io.kubernetes.client.openapi.models.V1Ingress; -import io.kubernetes.client.openapi.models.V1IngressList; -import io.kubernetes.client.openapi.models.V1ObjectMeta; -import io.kubernetes.client.openapi.models.V1Secret; -import io.kubernetes.client.openapi.models.V1SecretList; -import io.kubernetes.client.openapi.models.V1Status; import io.kubernetes.client.util.ClientBuilder; import io.kubernetes.client.util.KubeConfig; import io.kubernetes.client.util.Strings; @@ -353,6 +342,21 @@ public V1ConfigMap readConfigMap(String name) throws ApiException { } } + public V1ConfigMap readOrCreateConfigMap(String name) throws ApiException { + CoreV1Api coreV1Api = new CoreV1Api(client); + try { + return coreV1Api.readNamespacedConfigMap(name, controllerNamespace, null); + } catch (ApiException e) { + if (e.getCode() == HttpStatus.NOT_FOUND) { + // ConfigMap not found, create a new one + V1ConfigMap newConfigMap = new V1ConfigMap(); + newConfigMap.setMetadata(new V1ObjectMeta().name(name)); + return createConfigMap(newConfigMap); + } + throw e; + } + } + public void deleteConfigMap(String name) throws ApiException { CoreV1Api coreV1Api = new CoreV1Api(client); V1Status status; @@ -488,6 +492,123 @@ public V1McpBridge readMcpBridge(String name) throws ApiException { } } + public List listGateway() { + CustomObjectsApi customObjectsApi = new CustomObjectsApi(client); + try { + Object response = customObjectsApi.listNamespacedCustomObject(V1Gateway.API_GROUP, V1Gateway.VERSION, + controllerNamespace, V1Gateway.PLURAL, null, null, null, null, null, null, null, null, null, null); + io.kubernetes.client.openapi.JSON json = new io.kubernetes.client.openapi.JSON(); + V1GatewayList list = json.deserialize(json.serialize(response), V1McpBridgeList.class); + return sortKubernetesObjects(list.getItems()); + } catch (ApiException e) { + log.error("listGateway Status code: " + e.getCode() + "Reason: " + e.getResponseBody() + + "Response headers: " + e.getResponseHeaders(), e); + return null; + } + } + + public V1Gateway createGateway(V1Gateway gateway) throws ApiException { + modifyLoadBalancerPorts(null, gateway); + CustomObjectsApi customObjectsApi = new CustomObjectsApi(client); + Object response = customObjectsApi.createNamespacedCustomObject(V1Gateway.API_GROUP, V1Gateway.VERSION, + controllerNamespace, V1Gateway.PLURAL, gateway, null, null, null); + return client.getJSON().deserialize(client.getJSON().serialize(response), V1Gateway.class); + } + + public V1Gateway replaceGateway(V1Gateway gateway) throws ApiException { + V1ObjectMeta metadata = gateway.getMetadata(); + if (metadata == null) { + throw new IllegalArgumentException("gateway doesn't have a valid metadata."); + } + V1Gateway gatewayOri = readGateway(metadata.getName()); + modifyLoadBalancerPorts(gatewayOri, gateway); + gateway.getMetadata().setResourceVersion(gatewayOri.getMetadata().getResourceVersion()); + //TODO: consider different ns + metadata.setNamespace(controllerNamespace); + CustomObjectsApi customObjectsApi = new CustomObjectsApi(client); + Object response = customObjectsApi.replaceNamespacedCustomObject(V1Gateway.API_GROUP, V1Gateway.VERSION, + controllerNamespace, V1Gateway.PLURAL, metadata.getName(), gateway, null, null); + return client.getJSON().deserialize(client.getJSON().serialize(response), V1Gateway.class); + } + + public void deleteGateway(String name) throws ApiException { + V1Gateway gateway = readGateway(name); + modifyLoadBalancerPorts(gateway, null); + CustomObjectsApi customObjectsApi = new CustomObjectsApi(client); + customObjectsApi.deleteNamespacedCustomObject(V1Gateway.API_GROUP, V1Gateway.VERSION, controllerNamespace, + V1Gateway.PLURAL, name, null, null, null, null, null); + } + + public V1Gateway readGateway(String name) throws ApiException { + CustomObjectsApi customObjectsApi = new CustomObjectsApi(client); + try { + Object response = customObjectsApi.getNamespacedCustomObject(V1Gateway.API_GROUP, V1Gateway.VERSION, + controllerNamespace, V1Gateway.PLURAL, name); + return client.getJSON().deserialize(client.getJSON().serialize(response), V1Gateway.class); + } catch (ApiException e) { + if (e.getCode() == HttpStatus.NOT_FOUND) { + return null; + } + throw e; + } + } + + public void modifyLoadBalancerPorts(V1Gateway gatewayOri, V1Gateway gatewayReplaced) { + CoreV1Api coreV1Api = new CoreV1Api(client); + try { + // 获取配置中的端口计数 + V1ConfigMap portConfig = readOrCreateConfigMap(HigressConstants.PORT_CONFIG); + Map portCount = portConfig.getData(); + if (portCount == null) portCount = new HashMap<>(); + V1Service service = coreV1Api.readNamespacedService(V1GatewayClass.DEFAULT_NAME, controllerNamespace, null); + List ports = Objects.requireNonNull(service.getSpec()).getPorts(); + assert ports != null; + + // 合并端口监听列表并统计端口出现频率 + Map portFrequency = new HashMap<>(); + if(gatewayOri != null){ + List listenersOri = gatewayOri.getSpec().getListeners(); + for (V1GatewaySpecListeners listener : listenersOri) { + portFrequency.put(listener.getPort(), portFrequency.getOrDefault(listener.getPort(), 0) - 1); + } + } + if(gatewayReplaced != null){ + List listenersReplaced = gatewayReplaced.getSpec().getListeners(); + for (V1GatewaySpecListeners listener : listenersReplaced) { + portFrequency.put(listener.getPort(), portFrequency.getOrDefault(listener.getPort(), 0) + 1); + } + } + + for (Map.Entry entry : portFrequency.entrySet()) { + Integer port = entry.getKey(); + Integer freq = entry.getValue(); + if(port == 80 || port == 443 || freq == 0) continue; + int count = Integer.parseInt(portCount.getOrDefault(port.toString(), "0")) + (freq>0?1:-1); + + if (count <= 0) { + portCount.remove(port.toString()); + // 删除端口 + ports.removeIf(p -> p.getPort().equals(port)); + } else { + portCount.put(port.toString(), Integer.toString(count)); + if(count==1) { + V1ServicePort servicePort = new V1ServicePort().port(port); + servicePort.setProtocol("TCP"); + servicePort.setName("port"+Separators.DASH+ port); + ports.add(servicePort); + } + } + } + + portConfig.setData(portCount); + replaceConfigMap(portConfig); + service.getSpec().setPorts(ports); + coreV1Api.replaceNamespacedService(V1GatewayClass.DEFAULT_NAME, controllerNamespace, service, null, null, null, null); + } catch (ApiException e) { + log.error("Error when modifying LoadBalancer ports ", e); + } + } + public List listWasmPlugin() throws ApiException { return listWasmPlugin(null, null, null); } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java index 5e0fca2d..aed4abb9 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java @@ -39,6 +39,8 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONException; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gatewayclass.V1GatewayClass; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways.*; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.ObjectUtils; @@ -93,6 +95,7 @@ import io.kubernetes.client.openapi.models.V1TypedLocalObjectReference; import io.kubernetes.client.util.Strings; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NotNull; /** * @author CH3CHO @@ -199,6 +202,66 @@ public V1Ingress route2Ingress(Route route) { return ingress; } + public V1Gateway domain2Gateway(Domain domain){ + V1Gateway gateway = new V1Gateway(); + V1ObjectMeta metadata = new V1ObjectMeta(); + metadata.setName(domainName2GatewayName(domain.getName())); + metadata.setResourceVersion(domain.getVersion()); + // TODO: consider the gateway's spec here. + metadata.setNamespace(HigressConstants.NS_DEFAULT); + gateway.setMetadata(metadata); + // set the gateway address to higress-gateway + V1GatewaySpec spec = new V1GatewaySpec().addDefaultAddress(); + spec.setGatewayClassName(V1GatewayClass.DEFAULT_NAME); + List listeners = new ArrayList<>(); + if (domain.getPortAndCertMap().isEmpty()){ + // 提示错误信息 + log.error("Domain must have at least one port!"); + return null; + } + domain.getPortAndCertMap().forEach((port, cert) -> { + V1GatewaySpecListeners listener = new V1GatewaySpecListeners(); + listener.setName(domain.getName()+Separators.DASH+port); + listener.setPort(port); + listener.setHostname(domain.getName()); + listener.setProtocol("HTTP"); + if(!"".equals(cert)){ //证书不为空 + listener.setProtocol("HTTPS"); + V1GatewaySpecTls tls = V1GatewaySpecListeners.getDefaultTls(cert); + listener.setTls(tls); + } + listener.setAllowedRoutes(V1GatewaySpecListeners.getDefaultAllowedRoutes()); + listeners.add(listener); + }); + spec.setListeners(listeners); + gateway.setSpec(spec); + return gateway; + } + + + + public Domain gateway2Domain(V1Gateway gateway){ + Domain domain = new Domain(); + V1ObjectMeta metadata = gateway.getMetadata(); + if (metadata != null) { + domain.setVersion(metadata.getResourceVersion()); + } + List listeners = gateway.getSpec().getListeners(); + domain.setName(listeners.get(0).getHostname()); + domain.setEnableHttps("OFF"); + for (V1GatewaySpecListeners listener:listeners){ + if(listener.getTls() == null){ + domain.getPortAndCertMap().put(listener.getPort(),""); + }else{ + domain.setEnableHttps("ON"); + domain.getPortAndCertMap().put(listener.getPort(), + listener.getTls().getCertificateRefs().get(0).getName()); + } + } + // TODO: find HTTPRoute named "port-xxx-tls-redirect", if domain in hostnames -> domain.setEnableHttps("FORCE"); + return domain; + } + private static void fillRouteCors(Route route, V1ObjectMeta metadata) { if (metadata == null || metadata.getAnnotations() == null) { return; @@ -284,6 +347,11 @@ public String domainName2ConfigMapName(String domainName) { return CommonKey.DOMAIN_PREFIX + KubernetesUtil.normalizeDomainName(domainName); } + public String domainName2GatewayName(String domainName) { + return domainName.replace('.', '-'); + } + + public V1Secret tlsCertificate2Secret(TlsCertificate certificate) { V1Secret secret = new V1Secret(); diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesUtil.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesUtil.java index 069af9a3..a3a67053 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesUtil.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesUtil.java @@ -91,6 +91,7 @@ public static String normalizeDomainName(String name) { return name; } + public static String joinLabelSelectors(String... selectors) { return String.join(Separators.COMMA, selectors); } From f94c4c65978b19ad8955faf71ebcd56a22454609 Mon Sep 17 00:00:00 2001 From: zxlin <860620266@qq.com> Date: Mon, 2 Sep 2024 10:41:22 +0800 Subject: [PATCH 06/24] Refactor: Add comments to enum constants and rename variables to comply with PMD rules and lowerCamelCase naming conventions --- .../V1GatewayClassStatusConditions.java | 9 +++ .../V1GatewaySpecAllowedRoutesNamespaces.java | 9 +++ .../gatewayapi/gateways/V1GatewaySpecTls.java | 9 +++ .../gateways/V1GatewayStatusConditions.java | 13 +++- .../crd/gatewayapi/httproute/V1HTTPRoute.java | 14 ++--- .../gatewayapi/httproute/V1HTTPRouteList.java | 12 ++-- .../gatewayapi/httproute/V1HTTPRouteSpec.java | 10 ++- .../httproute/V1HTTPRouteSpecBackendRefs.java | 16 ++--- .../V1HTTPRouteSpecExtensionRef.java | 8 +-- .../httproute/V1HTTPRouteSpecFilters.java | 51 +++++++++++---- .../httproute/V1HTTPRouteSpecHeaders.java | 18 ++++-- .../httproute/V1HTTPRouteSpecMatches.java | 62 +++++++++++++++---- .../httproute/V1HTTPRouteSpecParentRefs.java | 14 ++--- .../httproute/V1HTTPRouteSpecPath.java | 22 +++++-- .../httproute/V1HTTPRouteSpecQueryParams.java | 18 ++++-- .../V1HTTPRouteSpecRequestHeaderModifier.java | 8 +-- ...HTTPRouteSpecRequestHeaderModifierAdd.java | 6 +- .../V1HTTPRouteSpecRequestMirror.java | 4 +- ...1HTTPRouteSpecRequestMirrorBackendRef.java | 12 ++-- .../V1HTTPRouteSpecRequestRedirect.java | 22 ++++--- .../V1HTTPRouteSpecRequestRedirectPath.java | 18 ++++-- ...V1HTTPRouteSpecResponseHeaderModifier.java | 8 +-- .../httproute/V1HTTPRouteSpecRules.java | 8 +-- .../httproute/V1HTTPRouteSpecUrlRewrite.java | 6 +- .../V1HTTPRouteSpecUrlRewritePath.java | 18 ++++-- .../httproute/V1HTTPRouteStatus.java | 4 +- .../V1HTTPRouteStatusConditions.java | 27 +++++--- .../httproute/V1HTTPRouteStatusParentRef.java | 14 ++--- .../httproute/V1HTTPRouteStatusParents.java | 8 +-- 29 files changed, 300 insertions(+), 148 deletions(-) diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassStatusConditions.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassStatusConditions.java index 16ef10c2..068a4bca 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassStatusConditions.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassStatusConditions.java @@ -53,10 +53,19 @@ public class V1GatewayClassStatusConditions { */ @JsonAdapter(StatusEnum.Adapter.class) public enum StatusEnum { + /** + * Represents the state where the condition is true. + */ TRUE("True"), + /** + * Represents the state where the condition is false. + */ FALSE("False"), + /** + * Represents an unknown state. + */ UNKNOWN("Unknown"); private String value; diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespaces.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespaces.java index 5212524c..5d2b349f 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespaces.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespaces.java @@ -35,8 +35,17 @@ public class V1GatewaySpecAllowedRoutesNamespaces { */ @JsonAdapter(FromEnum.Adapter.class) public enum FromEnum { + /** + * Routes in all namespaces may be used by this Gateway. + */ ALL("All"), + /** + * Routes in namespaces selected by the selector may be used by this Gateway. + */ SELECTOR("Selector"), + /** + * only Routes in the same namespace may be used by this Gateway. + */ SAME("Same"); private String value; diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecTls.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecTls.java index b3c4d9a9..825a998e 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecTls.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecTls.java @@ -39,7 +39,16 @@ public class V1GatewaySpecTls { */ @JsonAdapter(ModeEnum.Adapter.class) public enum ModeEnum { + /** + * The TLS session between the downstream client and the Gateway is terminated at the Gateway. + * This mode requires certificates to be specified in some way, such as populating the certificateRefs field. + */ TERMINATE("Terminate"), + /** + * The TLS session is NOT terminated by the Gateway. + * This implies that the Gateway can't decipher the TLS stream except for the ClientHello message of the TLS protocol. + * The certificateRefs field is ignored in this mode. + */ PASSTHROUGH("Passthrough"); private String value; diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusConditions.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusConditions.java index 6d1c6ab2..536f9643 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusConditions.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusConditions.java @@ -53,10 +53,19 @@ public class V1GatewayStatusConditions { */ @JsonAdapter(StatusEnum.Adapter.class) public enum StatusEnum { + /** + * Represents the state where the condition is true. + */ TRUE("True"), - + + /** + * Represents the state where the condition is false. + */ FALSE("False"), - + + /** + * Represents an unknown state. + */ UNKNOWN("Unknown"); private String value; diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRoute.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRoute.java index bc1defcc..543b7e75 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRoute.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRoute.java @@ -15,8 +15,6 @@ import com.google.gson.annotations.SerializedName; import io.kubernetes.client.openapi.models.V1ObjectMeta; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Objects; @@ -60,12 +58,12 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRoute v1HTTPRoute = (V1HTTPRoute) o; - return Objects.equals(this.apiVersion, v1HTTPRoute.apiVersion) && - Objects.equals(this.kind, v1HTTPRoute.kind) && - Objects.equals(this.metadata, v1HTTPRoute.metadata) && - Objects.equals(this.spec, v1HTTPRoute.spec) && - Objects.equals(this.status, v1HTTPRoute.status); + V1HTTPRoute v1HttpRoute = (V1HTTPRoute) o; + return Objects.equals(this.apiVersion, v1HttpRoute.apiVersion) && + Objects.equals(this.kind, v1HttpRoute.kind) && + Objects.equals(this.metadata, v1HttpRoute.metadata) && + Objects.equals(this.spec, v1HttpRoute.spec) && + Objects.equals(this.status, v1HttpRoute.status); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteList.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteList.java index 40369f32..e5e30c51 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteList.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteList.java @@ -15,8 +15,6 @@ import com.google.gson.annotations.SerializedName; import io.kubernetes.client.openapi.models.V1ListMeta; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.ArrayList; @@ -58,11 +56,11 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteList v1HTTPRouteList = (V1HTTPRouteList) o; - return Objects.equals(this.apiVersion, v1HTTPRouteList.apiVersion) && - Objects.equals(this.items, v1HTTPRouteList.items) && - Objects.equals(this.kind, v1HTTPRouteList.kind) && - Objects.equals(this.metadata, v1HTTPRouteList.metadata); + V1HTTPRouteList v1HttpRouteList = (V1HTTPRouteList) o; + return Objects.equals(this.apiVersion, v1HttpRouteList.apiVersion) && + Objects.equals(this.items, v1HttpRouteList.items) && + Objects.equals(this.kind, v1HttpRouteList.kind) && + Objects.equals(this.metadata, v1HttpRouteList.metadata); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpec.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpec.java index cd444fc0..c544f73e 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpec.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpec.java @@ -14,8 +14,6 @@ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.ArrayList; @@ -64,10 +62,10 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteSpec v1HTTPRouteSpec = (V1HTTPRouteSpec) o; - return Objects.equals(this.hostnames, v1HTTPRouteSpec.hostnames) && - Objects.equals(this.parentRefs, v1HTTPRouteSpec.parentRefs) && - Objects.equals(this.rules, v1HTTPRouteSpec.rules); + V1HTTPRouteSpec v1HttpRouteSpec = (V1HTTPRouteSpec) o; + return Objects.equals(this.hostnames, v1HttpRouteSpec.hostnames) && + Objects.equals(this.parentRefs, v1HttpRouteSpec.parentRefs) && + Objects.equals(this.rules, v1HttpRouteSpec.rules); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecBackendRefs.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecBackendRefs.java index 42b27405..938d5d0d 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecBackendRefs.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecBackendRefs.java @@ -72,14 +72,14 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteSpecBackendRefs v1HTTPRouteSpecBackendRefs = (V1HTTPRouteSpecBackendRefs) o; - return Objects.equals(this.filters, v1HTTPRouteSpecBackendRefs.filters) && - Objects.equals(this.group, v1HTTPRouteSpecBackendRefs.group) && - Objects.equals(this.kind, v1HTTPRouteSpecBackendRefs.kind) && - Objects.equals(this.name, v1HTTPRouteSpecBackendRefs.name) && - Objects.equals(this.namespace, v1HTTPRouteSpecBackendRefs.namespace) && - Objects.equals(this.port, v1HTTPRouteSpecBackendRefs.port) && - Objects.equals(this.weight, v1HTTPRouteSpecBackendRefs.weight); + V1HTTPRouteSpecBackendRefs v1HttpRouteSpecBackendRefs = (V1HTTPRouteSpecBackendRefs) o; + return Objects.equals(this.filters, v1HttpRouteSpecBackendRefs.filters) && + Objects.equals(this.group, v1HttpRouteSpecBackendRefs.group) && + Objects.equals(this.kind, v1HttpRouteSpecBackendRefs.kind) && + Objects.equals(this.name, v1HttpRouteSpecBackendRefs.name) && + Objects.equals(this.namespace, v1HttpRouteSpecBackendRefs.namespace) && + Objects.equals(this.port, v1HttpRouteSpecBackendRefs.port) && + Objects.equals(this.weight, v1HttpRouteSpecBackendRefs.weight); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecExtensionRef.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecExtensionRef.java index 3a09070f..460845f2 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecExtensionRef.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecExtensionRef.java @@ -46,10 +46,10 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteSpecExtensionRef v1HTTPRouteSpecExtensionRef = (V1HTTPRouteSpecExtensionRef) o; - return Objects.equals(this.group, v1HTTPRouteSpecExtensionRef.group) && - Objects.equals(this.kind, v1HTTPRouteSpecExtensionRef.kind) && - Objects.equals(this.name, v1HTTPRouteSpecExtensionRef.name); + V1HTTPRouteSpecExtensionRef v1HttpRouteSpecExtensionRef = (V1HTTPRouteSpecExtensionRef) o; + return Objects.equals(this.group, v1HttpRouteSpecExtensionRef.group) && + Objects.equals(this.kind, v1HttpRouteSpecExtensionRef.kind) && + Objects.equals(this.name, v1HttpRouteSpecExtensionRef.name); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecFilters.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecFilters.java index cbf5eaee..0fccf52b 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecFilters.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecFilters.java @@ -56,16 +56,41 @@ public class V1HTTPRouteSpecFilters { */ @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { + /** + * RequestHeaderModifier is a core filter type used to modify the headers of incoming HTTP requests. + * All implementations must support this filter type. + */ REQUESTHEADERMODIFIER("RequestHeaderModifier"), - + + /** + * ResponseHeaderModifier is a core filter type used to modify the headers of outgoing HTTP responses. + * All implementations must support this filter type. + */ RESPONSEHEADERMODIFIER("ResponseHeaderModifier"), - + + /** + * RequestMirror is an extended filter type used to mirror HTTP requests to another service or destination. + * Implementers are encouraged to support this filter type. + */ REQUESTMIRROR("RequestMirror"), - + + /** + * RequestRedirect is a core filter type used to redirect HTTP requests to a different URL. + * All implementations must support this filter type. + */ REQUESTREDIRECT("RequestRedirect"), - + + /** + * URLRewrite is a core filter type used to rewrite the URL path or query in an HTTP request. + * All implementations must support this filter type. + */ URLREWRITE("URLRewrite"), - + + /** + * ExtensionRef is an implementation-specific filter type used for custom filters defined by the implementer. + * This type should be set to "ExtensionRef" for custom filters, and the specific configuration is specified using the ExtensionRef field. + * If a reference to a custom filter type cannot be resolved, the filter MUST NOT be skipped, and the request must receive an HTTP error response. + */ EXTENSIONREF("ExtensionRef"); private String value; @@ -124,14 +149,14 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteSpecFilters v1HTTPRouteSpecFilters = (V1HTTPRouteSpecFilters) o; - return Objects.equals(this.extensionRef, v1HTTPRouteSpecFilters.extensionRef) && - Objects.equals(this.requestHeaderModifier, v1HTTPRouteSpecFilters.requestHeaderModifier) && - Objects.equals(this.requestMirror, v1HTTPRouteSpecFilters.requestMirror) && - Objects.equals(this.requestRedirect, v1HTTPRouteSpecFilters.requestRedirect) && - Objects.equals(this.responseHeaderModifier, v1HTTPRouteSpecFilters.responseHeaderModifier) && - Objects.equals(this.type, v1HTTPRouteSpecFilters.type) && - Objects.equals(this.urlRewrite, v1HTTPRouteSpecFilters.urlRewrite); + V1HTTPRouteSpecFilters v1HttpRouteSpecFilters = (V1HTTPRouteSpecFilters) o; + return Objects.equals(this.extensionRef, v1HttpRouteSpecFilters.extensionRef) && + Objects.equals(this.requestHeaderModifier, v1HttpRouteSpecFilters.requestHeaderModifier) && + Objects.equals(this.requestMirror, v1HttpRouteSpecFilters.requestMirror) && + Objects.equals(this.requestRedirect, v1HttpRouteSpecFilters.requestRedirect) && + Objects.equals(this.responseHeaderModifier, v1HttpRouteSpecFilters.responseHeaderModifier) && + Objects.equals(this.type, v1HttpRouteSpecFilters.type) && + Objects.equals(this.urlRewrite, v1HttpRouteSpecFilters.urlRewrite); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecHeaders.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecHeaders.java index 63c4aac6..c5b380cf 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecHeaders.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecHeaders.java @@ -39,8 +39,16 @@ public class V1HTTPRouteSpecHeaders { */ @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { + /** + * EXACT is a core match type that matches the header value exactly. + * All implementations must support this match type. + */ EXACT("Exact"), - + + /** + * REGULAREXPRESSION is an implementation-specific match type that allows matching header values using regular expressions. + * The specific regular expression dialect supported may vary between implementations. + */ REGULAREXPRESSION("RegularExpression"); private String value; @@ -98,10 +106,10 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteSpecHeaders v1HTTPRouteSpecHeaders = (V1HTTPRouteSpecHeaders) o; - return Objects.equals(this.name, v1HTTPRouteSpecHeaders.name) && - Objects.equals(this.type, v1HTTPRouteSpecHeaders.type) && - Objects.equals(this.value, v1HTTPRouteSpecHeaders.value); + V1HTTPRouteSpecHeaders v1HttpRouteSpecHeaders = (V1HTTPRouteSpecHeaders) o; + return Objects.equals(this.name, v1HttpRouteSpecHeaders.name) && + Objects.equals(this.type, v1HttpRouteSpecHeaders.type) && + Objects.equals(this.value, v1HttpRouteSpecHeaders.value); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecMatches.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecMatches.java index bd9ed0cd..fc02cd28 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecMatches.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecMatches.java @@ -41,22 +41,58 @@ public class V1HTTPRouteSpecMatches { */ @JsonAdapter(MethodEnum.Adapter.class) public enum MethodEnum { + /** + * GET is an HTTP method used to request data from a specified resource. + * Commonly used to retrieve information. + */ GET("GET"), - + + /** + * HEAD is an HTTP method used to request headers from a specified resource. + * Similar to GET, but without the response body. + */ HEAD("HEAD"), - + + /** + * POST is an HTTP method used to send data to a server to create/update a resource. + * Commonly used for submitting form data or uploading files. + */ POST("POST"), - + + /** + * PUT is an HTTP method used to update or create a resource at the specified resource. + * Typically used for updating existing resources. + */ PUT("PUT"), - + + /** + * DELETE is an HTTP method used to delete a specified resource. + * Used for removing resources from the server. + */ DELETE("DELETE"), - + + /** + * CONNECT is an HTTP method used to establish a tunnel to the server identified by the target resource. + * Commonly used for tunneling HTTP requests over a network. + */ CONNECT("CONNECT"), - + + /** + * OPTIONS is an HTTP method used to describe the communication options for the target resource. + * Used to determine the capabilities of a server, such as allowed HTTP methods. + */ OPTIONS("OPTIONS"), - + + /** + * TRACE is an HTTP method used to perform a message loop-back test along the path to the target resource. + * Typically used for diagnostic purposes. + */ TRACE("TRACE"), - + + /** + * PATCH is an HTTP method used to apply partial modifications to a resource. + * Often used when you need to update a resource with a few changes rather than replacing the entire resource. + */ PATCH("PATCH"); private String value; @@ -135,11 +171,11 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteSpecMatches v1HTTPRouteSpecMatches = (V1HTTPRouteSpecMatches) o; - return Objects.equals(this.headers, v1HTTPRouteSpecMatches.headers) && - Objects.equals(this.method, v1HTTPRouteSpecMatches.method) && - Objects.equals(this.path, v1HTTPRouteSpecMatches.path) && - Objects.equals(this.queryParams, v1HTTPRouteSpecMatches.queryParams); + V1HTTPRouteSpecMatches v1HttpRouteSpecMatches = (V1HTTPRouteSpecMatches) o; + return Objects.equals(this.headers, v1HttpRouteSpecMatches.headers) && + Objects.equals(this.method, v1HttpRouteSpecMatches.method) && + Objects.equals(this.path, v1HttpRouteSpecMatches.path) && + Objects.equals(this.queryParams, v1HttpRouteSpecMatches.queryParams); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecParentRefs.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecParentRefs.java index 4c0c54af..a698961f 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecParentRefs.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecParentRefs.java @@ -58,13 +58,13 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteSpecParentRefs v1HTTPRouteSpecParentRefs = (V1HTTPRouteSpecParentRefs) o; - return Objects.equals(this.group, v1HTTPRouteSpecParentRefs.group) && - Objects.equals(this.kind, v1HTTPRouteSpecParentRefs.kind) && - Objects.equals(this.name, v1HTTPRouteSpecParentRefs.name) && - Objects.equals(this.namespace, v1HTTPRouteSpecParentRefs.namespace) && - Objects.equals(this.port, v1HTTPRouteSpecParentRefs.port) && - Objects.equals(this.sectionName, v1HTTPRouteSpecParentRefs.sectionName); + V1HTTPRouteSpecParentRefs v1HttpRouteSpecParentRefs = (V1HTTPRouteSpecParentRefs) o; + return Objects.equals(this.group, v1HttpRouteSpecParentRefs.group) && + Objects.equals(this.kind, v1HttpRouteSpecParentRefs.kind) && + Objects.equals(this.name, v1HttpRouteSpecParentRefs.name) && + Objects.equals(this.namespace, v1HttpRouteSpecParentRefs.namespace) && + Objects.equals(this.port, v1HttpRouteSpecParentRefs.port) && + Objects.equals(this.sectionName, v1HttpRouteSpecParentRefs.sectionName); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecPath.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecPath.java index 0cdf57a6..f4b12576 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecPath.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecPath.java @@ -36,10 +36,22 @@ public class V1HTTPRouteSpecPath { */ @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { + /** + * EXACT matches the path exactly as specified. + * This is a core match type and must be supported by all implementations. + */ EXACT("Exact"), - + + /** + * PATHPREFIX matches the beginning of the path against the specified value. + * This is a core match type and must be supported by all implementations. + */ PATHPREFIX("PathPrefix"), - + + /** + * REGULAREXPRESSION allows matching the path using a regular expression. + * This is an implementation-specific match type and may vary depending on the implementation. + */ REGULAREXPRESSION("RegularExpression"); private String value; @@ -97,9 +109,9 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteSpecPath v1HTTPRouteSpecPath = (V1HTTPRouteSpecPath) o; - return Objects.equals(this.type, v1HTTPRouteSpecPath.type) && - Objects.equals(this.value, v1HTTPRouteSpecPath.value); + V1HTTPRouteSpecPath v1HttpRouteSpecPath = (V1HTTPRouteSpecPath) o; + return Objects.equals(this.type, v1HttpRouteSpecPath.type) && + Objects.equals(this.value, v1HttpRouteSpecPath.value); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecQueryParams.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecQueryParams.java index 48a832c3..24f5eecb 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecQueryParams.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecQueryParams.java @@ -39,8 +39,16 @@ public class V1HTTPRouteSpecQueryParams { */ @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { + /** + * EXACT matches the query parameter value exactly as specified. + * This is an extended match type that is commonly supported by implementations. + */ EXACT("Exact"), - + + /** + * REGULAREXPRESSION allows matching the query parameter value using a regular expression. + * This is an implementation-specific match type, and the supported regular expression dialect may vary depending on the implementation. + */ REGULAREXPRESSION("RegularExpression"); private String value; @@ -98,10 +106,10 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteSpecQueryParams v1HTTPRouteSpecQueryParams = (V1HTTPRouteSpecQueryParams) o; - return Objects.equals(this.name, v1HTTPRouteSpecQueryParams.name) && - Objects.equals(this.type, v1HTTPRouteSpecQueryParams.type) && - Objects.equals(this.value, v1HTTPRouteSpecQueryParams.value); + V1HTTPRouteSpecQueryParams v1HttpRouteSpecQueryParams = (V1HTTPRouteSpecQueryParams) o; + return Objects.equals(this.name, v1HttpRouteSpecQueryParams.name) && + Objects.equals(this.type, v1HttpRouteSpecQueryParams.type) && + Objects.equals(this.value, v1HttpRouteSpecQueryParams.value); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifier.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifier.java index 9f92b8c0..8dada51c 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifier.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifier.java @@ -78,10 +78,10 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteSpecRequestHeaderModifier v1HTTPRouteSpecRequestHeaderModifier = (V1HTTPRouteSpecRequestHeaderModifier) o; - return Objects.equals(this.add, v1HTTPRouteSpecRequestHeaderModifier.add) && - Objects.equals(this.remove, v1HTTPRouteSpecRequestHeaderModifier.remove) && - Objects.equals(this.set, v1HTTPRouteSpecRequestHeaderModifier.set); + V1HTTPRouteSpecRequestHeaderModifier v1HttpRouteSpecRequestHeaderModifier = (V1HTTPRouteSpecRequestHeaderModifier) o; + return Objects.equals(this.add, v1HttpRouteSpecRequestHeaderModifier.add) && + Objects.equals(this.remove, v1HttpRouteSpecRequestHeaderModifier.remove) && + Objects.equals(this.set, v1HttpRouteSpecRequestHeaderModifier.set); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifierAdd.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifierAdd.java index 6d9409f4..1484e657 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifierAdd.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifierAdd.java @@ -42,9 +42,9 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteSpecRequestHeaderModifierAdd v1HTTPRouteSpecRequestHeaderModifierAdd = (V1HTTPRouteSpecRequestHeaderModifierAdd) o; - return Objects.equals(this.name, v1HTTPRouteSpecRequestHeaderModifierAdd.name) && - Objects.equals(this.value, v1HTTPRouteSpecRequestHeaderModifierAdd.value); + V1HTTPRouteSpecRequestHeaderModifierAdd v1HttpRouteSpecRequestHeaderModifierAdd = (V1HTTPRouteSpecRequestHeaderModifierAdd) o; + return Objects.equals(this.name, v1HttpRouteSpecRequestHeaderModifierAdd.name) && + Objects.equals(this.value, v1HttpRouteSpecRequestHeaderModifierAdd.value); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirror.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirror.java index 389e20d1..90784666 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirror.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirror.java @@ -38,8 +38,8 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteSpecRequestMirror v1HTTPRouteSpecRequestMirror = (V1HTTPRouteSpecRequestMirror) o; - return Objects.equals(this.backendRef, v1HTTPRouteSpecRequestMirror.backendRef); + V1HTTPRouteSpecRequestMirror v1HttpRouteSpecRequestMirror = (V1HTTPRouteSpecRequestMirror) o; + return Objects.equals(this.backendRef, v1HttpRouteSpecRequestMirror.backendRef); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirrorBackendRef.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirrorBackendRef.java index 441d9258..3fb454e8 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirrorBackendRef.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirrorBackendRef.java @@ -54,12 +54,12 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteSpecRequestMirrorBackendRef v1HTTPRouteSpecRequestMirrorBackendRef = (V1HTTPRouteSpecRequestMirrorBackendRef) o; - return Objects.equals(this.group, v1HTTPRouteSpecRequestMirrorBackendRef.group) && - Objects.equals(this.kind, v1HTTPRouteSpecRequestMirrorBackendRef.kind) && - Objects.equals(this.name, v1HTTPRouteSpecRequestMirrorBackendRef.name) && - Objects.equals(this.namespace, v1HTTPRouteSpecRequestMirrorBackendRef.namespace) && - Objects.equals(this.port, v1HTTPRouteSpecRequestMirrorBackendRef.port); + V1HTTPRouteSpecRequestMirrorBackendRef v1HttpRouteSpecRequestMirrorBackendRef = (V1HTTPRouteSpecRequestMirrorBackendRef) o; + return Objects.equals(this.group, v1HttpRouteSpecRequestMirrorBackendRef.group) && + Objects.equals(this.kind, v1HttpRouteSpecRequestMirrorBackendRef.kind) && + Objects.equals(this.name, v1HttpRouteSpecRequestMirrorBackendRef.name) && + Objects.equals(this.namespace, v1HttpRouteSpecRequestMirrorBackendRef.namespace) && + Objects.equals(this.port, v1HttpRouteSpecRequestMirrorBackendRef.port); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirect.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirect.java index b2c98e8c..57fc3f7c 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirect.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirect.java @@ -47,8 +47,16 @@ public class V1HTTPRouteSpecRequestRedirect { */ @JsonAdapter(SchemeEnum.Adapter.class) public enum SchemeEnum { + /** + * HTTP is used to specify that the scheme in the `Location` header should be "http". + * This is commonly used for non-secure redirects. + */ HTTP("http"), - + + /** + * HTTPS is used to specify that the scheme in the `Location` header should be "https". + * This is commonly used for secure redirects. + */ HTTPS("https"); private String value; @@ -107,12 +115,12 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteSpecRequestRedirect v1HTTPRouteSpecRequestRedirect = (V1HTTPRouteSpecRequestRedirect) o; - return Objects.equals(this.hostname, v1HTTPRouteSpecRequestRedirect.hostname) && - Objects.equals(this.path, v1HTTPRouteSpecRequestRedirect.path) && - Objects.equals(this.port, v1HTTPRouteSpecRequestRedirect.port) && - Objects.equals(this.scheme, v1HTTPRouteSpecRequestRedirect.scheme) && - Objects.equals(this.statusCode, v1HTTPRouteSpecRequestRedirect.statusCode); + V1HTTPRouteSpecRequestRedirect v1HttpRouteSpecRequestRedirect = (V1HTTPRouteSpecRequestRedirect) o; + return Objects.equals(this.hostname, v1HttpRouteSpecRequestRedirect.hostname) && + Objects.equals(this.path, v1HttpRouteSpecRequestRedirect.path) && + Objects.equals(this.port, v1HttpRouteSpecRequestRedirect.port) && + Objects.equals(this.scheme, v1HttpRouteSpecRequestRedirect.scheme) && + Objects.equals(this.statusCode, v1HttpRouteSpecRequestRedirect.statusCode); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirectPath.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirectPath.java index 1aa32be8..48e51c80 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirectPath.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirectPath.java @@ -43,8 +43,16 @@ public class V1HTTPRouteSpecRequestRedirectPath { */ @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { + /** + * REPLACEFULLPATH is used to replace the entire path of the request with a new path. + * This modifier is typically used when you need to completely change the path in a request. + */ REPLACEFULLPATH("ReplaceFullPath"), - + + /** + * REPLACEPREFIXMATCH is used to replace the matching prefix of the path in the request. + * This modifier is commonly used when you want to modify just the beginning of the path while preserving the rest. + */ REPLACEPREFIXMATCH("ReplacePrefixMatch"); private String value; @@ -98,10 +106,10 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteSpecRequestRedirectPath v1HTTPRouteSpecRequestRedirectPath = (V1HTTPRouteSpecRequestRedirectPath) o; - return Objects.equals(this.replaceFullPath, v1HTTPRouteSpecRequestRedirectPath.replaceFullPath) && - Objects.equals(this.replacePrefixMatch, v1HTTPRouteSpecRequestRedirectPath.replacePrefixMatch) && - Objects.equals(this.type, v1HTTPRouteSpecRequestRedirectPath.type); + V1HTTPRouteSpecRequestRedirectPath v1HttpRouteSpecRequestRedirectPath = (V1HTTPRouteSpecRequestRedirectPath) o; + return Objects.equals(this.replaceFullPath, v1HttpRouteSpecRequestRedirectPath.replaceFullPath) && + Objects.equals(this.replacePrefixMatch, v1HttpRouteSpecRequestRedirectPath.replacePrefixMatch) && + Objects.equals(this.type, v1HttpRouteSpecRequestRedirectPath.type); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecResponseHeaderModifier.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecResponseHeaderModifier.java index f4f99308..89633dcd 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecResponseHeaderModifier.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecResponseHeaderModifier.java @@ -72,10 +72,10 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteSpecResponseHeaderModifier v1HTTPRouteSpecResponseHeaderModifier = (V1HTTPRouteSpecResponseHeaderModifier) o; - return Objects.equals(this.add, v1HTTPRouteSpecResponseHeaderModifier.add) && - Objects.equals(this.remove, v1HTTPRouteSpecResponseHeaderModifier.remove) && - Objects.equals(this.set, v1HTTPRouteSpecResponseHeaderModifier.set); + V1HTTPRouteSpecResponseHeaderModifier v1HttpRouteSpecResponseHeaderModifier = (V1HTTPRouteSpecResponseHeaderModifier) o; + return Objects.equals(this.add, v1HttpRouteSpecResponseHeaderModifier.add) && + Objects.equals(this.remove, v1HttpRouteSpecResponseHeaderModifier.remove) && + Objects.equals(this.set, v1HttpRouteSpecResponseHeaderModifier.set); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRules.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRules.java index 48a910e4..38cba712 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRules.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRules.java @@ -73,10 +73,10 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteSpecRules v1HTTPRouteSpecRules = (V1HTTPRouteSpecRules) o; - return Objects.equals(this.backendRefs, v1HTTPRouteSpecRules.backendRefs) && - Objects.equals(this.filters, v1HTTPRouteSpecRules.filters) && - Objects.equals(this.matches, v1HTTPRouteSpecRules.matches); + V1HTTPRouteSpecRules v1HttpRouteSpecRules = (V1HTTPRouteSpecRules) o; + return Objects.equals(this.backendRefs, v1HttpRouteSpecRules.backendRefs) && + Objects.equals(this.filters, v1HttpRouteSpecRules.filters) && + Objects.equals(this.matches, v1HttpRouteSpecRules.matches); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewrite.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewrite.java index 1ad9fe73..1e615846 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewrite.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewrite.java @@ -43,9 +43,9 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteSpecUrlRewrite v1HTTPRouteSpecUrlRewrite = (V1HTTPRouteSpecUrlRewrite) o; - return Objects.equals(this.hostname, v1HTTPRouteSpecUrlRewrite.hostname) && - Objects.equals(this.path, v1HTTPRouteSpecUrlRewrite.path); + V1HTTPRouteSpecUrlRewrite v1HttpRouteSpecUrlRewrite = (V1HTTPRouteSpecUrlRewrite) o; + return Objects.equals(this.hostname, v1HttpRouteSpecUrlRewrite.hostname) && + Objects.equals(this.path, v1HttpRouteSpecUrlRewrite.path); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewritePath.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewritePath.java index fc98e077..0d662aa1 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewritePath.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewritePath.java @@ -43,8 +43,16 @@ public class V1HTTPRouteSpecUrlRewritePath { */ @JsonAdapter(TypeEnum.Adapter.class) public enum TypeEnum { + /** + * REPLACEFULLPATH replaces the entire path of the incoming request with a new specified path. + * This is useful when you want to completely override the original request path. + */ REPLACEFULLPATH("ReplaceFullPath"), - + + /** + * REPLACEPREFIXMATCH replaces the matching prefix of the path in the incoming request with a new prefix. + * This is commonly used when you need to change the beginning of the path while preserving the rest of the original path. + */ REPLACEPREFIXMATCH("ReplacePrefixMatch"); private String value; @@ -99,10 +107,10 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteSpecUrlRewritePath v1HTTPRouteSpecUrlRewritePath = (V1HTTPRouteSpecUrlRewritePath) o; - return Objects.equals(this.replaceFullPath, v1HTTPRouteSpecUrlRewritePath.replaceFullPath) && - Objects.equals(this.replacePrefixMatch, v1HTTPRouteSpecUrlRewritePath.replacePrefixMatch) && - Objects.equals(this.type, v1HTTPRouteSpecUrlRewritePath.type); + V1HTTPRouteSpecUrlRewritePath v1HttpRouteSpecUrlRewritePath = (V1HTTPRouteSpecUrlRewritePath) o; + return Objects.equals(this.replaceFullPath, v1HttpRouteSpecUrlRewritePath.replaceFullPath) && + Objects.equals(this.replacePrefixMatch, v1HttpRouteSpecUrlRewritePath.replacePrefixMatch) && + Objects.equals(this.type, v1HttpRouteSpecUrlRewritePath.type); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatus.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatus.java index 4e5c0b29..f57e6932 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatus.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatus.java @@ -45,8 +45,8 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteStatus v1HTTPRouteStatus = (V1HTTPRouteStatus) o; - return Objects.equals(this.parents, v1HTTPRouteStatus.parents); + V1HTTPRouteStatus v1HttpRouteStatus = (V1HTTPRouteStatus) o; + return Objects.equals(this.parents, v1HttpRouteStatus.parents); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusConditions.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusConditions.java index 1aa3d909..d2b6043f 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusConditions.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusConditions.java @@ -52,10 +52,19 @@ public class V1HTTPRouteStatusConditions { */ @JsonAdapter(StatusEnum.Adapter.class) public enum StatusEnum { + /** + * Represents the state where the condition is true. + */ TRUE("True"), - + + /** + * Represents the state where the condition is false. + */ FALSE("False"), - + + /** + * Represents an unknown state. + */ UNKNOWN("Unknown"); private String value; @@ -113,13 +122,13 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteStatusConditions v1HTTPRouteStatusConditions = (V1HTTPRouteStatusConditions) o; - return Objects.equals(this.lastTransitionTime, v1HTTPRouteStatusConditions.lastTransitionTime) && - Objects.equals(this.message, v1HTTPRouteStatusConditions.message) && - Objects.equals(this.observedGeneration, v1HTTPRouteStatusConditions.observedGeneration) && - Objects.equals(this.reason, v1HTTPRouteStatusConditions.reason) && - Objects.equals(this.status, v1HTTPRouteStatusConditions.status) && - Objects.equals(this.type, v1HTTPRouteStatusConditions.type); + V1HTTPRouteStatusConditions v1HttpRouteStatusConditions = (V1HTTPRouteStatusConditions) o; + return Objects.equals(this.lastTransitionTime, v1HttpRouteStatusConditions.lastTransitionTime) && + Objects.equals(this.message, v1HttpRouteStatusConditions.message) && + Objects.equals(this.observedGeneration, v1HttpRouteStatusConditions.observedGeneration) && + Objects.equals(this.reason, v1HttpRouteStatusConditions.reason) && + Objects.equals(this.status, v1HttpRouteStatusConditions.status) && + Objects.equals(this.type, v1HttpRouteStatusConditions.type); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParentRef.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParentRef.java index 1bd63bbf..83306a09 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParentRef.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParentRef.java @@ -58,13 +58,13 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteStatusParentRef v1HTTPRouteStatusParentRef = (V1HTTPRouteStatusParentRef) o; - return Objects.equals(this.group, v1HTTPRouteStatusParentRef.group) && - Objects.equals(this.kind, v1HTTPRouteStatusParentRef.kind) && - Objects.equals(this.name, v1HTTPRouteStatusParentRef.name) && - Objects.equals(this.namespace, v1HTTPRouteStatusParentRef.namespace) && - Objects.equals(this.port, v1HTTPRouteStatusParentRef.port) && - Objects.equals(this.sectionName, v1HTTPRouteStatusParentRef.sectionName); + V1HTTPRouteStatusParentRef v1HttpRouteStatusParentRef = (V1HTTPRouteStatusParentRef) o; + return Objects.equals(this.group, v1HttpRouteStatusParentRef.group) && + Objects.equals(this.kind, v1HttpRouteStatusParentRef.kind) && + Objects.equals(this.name, v1HttpRouteStatusParentRef.name) && + Objects.equals(this.namespace, v1HttpRouteStatusParentRef.namespace) && + Objects.equals(this.port, v1HttpRouteStatusParentRef.port) && + Objects.equals(this.sectionName, v1HttpRouteStatusParentRef.sectionName); } @Override diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParents.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParents.java index 8d1aacd2..cc5a6889 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParents.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParents.java @@ -57,10 +57,10 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - V1HTTPRouteStatusParents v1HTTPRouteStatusParents = (V1HTTPRouteStatusParents) o; - return Objects.equals(this.conditions, v1HTTPRouteStatusParents.conditions) && - Objects.equals(this.controllerName, v1HTTPRouteStatusParents.controllerName) && - Objects.equals(this.parentRef, v1HTTPRouteStatusParents.parentRef); + V1HTTPRouteStatusParents v1HttpRouteStatusParents = (V1HTTPRouteStatusParents) o; + return Objects.equals(this.conditions, v1HttpRouteStatusParents.conditions) && + Objects.equals(this.controllerName, v1HttpRouteStatusParents.controllerName) && + Objects.equals(this.parentRef, v1HttpRouteStatusParents.parentRef); } @Override From 2e18b4b143b8e28b2937350e518104ffbd6b148d Mon Sep 17 00:00:00 2001 From: zxlin <860620266@qq.com> Date: Mon, 2 Sep 2024 10:52:33 +0800 Subject: [PATCH 07/24] Refactor: modify codestyle of modelConverter and clientService Refactor: modify codestyle --- .../kubernetes/KubernetesClientService.java | 39 ++++++++++++++----- .../kubernetes/KubernetesModelConverter.java | 11 +++--- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java index b1c6b6e6..86b24348 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java @@ -21,7 +21,14 @@ import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Paths; -import java.util.*; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.HashMap; +import java.util.ArrayList; +import java.util.Comparator; import com.alibaba.higress.sdk.constant.HigressConstants; import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gatewayclass.V1GatewayClass; @@ -29,7 +36,19 @@ import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways.V1Gateway; import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways.V1GatewayList; import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways.V1GatewaySpecListeners; -import io.kubernetes.client.openapi.models.*; + +import io.kubernetes.client.openapi.models.V1APIResource; +import io.kubernetes.client.openapi.models.V1ConfigMap; +import io.kubernetes.client.openapi.models.V1ConfigMapList; +import io.kubernetes.client.openapi.models.V1Ingress; +import io.kubernetes.client.openapi.models.V1IngressList; +import io.kubernetes.client.openapi.models.V1ObjectMeta; +import io.kubernetes.client.openapi.models.V1Secret; +import io.kubernetes.client.openapi.models.V1SecretList; +import io.kubernetes.client.openapi.models.V1Service; +import io.kubernetes.client.openapi.models.V1ServicePort; +import io.kubernetes.client.openapi.models.V1Status; + import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; @@ -155,7 +174,7 @@ private void initGatewayClass() { V1GatewayClass.PLURAL, V1GatewayClass.DEFAULT_NAME); log.info("GatewayClass already exists: " + existingGatewayClass); } catch (ApiException e) { - if (e.getCode() == HttpStatus.NOT_FOUND) { // 如果不存在,则创建新的 GatewayClass + if (e.getCode() == HttpStatus.NOT_FOUND) { // if not exist, create new GatewayClass try { Object response = customObjectsApi.createClusterCustomObject(V1GatewayClass.API_GROUP, V1GatewayClass.VERSION, V1GatewayClass.PLURAL, gatewayClass, null, null, null); @@ -172,7 +191,7 @@ private void initGatewayClass() { } private void getIngressOrGatewayMode(){ - // 读取全局配置,看当前是ingress or gateway 模式 + // read config, check if ingress or gateway mode V1ConfigMap higressConfig; try { higressConfig = readConfigMap(HigressConstants.DEFAULT_CONFIG); @@ -556,15 +575,16 @@ public V1Gateway readGateway(String name) throws ApiException { public void modifyLoadBalancerPorts(V1Gateway gatewayOri, V1Gateway gatewayReplaced) { CoreV1Api coreV1Api = new CoreV1Api(client); try { - // 获取配置中的端口计数 + // get port counter from config V1ConfigMap portConfig = readOrCreateConfigMap(HigressConstants.PORT_CONFIG); Map portCount = portConfig.getData(); - if (portCount == null) portCount = new HashMap<>(); + if (portCount == null) { + portCount = new HashMap<>(); + } V1Service service = coreV1Api.readNamespacedService(V1GatewayClass.DEFAULT_NAME, controllerNamespace, null); List ports = Objects.requireNonNull(service.getSpec()).getPorts(); assert ports != null; - // 合并端口监听列表并统计端口出现频率 Map portFrequency = new HashMap<>(); if(gatewayOri != null){ List listenersOri = gatewayOri.getSpec().getListeners(); @@ -582,12 +602,13 @@ public void modifyLoadBalancerPorts(V1Gateway gatewayOri, V1Gateway gatewayRepla for (Map.Entry entry : portFrequency.entrySet()) { Integer port = entry.getKey(); Integer freq = entry.getValue(); - if(port == 80 || port == 443 || freq == 0) continue; + if(port == 80 || port == 443 || freq == 0) { + continue; + } int count = Integer.parseInt(portCount.getOrDefault(port.toString(), "0")) + (freq>0?1:-1); if (count <= 0) { portCount.remove(port.toString()); - // 删除端口 ports.removeIf(p -> p.getPort().equals(port)); } else { portCount.put(port.toString(), Integer.toString(count)); diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java index aed4abb9..2414a1e3 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java @@ -40,7 +40,10 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONException; import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gatewayclass.V1GatewayClass; -import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways.*; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways.V1Gateway; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways.V1GatewaySpec; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways.V1GatewaySpecListeners; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways.V1GatewaySpecTls; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.ObjectUtils; @@ -95,7 +98,6 @@ import io.kubernetes.client.openapi.models.V1TypedLocalObjectReference; import io.kubernetes.client.util.Strings; import lombok.extern.slf4j.Slf4j; -import org.jetbrains.annotations.NotNull; /** * @author CH3CHO @@ -215,7 +217,6 @@ public V1Gateway domain2Gateway(Domain domain){ spec.setGatewayClassName(V1GatewayClass.DEFAULT_NAME); List listeners = new ArrayList<>(); if (domain.getPortAndCertMap().isEmpty()){ - // 提示错误信息 log.error("Domain must have at least one port!"); return null; } @@ -225,7 +226,7 @@ public V1Gateway domain2Gateway(Domain domain){ listener.setPort(port); listener.setHostname(domain.getName()); listener.setProtocol("HTTP"); - if(!"".equals(cert)){ //证书不为空 + if(!"".equals(cert)){ //tls is not null listener.setProtocol("HTTPS"); V1GatewaySpecTls tls = V1GatewaySpecListeners.getDefaultTls(cert); listener.setTls(tls); @@ -333,7 +334,7 @@ public Domain configMap2Domain(V1ConfigMap configMap) { try { domain.setPortAndCertMap(JSON.parseObject(certData, Map.class)); }catch(JSONException e){ - // 原先ingress模式下的cert + // ingress-left cert Map portCertMap = new HashMap<>(); portCertMap.put(443, certData); domain.setPortAndCertMap(portCertMap); From 058874f289c84727a1f727aa989f714826c10356 Mon Sep 17 00:00:00 2001 From: zxlin <860620266@qq.com> Date: Mon, 2 Sep 2024 11:44:52 +0800 Subject: [PATCH 08/24] Refactor: modify codestyle and add license Refactor: modify codestyle and change code level Refactor: modify codestyle and change code level --- .../gatewayclass/V1GatewayClass.java | 64 ++-- .../gatewayclass/V1GatewayClassList.java | 46 ++- .../gatewayclass/V1GatewayClassSpec.java | 42 ++- .../V1GatewayClassSpecParametersRef.java | 45 ++- .../gatewayclass/V1GatewayClassStatus.java | 39 +-- .../V1GatewayClassStatusConditions.java | 158 ++++----- .../crd/gatewayapi/gateways/V1Gateway.java | 142 ++++---- .../gatewayapi/gateways/V1GatewayList.java | 128 ++++--- .../gatewayapi/gateways/V1GatewaySpec.java | 137 ++++---- .../gateways/V1GatewaySpecAddresses.java | 96 +++--- .../gateways/V1GatewaySpecAllowedRoutes.java | 114 +++---- .../V1GatewaySpecAllowedRoutesKinds.java | 95 +++--- .../V1GatewaySpecAllowedRoutesNamespaces.java | 185 +++++----- ...aySpecAllowedRoutesNamespacesSelector.java | 144 ++++---- ...tesNamespacesSelectorMatchExpressions.java | 122 ++++--- .../gateways/V1GatewaySpecListeners.java | 181 +++++----- .../gatewayapi/gateways/V1GatewaySpecTls.java | 244 +++++++------ .../V1GatewaySpecTlsCertificateRefs.java | 121 ++++--- .../gatewayapi/gateways/V1GatewayStatus.java | 144 ++++---- .../gateways/V1GatewayStatusAddresses.java | 95 +++--- .../gateways/V1GatewayStatusConditions.java | 237 ++++++------- .../gateways/V1GatewayStatusListeners.java | 135 ++++---- .../crd/gatewayapi/httproute/V1HTTPRoute.java | 140 ++++---- .../gatewayapi/httproute/V1HTTPRouteList.java | 126 ++++--- .../gatewayapi/httproute/V1HTTPRouteSpec.java | 130 ++++--- .../httproute/V1HTTPRouteSpecBackendRefs.java | 164 +++++---- .../V1HTTPRouteSpecExtensionRef.java | 106 +++--- .../httproute/V1HTTPRouteSpecFilters.java | 292 ++++++++-------- .../httproute/V1HTTPRouteSpecHeaders.java | 194 +++++------ .../httproute/V1HTTPRouteSpecMatches.java | 322 +++++++++--------- .../httproute/V1HTTPRouteSpecParentRefs.java | 143 ++++---- .../httproute/V1HTTPRouteSpecPath.java | 196 ++++++----- .../httproute/V1HTTPRouteSpecQueryParams.java | 195 +++++------ .../V1HTTPRouteSpecRequestHeaderModifier.java | 161 +++++---- ...HTTPRouteSpecRequestHeaderModifierAdd.java | 95 +++--- .../V1HTTPRouteSpecRequestMirror.java | 84 +++-- ...1HTTPRouteSpecRequestMirrorBackendRef.java | 133 ++++---- .../V1HTTPRouteSpecRequestRedirect.java | 219 ++++++------ .../V1HTTPRouteSpecRequestRedirectPath.java | 199 ++++++----- ...V1HTTPRouteSpecResponseHeaderModifier.java | 145 ++++---- .../httproute/V1HTTPRouteSpecRules.java | 148 ++++---- .../httproute/V1HTTPRouteSpecUrlRewrite.java | 96 +++--- .../V1HTTPRouteSpecUrlRewritePath.java | 197 ++++++----- .../httproute/V1HTTPRouteStatus.java | 92 +++-- .../V1HTTPRouteStatusConditions.java | 235 ++++++------- .../httproute/V1HTTPRouteStatusParentRef.java | 144 ++++---- .../httproute/V1HTTPRouteStatusParents.java | 122 ++++--- .../referencegrant/V1beta1ReferenceGrant.java | 135 ++++---- .../V1beta1ReferenceGrantList.java | 129 ++++--- .../V1beta1ReferenceGrantSpec.java | 104 +++--- .../V1beta1ReferenceGrantSpecFrom.java | 106 +++--- .../V1beta1ReferenceGrantSpecTo.java | 106 +++--- 52 files changed, 3551 insertions(+), 3821 deletions(-) diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClass.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClass.java index 47986f0c..4c0f63e1 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClass.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClass.java @@ -1,13 +1,14 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ @@ -16,37 +17,32 @@ import com.google.gson.annotations.SerializedName; import io.kubernetes.client.openapi.models.V1ObjectMeta; import lombok.Data; -import java.util.Objects; @Data public class V1GatewayClass implements io.kubernetes.client.common.KubernetesObject { - public static final String API_GROUP = "gateway.networking.k8s.io"; - public static final String VERSION = "v1"; - public static final String KIND = "GatewayClass"; - public static final String PLURAL = "gatewayclasses"; - public static final String DEFAULT_NAME = "higress-gateway"; - - - public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; - @SerializedName(SERIALIZED_NAME_API_VERSION) - private String apiVersion = API_GROUP + "/" + VERSION; - - public static final String SERIALIZED_NAME_KIND = "kind"; - @SerializedName(SERIALIZED_NAME_KIND) - private String kind = KIND; - - public static final String SERIALIZED_NAME_METADATA = "metadata"; - @SerializedName(SERIALIZED_NAME_METADATA) - private V1ObjectMeta metadata = null; - - public static final String SERIALIZED_NAME_SPEC = "spec"; - @SerializedName(SERIALIZED_NAME_SPEC) - private V1GatewayClassSpec spec; - - public static final String SERIALIZED_NAME_STATUS = "status"; - @SerializedName(SERIALIZED_NAME_STATUS) - private V1GatewayClassStatus status; + public static final String API_GROUP = "gateway.networking.k8s.io"; + public static final String VERSION = "v1"; + public static final String KIND = "GatewayClass"; + public static final String PLURAL = "gatewayclasses"; + public static final String DEFAULT_NAME = "higress-gateway"; + + + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; + public static final String SERIALIZED_NAME_KIND = "kind"; + public static final String SERIALIZED_NAME_METADATA = "metadata"; + public static final String SERIALIZED_NAME_SPEC = "spec"; + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_API_VERSION) + private String apiVersion = API_GROUP + "/" + VERSION; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind = KIND; + @SerializedName(SERIALIZED_NAME_METADATA) + private V1ObjectMeta metadata = null; + @SerializedName(SERIALIZED_NAME_SPEC) + private V1GatewayClassSpec spec; + @SerializedName(SERIALIZED_NAME_STATUS) + private V1GatewayClassStatus status; } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassList.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassList.java index 3f3116ac..46218e1e 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassList.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassList.java @@ -1,13 +1,14 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ @@ -15,35 +16,28 @@ import com.google.gson.annotations.SerializedName; import io.kubernetes.client.openapi.models.V1ListMeta; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.ArrayList; import java.util.List; -import java.util.Objects; /** * GatewayClassList is a list of GatewayClass */ @Data public class V1GatewayClassList implements io.kubernetes.client.common.KubernetesListObject { - public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; - @SerializedName(SERIALIZED_NAME_API_VERSION) - private String apiVersion; - - public static final String SERIALIZED_NAME_ITEMS = "items"; - @SerializedName(SERIALIZED_NAME_ITEMS) - private List items = new ArrayList<>(); - - public static final String SERIALIZED_NAME_KIND = "kind"; - @SerializedName(SERIALIZED_NAME_KIND) - private String kind; - - public static final String SERIALIZED_NAME_METADATA = "metadata"; - @SerializedName(SERIALIZED_NAME_METADATA) - private V1ListMeta metadata = null; - + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; + public static final String SERIALIZED_NAME_ITEMS = "items"; + public static final String SERIALIZED_NAME_KIND = "kind"; + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_API_VERSION) + private String apiVersion; + @SerializedName(SERIALIZED_NAME_ITEMS) + private List items = new ArrayList<>(); + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + @SerializedName(SERIALIZED_NAME_METADATA) + private V1ListMeta metadata = null; } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassSpec.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassSpec.java index a809eb02..3ae13613 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassSpec.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassSpec.java @@ -1,42 +1,38 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gatewayclass; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import java.util.Objects; - /** * Spec defines the desired state of GatewayClass. */ @Data public class V1GatewayClassSpec { - public static final String CONTROLLER_NAME = "higress.io/gateway-controller"; - - public static final String SERIALIZED_NAME_CONTROLLER_NAME = "controllerName"; - @SerializedName(SERIALIZED_NAME_CONTROLLER_NAME) - private String controllerName = CONTROLLER_NAME; - - public static final String SERIALIZED_NAME_DESCRIPTION = "description"; - @SerializedName(SERIALIZED_NAME_DESCRIPTION) - private String description; - - public static final String SERIALIZED_NAME_PARAMETERS_REF = "parametersRef"; - @SerializedName(SERIALIZED_NAME_PARAMETERS_REF) - private V1GatewayClassSpecParametersRef parametersRef; + public static final String CONTROLLER_NAME = "higress.io/gateway-controller"; + + public static final String SERIALIZED_NAME_CONTROLLER_NAME = "controllerName"; + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + public static final String SERIALIZED_NAME_PARAMETERS_REF = "parametersRef"; + @SerializedName(SERIALIZED_NAME_CONTROLLER_NAME) + private String controllerName = CONTROLLER_NAME; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + private String description; + @SerializedName(SERIALIZED_NAME_PARAMETERS_REF) + private V1GatewayClassSpecParametersRef parametersRef; } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassSpecParametersRef.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassSpecParametersRef.java index 75de4943..6760fe42 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassSpecParametersRef.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassSpecParametersRef.java @@ -1,45 +1,40 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gatewayclass; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import java.util.Objects; /** * ParametersRef is a reference to a resource that contains the configuration parameters corresponding to the GatewayClass. This is optional if the controller does not require any additional configuration. ParametersRef can reference a standard Kubernetes resource, i.e. ConfigMap, or an implementation-specific custom resource. The resource can be cluster-scoped or namespace-scoped. If the referent cannot be found, refers to an unsupported kind, or when the data within that resource is malformed, the GatewayClass SHOULD be rejected with the \"Accepted\" status condition set to \"False\" and an \"InvalidParameters\" reason. A Gateway for this GatewayClass may provide its own `parametersRef`. When both are specified, the merging behavior is implementation specific. It is generally recommended that GatewayClass provides defaults that can be overridden by a Gateway. Support: Implementation-specific */ @Data public class V1GatewayClassSpecParametersRef { - static final String SERIALIZED_NAME_GROUP = "group"; - @SerializedName(SERIALIZED_NAME_GROUP) - private String group; - - public static final String SERIALIZED_NAME_KIND = "kind"; - @SerializedName(SERIALIZED_NAME_KIND) - private String kind; - - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) - private String name; - - public static final String SERIALIZED_NAME_NAMESPACE = "namespace"; - @SerializedName(SERIALIZED_NAME_NAMESPACE) - private String namespace; + public static final String SERIALIZED_NAME_KIND = "kind"; + public static final String SERIALIZED_NAME_NAME = "name"; + public static final String SERIALIZED_NAME_NAMESPACE = "namespace"; + static final String SERIALIZED_NAME_GROUP = "group"; + @SerializedName(SERIALIZED_NAME_GROUP) + private String group; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + @SerializedName(SERIALIZED_NAME_NAMESPACE) + private String namespace; } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassStatus.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassStatus.java index 29faa324..eb0699f3 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassStatus.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassStatus.java @@ -1,43 +1,40 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gatewayclass; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.ArrayList; import java.util.List; -import java.util.Objects; /** * Status defines the current state of GatewayClass. Implementations MUST populate status on all GatewayClass resources which specify their controller name. */ @Data public class V1GatewayClassStatus { - - public static final String SERIALIZED_NAME_CONDITIONS = "conditions"; - @SerializedName(SERIALIZED_NAME_CONDITIONS) - private List conditions = null; - - public V1GatewayClassStatus addConditionsItem(V1GatewayClassStatusConditions conditionsItem) { - if (this.conditions == null) { - this.conditions = new ArrayList<>(); + public static final String SERIALIZED_NAME_CONDITIONS = "conditions"; + @SerializedName(SERIALIZED_NAME_CONDITIONS) + private List conditions = null; + + public V1GatewayClassStatus addConditionsItem(V1GatewayClassStatusConditions conditionsItem) { + if (this.conditions == null) { + this.conditions = new ArrayList<>(); + } + this.conditions.add(conditionsItem); + return this; } - this.conditions.add(conditionsItem); - return this; - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassStatusConditions.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassStatusConditions.java index 068a4bca..d093653d 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassStatusConditions.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gatewayclass/V1GatewayClassStatusConditions.java @@ -1,13 +1,14 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ @@ -18,13 +19,10 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.IOException; import java.time.OffsetDateTime; -import java.util.Objects; /** * Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` // other fields } @@ -32,86 +30,80 @@ @Data public class V1GatewayClassStatusConditions { - public static final String SERIALIZED_NAME_LAST_TRANSITION_TIME = "lastTransitionTime"; - @SerializedName(SERIALIZED_NAME_LAST_TRANSITION_TIME) - private OffsetDateTime lastTransitionTime; - - public static final String SERIALIZED_NAME_MESSAGE = "message"; - @SerializedName(SERIALIZED_NAME_MESSAGE) - private String message; - - public static final String SERIALIZED_NAME_OBSERVED_GENERATION = "observedGeneration"; - @SerializedName(SERIALIZED_NAME_OBSERVED_GENERATION) - private Long observedGeneration; - - public static final String SERIALIZED_NAME_REASON = "reason"; - @SerializedName(SERIALIZED_NAME_REASON) - private String reason; - - /** - * status of the condition, one of True, False, Unknown. - */ - @JsonAdapter(StatusEnum.Adapter.class) - public enum StatusEnum { - /** - * Represents the state where the condition is true. - */ - TRUE("True"), - - /** - * Represents the state where the condition is false. - */ - FALSE("False"), - + public static final String SERIALIZED_NAME_LAST_TRANSITION_TIME = "lastTransitionTime"; + public static final String SERIALIZED_NAME_MESSAGE = "message"; + public static final String SERIALIZED_NAME_OBSERVED_GENERATION = "observedGeneration"; + public static final String SERIALIZED_NAME_REASON = "reason"; + public static final String SERIALIZED_NAME_STATUS = "status"; + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_LAST_TRANSITION_TIME) + private OffsetDateTime lastTransitionTime; + @SerializedName(SERIALIZED_NAME_MESSAGE) + private String message; + @SerializedName(SERIALIZED_NAME_OBSERVED_GENERATION) + private Long observedGeneration; + @SerializedName(SERIALIZED_NAME_REASON) + private String reason; + @SerializedName(SERIALIZED_NAME_STATUS) + private StatusEnum status; + @SerializedName(SERIALIZED_NAME_TYPE) + private String type; /** - * Represents an unknown state. + * status of the condition, one of True, False, Unknown. */ - UNKNOWN("Unknown"); - - private String value; - - StatusEnum(String value) { - this.value = value; - } + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + /** + * Represents the state where the condition is true. + */ + TRUE("True"), + + /** + * Represents the state where the condition is false. + */ + FALSE("False"), + + /** + * Represents an unknown state. + */ + UNKNOWN("Unknown"); + + private final String value; + + StatusEnum(String value) { + this.value = value; + } - public String getValue() { - return value; - } + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } - @Override - public String toString() { - return String.valueOf(value); - } + public String getValue() { + return value; + } - public static StatusEnum fromValue(String value) { - for (StatusEnum b : StatusEnum.values()) { - if (b.value.equals(value)) { - return b; + @Override + public String toString() { + return String.valueOf(value); } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public StatusEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return StatusEnum.fromValue(value); - } + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } } - } - - public static final String SERIALIZED_NAME_STATUS = "status"; - @SerializedName(SERIALIZED_NAME_STATUS) - private StatusEnum status; - - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) - private String type; } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1Gateway.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1Gateway.java index 6579b367..394a39b5 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1Gateway.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1Gateway.java @@ -1,13 +1,14 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ @@ -15,8 +16,6 @@ import com.google.gson.annotations.SerializedName; import io.kubernetes.client.openapi.models.V1ObjectMeta; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Objects; @@ -26,77 +25,72 @@ */ @Data public class V1Gateway implements io.kubernetes.client.common.KubernetesObject { - public static final String API_GROUP = "gateway.networking.k8s.io"; - public static final String VERSION = "v1"; - public static final String KIND = "Gateway"; - public static final String PLURAL = "gateways"; - - public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; - @SerializedName(SERIALIZED_NAME_API_VERSION) - private String apiVersion = API_GROUP + "/" + VERSION; - - public static final String SERIALIZED_NAME_KIND = "kind"; - @SerializedName(SERIALIZED_NAME_KIND) - private String kind = KIND; - - public static final String SERIALIZED_NAME_METADATA = "metadata"; - @SerializedName(SERIALIZED_NAME_METADATA) - private V1ObjectMeta metadata = null; - - public static final String SERIALIZED_NAME_SPEC = "spec"; - @SerializedName(SERIALIZED_NAME_SPEC) - private V1GatewaySpec spec; - - public static final String SERIALIZED_NAME_STATUS = "status"; - @SerializedName(SERIALIZED_NAME_STATUS) - private V1GatewayStatus status; - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; + public static final String API_GROUP = "gateway.networking.k8s.io"; + public static final String VERSION = "v1"; + public static final String KIND = "Gateway"; + public static final String PLURAL = "gateways"; + + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; + public static final String SERIALIZED_NAME_KIND = "kind"; + public static final String SERIALIZED_NAME_METADATA = "metadata"; + public static final String SERIALIZED_NAME_SPEC = "spec"; + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_API_VERSION) + private String apiVersion = API_GROUP + "/" + VERSION; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind = KIND; + @SerializedName(SERIALIZED_NAME_METADATA) + private V1ObjectMeta metadata = null; + @SerializedName(SERIALIZED_NAME_SPEC) + private V1GatewaySpec spec; + @SerializedName(SERIALIZED_NAME_STATUS) + private V1GatewayStatus status; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1Gateway v1Gateway = (V1Gateway) o; + return Objects.equals(this.apiVersion, v1Gateway.apiVersion) && + Objects.equals(this.kind, v1Gateway.kind) && + Objects.equals(this.metadata, v1Gateway.metadata) && + Objects.equals(this.spec, v1Gateway.spec) && + Objects.equals(this.status, v1Gateway.status); } - V1Gateway v1Gateway = (V1Gateway) o; - return Objects.equals(this.apiVersion, v1Gateway.apiVersion) && - Objects.equals(this.kind, v1Gateway.kind) && - Objects.equals(this.metadata, v1Gateway.metadata) && - Objects.equals(this.spec, v1Gateway.spec) && - Objects.equals(this.status, v1Gateway.status); - } - @Override - public int hashCode() { - return Objects.hash(apiVersion, kind, metadata, spec, status); - } + @Override + public int hashCode() { + return Objects.hash(apiVersion, kind, metadata, spec, status); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1beta1Gateway {\n"); - sb.append(" apiVersion: ").append(toIndentedString(apiVersion)).append("\n"); - sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); - sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); - sb.append(" spec: ").append(toIndentedString(spec)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1beta1Gateway {\n" + + " apiVersion: " + toIndentedString(apiVersion) + "\n" + + " kind: " + toIndentedString(kind) + "\n" + + " metadata: " + toIndentedString(metadata) + "\n" + + " spec: " + toIndentedString(spec) + "\n" + + " status: " + toIndentedString(status) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayList.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayList.java index c2047c0c..298bf7a9 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayList.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayList.java @@ -1,13 +1,14 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ @@ -15,8 +16,6 @@ import com.google.gson.annotations.SerializedName; import io.kubernetes.client.openapi.models.V1ListMeta; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.ArrayList; @@ -28,71 +27,66 @@ */ @Data public class V1GatewayList implements io.kubernetes.client.common.KubernetesListObject { - public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; - @SerializedName(SERIALIZED_NAME_API_VERSION) - private String apiVersion; - - public static final String SERIALIZED_NAME_ITEMS = "items"; - @SerializedName(SERIALIZED_NAME_ITEMS) - private List items = new ArrayList<>(); - - - public static final String SERIALIZED_NAME_KIND = "kind"; - @SerializedName(SERIALIZED_NAME_KIND) - private String kind; - - public static final String SERIALIZED_NAME_METADATA = "metadata"; - @SerializedName(SERIALIZED_NAME_METADATA) - private V1ListMeta metadata = null; - - public V1GatewayList addItemsItem(V1Gateway itemsItem) { - this.items.add(itemsItem); - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; + public static final String SERIALIZED_NAME_ITEMS = "items"; + public static final String SERIALIZED_NAME_KIND = "kind"; + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_API_VERSION) + private String apiVersion; + @SerializedName(SERIALIZED_NAME_ITEMS) + private List items = new ArrayList<>(); + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + @SerializedName(SERIALIZED_NAME_METADATA) + private V1ListMeta metadata = null; + + public V1GatewayList addItemsItem(V1Gateway itemsItem) { + this.items.add(itemsItem); + return this; } - if (o == null || getClass() != o.getClass()) { - return false; + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewayList v1GatewayList = (V1GatewayList) o; + return Objects.equals(this.apiVersion, v1GatewayList.apiVersion) && + Objects.equals(this.items, v1GatewayList.items) && + Objects.equals(this.kind, v1GatewayList.kind) && + Objects.equals(this.metadata, v1GatewayList.metadata); } - V1GatewayList v1GatewayList = (V1GatewayList) o; - return Objects.equals(this.apiVersion, v1GatewayList.apiVersion) && - Objects.equals(this.items, v1GatewayList.items) && - Objects.equals(this.kind, v1GatewayList.kind) && - Objects.equals(this.metadata, v1GatewayList.metadata); - } - @Override - public int hashCode() { - return Objects.hash(apiVersion, items, kind, metadata); - } + @Override + public int hashCode() { + return Objects.hash(apiVersion, items, kind, metadata); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1beta1GatewayList {\n"); - sb.append(" apiVersion: ").append(toIndentedString(apiVersion)).append("\n"); - sb.append(" items: ").append(toIndentedString(items)).append("\n"); - sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); - sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1beta1GatewayList {\n" + + " apiVersion: " + toIndentedString(apiVersion) + "\n" + + " items: " + toIndentedString(items) + "\n" + + " kind: " + toIndentedString(kind) + "\n" + + " metadata: " + toIndentedString(metadata) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpec.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpec.java index fbe48cd8..5148ee0b 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpec.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpec.java @@ -1,21 +1,19 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ - package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.ArrayList; @@ -27,76 +25,73 @@ */ @Data public class V1GatewaySpec { - public static final String HIGRESS_GATEWAY_SERVICE = "higress-gateway.higress-system.svc.cluster.local"; - - public static final String SERIALIZED_NAME_ADDRESSES = "addresses"; - @SerializedName(SERIALIZED_NAME_ADDRESSES) - private List addresses = null; - - public static final String SERIALIZED_NAME_GATEWAY_CLASS_NAME = "gatewayClassName"; - @SerializedName(SERIALIZED_NAME_GATEWAY_CLASS_NAME) - private String gatewayClassName; - - public static final String SERIALIZED_NAME_LISTENERS = "listeners"; - @SerializedName(SERIALIZED_NAME_LISTENERS) - private List listeners = new ArrayList<>(); - - public V1GatewaySpec addAddressesItem(V1GatewaySpecAddresses addressesItem) { - if (this.addresses == null) { - this.addresses = new ArrayList<>(); + public static final String HIGRESS_GATEWAY_SERVICE = "higress-gateway.higress-system.svc.cluster.local"; + + public static final String SERIALIZED_NAME_ADDRESSES = "addresses"; + public static final String SERIALIZED_NAME_GATEWAY_CLASS_NAME = "gatewayClassName"; + public static final String SERIALIZED_NAME_LISTENERS = "listeners"; + @SerializedName(SERIALIZED_NAME_ADDRESSES) + private List addresses = null; + @SerializedName(SERIALIZED_NAME_GATEWAY_CLASS_NAME) + private String gatewayClassName; + @SerializedName(SERIALIZED_NAME_LISTENERS) + private List listeners = new ArrayList<>(); + + public V1GatewaySpec addAddressesItem(V1GatewaySpecAddresses addressesItem) { + if (this.addresses == null) { + this.addresses = new ArrayList<>(); + } + this.addresses.add(addressesItem); + return this; } - this.addresses.add(addressesItem); - return this; - } - - public V1GatewaySpec addDefaultAddress(){ - V1GatewaySpecAddresses addressesItem = new V1GatewaySpecAddresses(); - addressesItem.setType("Hostname"); - addressesItem.setValue(HIGRESS_GATEWAY_SERVICE); - return addAddressesItem(addressesItem); - } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; + public V1GatewaySpec addDefaultAddress() { + V1GatewaySpecAddresses addressesItem = new V1GatewaySpecAddresses(); + addressesItem.setType("Hostname"); + addressesItem.setValue(HIGRESS_GATEWAY_SERVICE); + return addAddressesItem(addressesItem); } - if (o == null || getClass() != o.getClass()) { - return false; + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewaySpec v1GatewaySpec = (V1GatewaySpec) o; + return Objects.equals(this.addresses, v1GatewaySpec.addresses) && + Objects.equals(this.gatewayClassName, v1GatewaySpec.gatewayClassName) && + Objects.equals(this.listeners, v1GatewaySpec.listeners); } - V1GatewaySpec v1GatewaySpec = (V1GatewaySpec) o; - return Objects.equals(this.addresses, v1GatewaySpec.addresses) && - Objects.equals(this.gatewayClassName, v1GatewaySpec.gatewayClassName) && - Objects.equals(this.listeners, v1GatewaySpec.listeners); - } - @Override - public int hashCode() { - return Objects.hash(addresses, gatewayClassName, listeners); - } + @Override + public int hashCode() { + return Objects.hash(addresses, gatewayClassName, listeners); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1beta1GatewaySpec {\n"); - sb.append(" addresses: ").append(toIndentedString(addresses)).append("\n"); - sb.append(" gatewayClassName: ").append(toIndentedString(gatewayClassName)).append("\n"); - sb.append(" listeners: ").append(toIndentedString(listeners)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1beta1GatewaySpec {\n" + + " addresses: " + toIndentedString(addresses) + "\n" + + " gatewayClassName: " + toIndentedString(gatewayClassName) + "\n" + + " listeners: " + toIndentedString(listeners) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAddresses.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAddresses.java index 59bfb0fc..d408b927 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAddresses.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAddresses.java @@ -1,21 +1,20 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Objects; @@ -25,55 +24,52 @@ */ @Data public class V1GatewaySpecAddresses { - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) - private String type; - - - public static final String SERIALIZED_NAME_VALUE = "value"; - @SerializedName(SERIALIZED_NAME_VALUE) - private String value; + public static final String SERIALIZED_NAME_TYPE = "type"; + public static final String SERIALIZED_NAME_VALUE = "value"; + @SerializedName(SERIALIZED_NAME_TYPE) + private String type; + @SerializedName(SERIALIZED_NAME_VALUE) + private String value; - @Override - public boolean equals(Object o) { - if (this == o) { - return true; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewaySpecAddresses v1GatewaySpecAddresses = (V1GatewaySpecAddresses) o; + return Objects.equals(this.type, v1GatewaySpecAddresses.type) && + Objects.equals(this.value, v1GatewaySpecAddresses.value); } - if (o == null || getClass() != o.getClass()) { - return false; - } - V1GatewaySpecAddresses v1GatewaySpecAddresses = (V1GatewaySpecAddresses) o; - return Objects.equals(this.type, v1GatewaySpecAddresses.type) && - Objects.equals(this.value, v1GatewaySpecAddresses.value); - } - @Override - public int hashCode() { - return Objects.hash(type, value); - } + @Override + public int hashCode() { + return Objects.hash(type, value); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1beta1GatewaySpecAddresses {\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" value: ").append(toIndentedString(value)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1beta1GatewaySpecAddresses {\n" + + " type: " + toIndentedString(type) + "\n" + + " value: " + toIndentedString(value) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutes.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutes.java index 8b5f9654..d3e85fbe 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutes.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutes.java @@ -1,21 +1,20 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.ArrayList; @@ -27,66 +26,61 @@ */ @Data public class V1GatewaySpecAllowedRoutes { - public static final String SERIALIZED_NAME_KINDS = "kinds"; - @SerializedName(SERIALIZED_NAME_KINDS) - private List kinds = null; - - - public static final String SERIALIZED_NAME_NAMESPACES = "namespaces"; - @SerializedName(SERIALIZED_NAME_NAMESPACES) - private V1GatewaySpecAllowedRoutesNamespaces namespaces; - - - public V1GatewaySpecAllowedRoutes addKindsItem(V1GatewaySpecAllowedRoutesKinds kindsItem) { - if (this.kinds == null) { - this.kinds = new ArrayList<>(); + public static final String SERIALIZED_NAME_KINDS = "kinds"; + public static final String SERIALIZED_NAME_NAMESPACES = "namespaces"; + @SerializedName(SERIALIZED_NAME_KINDS) + private List kinds = null; + @SerializedName(SERIALIZED_NAME_NAMESPACES) + private V1GatewaySpecAllowedRoutesNamespaces namespaces; + + + public V1GatewaySpecAllowedRoutes addKindsItem(V1GatewaySpecAllowedRoutesKinds kindsItem) { + if (this.kinds == null) { + this.kinds = new ArrayList<>(); + } + this.kinds.add(kindsItem); + return this; } - this.kinds.add(kindsItem); - return this; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewaySpecAllowedRoutes v1GatewaySpecAllowedRoutes = (V1GatewaySpecAllowedRoutes) o; + return Objects.equals(this.kinds, v1GatewaySpecAllowedRoutes.kinds) && + Objects.equals(this.namespaces, v1GatewaySpecAllowedRoutes.namespaces); } - V1GatewaySpecAllowedRoutes v1GatewaySpecAllowedRoutes = (V1GatewaySpecAllowedRoutes) o; - return Objects.equals(this.kinds, v1GatewaySpecAllowedRoutes.kinds) && - Objects.equals(this.namespaces, v1GatewaySpecAllowedRoutes.namespaces); - } - @Override - public int hashCode() { - return Objects.hash(kinds, namespaces); - } + @Override + public int hashCode() { + return Objects.hash(kinds, namespaces); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1beta1GatewaySpecAllowedRoutes {\n"); - sb.append(" kinds: ").append(toIndentedString(kinds)).append("\n"); - sb.append(" namespaces: ").append(toIndentedString(namespaces)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1beta1GatewaySpecAllowedRoutes {\n" + + " kinds: " + toIndentedString(kinds) + "\n" + + " namespaces: " + toIndentedString(namespaces) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesKinds.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesKinds.java index 6fa9cbb3..65fbc097 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesKinds.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesKinds.java @@ -1,21 +1,20 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Objects; @@ -25,54 +24,52 @@ */ @Data public class V1GatewaySpecAllowedRoutesKinds { - public static final String SERIALIZED_NAME_GROUP = "group"; - @SerializedName(SERIALIZED_NAME_GROUP) - private String group; - - public static final String SERIALIZED_NAME_KIND = "kind"; - @SerializedName(SERIALIZED_NAME_KIND) - private String kind; + public static final String SERIALIZED_NAME_GROUP = "group"; + public static final String SERIALIZED_NAME_KIND = "kind"; + @SerializedName(SERIALIZED_NAME_GROUP) + private String group; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewaySpecAllowedRoutesKinds v1GatewaySpecAllowedRoutesKinds = (V1GatewaySpecAllowedRoutesKinds) o; + return Objects.equals(this.group, v1GatewaySpecAllowedRoutesKinds.group) && + Objects.equals(this.kind, v1GatewaySpecAllowedRoutesKinds.kind); } - V1GatewaySpecAllowedRoutesKinds v1GatewaySpecAllowedRoutesKinds = (V1GatewaySpecAllowedRoutesKinds) o; - return Objects.equals(this.group, v1GatewaySpecAllowedRoutesKinds.group) && - Objects.equals(this.kind, v1GatewaySpecAllowedRoutesKinds.kind); - } - @Override - public int hashCode() { - return Objects.hash(group, kind); - } + @Override + public int hashCode() { + return Objects.hash(group, kind); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1beta1GatewaySpecAllowedRoutesKinds {\n"); - sb.append(" group: ").append(toIndentedString(group)).append("\n"); - sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1beta1GatewaySpecAllowedRoutesKinds {\n" + + " group: " + toIndentedString(group) + "\n" + + " kind: " + toIndentedString(kind) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespaces.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespaces.java index 5d2b349f..3148c27b 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespaces.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespaces.java @@ -1,13 +1,14 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ @@ -18,8 +19,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.IOException; @@ -30,109 +29,105 @@ */ @Data public class V1GatewaySpecAllowedRoutesNamespaces { - /** - * From indicates where Routes will be selected for this Gateway. Possible values are: * All: Routes in all namespaces may be used by this Gateway. * Selector: Routes in namespaces selected by the selector may be used by this Gateway. * Same: Only Routes in the same namespace may be used by this Gateway. Support: Core - */ - @JsonAdapter(FromEnum.Adapter.class) - public enum FromEnum { - /** - * Routes in all namespaces may be used by this Gateway. - */ - ALL("All"), - /** - * Routes in namespaces selected by the selector may be used by this Gateway. - */ - SELECTOR("Selector"), - /** - * only Routes in the same namespace may be used by this Gateway. - */ - SAME("Same"); - private String value; + public static final String SERIALIZED_NAME_FROM = "from"; + public static final String SERIALIZED_NAME_SELECTOR = "selector"; + @SerializedName(SERIALIZED_NAME_FROM) + private FromEnum from; + @SerializedName(SERIALIZED_NAME_SELECTOR) + private V1GatewaySpecAllowedRoutesNamespacesSelector selector; - FromEnum(String value) { - this.value = value; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewaySpecAllowedRoutesNamespaces v1GatewaySpecAllowedRoutesNamespaces = (V1GatewaySpecAllowedRoutesNamespaces) o; + return Objects.equals(this.from, v1GatewaySpecAllowedRoutesNamespaces.from) && + Objects.equals(this.selector, v1GatewaySpecAllowedRoutesNamespaces.selector); } - public String getValue() { - return value; + @Override + public int hashCode() { + return Objects.hash(from, selector); } @Override public String toString() { - return String.valueOf(value); + String sb = "class V1beta1GatewaySpecAllowedRoutesNamespaces {\n" + + " from: " + toIndentedString(from) + "\n" + + " selector: " + toIndentedString(selector) + "\n" + + "}"; + return sb; } - public static FromEnum fromValue(String value) { - for (FromEnum b : FromEnum.values()) { - if (b.value.equals(value)) { - return b; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return o.toString().replace("\n", "\n "); } - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final FromEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public FromEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return FromEnum.fromValue(value); - } - } - } + /** + * From indicates where Routes will be selected for this Gateway. Possible values are: * All: Routes in all namespaces may be used by this Gateway. * Selector: Routes in namespaces selected by the selector may be used by this Gateway. * Same: Only Routes in the same namespace may be used by this Gateway. Support: Core + */ + @JsonAdapter(FromEnum.Adapter.class) + public enum FromEnum { + /** + * Routes in all namespaces may be used by this Gateway. + */ + ALL("All"), + /** + * Routes in namespaces selected by the selector may be used by this Gateway. + */ + SELECTOR("Selector"), + /** + * only Routes in the same namespace may be used by this Gateway. + */ + SAME("Same"); + private final String value; + + FromEnum(String value) { + this.value = value; + } - public static final String SERIALIZED_NAME_FROM = "from"; - @SerializedName(SERIALIZED_NAME_FROM) - private FromEnum from; + public static FromEnum fromValue(String value) { + for (FromEnum b : FromEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + public String getValue() { + return value; + } - public static final String SERIALIZED_NAME_SELECTOR = "selector"; - @SerializedName(SERIALIZED_NAME_SELECTOR) - private V1GatewaySpecAllowedRoutesNamespacesSelector selector; + @Override + public String toString() { + return String.valueOf(value); + } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - V1GatewaySpecAllowedRoutesNamespaces v1GatewaySpecAllowedRoutesNamespaces = (V1GatewaySpecAllowedRoutesNamespaces) o; - return Objects.equals(this.from, v1GatewaySpecAllowedRoutesNamespaces.from) && - Objects.equals(this.selector, v1GatewaySpecAllowedRoutesNamespaces.selector); - } - - @Override - public int hashCode() { - return Objects.hash(from, selector); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1beta1GatewaySpecAllowedRoutesNamespaces {\n"); - sb.append(" from: ").append(toIndentedString(from)).append("\n"); - sb.append(" selector: ").append(toIndentedString(selector)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final FromEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public FromEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return FromEnum.fromValue(value); + } + } } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespacesSelector.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespacesSelector.java index 5f75b738..8ebbd813 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespacesSelector.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespacesSelector.java @@ -1,100 +1,102 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; /** * Selector must be specified when From is set to \"Selector\". In that case, only Routes in Namespaces matching this Selector will be selected by this Gateway. This field is ignored for other values of \"From\". Support: Core */ @Data public class V1GatewaySpecAllowedRoutesNamespacesSelector { - public static final String SERIALIZED_NAME_MATCH_EXPRESSIONS = "matchExpressions"; - @SerializedName(SERIALIZED_NAME_MATCH_EXPRESSIONS) - private List matchExpressions = null; + public static final String SERIALIZED_NAME_MATCH_EXPRESSIONS = "matchExpressions"; + public static final String SERIALIZED_NAME_MATCH_LABELS = "matchLabels"; + @SerializedName(SERIALIZED_NAME_MATCH_EXPRESSIONS) + private List matchExpressions = null; + @SerializedName(SERIALIZED_NAME_MATCH_LABELS) + private Map matchLabels = null; + + + public V1GatewaySpecAllowedRoutesNamespacesSelector addMatchExpressionsItem(V1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions matchExpressionsItem) { + if (this.matchExpressions == null) { + this.matchExpressions = new ArrayList<>(); + } + this.matchExpressions.add(matchExpressionsItem); + return this; + } - public static final String SERIALIZED_NAME_MATCH_LABELS = "matchLabels"; - @SerializedName(SERIALIZED_NAME_MATCH_LABELS) - private Map matchLabels = null; + /** + * matchExpressions is a list of label selector requirements. The requirements are ANDed. + * + * @return matchExpressions + **/ + + public V1GatewaySpecAllowedRoutesNamespacesSelector putMatchLabelsItem(String key, String matchLabelsItem) { + if (this.matchLabels == null) { + this.matchLabels = new HashMap<>(); + } + this.matchLabels.put(key, matchLabelsItem); + return this; + } - public V1GatewaySpecAllowedRoutesNamespacesSelector addMatchExpressionsItem(V1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions matchExpressionsItem) { - if (this.matchExpressions == null) { - this.matchExpressions = new ArrayList<>(); + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewaySpecAllowedRoutesNamespacesSelector v1GatewaySpecAllowedRoutesNamespacesSelector = (V1GatewaySpecAllowedRoutesNamespacesSelector) o; + return Objects.equals(this.matchExpressions, v1GatewaySpecAllowedRoutesNamespacesSelector.matchExpressions) && + Objects.equals(this.matchLabels, v1GatewaySpecAllowedRoutesNamespacesSelector.matchLabels); } - this.matchExpressions.add(matchExpressionsItem); - return this; - } - - /** - * matchExpressions is a list of label selector requirements. The requirements are ANDed. - * @return matchExpressions - **/ - - public V1GatewaySpecAllowedRoutesNamespacesSelector putMatchLabelsItem(String key, String matchLabelsItem) { - if (this.matchLabels == null) { - this.matchLabels = new HashMap<>(); + + @Override + public int hashCode() { + return Objects.hash(matchExpressions, matchLabels); } - this.matchLabels.put(key, matchLabelsItem); - return this; - } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; + @Override + public String toString() { + String sb = "class V1beta1GatewaySpecAllowedRoutesNamespacesSelector {\n" + + " matchExpressions: " + toIndentedString(matchExpressions) + "\n" + + " matchLabels: " + toIndentedString(matchLabels) + "\n" + + "}"; + return sb; } - V1GatewaySpecAllowedRoutesNamespacesSelector v1GatewaySpecAllowedRoutesNamespacesSelector = (V1GatewaySpecAllowedRoutesNamespacesSelector) o; - return Objects.equals(this.matchExpressions, v1GatewaySpecAllowedRoutesNamespacesSelector.matchExpressions) && - Objects.equals(this.matchLabels, v1GatewaySpecAllowedRoutesNamespacesSelector.matchLabels); - } - - @Override - public int hashCode() { - return Objects.hash(matchExpressions, matchLabels); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1beta1GatewaySpecAllowedRoutesNamespacesSelector {\n"); - sb.append(" matchExpressions: ").append(toIndentedString(matchExpressions)).append("\n"); - sb.append(" matchLabels: ").append(toIndentedString(matchLabels)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions.java index e8d0ffcf..ae8e0f7d 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions.java @@ -1,21 +1,20 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.ArrayList; @@ -27,69 +26,66 @@ */ @Data public class V1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions { - public static final String SERIALIZED_NAME_KEY = "key"; - @SerializedName(SERIALIZED_NAME_KEY) - private String key; - - public static final String SERIALIZED_NAME_OPERATOR = "operator"; - @SerializedName(SERIALIZED_NAME_OPERATOR) - private String operator; - - public static final String SERIALIZED_NAME_VALUES = "values"; - @SerializedName(SERIALIZED_NAME_VALUES) - private List values = null; - - - public V1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions addValuesItem(String valuesItem) { - if (this.values == null) { - this.values = new ArrayList<>(); + public static final String SERIALIZED_NAME_KEY = "key"; + public static final String SERIALIZED_NAME_OPERATOR = "operator"; + public static final String SERIALIZED_NAME_VALUES = "values"; + @SerializedName(SERIALIZED_NAME_KEY) + private String key; + @SerializedName(SERIALIZED_NAME_OPERATOR) + private String operator; + @SerializedName(SERIALIZED_NAME_VALUES) + private List values = null; + + + public V1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions addValuesItem(String valuesItem) { + if (this.values == null) { + this.values = new ArrayList<>(); + } + this.values.add(valuesItem); + return this; } - this.values.add(valuesItem); - return this; - } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions v1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions = (V1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions) o; + return Objects.equals(this.key, v1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions.key) && + Objects.equals(this.operator, v1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions.operator) && + Objects.equals(this.values, v1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions.values); } - V1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions v1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions = (V1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions) o; - return Objects.equals(this.key, v1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions.key) && - Objects.equals(this.operator, v1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions.operator) && - Objects.equals(this.values, v1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions.values); - } - @Override - public int hashCode() { - return Objects.hash(key, operator, values); - } + @Override + public int hashCode() { + return Objects.hash(key, operator, values); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1beta1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions {\n"); - sb.append(" key: ").append(toIndentedString(key)).append("\n"); - sb.append(" operator: ").append(toIndentedString(operator)).append("\n"); - sb.append(" values: ").append(toIndentedString(values)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1beta1GatewaySpecAllowedRoutesNamespacesSelectorMatchExpressions {\n" + + " key: " + toIndentedString(key) + "\n" + + " operator: " + toIndentedString(operator) + "\n" + + " values: " + toIndentedString(values) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecListeners.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecListeners.java index 49ede64c..4b438ac0 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecListeners.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecListeners.java @@ -1,21 +1,19 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ - package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.jetbrains.annotations.NotNull; @@ -28,98 +26,93 @@ */ @Data public class V1GatewaySpecListeners { - public static final String SERIALIZED_NAME_ALLOWED_ROUTES = "allowedRoutes"; - @SerializedName(SERIALIZED_NAME_ALLOWED_ROUTES) - private V1GatewaySpecAllowedRoutes allowedRoutes; - - - public static final String SERIALIZED_NAME_HOSTNAME = "hostname"; - @SerializedName(SERIALIZED_NAME_HOSTNAME) - private String hostname; - - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) - private String name; - - public static final String SERIALIZED_NAME_PORT = "port"; - @SerializedName(SERIALIZED_NAME_PORT) - private Integer port; - - public static final String SERIALIZED_NAME_PROTOCOL = "protocol"; - @SerializedName(SERIALIZED_NAME_PROTOCOL) - private String protocol; - - public static final String SERIALIZED_NAME_TLS = "tls"; - @SerializedName(SERIALIZED_NAME_TLS) - private V1GatewaySpecTls tls; + public static final String SERIALIZED_NAME_ALLOWED_ROUTES = "allowedRoutes"; + public static final String SERIALIZED_NAME_HOSTNAME = "hostname"; + public static final String SERIALIZED_NAME_NAME = "name"; + public static final String SERIALIZED_NAME_PORT = "port"; + public static final String SERIALIZED_NAME_PROTOCOL = "protocol"; + public static final String SERIALIZED_NAME_TLS = "tls"; + @SerializedName(SERIALIZED_NAME_ALLOWED_ROUTES) + private V1GatewaySpecAllowedRoutes allowedRoutes; + @SerializedName(SERIALIZED_NAME_HOSTNAME) + private String hostname; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + @SerializedName(SERIALIZED_NAME_PORT) + private Integer port; + @SerializedName(SERIALIZED_NAME_PROTOCOL) + private String protocol; + @SerializedName(SERIALIZED_NAME_TLS) + private V1GatewaySpecTls tls; + + @NotNull + public static V1GatewaySpecTls getDefaultTls(String cert) { + V1GatewaySpecTls tls = new V1GatewaySpecTls(); + List certificateRefs = new ArrayList<>(); + V1GatewaySpecTlsCertificateRefs certificateRef = new V1GatewaySpecTlsCertificateRefs(); + certificateRef.setKind("Secret"); + certificateRef.setName(cert); + certificateRefs.add(certificateRef); + tls.setCertificateRefs(certificateRefs); + tls.setMode(V1GatewaySpecTls.ModeEnum.TERMINATE); + return tls; + } - @NotNull - public static V1GatewaySpecTls getDefaultTls(String cert) { - V1GatewaySpecTls tls = new V1GatewaySpecTls(); - List certificateRefs = new ArrayList<>(); - V1GatewaySpecTlsCertificateRefs certificateRef = new V1GatewaySpecTlsCertificateRefs(); - certificateRef.setKind("Secret"); - certificateRef.setName(cert); - certificateRefs.add(certificateRef); - tls.setCertificateRefs(certificateRefs); - tls.setMode(V1GatewaySpecTls.ModeEnum.TERMINATE); - return tls; - } - @NotNull - public static V1GatewaySpecAllowedRoutes getDefaultAllowedRoutes() { - V1GatewaySpecAllowedRoutes allowedRoute = new V1GatewaySpecAllowedRoutes(); - V1GatewaySpecAllowedRoutesNamespaces ns = new V1GatewaySpecAllowedRoutesNamespaces(); - ns.setFrom(V1GatewaySpecAllowedRoutesNamespaces.FromEnum.ALL); - allowedRoute.setNamespaces(ns); - return allowedRoute; - } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; + @NotNull + public static V1GatewaySpecAllowedRoutes getDefaultAllowedRoutes() { + V1GatewaySpecAllowedRoutes allowedRoute = new V1GatewaySpecAllowedRoutes(); + V1GatewaySpecAllowedRoutesNamespaces ns = new V1GatewaySpecAllowedRoutesNamespaces(); + ns.setFrom(V1GatewaySpecAllowedRoutesNamespaces.FromEnum.ALL); + allowedRoute.setNamespaces(ns); + return allowedRoute; } - if (o == null || getClass() != o.getClass()) { - return false; + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewaySpecListeners v1GatewaySpecListeners = (V1GatewaySpecListeners) o; + return Objects.equals(this.allowedRoutes, v1GatewaySpecListeners.allowedRoutes) && + Objects.equals(this.hostname, v1GatewaySpecListeners.hostname) && + Objects.equals(this.name, v1GatewaySpecListeners.name) && + Objects.equals(this.port, v1GatewaySpecListeners.port) && + Objects.equals(this.protocol, v1GatewaySpecListeners.protocol) && + Objects.equals(this.tls, v1GatewaySpecListeners.tls); } - V1GatewaySpecListeners v1GatewaySpecListeners = (V1GatewaySpecListeners) o; - return Objects.equals(this.allowedRoutes, v1GatewaySpecListeners.allowedRoutes) && - Objects.equals(this.hostname, v1GatewaySpecListeners.hostname) && - Objects.equals(this.name, v1GatewaySpecListeners.name) && - Objects.equals(this.port, v1GatewaySpecListeners.port) && - Objects.equals(this.protocol, v1GatewaySpecListeners.protocol) && - Objects.equals(this.tls, v1GatewaySpecListeners.tls); - } - @Override - public int hashCode() { - return Objects.hash(allowedRoutes, hostname, name, port, protocol, tls); - } + @Override + public int hashCode() { + return Objects.hash(allowedRoutes, hostname, name, port, protocol, tls); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1beta1GatewaySpecListeners {\n"); - sb.append(" allowedRoutes: ").append(toIndentedString(allowedRoutes)).append("\n"); - sb.append(" hostname: ").append(toIndentedString(hostname)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" port: ").append(toIndentedString(port)).append("\n"); - sb.append(" protocol: ").append(toIndentedString(protocol)).append("\n"); - sb.append(" tls: ").append(toIndentedString(tls)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1beta1GatewaySpecListeners {\n" + + " allowedRoutes: " + toIndentedString(allowedRoutes) + "\n" + + " hostname: " + toIndentedString(hostname) + "\n" + + " name: " + toIndentedString(name) + "\n" + + " port: " + toIndentedString(port) + "\n" + + " protocol: " + toIndentedString(protocol) + "\n" + + " tls: " + toIndentedString(tls) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecTls.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecTls.java index 825a998e..e26371fd 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecTls.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecTls.java @@ -1,13 +1,14 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ @@ -18,149 +19,146 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; /** * TLS is the TLS configuration for the Listener. This field is required if the Protocol field is \"HTTPS\" or \"TLS\". It is invalid to set this field if the Protocol field is \"HTTP\", \"TCP\", or \"UDP\". The association of SNIs to Certificate defined in GatewayTLSConfig is defined based on the Hostname field for this listener. The GatewayClass MUST use the longest matching SNI out of all available certificates for any TLS handshake. Support: Core */ @Data public class V1GatewaySpecTls { - public static final String SERIALIZED_NAME_CERTIFICATE_REFS = "certificateRefs"; - @SerializedName(SERIALIZED_NAME_CERTIFICATE_REFS) - private List certificateRefs = null; - - /** - * Mode defines the TLS behavior for the TLS session initiated by the client. There are two possible modes: - Terminate: The TLS session between the downstream client and the Gateway is terminated at the Gateway. This mode requires certificates to be specified in some way, such as populating the certificateRefs field. - Passthrough: The TLS session is NOT terminated by the Gateway. This implies that the Gateway can't decipher the TLS stream except for the ClientHello message of the TLS protocol. The certificateRefs field is ignored in this mode. Support: Core - */ - @JsonAdapter(ModeEnum.Adapter.class) - public enum ModeEnum { - /** - * The TLS session between the downstream client and the Gateway is terminated at the Gateway. - * This mode requires certificates to be specified in some way, such as populating the certificateRefs field. - */ - TERMINATE("Terminate"), - /** - * The TLS session is NOT terminated by the Gateway. - * This implies that the Gateway can't decipher the TLS stream except for the ClientHello message of the TLS protocol. - * The certificateRefs field is ignored in this mode. - */ - PASSTHROUGH("Passthrough"); + public static final String SERIALIZED_NAME_CERTIFICATE_REFS = "certificateRefs"; + public static final String SERIALIZED_NAME_MODE = "mode"; + public static final String SERIALIZED_NAME_OPTIONS = "options"; + @SerializedName(SERIALIZED_NAME_CERTIFICATE_REFS) + private List certificateRefs = null; + @SerializedName(SERIALIZED_NAME_MODE) + private ModeEnum mode; + @SerializedName(SERIALIZED_NAME_OPTIONS) + private Map options = null; + + public V1GatewaySpecTls addCertificateRefsItem(V1GatewaySpecTlsCertificateRefs certificateRefsItem) { + if (this.certificateRefs == null) { + this.certificateRefs = new ArrayList<>(); + } + this.certificateRefs.add(certificateRefsItem); + return this; + } - private String value; + /** + * CertificateRefs contains a series of references to Kubernetes objects that contains TLS certificates and private keys. These certificates are used to establish a TLS handshake for requests that match the hostname of the associated listener. A single CertificateRef to a Kubernetes Secret has \"Core\" support. Implementations MAY choose to support attaching multiple certificates to a Listener, but this behavior is implementation-specific. References to a resource in different namespace are invalid UNLESS there is a ReferenceGrant in the target namespace that allows the certificate to be attached. If a ReferenceGrant does not allow this reference, the \"ResolvedRefs\" condition MUST be set to False for this listener with the \"RefNotPermitted\" reason. This field is required to have at least one element when the mode is set to \"Terminate\" (default) and is optional otherwise. CertificateRefs can reference to standard Kubernetes resources, i.e. Secret, or implementation-specific custom resources. Support: Core - A single reference to a Kubernetes Secret of type kubernetes.io/tls Support: Implementation-specific (More than one reference or other resource types) + * + * @return certificateRefs + **/ + + public V1GatewaySpecTls putOptionsItem(String key, String optionsItem) { + if (this.options == null) { + this.options = new HashMap<>(); + } + this.options.put(key, optionsItem); + return this; + } - ModeEnum(String value) { - this.value = value; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewaySpecTls v1GatewaySpecTls = (V1GatewaySpecTls) o; + return Objects.equals(this.certificateRefs, v1GatewaySpecTls.certificateRefs) && + Objects.equals(this.mode, v1GatewaySpecTls.mode) && + Objects.equals(this.options, v1GatewaySpecTls.options); } - public String getValue() { - return value; + @Override + public int hashCode() { + return Objects.hash(certificateRefs, mode, options); } @Override public String toString() { - return String.valueOf(value); + String sb = "class V1beta1GatewaySpecTls {\n" + + " certificateRefs: " + toIndentedString(certificateRefs) + "\n" + + " mode: " + toIndentedString(mode) + "\n" + + " options: " + toIndentedString(options) + "\n" + + "}"; + return sb; } - public static ModeEnum fromValue(String value) { - for (ModeEnum b : ModeEnum.values()) { - if (b.value.equals(value)) { - return b; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return o.toString().replace("\n", "\n "); } - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final ModeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public ModeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return ModeEnum.fromValue(value); - } - } - } - - - public static final String SERIALIZED_NAME_MODE = "mode"; - @SerializedName(SERIALIZED_NAME_MODE) - private ModeEnum mode; - - public static final String SERIALIZED_NAME_OPTIONS = "options"; - @SerializedName(SERIALIZED_NAME_OPTIONS) - private Map options = null; + /** + * Mode defines the TLS behavior for the TLS session initiated by the client. There are two possible modes: - Terminate: The TLS session between the downstream client and the Gateway is terminated at the Gateway. This mode requires certificates to be specified in some way, such as populating the certificateRefs field. - Passthrough: The TLS session is NOT terminated by the Gateway. This implies that the Gateway can't decipher the TLS stream except for the ClientHello message of the TLS protocol. The certificateRefs field is ignored in this mode. Support: Core + */ + @JsonAdapter(ModeEnum.Adapter.class) + public enum ModeEnum { + /** + * The TLS session between the downstream client and the Gateway is terminated at the Gateway. + * This mode requires certificates to be specified in some way, such as populating the certificateRefs field. + */ + TERMINATE("Terminate"), + /** + * The TLS session is NOT terminated by the Gateway. + * This implies that the Gateway can't decipher the TLS stream except for the ClientHello message of the TLS protocol. + * The certificateRefs field is ignored in this mode. + */ + PASSTHROUGH("Passthrough"); + + private final String value; + + ModeEnum(String value) { + this.value = value; + } + public static ModeEnum fromValue(String value) { + for (ModeEnum b : ModeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } - public V1GatewaySpecTls addCertificateRefsItem(V1GatewaySpecTlsCertificateRefs certificateRefsItem) { - if (this.certificateRefs == null) { - this.certificateRefs = new ArrayList<>(); - } - this.certificateRefs.add(certificateRefsItem); - return this; - } - - /** - * CertificateRefs contains a series of references to Kubernetes objects that contains TLS certificates and private keys. These certificates are used to establish a TLS handshake for requests that match the hostname of the associated listener. A single CertificateRef to a Kubernetes Secret has \"Core\" support. Implementations MAY choose to support attaching multiple certificates to a Listener, but this behavior is implementation-specific. References to a resource in different namespace are invalid UNLESS there is a ReferenceGrant in the target namespace that allows the certificate to be attached. If a ReferenceGrant does not allow this reference, the \"ResolvedRefs\" condition MUST be set to False for this listener with the \"RefNotPermitted\" reason. This field is required to have at least one element when the mode is set to \"Terminate\" (default) and is optional otherwise. CertificateRefs can reference to standard Kubernetes resources, i.e. Secret, or implementation-specific custom resources. Support: Core - A single reference to a Kubernetes Secret of type kubernetes.io/tls Support: Implementation-specific (More than one reference or other resource types) - * @return certificateRefs - **/ - - public V1GatewaySpecTls putOptionsItem(String key, String optionsItem) { - if (this.options == null) { - this.options = new HashMap<>(); - } - this.options.put(key, optionsItem); - return this; - } + public String getValue() { + return value; + } + @Override + public String toString() { + return String.valueOf(value); + } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - V1GatewaySpecTls v1GatewaySpecTls = (V1GatewaySpecTls) o; - return Objects.equals(this.certificateRefs, v1GatewaySpecTls.certificateRefs) && - Objects.equals(this.mode, v1GatewaySpecTls.mode) && - Objects.equals(this.options, v1GatewaySpecTls.options); - } - - @Override - public int hashCode() { - return Objects.hash(certificateRefs, mode, options); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1beta1GatewaySpecTls {\n"); - sb.append(" certificateRefs: ").append(toIndentedString(certificateRefs)).append("\n"); - sb.append(" mode: ").append(toIndentedString(mode)).append("\n"); - sb.append(" options: ").append(toIndentedString(options)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final ModeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ModeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return ModeEnum.fromValue(value); + } + } } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecTlsCertificateRefs.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecTlsCertificateRefs.java index cb1c5e8a..1630ef12 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecTlsCertificateRefs.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewaySpecTlsCertificateRefs.java @@ -1,20 +1,19 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ - package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Objects; @@ -25,66 +24,62 @@ @Data public class V1GatewaySpecTlsCertificateRefs { - public static final String SERIALIZED_NAME_GROUP = "group"; - @SerializedName(SERIALIZED_NAME_GROUP) - private String group; - - public static final String SERIALIZED_NAME_KIND = "kind"; - @SerializedName(SERIALIZED_NAME_KIND) - private String kind; - - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) - private String name; - - public static final String SERIALIZED_NAME_NAMESPACE = "namespace"; - @SerializedName(SERIALIZED_NAME_NAMESPACE) - private String namespace; - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; + public static final String SERIALIZED_NAME_GROUP = "group"; + public static final String SERIALIZED_NAME_KIND = "kind"; + public static final String SERIALIZED_NAME_NAME = "name"; + public static final String SERIALIZED_NAME_NAMESPACE = "namespace"; + @SerializedName(SERIALIZED_NAME_GROUP) + private String group; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + @SerializedName(SERIALIZED_NAME_NAMESPACE) + private String namespace; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewaySpecTlsCertificateRefs v1GatewaySpecTlsCertificateRefs = (V1GatewaySpecTlsCertificateRefs) o; + return Objects.equals(this.group, v1GatewaySpecTlsCertificateRefs.group) && + Objects.equals(this.kind, v1GatewaySpecTlsCertificateRefs.kind) && + Objects.equals(this.name, v1GatewaySpecTlsCertificateRefs.name) && + Objects.equals(this.namespace, v1GatewaySpecTlsCertificateRefs.namespace); } - V1GatewaySpecTlsCertificateRefs v1GatewaySpecTlsCertificateRefs = (V1GatewaySpecTlsCertificateRefs) o; - return Objects.equals(this.group, v1GatewaySpecTlsCertificateRefs.group) && - Objects.equals(this.kind, v1GatewaySpecTlsCertificateRefs.kind) && - Objects.equals(this.name, v1GatewaySpecTlsCertificateRefs.name) && - Objects.equals(this.namespace, v1GatewaySpecTlsCertificateRefs.namespace); - } - @Override - public int hashCode() { - return Objects.hash(group, kind, name, namespace); - } + @Override + public int hashCode() { + return Objects.hash(group, kind, name, namespace); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1beta1GatewaySpecTlsCertificateRefs {\n"); - sb.append(" group: ").append(toIndentedString(group)).append("\n"); - sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1beta1GatewaySpecTlsCertificateRefs {\n" + + " group: " + toIndentedString(group) + "\n" + + " kind: " + toIndentedString(kind) + "\n" + + " name: " + toIndentedString(name) + "\n" + + " namespace: " + toIndentedString(namespace) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatus.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatus.java index e1241c73..67ca85ec 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatus.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatus.java @@ -1,21 +1,20 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.ArrayList; @@ -27,83 +26,80 @@ */ @Data public class V1GatewayStatus { - public static final String SERIALIZED_NAME_ADDRESSES = "addresses"; - @SerializedName(SERIALIZED_NAME_ADDRESSES) - private List addresses = null; - - public static final String SERIALIZED_NAME_CONDITIONS = "conditions"; - @SerializedName(SERIALIZED_NAME_CONDITIONS) - private List conditions = null; - - public static final String SERIALIZED_NAME_LISTENERS = "listeners"; - @SerializedName(SERIALIZED_NAME_LISTENERS) - private List listeners = null; - - public V1GatewayStatus addAddressesItem(V1GatewayStatusAddresses addressesItem) { - if (this.addresses == null) { - this.addresses = new ArrayList<>(); + public static final String SERIALIZED_NAME_ADDRESSES = "addresses"; + public static final String SERIALIZED_NAME_CONDITIONS = "conditions"; + public static final String SERIALIZED_NAME_LISTENERS = "listeners"; + @SerializedName(SERIALIZED_NAME_ADDRESSES) + private List addresses = null; + @SerializedName(SERIALIZED_NAME_CONDITIONS) + private List conditions = null; + @SerializedName(SERIALIZED_NAME_LISTENERS) + private List listeners = null; + + public V1GatewayStatus addAddressesItem(V1GatewayStatusAddresses addressesItem) { + if (this.addresses == null) { + this.addresses = new ArrayList<>(); + } + this.addresses.add(addressesItem); + return this; } - this.addresses.add(addressesItem); - return this; - } - public V1GatewayStatus addConditionsItem(V1GatewayStatusConditions conditionsItem) { - if (this.conditions == null) { - this.conditions = new ArrayList<>(); + public V1GatewayStatus addConditionsItem(V1GatewayStatusConditions conditionsItem) { + if (this.conditions == null) { + this.conditions = new ArrayList<>(); + } + this.conditions.add(conditionsItem); + return this; } - this.conditions.add(conditionsItem); - return this; - } - public V1GatewayStatus addListenersItem(V1GatewayStatusListeners listenersItem) { - if (this.listeners == null) { - this.listeners = new ArrayList<>(); + public V1GatewayStatus addListenersItem(V1GatewayStatusListeners listenersItem) { + if (this.listeners == null) { + this.listeners = new ArrayList<>(); + } + this.listeners.add(listenersItem); + return this; } - this.listeners.add(listenersItem); - return this; - } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewayStatus v1GatewayStatus = (V1GatewayStatus) o; + return Objects.equals(this.addresses, v1GatewayStatus.addresses) && + Objects.equals(this.conditions, v1GatewayStatus.conditions) && + Objects.equals(this.listeners, v1GatewayStatus.listeners); } - if (o == null || getClass() != o.getClass()) { - return false; - } - V1GatewayStatus v1GatewayStatus = (V1GatewayStatus) o; - return Objects.equals(this.addresses, v1GatewayStatus.addresses) && - Objects.equals(this.conditions, v1GatewayStatus.conditions) && - Objects.equals(this.listeners, v1GatewayStatus.listeners); - } - @Override - public int hashCode() { - return Objects.hash(addresses, conditions, listeners); - } + @Override + public int hashCode() { + return Objects.hash(addresses, conditions, listeners); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1beta1GatewayStatus {\n"); - sb.append(" addresses: ").append(toIndentedString(addresses)).append("\n"); - sb.append(" conditions: ").append(toIndentedString(conditions)).append("\n"); - sb.append(" listeners: ").append(toIndentedString(listeners)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1beta1GatewayStatus {\n" + + " addresses: " + toIndentedString(addresses) + "\n" + + " conditions: " + toIndentedString(conditions) + "\n" + + " listeners: " + toIndentedString(listeners) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusAddresses.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusAddresses.java index bdfbc1a0..9a1a894f 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusAddresses.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusAddresses.java @@ -1,21 +1,20 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Objects; @@ -25,54 +24,52 @@ */ @Data public class V1GatewayStatusAddresses { - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) - private String type; - - public static final String SERIALIZED_NAME_VALUE = "value"; - @SerializedName(SERIALIZED_NAME_VALUE) - private String value; + public static final String SERIALIZED_NAME_TYPE = "type"; + public static final String SERIALIZED_NAME_VALUE = "value"; + @SerializedName(SERIALIZED_NAME_TYPE) + private String type; + @SerializedName(SERIALIZED_NAME_VALUE) + private String value; - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewayStatusAddresses v1GatewayStatusAddresses = (V1GatewayStatusAddresses) o; + return Objects.equals(this.type, v1GatewayStatusAddresses.type) && + Objects.equals(this.value, v1GatewayStatusAddresses.value); } - V1GatewayStatusAddresses v1GatewayStatusAddresses = (V1GatewayStatusAddresses) o; - return Objects.equals(this.type, v1GatewayStatusAddresses.type) && - Objects.equals(this.value, v1GatewayStatusAddresses.value); - } - @Override - public int hashCode() { - return Objects.hash(type, value); - } + @Override + public int hashCode() { + return Objects.hash(type, value); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1beta1GatewayStatusAddresses {\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" value: ").append(toIndentedString(value)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1beta1GatewayStatusAddresses {\n" + + " type: " + toIndentedString(type) + "\n" + + " value: " + toIndentedString(value) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusConditions.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusConditions.java index 536f9643..ffcb6f45 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusConditions.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusConditions.java @@ -1,13 +1,14 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ @@ -18,8 +19,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.IOException; @@ -31,138 +30,128 @@ */ @Data public class V1GatewayStatusConditions { - public static final String SERIALIZED_NAME_LAST_TRANSITION_TIME = "lastTransitionTime"; - - @SerializedName(SERIALIZED_NAME_LAST_TRANSITION_TIME) - private OffsetDateTime lastTransitionTime; - - public static final String SERIALIZED_NAME_MESSAGE = "message"; - @SerializedName(SERIALIZED_NAME_MESSAGE) - private String message; - - public static final String SERIALIZED_NAME_OBSERVED_GENERATION = "observedGeneration"; - @SerializedName(SERIALIZED_NAME_OBSERVED_GENERATION) - private Long observedGeneration; - - public static final String SERIALIZED_NAME_REASON = "reason"; - @SerializedName(SERIALIZED_NAME_REASON) - private String reason; - - /** - * status of the condition, one of True, False, Unknown. - */ - @JsonAdapter(StatusEnum.Adapter.class) - public enum StatusEnum { - /** - * Represents the state where the condition is true. - */ - TRUE("True"), + public static final String SERIALIZED_NAME_LAST_TRANSITION_TIME = "lastTransitionTime"; + public static final String SERIALIZED_NAME_MESSAGE = "message"; + public static final String SERIALIZED_NAME_OBSERVED_GENERATION = "observedGeneration"; + public static final String SERIALIZED_NAME_REASON = "reason"; + public static final String SERIALIZED_NAME_STATUS = "status"; + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_LAST_TRANSITION_TIME) + private OffsetDateTime lastTransitionTime; + @SerializedName(SERIALIZED_NAME_MESSAGE) + private String message; + @SerializedName(SERIALIZED_NAME_OBSERVED_GENERATION) + private Long observedGeneration; + @SerializedName(SERIALIZED_NAME_REASON) + private String reason; + @SerializedName(SERIALIZED_NAME_STATUS) + private StatusEnum status; + @SerializedName(SERIALIZED_NAME_TYPE) + private String type; - /** - * Represents the state where the condition is false. - */ - FALSE("False"), - - /** - * Represents an unknown state. - */ - UNKNOWN("Unknown"); - - private String value; - - StatusEnum(String value) { - this.value = value; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewayStatusConditions v1GatewayStatusConditions = (V1GatewayStatusConditions) o; + return Objects.equals(this.lastTransitionTime, v1GatewayStatusConditions.lastTransitionTime) && + Objects.equals(this.message, v1GatewayStatusConditions.message) && + Objects.equals(this.observedGeneration, v1GatewayStatusConditions.observedGeneration) && + Objects.equals(this.reason, v1GatewayStatusConditions.reason) && + Objects.equals(this.status, v1GatewayStatusConditions.status) && + Objects.equals(this.type, v1GatewayStatusConditions.type); } - public String getValue() { - return value; + @Override + public int hashCode() { + return Objects.hash(lastTransitionTime, message, observedGeneration, reason, status, type); } @Override public String toString() { - return String.valueOf(value); + String sb = "class V1beta1GatewayStatusConditions {\n" + + " lastTransitionTime: " + toIndentedString(lastTransitionTime) + "\n" + + " message: " + toIndentedString(message) + "\n" + + " observedGeneration: " + toIndentedString(observedGeneration) + "\n" + + " reason: " + toIndentedString(reason) + "\n" + + " status: " + toIndentedString(status) + "\n" + + " type: " + toIndentedString(type) + "\n" + + "}"; + return sb; } - public static StatusEnum fromValue(String value) { - for (StatusEnum b : StatusEnum.values()) { - if (b.value.equals(value)) { - return b; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public StatusEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return StatusEnum.fromValue(value); - } + return o.toString().replace("\n", "\n "); } - } + /** + * status of the condition, one of True, False, Unknown. + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + /** + * Represents the state where the condition is true. + */ + TRUE("True"), + + /** + * Represents the state where the condition is false. + */ + FALSE("False"), + + /** + * Represents an unknown state. + */ + UNKNOWN("Unknown"); + + private final String value; + + StatusEnum(String value) { + this.value = value; + } - public static final String SERIALIZED_NAME_STATUS = "status"; - @SerializedName(SERIALIZED_NAME_STATUS) - private StatusEnum status; + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) - private String type; + public String getValue() { + return value; + } + @Override + public String toString() { + return String.valueOf(value); + } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - V1GatewayStatusConditions v1GatewayStatusConditions = (V1GatewayStatusConditions) o; - return Objects.equals(this.lastTransitionTime, v1GatewayStatusConditions.lastTransitionTime) && - Objects.equals(this.message, v1GatewayStatusConditions.message) && - Objects.equals(this.observedGeneration, v1GatewayStatusConditions.observedGeneration) && - Objects.equals(this.reason, v1GatewayStatusConditions.reason) && - Objects.equals(this.status, v1GatewayStatusConditions.status) && - Objects.equals(this.type, v1GatewayStatusConditions.type); - } - - @Override - public int hashCode() { - return Objects.hash(lastTransitionTime, message, observedGeneration, reason, status, type); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1beta1GatewayStatusConditions {\n"); - sb.append(" lastTransitionTime: ").append(toIndentedString(lastTransitionTime)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append(" observedGeneration: ").append(toIndentedString(observedGeneration)).append("\n"); - sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusListeners.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusListeners.java index ab89cd86..b69a1aa2 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusListeners.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/gateways/V1GatewayStatusListeners.java @@ -1,21 +1,20 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.ArrayList; @@ -27,75 +26,71 @@ */ @Data public class V1GatewayStatusListeners { - public static final String SERIALIZED_NAME_ATTACHED_ROUTES = "attachedRoutes"; - @SerializedName(SERIALIZED_NAME_ATTACHED_ROUTES) - private Integer attachedRoutes; - - public static final String SERIALIZED_NAME_CONDITIONS = "conditions"; - @SerializedName(SERIALIZED_NAME_CONDITIONS) - private List conditions = new ArrayList<>(); - - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) - private String name; - - public static final String SERIALIZED_NAME_SUPPORTED_KINDS = "supportedKinds"; - @SerializedName(SERIALIZED_NAME_SUPPORTED_KINDS) - private List supportedKinds = new ArrayList<>(); - - public V1GatewayStatusListeners addConditionsItem(V1GatewayStatusConditions conditionsItem) { - this.conditions.add(conditionsItem); - return this; - } - - public V1GatewayStatusListeners addSupportedKindsItem(V1GatewaySpecAllowedRoutesKinds supportedKindsItem) { - this.supportedKinds.add(supportedKindsItem); - return this; - } + public static final String SERIALIZED_NAME_ATTACHED_ROUTES = "attachedRoutes"; + public static final String SERIALIZED_NAME_CONDITIONS = "conditions"; + public static final String SERIALIZED_NAME_NAME = "name"; + public static final String SERIALIZED_NAME_SUPPORTED_KINDS = "supportedKinds"; + @SerializedName(SERIALIZED_NAME_ATTACHED_ROUTES) + private Integer attachedRoutes; + @SerializedName(SERIALIZED_NAME_CONDITIONS) + private List conditions = new ArrayList<>(); + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + @SerializedName(SERIALIZED_NAME_SUPPORTED_KINDS) + private List supportedKinds = new ArrayList<>(); + + public V1GatewayStatusListeners addConditionsItem(V1GatewayStatusConditions conditionsItem) { + this.conditions.add(conditionsItem); + return this; + } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; + public V1GatewayStatusListeners addSupportedKindsItem(V1GatewaySpecAllowedRoutesKinds supportedKindsItem) { + this.supportedKinds.add(supportedKindsItem); + return this; } - if (o == null || getClass() != o.getClass()) { - return false; + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1GatewayStatusListeners v1GatewayStatusListeners = (V1GatewayStatusListeners) o; + return Objects.equals(this.attachedRoutes, v1GatewayStatusListeners.attachedRoutes) && + Objects.equals(this.conditions, v1GatewayStatusListeners.conditions) && + Objects.equals(this.name, v1GatewayStatusListeners.name) && + Objects.equals(this.supportedKinds, v1GatewayStatusListeners.supportedKinds); } - V1GatewayStatusListeners v1GatewayStatusListeners = (V1GatewayStatusListeners) o; - return Objects.equals(this.attachedRoutes, v1GatewayStatusListeners.attachedRoutes) && - Objects.equals(this.conditions, v1GatewayStatusListeners.conditions) && - Objects.equals(this.name, v1GatewayStatusListeners.name) && - Objects.equals(this.supportedKinds, v1GatewayStatusListeners.supportedKinds); - } - @Override - public int hashCode() { - return Objects.hash(attachedRoutes, conditions, name, supportedKinds); - } + @Override + public int hashCode() { + return Objects.hash(attachedRoutes, conditions, name, supportedKinds); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1beta1GatewayStatusListeners {\n"); - sb.append(" attachedRoutes: ").append(toIndentedString(attachedRoutes)).append("\n"); - sb.append(" conditions: ").append(toIndentedString(conditions)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" supportedKinds: ").append(toIndentedString(supportedKinds)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1beta1GatewayStatusListeners {\n" + + " attachedRoutes: " + toIndentedString(attachedRoutes) + "\n" + + " conditions: " + toIndentedString(conditions) + "\n" + + " name: " + toIndentedString(name) + "\n" + + " supportedKinds: " + toIndentedString(supportedKinds) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRoute.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRoute.java index 543b7e75..21a048f9 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRoute.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRoute.java @@ -1,13 +1,14 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ @@ -24,77 +25,72 @@ */ @Data public class V1HTTPRoute implements io.kubernetes.client.common.KubernetesObject { - public static final String API_GROUP = "gateway.networking.k8s.io"; - public static final String VERSION = "v1"; - public static final String KIND = "HTTPRoute"; - public static final String PLURAL = "httproutes"; - - public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; - @SerializedName(SERIALIZED_NAME_API_VERSION) - private String apiVersion = API_GROUP + "/" + VERSION; - - public static final String SERIALIZED_NAME_KIND = "kind"; - @SerializedName(SERIALIZED_NAME_KIND) - private String kind = KIND; - - public static final String SERIALIZED_NAME_METADATA = "metadata"; - @SerializedName(SERIALIZED_NAME_METADATA) - private V1ObjectMeta metadata = null; - - public static final String SERIALIZED_NAME_SPEC = "spec"; - @SerializedName(SERIALIZED_NAME_SPEC) - private V1HTTPRouteSpec spec; - - public static final String SERIALIZED_NAME_STATUS = "status"; - @SerializedName(SERIALIZED_NAME_STATUS) - private V1HTTPRouteStatus status; - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; + public static final String API_GROUP = "gateway.networking.k8s.io"; + public static final String VERSION = "v1"; + public static final String KIND = "HTTPRoute"; + public static final String PLURAL = "httproutes"; + + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; + public static final String SERIALIZED_NAME_KIND = "kind"; + public static final String SERIALIZED_NAME_METADATA = "metadata"; + public static final String SERIALIZED_NAME_SPEC = "spec"; + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_API_VERSION) + private String apiVersion = API_GROUP + "/" + VERSION; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind = KIND; + @SerializedName(SERIALIZED_NAME_METADATA) + private V1ObjectMeta metadata = null; + @SerializedName(SERIALIZED_NAME_SPEC) + private V1HTTPRouteSpec spec; + @SerializedName(SERIALIZED_NAME_STATUS) + private V1HTTPRouteStatus status; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRoute v1HttpRoute = (V1HTTPRoute) o; + return Objects.equals(this.apiVersion, v1HttpRoute.apiVersion) && + Objects.equals(this.kind, v1HttpRoute.kind) && + Objects.equals(this.metadata, v1HttpRoute.metadata) && + Objects.equals(this.spec, v1HttpRoute.spec) && + Objects.equals(this.status, v1HttpRoute.status); } - V1HTTPRoute v1HttpRoute = (V1HTTPRoute) o; - return Objects.equals(this.apiVersion, v1HttpRoute.apiVersion) && - Objects.equals(this.kind, v1HttpRoute.kind) && - Objects.equals(this.metadata, v1HttpRoute.metadata) && - Objects.equals(this.spec, v1HttpRoute.spec) && - Objects.equals(this.status, v1HttpRoute.status); - } - @Override - public int hashCode() { - return Objects.hash(apiVersion, kind, metadata, spec, status); - } + @Override + public int hashCode() { + return Objects.hash(apiVersion, kind, metadata, spec, status); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRoute {\n"); - sb.append(" apiVersion: ").append(toIndentedString(apiVersion)).append("\n"); - sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); - sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); - sb.append(" spec: ").append(toIndentedString(spec)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1HTTPRoute {\n" + + " apiVersion: " + toIndentedString(apiVersion) + "\n" + + " kind: " + toIndentedString(kind) + "\n" + + " metadata: " + toIndentedString(metadata) + "\n" + + " spec: " + toIndentedString(spec) + "\n" + + " status: " + toIndentedString(status) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteList.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteList.java index e5e30c51..00d3f09d 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteList.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteList.java @@ -1,16 +1,16 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ - package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; import com.google.gson.annotations.SerializedName; @@ -26,71 +26,67 @@ */ @Data public class V1HTTPRouteList implements io.kubernetes.client.common.KubernetesListObject { - public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; - @SerializedName(SERIALIZED_NAME_API_VERSION) - private String apiVersion; - - public static final String SERIALIZED_NAME_ITEMS = "items"; - @SerializedName(SERIALIZED_NAME_ITEMS) - private List items = new ArrayList<>(); - - public static final String SERIALIZED_NAME_KIND = "kind"; - @SerializedName(SERIALIZED_NAME_KIND) - private String kind; - - public static final String SERIALIZED_NAME_METADATA = "metadata"; - @SerializedName(SERIALIZED_NAME_METADATA) - private V1ListMeta metadata = null; - - public V1HTTPRouteList addItemsItem(V1HTTPRoute itemsItem) { - this.items.add(itemsItem); - return this; - } + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; + public static final String SERIALIZED_NAME_ITEMS = "items"; + public static final String SERIALIZED_NAME_KIND = "kind"; + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_API_VERSION) + private String apiVersion; + @SerializedName(SERIALIZED_NAME_ITEMS) + private List items = new ArrayList<>(); + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + @SerializedName(SERIALIZED_NAME_METADATA) + private V1ListMeta metadata = null; + + public V1HTTPRouteList addItemsItem(V1HTTPRoute itemsItem) { + this.items.add(itemsItem); + return this; + } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteList v1HttpRouteList = (V1HTTPRouteList) o; + return Objects.equals(this.apiVersion, v1HttpRouteList.apiVersion) && + Objects.equals(this.items, v1HttpRouteList.items) && + Objects.equals(this.kind, v1HttpRouteList.kind) && + Objects.equals(this.metadata, v1HttpRouteList.metadata); } - V1HTTPRouteList v1HttpRouteList = (V1HTTPRouteList) o; - return Objects.equals(this.apiVersion, v1HttpRouteList.apiVersion) && - Objects.equals(this.items, v1HttpRouteList.items) && - Objects.equals(this.kind, v1HttpRouteList.kind) && - Objects.equals(this.metadata, v1HttpRouteList.metadata); - } - @Override - public int hashCode() { - return Objects.hash(apiVersion, items, kind, metadata); - } + @Override + public int hashCode() { + return Objects.hash(apiVersion, items, kind, metadata); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteList {\n"); - sb.append(" apiVersion: ").append(toIndentedString(apiVersion)).append("\n"); - sb.append(" items: ").append(toIndentedString(items)).append("\n"); - sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); - sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1HTTPRouteList {\n" + + " apiVersion: " + toIndentedString(apiVersion) + "\n" + + " items: " + toIndentedString(items) + "\n" + + " kind: " + toIndentedString(kind) + "\n" + + " metadata: " + toIndentedString(metadata) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpec.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpec.java index c544f73e..6a346697 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpec.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpec.java @@ -1,13 +1,14 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ @@ -25,76 +26,73 @@ */ @Data public class V1HTTPRouteSpec { - public static final String SERIALIZED_NAME_HOSTNAMES = "hostnames"; - @SerializedName(SERIALIZED_NAME_HOSTNAMES) - private List hostnames = null; - - public static final String SERIALIZED_NAME_PARENT_REFS = "parentRefs"; - @SerializedName(SERIALIZED_NAME_PARENT_REFS) - private List parentRefs = null; - - public static final String SERIALIZED_NAME_RULES = "rules"; - @SerializedName(SERIALIZED_NAME_RULES) - private List rules = null; - - public V1HTTPRouteSpec addHostnamesItem(String hostnamesItem) { - if (this.hostnames == null) { - this.hostnames = new ArrayList<>(); + public static final String SERIALIZED_NAME_HOSTNAMES = "hostnames"; + public static final String SERIALIZED_NAME_PARENT_REFS = "parentRefs"; + public static final String SERIALIZED_NAME_RULES = "rules"; + @SerializedName(SERIALIZED_NAME_HOSTNAMES) + private List hostnames = null; + @SerializedName(SERIALIZED_NAME_PARENT_REFS) + private List parentRefs = null; + @SerializedName(SERIALIZED_NAME_RULES) + private List rules = null; + + public V1HTTPRouteSpec addHostnamesItem(String hostnamesItem) { + if (this.hostnames == null) { + this.hostnames = new ArrayList<>(); + } + this.hostnames.add(hostnamesItem); + return this; } - this.hostnames.add(hostnamesItem); - return this; - } - public V1HTTPRouteSpec addParentRefsItem(V1HTTPRouteSpecParentRefs parentRefsItem) { - if (this.parentRefs == null) { - this.parentRefs = new ArrayList<>(); + public V1HTTPRouteSpec addParentRefsItem(V1HTTPRouteSpecParentRefs parentRefsItem) { + if (this.parentRefs == null) { + this.parentRefs = new ArrayList<>(); + } + this.parentRefs.add(parentRefsItem); + return this; } - this.parentRefs.add(parentRefsItem); - return this; - } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpec v1HttpRouteSpec = (V1HTTPRouteSpec) o; + return Objects.equals(this.hostnames, v1HttpRouteSpec.hostnames) && + Objects.equals(this.parentRefs, v1HttpRouteSpec.parentRefs) && + Objects.equals(this.rules, v1HttpRouteSpec.rules); } - if (o == null || getClass() != o.getClass()) { - return false; - } - V1HTTPRouteSpec v1HttpRouteSpec = (V1HTTPRouteSpec) o; - return Objects.equals(this.hostnames, v1HttpRouteSpec.hostnames) && - Objects.equals(this.parentRefs, v1HttpRouteSpec.parentRefs) && - Objects.equals(this.rules, v1HttpRouteSpec.rules); - } - @Override - public int hashCode() { - return Objects.hash(hostnames, parentRefs, rules); - } + @Override + public int hashCode() { + return Objects.hash(hostnames, parentRefs, rules); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteSpec {\n"); - sb.append(" hostnames: ").append(toIndentedString(hostnames)).append("\n"); - sb.append(" parentRefs: ").append(toIndentedString(parentRefs)).append("\n"); - sb.append(" rules: ").append(toIndentedString(rules)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1HTTPRouteSpec {\n" + + " hostnames: " + toIndentedString(hostnames) + "\n" + + " parentRefs: " + toIndentedString(parentRefs) + "\n" + + " rules: " + toIndentedString(rules) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecBackendRefs.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecBackendRefs.java index 938d5d0d..3ca72f16 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecBackendRefs.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecBackendRefs.java @@ -1,21 +1,20 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.ArrayList; @@ -27,92 +26,85 @@ */ @Data public class V1HTTPRouteSpecBackendRefs { - public static final String SERIALIZED_NAME_FILTERS = "filters"; - @SerializedName(SERIALIZED_NAME_FILTERS) - private List filters = null; - - public static final String SERIALIZED_NAME_GROUP = "group"; - @SerializedName(SERIALIZED_NAME_GROUP) - private String group; - - public static final String SERIALIZED_NAME_KIND = "kind"; - @SerializedName(SERIALIZED_NAME_KIND) - private String kind; - - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) - private String name; - - public static final String SERIALIZED_NAME_NAMESPACE = "namespace"; - @SerializedName(SERIALIZED_NAME_NAMESPACE) - private String namespace; - - public static final String SERIALIZED_NAME_PORT = "port"; - @SerializedName(SERIALIZED_NAME_PORT) - private Integer port; - - public static final String SERIALIZED_NAME_WEIGHT = "weight"; - @SerializedName(SERIALIZED_NAME_WEIGHT) - private Integer weight; - - public V1HTTPRouteSpecBackendRefs addFiltersItem(V1HTTPRouteSpecFilters filtersItem) { - if (this.filters == null) { - this.filters = new ArrayList<>(); + public static final String SERIALIZED_NAME_FILTERS = "filters"; + public static final String SERIALIZED_NAME_GROUP = "group"; + public static final String SERIALIZED_NAME_KIND = "kind"; + public static final String SERIALIZED_NAME_NAME = "name"; + public static final String SERIALIZED_NAME_NAMESPACE = "namespace"; + public static final String SERIALIZED_NAME_PORT = "port"; + public static final String SERIALIZED_NAME_WEIGHT = "weight"; + @SerializedName(SERIALIZED_NAME_FILTERS) + private List filters = null; + @SerializedName(SERIALIZED_NAME_GROUP) + private String group; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + @SerializedName(SERIALIZED_NAME_NAMESPACE) + private String namespace; + @SerializedName(SERIALIZED_NAME_PORT) + private Integer port; + @SerializedName(SERIALIZED_NAME_WEIGHT) + private Integer weight; + + public V1HTTPRouteSpecBackendRefs addFiltersItem(V1HTTPRouteSpecFilters filtersItem) { + if (this.filters == null) { + this.filters = new ArrayList<>(); + } + this.filters.add(filtersItem); + return this; } - this.filters.add(filtersItem); - return this; - } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecBackendRefs v1HttpRouteSpecBackendRefs = (V1HTTPRouteSpecBackendRefs) o; + return Objects.equals(this.filters, v1HttpRouteSpecBackendRefs.filters) && + Objects.equals(this.group, v1HttpRouteSpecBackendRefs.group) && + Objects.equals(this.kind, v1HttpRouteSpecBackendRefs.kind) && + Objects.equals(this.name, v1HttpRouteSpecBackendRefs.name) && + Objects.equals(this.namespace, v1HttpRouteSpecBackendRefs.namespace) && + Objects.equals(this.port, v1HttpRouteSpecBackendRefs.port) && + Objects.equals(this.weight, v1HttpRouteSpecBackendRefs.weight); } - V1HTTPRouteSpecBackendRefs v1HttpRouteSpecBackendRefs = (V1HTTPRouteSpecBackendRefs) o; - return Objects.equals(this.filters, v1HttpRouteSpecBackendRefs.filters) && - Objects.equals(this.group, v1HttpRouteSpecBackendRefs.group) && - Objects.equals(this.kind, v1HttpRouteSpecBackendRefs.kind) && - Objects.equals(this.name, v1HttpRouteSpecBackendRefs.name) && - Objects.equals(this.namespace, v1HttpRouteSpecBackendRefs.namespace) && - Objects.equals(this.port, v1HttpRouteSpecBackendRefs.port) && - Objects.equals(this.weight, v1HttpRouteSpecBackendRefs.weight); - } - @Override - public int hashCode() { - return Objects.hash(filters, group, kind, name, namespace, port, weight); - } + @Override + public int hashCode() { + return Objects.hash(filters, group, kind, name, namespace, port, weight); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteSpecBackendRefs {\n"); - sb.append(" filters: ").append(toIndentedString(filters)).append("\n"); - sb.append(" group: ").append(toIndentedString(group)).append("\n"); - sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); - sb.append(" port: ").append(toIndentedString(port)).append("\n"); - sb.append(" weight: ").append(toIndentedString(weight)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1HTTPRouteSpecBackendRefs {\n" + + " filters: " + toIndentedString(filters) + "\n" + + " group: " + toIndentedString(group) + "\n" + + " kind: " + toIndentedString(kind) + "\n" + + " name: " + toIndentedString(name) + "\n" + + " namespace: " + toIndentedString(namespace) + "\n" + + " port: " + toIndentedString(port) + "\n" + + " weight: " + toIndentedString(weight) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecExtensionRef.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecExtensionRef.java index 460845f2..70ed816f 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecExtensionRef.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecExtensionRef.java @@ -1,21 +1,20 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Objects; @@ -25,60 +24,57 @@ */ @Data public class V1HTTPRouteSpecExtensionRef { - public static final String SERIALIZED_NAME_GROUP = "group"; - @SerializedName(SERIALIZED_NAME_GROUP) - private String group; - - public static final String SERIALIZED_NAME_KIND = "kind"; - @SerializedName(SERIALIZED_NAME_KIND) - private String kind; - - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) - private String name; + public static final String SERIALIZED_NAME_GROUP = "group"; + public static final String SERIALIZED_NAME_KIND = "kind"; + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_GROUP) + private String group; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; - @Override - public boolean equals(Object o) { - if (this == o) { - return true; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecExtensionRef v1HttpRouteSpecExtensionRef = (V1HTTPRouteSpecExtensionRef) o; + return Objects.equals(this.group, v1HttpRouteSpecExtensionRef.group) && + Objects.equals(this.kind, v1HttpRouteSpecExtensionRef.kind) && + Objects.equals(this.name, v1HttpRouteSpecExtensionRef.name); } - if (o == null || getClass() != o.getClass()) { - return false; - } - V1HTTPRouteSpecExtensionRef v1HttpRouteSpecExtensionRef = (V1HTTPRouteSpecExtensionRef) o; - return Objects.equals(this.group, v1HttpRouteSpecExtensionRef.group) && - Objects.equals(this.kind, v1HttpRouteSpecExtensionRef.kind) && - Objects.equals(this.name, v1HttpRouteSpecExtensionRef.name); - } - @Override - public int hashCode() { - return Objects.hash(group, kind, name); - } + @Override + public int hashCode() { + return Objects.hash(group, kind, name); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteSpecExtensionRef {\n"); - sb.append(" group: ").append(toIndentedString(group)).append("\n"); - sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1HTTPRouteSpecExtensionRef {\n" + + " group: " + toIndentedString(group) + "\n" + + " kind: " + toIndentedString(kind) + "\n" + + " name: " + toIndentedString(name) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecFilters.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecFilters.java index 0fccf52b..3c096d73 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecFilters.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecFilters.java @@ -1,13 +1,14 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ @@ -18,8 +19,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.IOException; @@ -30,166 +29,155 @@ */ @Data public class V1HTTPRouteSpecFilters { - public static final String SERIALIZED_NAME_EXTENSION_REF = "extensionRef"; - @SerializedName(SERIALIZED_NAME_EXTENSION_REF) - private V1HTTPRouteSpecExtensionRef extensionRef; - - - public static final String SERIALIZED_NAME_REQUEST_HEADER_MODIFIER = "requestHeaderModifier"; - @SerializedName(SERIALIZED_NAME_REQUEST_HEADER_MODIFIER) - private V1HTTPRouteSpecRequestHeaderModifier requestHeaderModifier; - - public static final String SERIALIZED_NAME_REQUEST_MIRROR = "requestMirror"; - @SerializedName(SERIALIZED_NAME_REQUEST_MIRROR) - private V1HTTPRouteSpecRequestMirror requestMirror; - - public static final String SERIALIZED_NAME_REQUEST_REDIRECT = "requestRedirect"; - @SerializedName(SERIALIZED_NAME_REQUEST_REDIRECT) - private V1HTTPRouteSpecRequestRedirect requestRedirect; - - public static final String SERIALIZED_NAME_RESPONSE_HEADER_MODIFIER = "responseHeaderModifier"; - @SerializedName(SERIALIZED_NAME_RESPONSE_HEADER_MODIFIER) - private V1HTTPRouteSpecResponseHeaderModifier responseHeaderModifier; - - /** - * Type identifies the type of filter to apply. As with other API fields, types are classified into three conformance levels: - Core: Filter types and their corresponding configuration defined by \"Support: Core\" in this package, e.g. \"RequestHeaderModifier\". All implementations must support core filters. - Extended: Filter types and their corresponding configuration defined by \"Support: Extended\" in this package, e.g. \"RequestMirror\". Implementers are encouraged to support extended filters. - Implementation-specific: Filters that are defined and supported by specific vendors. In the future, filters showing convergence in behavior across multiple implementations will be considered for inclusion in extended or core conformance levels. Filter-specific configuration for such filters is specified using the ExtensionRef field. `Type` should be set to \"ExtensionRef\" for custom filters. Implementers are encouraged to define custom implementation types to extend the core API with implementation-specific behavior. If a reference to a custom filter type cannot be resolved, the filter MUST NOT be skipped. Instead, requests that would have been processed by that filter MUST receive a HTTP error response. Note that values may be added to this enum, implementations must ensure that unknown values will not cause a crash. Unknown values here must result in the implementation setting the Accepted Condition for the Route to `status: False`, with a Reason of `UnsupportedValue`. - */ - @JsonAdapter(TypeEnum.Adapter.class) - public enum TypeEnum { - /** - * RequestHeaderModifier is a core filter type used to modify the headers of incoming HTTP requests. - * All implementations must support this filter type. - */ - REQUESTHEADERMODIFIER("RequestHeaderModifier"), - - /** - * ResponseHeaderModifier is a core filter type used to modify the headers of outgoing HTTP responses. - * All implementations must support this filter type. - */ - RESPONSEHEADERMODIFIER("ResponseHeaderModifier"), - - /** - * RequestMirror is an extended filter type used to mirror HTTP requests to another service or destination. - * Implementers are encouraged to support this filter type. - */ - REQUESTMIRROR("RequestMirror"), - - /** - * RequestRedirect is a core filter type used to redirect HTTP requests to a different URL. - * All implementations must support this filter type. - */ - REQUESTREDIRECT("RequestRedirect"), - - /** - * URLRewrite is a core filter type used to rewrite the URL path or query in an HTTP request. - * All implementations must support this filter type. - */ - URLREWRITE("URLRewrite"), + public static final String SERIALIZED_NAME_EXTENSION_REF = "extensionRef"; + public static final String SERIALIZED_NAME_REQUEST_HEADER_MODIFIER = "requestHeaderModifier"; + public static final String SERIALIZED_NAME_REQUEST_MIRROR = "requestMirror"; + public static final String SERIALIZED_NAME_REQUEST_REDIRECT = "requestRedirect"; + public static final String SERIALIZED_NAME_RESPONSE_HEADER_MODIFIER = "responseHeaderModifier"; + public static final String SERIALIZED_NAME_TYPE = "type"; + public static final String SERIALIZED_NAME_URL_REWRITE = "urlRewrite"; + @SerializedName(SERIALIZED_NAME_EXTENSION_REF) + private V1HTTPRouteSpecExtensionRef extensionRef; + @SerializedName(SERIALIZED_NAME_REQUEST_HEADER_MODIFIER) + private V1HTTPRouteSpecRequestHeaderModifier requestHeaderModifier; + @SerializedName(SERIALIZED_NAME_REQUEST_MIRROR) + private V1HTTPRouteSpecRequestMirror requestMirror; + @SerializedName(SERIALIZED_NAME_REQUEST_REDIRECT) + private V1HTTPRouteSpecRequestRedirect requestRedirect; + @SerializedName(SERIALIZED_NAME_RESPONSE_HEADER_MODIFIER) + private V1HTTPRouteSpecResponseHeaderModifier responseHeaderModifier; + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type; + @SerializedName(SERIALIZED_NAME_URL_REWRITE) + private V1HTTPRouteSpecUrlRewrite urlRewrite; - /** - * ExtensionRef is an implementation-specific filter type used for custom filters defined by the implementer. - * This type should be set to "ExtensionRef" for custom filters, and the specific configuration is specified using the ExtensionRef field. - * If a reference to a custom filter type cannot be resolved, the filter MUST NOT be skipped, and the request must receive an HTTP error response. - */ - EXTENSIONREF("ExtensionRef"); - - private String value; - - TypeEnum(String value) { - this.value = value; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecFilters v1HttpRouteSpecFilters = (V1HTTPRouteSpecFilters) o; + return Objects.equals(this.extensionRef, v1HttpRouteSpecFilters.extensionRef) && + Objects.equals(this.requestHeaderModifier, v1HttpRouteSpecFilters.requestHeaderModifier) && + Objects.equals(this.requestMirror, v1HttpRouteSpecFilters.requestMirror) && + Objects.equals(this.requestRedirect, v1HttpRouteSpecFilters.requestRedirect) && + Objects.equals(this.responseHeaderModifier, v1HttpRouteSpecFilters.responseHeaderModifier) && + Objects.equals(this.type, v1HttpRouteSpecFilters.type) && + Objects.equals(this.urlRewrite, v1HttpRouteSpecFilters.urlRewrite); } - public String getValue() { - return value; + @Override + public int hashCode() { + return Objects.hash(extensionRef, requestHeaderModifier, requestMirror, requestRedirect, responseHeaderModifier, type, urlRewrite); } @Override public String toString() { - return String.valueOf(value); + String sb = "class V1HTTPRouteSpecFilters {\n" + + " extensionRef: " + toIndentedString(extensionRef) + "\n" + + " requestHeaderModifier: " + toIndentedString(requestHeaderModifier) + "\n" + + " requestMirror: " + toIndentedString(requestMirror) + "\n" + + " requestRedirect: " + toIndentedString(requestRedirect) + "\n" + + " responseHeaderModifier: " + toIndentedString(responseHeaderModifier) + "\n" + + " type: " + toIndentedString(type) + "\n" + + " urlRewrite: " + toIndentedString(urlRewrite) + "\n" + + "}"; + return sb; } - public static TypeEnum fromValue(String value) { - for (TypeEnum b : TypeEnum.values()) { - if (b.value.equals(value)) { - return b; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return o.toString().replace("\n", "\n "); } - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } - } - - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) - private TypeEnum type; + /** + * Type identifies the type of filter to apply. As with other API fields, types are classified into three conformance levels: - Core: Filter types and their corresponding configuration defined by \"Support: Core\" in this package, e.g. \"RequestHeaderModifier\". All implementations must support core filters. - Extended: Filter types and their corresponding configuration defined by \"Support: Extended\" in this package, e.g. \"RequestMirror\". Implementers are encouraged to support extended filters. - Implementation-specific: Filters that are defined and supported by specific vendors. In the future, filters showing convergence in behavior across multiple implementations will be considered for inclusion in extended or core conformance levels. Filter-specific configuration for such filters is specified using the ExtensionRef field. `Type` should be set to \"ExtensionRef\" for custom filters. Implementers are encouraged to define custom implementation types to extend the core API with implementation-specific behavior. If a reference to a custom filter type cannot be resolved, the filter MUST NOT be skipped. Instead, requests that would have been processed by that filter MUST receive a HTTP error response. Note that values may be added to this enum, implementations must ensure that unknown values will not cause a crash. Unknown values here must result in the implementation setting the Accepted Condition for the Route to `status: False`, with a Reason of `UnsupportedValue`. + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + /** + * RequestHeaderModifier is a core filter type used to modify the headers of incoming HTTP requests. + * All implementations must support this filter type. + */ + REQUESTHEADERMODIFIER("RequestHeaderModifier"), + + /** + * ResponseHeaderModifier is a core filter type used to modify the headers of outgoing HTTP responses. + * All implementations must support this filter type. + */ + RESPONSEHEADERMODIFIER("ResponseHeaderModifier"), + + /** + * RequestMirror is an extended filter type used to mirror HTTP requests to another service or destination. + * Implementers are encouraged to support this filter type. + */ + REQUESTMIRROR("RequestMirror"), + + /** + * RequestRedirect is a core filter type used to redirect HTTP requests to a different URL. + * All implementations must support this filter type. + */ + REQUESTREDIRECT("RequestRedirect"), + + /** + * URLRewrite is a core filter type used to rewrite the URL path or query in an HTTP request. + * All implementations must support this filter type. + */ + URLREWRITE("URLRewrite"), + + /** + * ExtensionRef is an implementation-specific filter type used for custom filters defined by the implementer. + * This type should be set to "ExtensionRef" for custom filters, and the specific configuration is specified using the ExtensionRef field. + * If a reference to a custom filter type cannot be resolved, the filter MUST NOT be skipped, and the request must receive an HTTP error response. + */ + EXTENSIONREF("ExtensionRef"); + + private final String value; + + TypeEnum(String value) { + this.value = value; + } - public static final String SERIALIZED_NAME_URL_REWRITE = "urlRewrite"; - @SerializedName(SERIALIZED_NAME_URL_REWRITE) - private V1HTTPRouteSpecUrlRewrite urlRewrite; + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + public String getValue() { + return value; + } + @Override + public String toString() { + return String.valueOf(value); + } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - V1HTTPRouteSpecFilters v1HttpRouteSpecFilters = (V1HTTPRouteSpecFilters) o; - return Objects.equals(this.extensionRef, v1HttpRouteSpecFilters.extensionRef) && - Objects.equals(this.requestHeaderModifier, v1HttpRouteSpecFilters.requestHeaderModifier) && - Objects.equals(this.requestMirror, v1HttpRouteSpecFilters.requestMirror) && - Objects.equals(this.requestRedirect, v1HttpRouteSpecFilters.requestRedirect) && - Objects.equals(this.responseHeaderModifier, v1HttpRouteSpecFilters.responseHeaderModifier) && - Objects.equals(this.type, v1HttpRouteSpecFilters.type) && - Objects.equals(this.urlRewrite, v1HttpRouteSpecFilters.urlRewrite); - } - - @Override - public int hashCode() { - return Objects.hash(extensionRef, requestHeaderModifier, requestMirror, requestRedirect, responseHeaderModifier, type, urlRewrite); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteSpecFilters {\n"); - sb.append(" extensionRef: ").append(toIndentedString(extensionRef)).append("\n"); - sb.append(" requestHeaderModifier: ").append(toIndentedString(requestHeaderModifier)).append("\n"); - sb.append(" requestMirror: ").append(toIndentedString(requestMirror)).append("\n"); - sb.append(" requestRedirect: ").append(toIndentedString(requestRedirect)).append("\n"); - sb.append(" responseHeaderModifier: ").append(toIndentedString(responseHeaderModifier)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" urlRewrite: ").append(toIndentedString(urlRewrite)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecHeaders.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecHeaders.java index c5b380cf..3ca14b0f 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecHeaders.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecHeaders.java @@ -1,13 +1,14 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ @@ -18,8 +19,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.IOException; @@ -30,115 +29,110 @@ */ @Data public class V1HTTPRouteSpecHeaders { - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) - private String name; - - /** - * Type specifies how to match against the value of the header. Support: Core (Exact) Support: Implementation-specific (RegularExpression) Since RegularExpression HeaderMatchType has implementation-specific conformance, implementations can support POSIX, PCRE or any other dialects of regular expressions. Please read the implementation's documentation to determine the supported dialect. - */ - @JsonAdapter(TypeEnum.Adapter.class) - public enum TypeEnum { - /** - * EXACT is a core match type that matches the header value exactly. - * All implementations must support this match type. - */ - EXACT("Exact"), - - /** - * REGULAREXPRESSION is an implementation-specific match type that allows matching header values using regular expressions. - * The specific regular expression dialect supported may vary between implementations. - */ - REGULAREXPRESSION("RegularExpression"); - + public static final String SERIALIZED_NAME_NAME = "name"; + public static final String SERIALIZED_NAME_TYPE = "type"; + public static final String SERIALIZED_NAME_VALUE = "value"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type; + @SerializedName(SERIALIZED_NAME_VALUE) private String value; - TypeEnum(String value) { - this.value = value; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecHeaders v1HttpRouteSpecHeaders = (V1HTTPRouteSpecHeaders) o; + return Objects.equals(this.name, v1HttpRouteSpecHeaders.name) && + Objects.equals(this.type, v1HttpRouteSpecHeaders.type) && + Objects.equals(this.value, v1HttpRouteSpecHeaders.value); } - public String getValue() { - return value; + @Override + public int hashCode() { + return Objects.hash(name, type, value); } @Override public String toString() { - return String.valueOf(value); + String sb = "class V1HTTPRouteSpecHeaders {\n" + + " name: " + toIndentedString(name) + "\n" + + " type: " + toIndentedString(type) + "\n" + + " value: " + toIndentedString(value) + "\n" + + "}"; + return sb; } - public static TypeEnum fromValue(String value) { - for (TypeEnum b : TypeEnum.values()) { - if (b.value.equals(value)) { - return b; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return o.toString().replace("\n", "\n "); } - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } - } + /** + * Type specifies how to match against the value of the header. Support: Core (Exact) Support: Implementation-specific (RegularExpression) Since RegularExpression HeaderMatchType has implementation-specific conformance, implementations can support POSIX, PCRE or any other dialects of regular expressions. Please read the implementation's documentation to determine the supported dialect. + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + /** + * EXACT is a core match type that matches the header value exactly. + * All implementations must support this match type. + */ + EXACT("Exact"), + + /** + * REGULAREXPRESSION is an implementation-specific match type that allows matching header values using regular expressions. + * The specific regular expression dialect supported may vary between implementations. + */ + REGULAREXPRESSION("RegularExpression"); + + private final String value; + + TypeEnum(String value) { + this.value = value; + } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) - private TypeEnum type; + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } - public static final String SERIALIZED_NAME_VALUE = "value"; - @SerializedName(SERIALIZED_NAME_VALUE) - private String value; + public String getValue() { + return value; + } + @Override + public String toString() { + return String.valueOf(value); + } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - V1HTTPRouteSpecHeaders v1HttpRouteSpecHeaders = (V1HTTPRouteSpecHeaders) o; - return Objects.equals(this.name, v1HttpRouteSpecHeaders.name) && - Objects.equals(this.type, v1HttpRouteSpecHeaders.type) && - Objects.equals(this.value, v1HttpRouteSpecHeaders.value); - } - - @Override - public int hashCode() { - return Objects.hash(name, type, value); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteSpecHeaders {\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" value: ").append(toIndentedString(value)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecMatches.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecMatches.java index fc02cd28..0cd788f9 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecMatches.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecMatches.java @@ -1,13 +1,14 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ @@ -18,8 +19,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.IOException; @@ -32,180 +31,173 @@ */ @Data public class V1HTTPRouteSpecMatches { - public static final String SERIALIZED_NAME_HEADERS = "headers"; - @SerializedName(SERIALIZED_NAME_HEADERS) - private List headers = null; - - /** - * Method specifies HTTP method matcher. When specified, this route will be matched only if the request has the specified method. Support: Extended - */ - @JsonAdapter(MethodEnum.Adapter.class) - public enum MethodEnum { - /** - * GET is an HTTP method used to request data from a specified resource. - * Commonly used to retrieve information. - */ - GET("GET"), - - /** - * HEAD is an HTTP method used to request headers from a specified resource. - * Similar to GET, but without the response body. - */ - HEAD("HEAD"), - - /** - * POST is an HTTP method used to send data to a server to create/update a resource. - * Commonly used for submitting form data or uploading files. - */ - POST("POST"), - - /** - * PUT is an HTTP method used to update or create a resource at the specified resource. - * Typically used for updating existing resources. - */ - PUT("PUT"), - - /** - * DELETE is an HTTP method used to delete a specified resource. - * Used for removing resources from the server. - */ - DELETE("DELETE"), - - /** - * CONNECT is an HTTP method used to establish a tunnel to the server identified by the target resource. - * Commonly used for tunneling HTTP requests over a network. - */ - CONNECT("CONNECT"), - - /** - * OPTIONS is an HTTP method used to describe the communication options for the target resource. - * Used to determine the capabilities of a server, such as allowed HTTP methods. - */ - OPTIONS("OPTIONS"), - - /** - * TRACE is an HTTP method used to perform a message loop-back test along the path to the target resource. - * Typically used for diagnostic purposes. - */ - TRACE("TRACE"), - - /** - * PATCH is an HTTP method used to apply partial modifications to a resource. - * Often used when you need to update a resource with a few changes rather than replacing the entire resource. - */ - PATCH("PATCH"); + public static final String SERIALIZED_NAME_HEADERS = "headers"; + public static final String SERIALIZED_NAME_METHOD = "method"; + public static final String SERIALIZED_NAME_PATH = "path"; + public static final String SERIALIZED_NAME_QUERY_PARAMS = "queryParams"; + @SerializedName(SERIALIZED_NAME_HEADERS) + private List headers = null; + @SerializedName(SERIALIZED_NAME_METHOD) + private MethodEnum method; + @SerializedName(SERIALIZED_NAME_PATH) + private V1HTTPRouteSpecPath path; + @SerializedName(SERIALIZED_NAME_QUERY_PARAMS) + private List queryParams = null; + + public V1HTTPRouteSpecMatches addHeadersItem(V1HTTPRouteSpecHeaders headersItem) { + if (this.headers == null) { + this.headers = new ArrayList<>(); + } + this.headers.add(headersItem); + return this; + } - private String value; + public V1HTTPRouteSpecMatches addQueryParamsItem(V1HTTPRouteSpecQueryParams queryParamsItem) { + if (this.queryParams == null) { + this.queryParams = new ArrayList<>(); + } + this.queryParams.add(queryParamsItem); + return this; + } - MethodEnum(String value) { - this.value = value; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecMatches v1HttpRouteSpecMatches = (V1HTTPRouteSpecMatches) o; + return Objects.equals(this.headers, v1HttpRouteSpecMatches.headers) && + Objects.equals(this.method, v1HttpRouteSpecMatches.method) && + Objects.equals(this.path, v1HttpRouteSpecMatches.path) && + Objects.equals(this.queryParams, v1HttpRouteSpecMatches.queryParams); } - public String getValue() { - return value; + @Override + public int hashCode() { + return Objects.hash(headers, method, path, queryParams); } @Override public String toString() { - return String.valueOf(value); + String sb = "class V1HTTPRouteSpecMatches {\n" + + " headers: " + toIndentedString(headers) + "\n" + + " method: " + toIndentedString(method) + "\n" + + " path: " + toIndentedString(path) + "\n" + + " queryParams: " + toIndentedString(queryParams) + "\n" + + "}"; + return sb; } - public static MethodEnum fromValue(String value) { - for (MethodEnum b : MethodEnum.values()) { - if (b.value.equals(value)) { - return b; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return o.toString().replace("\n", "\n "); } - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final MethodEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public MethodEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return MethodEnum.fromValue(value); - } - } - } - - public static final String SERIALIZED_NAME_METHOD = "method"; - @SerializedName(SERIALIZED_NAME_METHOD) - private MethodEnum method; - - public static final String SERIALIZED_NAME_PATH = "path"; - @SerializedName(SERIALIZED_NAME_PATH) - private V1HTTPRouteSpecPath path; - - public static final String SERIALIZED_NAME_QUERY_PARAMS = "queryParams"; - @SerializedName(SERIALIZED_NAME_QUERY_PARAMS) - private List queryParams = null; - + /** + * Method specifies HTTP method matcher. When specified, this route will be matched only if the request has the specified method. Support: Extended + */ + @JsonAdapter(MethodEnum.Adapter.class) + public enum MethodEnum { + /** + * GET is an HTTP method used to request data from a specified resource. + * Commonly used to retrieve information. + */ + GET("GET"), + + /** + * HEAD is an HTTP method used to request headers from a specified resource. + * Similar to GET, but without the response body. + */ + HEAD("HEAD"), + + /** + * POST is an HTTP method used to send data to a server to create/update a resource. + * Commonly used for submitting form data or uploading files. + */ + POST("POST"), + + /** + * PUT is an HTTP method used to update or create a resource at the specified resource. + * Typically used for updating existing resources. + */ + PUT("PUT"), + + /** + * DELETE is an HTTP method used to delete a specified resource. + * Used for removing resources from the server. + */ + DELETE("DELETE"), + + /** + * CONNECT is an HTTP method used to establish a tunnel to the server identified by the target resource. + * Commonly used for tunneling HTTP requests over a network. + */ + CONNECT("CONNECT"), + + /** + * OPTIONS is an HTTP method used to describe the communication options for the target resource. + * Used to determine the capabilities of a server, such as allowed HTTP methods. + */ + OPTIONS("OPTIONS"), + + /** + * TRACE is an HTTP method used to perform a message loop-back test along the path to the target resource. + * Typically used for diagnostic purposes. + */ + TRACE("TRACE"), + + /** + * PATCH is an HTTP method used to apply partial modifications to a resource. + * Often used when you need to update a resource with a few changes rather than replacing the entire resource. + */ + PATCH("PATCH"); + + private final String value; + + MethodEnum(String value) { + this.value = value; + } - public V1HTTPRouteSpecMatches addHeadersItem(V1HTTPRouteSpecHeaders headersItem) { - if (this.headers == null) { - this.headers = new ArrayList<>(); - } - this.headers.add(headersItem); - return this; - } + public static MethodEnum fromValue(String value) { + for (MethodEnum b : MethodEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } - public V1HTTPRouteSpecMatches addQueryParamsItem(V1HTTPRouteSpecQueryParams queryParamsItem) { - if (this.queryParams == null) { - this.queryParams = new ArrayList<>(); - } - this.queryParams.add(queryParamsItem); - return this; - } + public String getValue() { + return value; + } + @Override + public String toString() { + return String.valueOf(value); + } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - V1HTTPRouteSpecMatches v1HttpRouteSpecMatches = (V1HTTPRouteSpecMatches) o; - return Objects.equals(this.headers, v1HttpRouteSpecMatches.headers) && - Objects.equals(this.method, v1HttpRouteSpecMatches.method) && - Objects.equals(this.path, v1HttpRouteSpecMatches.path) && - Objects.equals(this.queryParams, v1HttpRouteSpecMatches.queryParams); - } - - @Override - public int hashCode() { - return Objects.hash(headers, method, path, queryParams); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteSpecMatches {\n"); - sb.append(" headers: ").append(toIndentedString(headers)).append("\n"); - sb.append(" method: ").append(toIndentedString(method)).append("\n"); - sb.append(" path: ").append(toIndentedString(path)).append("\n"); - sb.append(" queryParams: ").append(toIndentedString(queryParams)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final MethodEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public MethodEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return MethodEnum.fromValue(value); + } + } } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecParentRefs.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecParentRefs.java index a698961f..7681a92f 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecParentRefs.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecParentRefs.java @@ -1,21 +1,20 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Objects; @@ -25,78 +24,72 @@ */ @Data public class V1HTTPRouteSpecParentRefs { - public static final String SERIALIZED_NAME_GROUP = "group"; - @SerializedName(SERIALIZED_NAME_GROUP) - private String group; - - public static final String SERIALIZED_NAME_KIND = "kind"; - @SerializedName(SERIALIZED_NAME_KIND) - private String kind; - - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) - private String name; - - public static final String SERIALIZED_NAME_NAMESPACE = "namespace"; - @SerializedName(SERIALIZED_NAME_NAMESPACE) - private String namespace; - - public static final String SERIALIZED_NAME_PORT = "port"; - @SerializedName(SERIALIZED_NAME_PORT) - private Integer port; - - public static final String SERIALIZED_NAME_SECTION_NAME = "sectionName"; - @SerializedName(SERIALIZED_NAME_SECTION_NAME) - private String sectionName; - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; + public static final String SERIALIZED_NAME_GROUP = "group"; + public static final String SERIALIZED_NAME_KIND = "kind"; + public static final String SERIALIZED_NAME_NAME = "name"; + public static final String SERIALIZED_NAME_NAMESPACE = "namespace"; + public static final String SERIALIZED_NAME_PORT = "port"; + public static final String SERIALIZED_NAME_SECTION_NAME = "sectionName"; + @SerializedName(SERIALIZED_NAME_GROUP) + private String group; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + @SerializedName(SERIALIZED_NAME_NAMESPACE) + private String namespace; + @SerializedName(SERIALIZED_NAME_PORT) + private Integer port; + @SerializedName(SERIALIZED_NAME_SECTION_NAME) + private String sectionName; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecParentRefs v1HttpRouteSpecParentRefs = (V1HTTPRouteSpecParentRefs) o; + return Objects.equals(this.group, v1HttpRouteSpecParentRefs.group) && + Objects.equals(this.kind, v1HttpRouteSpecParentRefs.kind) && + Objects.equals(this.name, v1HttpRouteSpecParentRefs.name) && + Objects.equals(this.namespace, v1HttpRouteSpecParentRefs.namespace) && + Objects.equals(this.port, v1HttpRouteSpecParentRefs.port) && + Objects.equals(this.sectionName, v1HttpRouteSpecParentRefs.sectionName); } - V1HTTPRouteSpecParentRefs v1HttpRouteSpecParentRefs = (V1HTTPRouteSpecParentRefs) o; - return Objects.equals(this.group, v1HttpRouteSpecParentRefs.group) && - Objects.equals(this.kind, v1HttpRouteSpecParentRefs.kind) && - Objects.equals(this.name, v1HttpRouteSpecParentRefs.name) && - Objects.equals(this.namespace, v1HttpRouteSpecParentRefs.namespace) && - Objects.equals(this.port, v1HttpRouteSpecParentRefs.port) && - Objects.equals(this.sectionName, v1HttpRouteSpecParentRefs.sectionName); - } - @Override - public int hashCode() { - return Objects.hash(group, kind, name, namespace, port, sectionName); - } + @Override + public int hashCode() { + return Objects.hash(group, kind, name, namespace, port, sectionName); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteSpecParentRefs {\n"); - sb.append(" group: ").append(toIndentedString(group)).append("\n"); - sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); - sb.append(" port: ").append(toIndentedString(port)).append("\n"); - sb.append(" sectionName: ").append(toIndentedString(sectionName)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1HTTPRouteSpecParentRefs {\n" + + " group: " + toIndentedString(group) + "\n" + + " kind: " + toIndentedString(kind) + "\n" + + " name: " + toIndentedString(name) + "\n" + + " namespace: " + toIndentedString(namespace) + "\n" + + " port: " + toIndentedString(port) + "\n" + + " sectionName: " + toIndentedString(sectionName) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecPath.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecPath.java index f4b12576..6afb1e38 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecPath.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecPath.java @@ -1,16 +1,16 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ - package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; import com.google.gson.TypeAdapter; @@ -18,8 +18,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.IOException; @@ -31,115 +29,111 @@ @Data public class V1HTTPRouteSpecPath { - /** - * Type specifies how to match against the path Value. Support: Core (Exact, PathPrefix) Support: Implementation-specific (RegularExpression) - */ - @JsonAdapter(TypeEnum.Adapter.class) - public enum TypeEnum { - /** - * EXACT matches the path exactly as specified. - * This is a core match type and must be supported by all implementations. - */ - EXACT("Exact"), - - /** - * PATHPREFIX matches the beginning of the path against the specified value. - * This is a core match type and must be supported by all implementations. - */ - PATHPREFIX("PathPrefix"), - - /** - * REGULAREXPRESSION allows matching the path using a regular expression. - * This is an implementation-specific match type and may vary depending on the implementation. - */ - REGULAREXPRESSION("RegularExpression"); - + public static final String SERIALIZED_NAME_TYPE = "type"; + public static final String SERIALIZED_NAME_VALUE = "value"; + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type; + @SerializedName(SERIALIZED_NAME_VALUE) private String value; - TypeEnum(String value) { - this.value = value; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecPath v1HttpRouteSpecPath = (V1HTTPRouteSpecPath) o; + return Objects.equals(this.type, v1HttpRouteSpecPath.type) && + Objects.equals(this.value, v1HttpRouteSpecPath.value); } - public String getValue() { - return value; + @Override + public int hashCode() { + return Objects.hash(type, value); } @Override public String toString() { - return String.valueOf(value); + String sb = "class V1HTTPRouteSpecPath {\n" + + " type: " + toIndentedString(type) + "\n" + + " value: " + toIndentedString(value) + "\n" + + "}"; + return sb; } - public static TypeEnum fromValue(String value) { - for (TypeEnum b : TypeEnum.values()) { - if (b.value.equals(value)) { - return b; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return o.toString().replace("\n", "\n "); } - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } - } + /** + * Type specifies how to match against the path Value. Support: Core (Exact, PathPrefix) Support: Implementation-specific (RegularExpression) + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + /** + * EXACT matches the path exactly as specified. + * This is a core match type and must be supported by all implementations. + */ + EXACT("Exact"), + + /** + * PATHPREFIX matches the beginning of the path against the specified value. + * This is a core match type and must be supported by all implementations. + */ + PATHPREFIX("PathPrefix"), + + /** + * REGULAREXPRESSION allows matching the path using a regular expression. + * This is an implementation-specific match type and may vary depending on the implementation. + */ + REGULAREXPRESSION("RegularExpression"); + + private final String value; + + TypeEnum(String value) { + this.value = value; + } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) - private TypeEnum type; + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } - public static final String SERIALIZED_NAME_VALUE = "value"; - @SerializedName(SERIALIZED_NAME_VALUE) - private String value; + public String getValue() { + return value; + } + @Override + public String toString() { + return String.valueOf(value); + } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - V1HTTPRouteSpecPath v1HttpRouteSpecPath = (V1HTTPRouteSpecPath) o; - return Objects.equals(this.type, v1HttpRouteSpecPath.type) && - Objects.equals(this.value, v1HttpRouteSpecPath.value); - } - - @Override - public int hashCode() { - return Objects.hash(type, value); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteSpecPath {\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" value: ").append(toIndentedString(value)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecQueryParams.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecQueryParams.java index 24f5eecb..7f2aaa54 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecQueryParams.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecQueryParams.java @@ -1,16 +1,16 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ - package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; import com.google.gson.TypeAdapter; @@ -18,8 +18,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.IOException; @@ -30,115 +28,110 @@ */ @Data public class V1HTTPRouteSpecQueryParams { - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) - private String name; - - /** - * Type specifies how to match against the value of the query parameter. Support: Extended (Exact) Support: Implementation-specific (RegularExpression) Since RegularExpression QueryParamMatchType has Implementation-specific conformance, implementations can support POSIX, PCRE or any other dialects of regular expressions. Please read the implementation's documentation to determine the supported dialect. - */ - @JsonAdapter(TypeEnum.Adapter.class) - public enum TypeEnum { - /** - * EXACT matches the query parameter value exactly as specified. - * This is an extended match type that is commonly supported by implementations. - */ - EXACT("Exact"), - - /** - * REGULAREXPRESSION allows matching the query parameter value using a regular expression. - * This is an implementation-specific match type, and the supported regular expression dialect may vary depending on the implementation. - */ - REGULAREXPRESSION("RegularExpression"); - + public static final String SERIALIZED_NAME_NAME = "name"; + public static final String SERIALIZED_NAME_TYPE = "type"; + public static final String SERIALIZED_NAME_VALUE = "value"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type; + @SerializedName(SERIALIZED_NAME_VALUE) private String value; - TypeEnum(String value) { - this.value = value; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecQueryParams v1HttpRouteSpecQueryParams = (V1HTTPRouteSpecQueryParams) o; + return Objects.equals(this.name, v1HttpRouteSpecQueryParams.name) && + Objects.equals(this.type, v1HttpRouteSpecQueryParams.type) && + Objects.equals(this.value, v1HttpRouteSpecQueryParams.value); } - public String getValue() { - return value; + @Override + public int hashCode() { + return Objects.hash(name, type, value); } @Override public String toString() { - return String.valueOf(value); + String sb = "class V1HTTPRouteSpecQueryParams {\n" + + " name: " + toIndentedString(name) + "\n" + + " type: " + toIndentedString(type) + "\n" + + " value: " + toIndentedString(value) + "\n" + + "}"; + return sb; } - public static TypeEnum fromValue(String value) { - for (TypeEnum b : TypeEnum.values()) { - if (b.value.equals(value)) { - return b; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return o.toString().replace("\n", "\n "); } - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } - } + /** + * Type specifies how to match against the value of the query parameter. Support: Extended (Exact) Support: Implementation-specific (RegularExpression) Since RegularExpression QueryParamMatchType has Implementation-specific conformance, implementations can support POSIX, PCRE or any other dialects of regular expressions. Please read the implementation's documentation to determine the supported dialect. + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + /** + * EXACT matches the query parameter value exactly as specified. + * This is an extended match type that is commonly supported by implementations. + */ + EXACT("Exact"), + + /** + * REGULAREXPRESSION allows matching the query parameter value using a regular expression. + * This is an implementation-specific match type, and the supported regular expression dialect may vary depending on the implementation. + */ + REGULAREXPRESSION("RegularExpression"); + + private final String value; + + TypeEnum(String value) { + this.value = value; + } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) - private TypeEnum type; + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } - public static final String SERIALIZED_NAME_VALUE = "value"; - @SerializedName(SERIALIZED_NAME_VALUE) - private String value; + public String getValue() { + return value; + } + @Override + public String toString() { + return String.valueOf(value); + } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - V1HTTPRouteSpecQueryParams v1HttpRouteSpecQueryParams = (V1HTTPRouteSpecQueryParams) o; - return Objects.equals(this.name, v1HttpRouteSpecQueryParams.name) && - Objects.equals(this.type, v1HttpRouteSpecQueryParams.type) && - Objects.equals(this.value, v1HttpRouteSpecQueryParams.value); - } - - @Override - public int hashCode() { - return Objects.hash(name, type, value); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteSpecQueryParams {\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" value: ").append(toIndentedString(value)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifier.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifier.java index 8dada51c..871764b3 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifier.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifier.java @@ -1,21 +1,20 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.ArrayList; @@ -27,90 +26,88 @@ */ @Data public class V1HTTPRouteSpecRequestHeaderModifier { - public static final String SERIALIZED_NAME_ADD = "add"; - @SerializedName(SERIALIZED_NAME_ADD) - private List add = null; + public static final String SERIALIZED_NAME_ADD = "add"; + public static final String SERIALIZED_NAME_REMOVE = "remove"; + public static final String SERIALIZED_NAME_SET = "set"; + @SerializedName(SERIALIZED_NAME_ADD) + private List add = null; + @SerializedName(SERIALIZED_NAME_REMOVE) + private List remove = null; + @SerializedName(SERIALIZED_NAME_SET) + private List set = null; + + + public V1HTTPRouteSpecRequestHeaderModifier addAddItem(V1HTTPRouteSpecRequestHeaderModifierAdd addItem) { + if (this.add == null) { + this.add = new ArrayList<>(); + } + this.add.add(addItem); + return this; + } - public static final String SERIALIZED_NAME_REMOVE = "remove"; - @SerializedName(SERIALIZED_NAME_REMOVE) - private List remove = null; + /** + * Add adds the given header(s) (name, value) to the request before the action. It appends to any existing values associated with the header name. Input: GET /foo HTTP/1.1 my-header: foo Config: add: - name: \"my-header\" value: \"bar,baz\" Output: GET /foo HTTP/1.1 my-header: foo,bar,baz + * + * @return add + **/ + + public V1HTTPRouteSpecRequestHeaderModifier addRemoveItem(String removeItem) { + if (this.remove == null) { + this.remove = new ArrayList<>(); + } + this.remove.add(removeItem); + return this; + } - public static final String SERIALIZED_NAME_SET = "set"; - @SerializedName(SERIALIZED_NAME_SET) - private List set = null; + public V1HTTPRouteSpecRequestHeaderModifier addSetItem(V1HTTPRouteSpecRequestHeaderModifierAdd setItem) { + if (this.set == null) { + this.set = new ArrayList<>(); + } + this.set.add(setItem); + return this; + } - public V1HTTPRouteSpecRequestHeaderModifier addAddItem(V1HTTPRouteSpecRequestHeaderModifierAdd addItem) { - if (this.add == null) { - this.add = new ArrayList<>(); + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecRequestHeaderModifier v1HttpRouteSpecRequestHeaderModifier = (V1HTTPRouteSpecRequestHeaderModifier) o; + return Objects.equals(this.add, v1HttpRouteSpecRequestHeaderModifier.add) && + Objects.equals(this.remove, v1HttpRouteSpecRequestHeaderModifier.remove) && + Objects.equals(this.set, v1HttpRouteSpecRequestHeaderModifier.set); } - this.add.add(addItem); - return this; - } - - /** - * Add adds the given header(s) (name, value) to the request before the action. It appends to any existing values associated with the header name. Input: GET /foo HTTP/1.1 my-header: foo Config: add: - name: \"my-header\" value: \"bar,baz\" Output: GET /foo HTTP/1.1 my-header: foo,bar,baz - * @return add - **/ - - public V1HTTPRouteSpecRequestHeaderModifier addRemoveItem(String removeItem) { - if (this.remove == null) { - this.remove = new ArrayList<>(); - } - this.remove.add(removeItem); - return this; - } - public V1HTTPRouteSpecRequestHeaderModifier addSetItem(V1HTTPRouteSpecRequestHeaderModifierAdd setItem) { - if (this.set == null) { - this.set = new ArrayList<>(); + @Override + public int hashCode() { + return Objects.hash(add, remove, set); } - this.set.add(setItem); - return this; - } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; + @Override + public String toString() { + String sb = "class V1HTTPRouteSpecRequestHeaderModifier {\n" + + " add: " + toIndentedString(add) + "\n" + + " remove: " + toIndentedString(remove) + "\n" + + " set: " + toIndentedString(set) + "\n" + + "}"; + return sb; } - V1HTTPRouteSpecRequestHeaderModifier v1HttpRouteSpecRequestHeaderModifier = (V1HTTPRouteSpecRequestHeaderModifier) o; - return Objects.equals(this.add, v1HttpRouteSpecRequestHeaderModifier.add) && - Objects.equals(this.remove, v1HttpRouteSpecRequestHeaderModifier.remove) && - Objects.equals(this.set, v1HttpRouteSpecRequestHeaderModifier.set); - } - - @Override - public int hashCode() { - return Objects.hash(add, remove, set); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteSpecRequestHeaderModifier {\n"); - sb.append(" add: ").append(toIndentedString(add)).append("\n"); - sb.append(" remove: ").append(toIndentedString(remove)).append("\n"); - sb.append(" set: ").append(toIndentedString(set)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifierAdd.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifierAdd.java index 1484e657..e77b7c89 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifierAdd.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestHeaderModifierAdd.java @@ -1,21 +1,20 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Objects; @@ -25,54 +24,52 @@ */ @Data public class V1HTTPRouteSpecRequestHeaderModifierAdd { - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) - private String name; - - public static final String SERIALIZED_NAME_VALUE = "value"; - @SerializedName(SERIALIZED_NAME_VALUE) - private String value; + public static final String SERIALIZED_NAME_NAME = "name"; + public static final String SERIALIZED_NAME_VALUE = "value"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + @SerializedName(SERIALIZED_NAME_VALUE) + private String value; - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecRequestHeaderModifierAdd v1HttpRouteSpecRequestHeaderModifierAdd = (V1HTTPRouteSpecRequestHeaderModifierAdd) o; + return Objects.equals(this.name, v1HttpRouteSpecRequestHeaderModifierAdd.name) && + Objects.equals(this.value, v1HttpRouteSpecRequestHeaderModifierAdd.value); } - V1HTTPRouteSpecRequestHeaderModifierAdd v1HttpRouteSpecRequestHeaderModifierAdd = (V1HTTPRouteSpecRequestHeaderModifierAdd) o; - return Objects.equals(this.name, v1HttpRouteSpecRequestHeaderModifierAdd.name) && - Objects.equals(this.value, v1HttpRouteSpecRequestHeaderModifierAdd.value); - } - @Override - public int hashCode() { - return Objects.hash(name, value); - } + @Override + public int hashCode() { + return Objects.hash(name, value); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteSpecRequestHeaderModifierAdd {\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" value: ").append(toIndentedString(value)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1HTTPRouteSpecRequestHeaderModifierAdd {\n" + + " name: " + toIndentedString(name) + "\n" + + " value: " + toIndentedString(value) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirror.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirror.java index 90784666..a1a74a31 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirror.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirror.java @@ -1,21 +1,20 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Objects; @@ -25,48 +24,47 @@ */ @Data public class V1HTTPRouteSpecRequestMirror { - public static final String SERIALIZED_NAME_BACKEND_REF = "backendRef"; - @SerializedName(SERIALIZED_NAME_BACKEND_REF) - private V1HTTPRouteSpecRequestMirrorBackendRef backendRef; + public static final String SERIALIZED_NAME_BACKEND_REF = "backendRef"; + @SerializedName(SERIALIZED_NAME_BACKEND_REF) + private V1HTTPRouteSpecRequestMirrorBackendRef backendRef; - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecRequestMirror v1HttpRouteSpecRequestMirror = (V1HTTPRouteSpecRequestMirror) o; + return Objects.equals(this.backendRef, v1HttpRouteSpecRequestMirror.backendRef); } - V1HTTPRouteSpecRequestMirror v1HttpRouteSpecRequestMirror = (V1HTTPRouteSpecRequestMirror) o; - return Objects.equals(this.backendRef, v1HttpRouteSpecRequestMirror.backendRef); - } - @Override - public int hashCode() { - return Objects.hash(backendRef); - } + @Override + public int hashCode() { + return Objects.hash(backendRef); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteSpecRequestMirror {\n"); - sb.append(" backendRef: ").append(toIndentedString(backendRef)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1HTTPRouteSpecRequestMirror {\n" + + " backendRef: " + toIndentedString(backendRef) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirrorBackendRef.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirrorBackendRef.java index 3fb454e8..edd30a8c 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirrorBackendRef.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestMirrorBackendRef.java @@ -1,21 +1,19 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ - package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Objects; @@ -25,72 +23,67 @@ */ @Data public class V1HTTPRouteSpecRequestMirrorBackendRef { - public static final String SERIALIZED_NAME_GROUP = "group"; - @SerializedName(SERIALIZED_NAME_GROUP) - private String group; - - public static final String SERIALIZED_NAME_KIND = "kind"; - @SerializedName(SERIALIZED_NAME_KIND) - private String kind; - - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) - private String name; - - public static final String SERIALIZED_NAME_NAMESPACE = "namespace"; - @SerializedName(SERIALIZED_NAME_NAMESPACE) - private String namespace; - - public static final String SERIALIZED_NAME_PORT = "port"; - @SerializedName(SERIALIZED_NAME_PORT) - private Integer port; - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; + public static final String SERIALIZED_NAME_GROUP = "group"; + public static final String SERIALIZED_NAME_KIND = "kind"; + public static final String SERIALIZED_NAME_NAME = "name"; + public static final String SERIALIZED_NAME_NAMESPACE = "namespace"; + public static final String SERIALIZED_NAME_PORT = "port"; + @SerializedName(SERIALIZED_NAME_GROUP) + private String group; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + @SerializedName(SERIALIZED_NAME_NAMESPACE) + private String namespace; + @SerializedName(SERIALIZED_NAME_PORT) + private Integer port; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecRequestMirrorBackendRef v1HttpRouteSpecRequestMirrorBackendRef = (V1HTTPRouteSpecRequestMirrorBackendRef) o; + return Objects.equals(this.group, v1HttpRouteSpecRequestMirrorBackendRef.group) && + Objects.equals(this.kind, v1HttpRouteSpecRequestMirrorBackendRef.kind) && + Objects.equals(this.name, v1HttpRouteSpecRequestMirrorBackendRef.name) && + Objects.equals(this.namespace, v1HttpRouteSpecRequestMirrorBackendRef.namespace) && + Objects.equals(this.port, v1HttpRouteSpecRequestMirrorBackendRef.port); } - V1HTTPRouteSpecRequestMirrorBackendRef v1HttpRouteSpecRequestMirrorBackendRef = (V1HTTPRouteSpecRequestMirrorBackendRef) o; - return Objects.equals(this.group, v1HttpRouteSpecRequestMirrorBackendRef.group) && - Objects.equals(this.kind, v1HttpRouteSpecRequestMirrorBackendRef.kind) && - Objects.equals(this.name, v1HttpRouteSpecRequestMirrorBackendRef.name) && - Objects.equals(this.namespace, v1HttpRouteSpecRequestMirrorBackendRef.namespace) && - Objects.equals(this.port, v1HttpRouteSpecRequestMirrorBackendRef.port); - } - @Override - public int hashCode() { - return Objects.hash(group, kind, name, namespace, port); - } + @Override + public int hashCode() { + return Objects.hash(group, kind, name, namespace, port); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteSpecRequestMirrorBackendRef {\n"); - sb.append(" group: ").append(toIndentedString(group)).append("\n"); - sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); - sb.append(" port: ").append(toIndentedString(port)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1HTTPRouteSpecRequestMirrorBackendRef {\n" + + " group: " + toIndentedString(group) + "\n" + + " kind: " + toIndentedString(kind) + "\n" + + " name: " + toIndentedString(name) + "\n" + + " namespace: " + toIndentedString(namespace) + "\n" + + " port: " + toIndentedString(port) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirect.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirect.java index 57fc3f7c..e2ac1b49 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirect.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirect.java @@ -1,13 +1,14 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ @@ -18,8 +19,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.IOException; @@ -30,128 +29,120 @@ */ @Data public class V1HTTPRouteSpecRequestRedirect { - public static final String SERIALIZED_NAME_HOSTNAME = "hostname"; - @SerializedName(SERIALIZED_NAME_HOSTNAME) - private String hostname; - - public static final String SERIALIZED_NAME_PATH = "path"; - @SerializedName(SERIALIZED_NAME_PATH) - private V1HTTPRouteSpecRequestRedirectPath path; - - public static final String SERIALIZED_NAME_PORT = "port"; - @SerializedName(SERIALIZED_NAME_PORT) - private Integer port; - - /** - * Scheme is the scheme to be used in the value of the `Location` header in the response. When empty, the scheme of the request is used. Scheme redirects can affect the port of the redirect, for more information, refer to the documentation for the port field of this filter. Note that values may be added to this enum, implementations must ensure that unknown values will not cause a crash. Unknown values here must result in the implementation setting the Accepted Condition for the Route to `status: False`, with a Reason of `UnsupportedValue`. Support: Extended - */ - @JsonAdapter(SchemeEnum.Adapter.class) - public enum SchemeEnum { - /** - * HTTP is used to specify that the scheme in the `Location` header should be "http". - * This is commonly used for non-secure redirects. - */ - HTTP("http"), - - /** - * HTTPS is used to specify that the scheme in the `Location` header should be "https". - * This is commonly used for secure redirects. - */ - HTTPS("https"); + public static final String SERIALIZED_NAME_HOSTNAME = "hostname"; + public static final String SERIALIZED_NAME_PATH = "path"; + public static final String SERIALIZED_NAME_PORT = "port"; + public static final String SERIALIZED_NAME_SCHEME = "scheme"; + public static final String SERIALIZED_NAME_STATUS_CODE = "statusCode"; + @SerializedName(SERIALIZED_NAME_HOSTNAME) + private String hostname; + @SerializedName(SERIALIZED_NAME_PATH) + private V1HTTPRouteSpecRequestRedirectPath path; + @SerializedName(SERIALIZED_NAME_PORT) + private Integer port; + @SerializedName(SERIALIZED_NAME_SCHEME) + private SchemeEnum scheme; + @SerializedName(SERIALIZED_NAME_STATUS_CODE) + private Integer statusCode; - private String value; - - SchemeEnum(String value) { - this.value = value; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecRequestRedirect v1HttpRouteSpecRequestRedirect = (V1HTTPRouteSpecRequestRedirect) o; + return Objects.equals(this.hostname, v1HttpRouteSpecRequestRedirect.hostname) && + Objects.equals(this.path, v1HttpRouteSpecRequestRedirect.path) && + Objects.equals(this.port, v1HttpRouteSpecRequestRedirect.port) && + Objects.equals(this.scheme, v1HttpRouteSpecRequestRedirect.scheme) && + Objects.equals(this.statusCode, v1HttpRouteSpecRequestRedirect.statusCode); } - public String getValue() { - return value; + @Override + public int hashCode() { + return Objects.hash(hostname, path, port, scheme, statusCode); } @Override public String toString() { - return String.valueOf(value); + String sb = "class V1HTTPRouteSpecRequestRedirect {\n" + + " hostname: " + toIndentedString(hostname) + "\n" + + " path: " + toIndentedString(path) + "\n" + + " port: " + toIndentedString(port) + "\n" + + " scheme: " + toIndentedString(scheme) + "\n" + + " statusCode: " + toIndentedString(statusCode) + "\n" + + "}"; + return sb; } - public static SchemeEnum fromValue(String value) { - for (SchemeEnum b : SchemeEnum.values()) { - if (b.value.equals(value)) { - return b; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final SchemeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public SchemeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return SchemeEnum.fromValue(value); - } + return o.toString().replace("\n", "\n "); } - } - public static final String SERIALIZED_NAME_SCHEME = "scheme"; - @SerializedName(SERIALIZED_NAME_SCHEME) - private SchemeEnum scheme; + /** + * Scheme is the scheme to be used in the value of the `Location` header in the response. When empty, the scheme of the request is used. Scheme redirects can affect the port of the redirect, for more information, refer to the documentation for the port field of this filter. Note that values may be added to this enum, implementations must ensure that unknown values will not cause a crash. Unknown values here must result in the implementation setting the Accepted Condition for the Route to `status: False`, with a Reason of `UnsupportedValue`. Support: Extended + */ + @JsonAdapter(SchemeEnum.Adapter.class) + public enum SchemeEnum { + /** + * HTTP is used to specify that the scheme in the `Location` header should be "http". + * This is commonly used for non-secure redirects. + */ + HTTP("http"), + + /** + * HTTPS is used to specify that the scheme in the `Location` header should be "https". + * This is commonly used for secure redirects. + */ + HTTPS("https"); + + private final String value; + + SchemeEnum(String value) { + this.value = value; + } - public static final String SERIALIZED_NAME_STATUS_CODE = "statusCode"; - @SerializedName(SERIALIZED_NAME_STATUS_CODE) - private Integer statusCode; + public static SchemeEnum fromValue(String value) { + for (SchemeEnum b : SchemeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + public String getValue() { + return value; + } + @Override + public String toString() { + return String.valueOf(value); + } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - V1HTTPRouteSpecRequestRedirect v1HttpRouteSpecRequestRedirect = (V1HTTPRouteSpecRequestRedirect) o; - return Objects.equals(this.hostname, v1HttpRouteSpecRequestRedirect.hostname) && - Objects.equals(this.path, v1HttpRouteSpecRequestRedirect.path) && - Objects.equals(this.port, v1HttpRouteSpecRequestRedirect.port) && - Objects.equals(this.scheme, v1HttpRouteSpecRequestRedirect.scheme) && - Objects.equals(this.statusCode, v1HttpRouteSpecRequestRedirect.statusCode); - } - - @Override - public int hashCode() { - return Objects.hash(hostname, path, port, scheme, statusCode); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteSpecRequestRedirect {\n"); - sb.append(" hostname: ").append(toIndentedString(hostname)).append("\n"); - sb.append(" path: ").append(toIndentedString(path)).append("\n"); - sb.append(" port: ").append(toIndentedString(port)).append("\n"); - sb.append(" scheme: ").append(toIndentedString(scheme)).append("\n"); - sb.append(" statusCode: ").append(toIndentedString(statusCode)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final SchemeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public SchemeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return SchemeEnum.fromValue(value); + } + } } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirectPath.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirectPath.java index 48e51c80..7528e5d3 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirectPath.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRequestRedirectPath.java @@ -1,16 +1,16 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ - package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; import com.google.gson.TypeAdapter; @@ -18,8 +18,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.IOException; @@ -30,115 +28,110 @@ */ @Data public class V1HTTPRouteSpecRequestRedirectPath { - public static final String SERIALIZED_NAME_REPLACE_FULL_PATH = "replaceFullPath"; - @SerializedName(SERIALIZED_NAME_REPLACE_FULL_PATH) - private String replaceFullPath; - - public static final String SERIALIZED_NAME_REPLACE_PREFIX_MATCH = "replacePrefixMatch"; - @SerializedName(SERIALIZED_NAME_REPLACE_PREFIX_MATCH) - private String replacePrefixMatch; - - /** - * Type defines the type of path modifier. Additional types may be added in a future release of the API. Note that values may be added to this enum, implementations must ensure that unknown values will not cause a crash. Unknown values here must result in the implementation setting the Accepted Condition for the Route to `status: False`, with a Reason of `UnsupportedValue`. - */ - @JsonAdapter(TypeEnum.Adapter.class) - public enum TypeEnum { - /** - * REPLACEFULLPATH is used to replace the entire path of the request with a new path. - * This modifier is typically used when you need to completely change the path in a request. - */ - REPLACEFULLPATH("ReplaceFullPath"), - - /** - * REPLACEPREFIXMATCH is used to replace the matching prefix of the path in the request. - * This modifier is commonly used when you want to modify just the beginning of the path while preserving the rest. - */ - REPLACEPREFIXMATCH("ReplacePrefixMatch"); + public static final String SERIALIZED_NAME_REPLACE_FULL_PATH = "replaceFullPath"; + public static final String SERIALIZED_NAME_REPLACE_PREFIX_MATCH = "replacePrefixMatch"; + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_REPLACE_FULL_PATH) + private String replaceFullPath; + @SerializedName(SERIALIZED_NAME_REPLACE_PREFIX_MATCH) + private String replacePrefixMatch; + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type; - private String value; - - TypeEnum(String value) { - this.value = value; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecRequestRedirectPath v1HttpRouteSpecRequestRedirectPath = (V1HTTPRouteSpecRequestRedirectPath) o; + return Objects.equals(this.replaceFullPath, v1HttpRouteSpecRequestRedirectPath.replaceFullPath) && + Objects.equals(this.replacePrefixMatch, v1HttpRouteSpecRequestRedirectPath.replacePrefixMatch) && + Objects.equals(this.type, v1HttpRouteSpecRequestRedirectPath.type); } - public String getValue() { - return value; + @Override + public int hashCode() { + return Objects.hash(replaceFullPath, replacePrefixMatch, type); } @Override public String toString() { - return String.valueOf(value); + String sb = "class V1HTTPRouteSpecRequestRedirectPath {\n" + + " replaceFullPath: " + toIndentedString(replaceFullPath) + "\n" + + " replacePrefixMatch: " + toIndentedString(replacePrefixMatch) + "\n" + + " type: " + toIndentedString(type) + "\n" + + "}"; + return sb; } - public static TypeEnum fromValue(String value) { - for (TypeEnum b : TypeEnum.values()) { - if (b.value.equals(value)) { - return b; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return o.toString().replace("\n", "\n "); } - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } - } + /** + * Type defines the type of path modifier. Additional types may be added in a future release of the API. Note that values may be added to this enum, implementations must ensure that unknown values will not cause a crash. Unknown values here must result in the implementation setting the Accepted Condition for the Route to `status: False`, with a Reason of `UnsupportedValue`. + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + /** + * REPLACEFULLPATH is used to replace the entire path of the request with a new path. + * This modifier is typically used when you need to completely change the path in a request. + */ + REPLACEFULLPATH("ReplaceFullPath"), + + /** + * REPLACEPREFIXMATCH is used to replace the matching prefix of the path in the request. + * This modifier is commonly used when you want to modify just the beginning of the path while preserving the rest. + */ + REPLACEPREFIXMATCH("ReplacePrefixMatch"); + + private final String value; + + TypeEnum(String value) { + this.value = value; + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) - private TypeEnum type; + public String getValue() { + return value; + } + @Override + public String toString() { + return String.valueOf(value); + } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - V1HTTPRouteSpecRequestRedirectPath v1HttpRouteSpecRequestRedirectPath = (V1HTTPRouteSpecRequestRedirectPath) o; - return Objects.equals(this.replaceFullPath, v1HttpRouteSpecRequestRedirectPath.replaceFullPath) && - Objects.equals(this.replacePrefixMatch, v1HttpRouteSpecRequestRedirectPath.replacePrefixMatch) && - Objects.equals(this.type, v1HttpRouteSpecRequestRedirectPath.type); - } - - @Override - public int hashCode() { - return Objects.hash(replaceFullPath, replacePrefixMatch, type); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteSpecRequestRedirectPath {\n"); - sb.append(" replaceFullPath: ").append(toIndentedString(replaceFullPath)).append("\n"); - sb.append(" replacePrefixMatch: ").append(toIndentedString(replacePrefixMatch)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecResponseHeaderModifier.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecResponseHeaderModifier.java index 89633dcd..b48a8940 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecResponseHeaderModifier.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecResponseHeaderModifier.java @@ -1,21 +1,19 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ - package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.ArrayList; @@ -27,84 +25,81 @@ */ @Data public class V1HTTPRouteSpecResponseHeaderModifier { - public static final String SERIALIZED_NAME_ADD = "add"; - @SerializedName(SERIALIZED_NAME_ADD) - private List add = null; - - public static final String SERIALIZED_NAME_REMOVE = "remove"; - @SerializedName(SERIALIZED_NAME_REMOVE) - private List remove = null; - - public static final String SERIALIZED_NAME_SET = "set"; - @SerializedName(SERIALIZED_NAME_SET) - private List set = null; - - public V1HTTPRouteSpecResponseHeaderModifier addAddItem(V1HTTPRouteSpecRequestHeaderModifierAdd addItem) { - if (this.add == null) { - this.add = new ArrayList<>(); + public static final String SERIALIZED_NAME_ADD = "add"; + public static final String SERIALIZED_NAME_REMOVE = "remove"; + public static final String SERIALIZED_NAME_SET = "set"; + @SerializedName(SERIALIZED_NAME_ADD) + private List add = null; + @SerializedName(SERIALIZED_NAME_REMOVE) + private List remove = null; + @SerializedName(SERIALIZED_NAME_SET) + private List set = null; + + public V1HTTPRouteSpecResponseHeaderModifier addAddItem(V1HTTPRouteSpecRequestHeaderModifierAdd addItem) { + if (this.add == null) { + this.add = new ArrayList<>(); + } + this.add.add(addItem); + return this; } - this.add.add(addItem); - return this; - } - public V1HTTPRouteSpecResponseHeaderModifier addRemoveItem(String removeItem) { - if (this.remove == null) { - this.remove = new ArrayList<>(); + public V1HTTPRouteSpecResponseHeaderModifier addRemoveItem(String removeItem) { + if (this.remove == null) { + this.remove = new ArrayList<>(); + } + this.remove.add(removeItem); + return this; } - this.remove.add(removeItem); - return this; - } - public V1HTTPRouteSpecResponseHeaderModifier addSetItem(V1HTTPRouteSpecRequestHeaderModifierAdd setItem) { - if (this.set == null) { - this.set = new ArrayList<>(); + public V1HTTPRouteSpecResponseHeaderModifier addSetItem(V1HTTPRouteSpecRequestHeaderModifierAdd setItem) { + if (this.set == null) { + this.set = new ArrayList<>(); + } + this.set.add(setItem); + return this; } - this.set.add(setItem); - return this; - } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecResponseHeaderModifier v1HttpRouteSpecResponseHeaderModifier = (V1HTTPRouteSpecResponseHeaderModifier) o; + return Objects.equals(this.add, v1HttpRouteSpecResponseHeaderModifier.add) && + Objects.equals(this.remove, v1HttpRouteSpecResponseHeaderModifier.remove) && + Objects.equals(this.set, v1HttpRouteSpecResponseHeaderModifier.set); } - V1HTTPRouteSpecResponseHeaderModifier v1HttpRouteSpecResponseHeaderModifier = (V1HTTPRouteSpecResponseHeaderModifier) o; - return Objects.equals(this.add, v1HttpRouteSpecResponseHeaderModifier.add) && - Objects.equals(this.remove, v1HttpRouteSpecResponseHeaderModifier.remove) && - Objects.equals(this.set, v1HttpRouteSpecResponseHeaderModifier.set); - } - @Override - public int hashCode() { - return Objects.hash(add, remove, set); - } + @Override + public int hashCode() { + return Objects.hash(add, remove, set); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteSpecResponseHeaderModifier {\n"); - sb.append(" add: ").append(toIndentedString(add)).append("\n"); - sb.append(" remove: ").append(toIndentedString(remove)).append("\n"); - sb.append(" set: ").append(toIndentedString(set)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1HTTPRouteSpecResponseHeaderModifier {\n" + + " add: " + toIndentedString(add) + "\n" + + " remove: " + toIndentedString(remove) + "\n" + + " set: " + toIndentedString(set) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRules.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRules.java index 38cba712..ad5825f3 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRules.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecRules.java @@ -1,21 +1,20 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.ArrayList; @@ -27,85 +26,82 @@ */ @Data public class V1HTTPRouteSpecRules { - public static final String SERIALIZED_NAME_BACKEND_REFS = "backendRefs"; - @SerializedName(SERIALIZED_NAME_BACKEND_REFS) - private List backendRefs = null; + public static final String SERIALIZED_NAME_BACKEND_REFS = "backendRefs"; + public static final String SERIALIZED_NAME_FILTERS = "filters"; + public static final String SERIALIZED_NAME_MATCHES = "matches"; + @SerializedName(SERIALIZED_NAME_BACKEND_REFS) + private List backendRefs = null; + @SerializedName(SERIALIZED_NAME_FILTERS) + private List filters = null; + @SerializedName(SERIALIZED_NAME_MATCHES) + private List matches = null; + + public V1HTTPRouteSpecRules addBackendRefsItem(V1HTTPRouteSpecBackendRefs backendRefsItem) { + if (this.backendRefs == null) { + this.backendRefs = new ArrayList<>(); + } + this.backendRefs.add(backendRefsItem); + return this; + } - public static final String SERIALIZED_NAME_FILTERS = "filters"; - @SerializedName(SERIALIZED_NAME_FILTERS) - private List filters = null; + public V1HTTPRouteSpecRules addFiltersItem(V1HTTPRouteSpecFilters filtersItem) { + if (this.filters == null) { + this.filters = new ArrayList<>(); + } + this.filters.add(filtersItem); + return this; + } - public static final String SERIALIZED_NAME_MATCHES = "matches"; - @SerializedName(SERIALIZED_NAME_MATCHES) - private List matches = null; - public V1HTTPRouteSpecRules addBackendRefsItem(V1HTTPRouteSpecBackendRefs backendRefsItem) { - if (this.backendRefs == null) { - this.backendRefs = new ArrayList<>(); + public V1HTTPRouteSpecRules addMatchesItem(V1HTTPRouteSpecMatches matchesItem) { + if (this.matches == null) { + this.matches = new ArrayList<>(); + } + this.matches.add(matchesItem); + return this; } - this.backendRefs.add(backendRefsItem); - return this; - } - public V1HTTPRouteSpecRules addFiltersItem(V1HTTPRouteSpecFilters filtersItem) { - if (this.filters == null) { - this.filters = new ArrayList<>(); - } - this.filters.add(filtersItem); - return this; - } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecRules v1HttpRouteSpecRules = (V1HTTPRouteSpecRules) o; + return Objects.equals(this.backendRefs, v1HttpRouteSpecRules.backendRefs) && + Objects.equals(this.filters, v1HttpRouteSpecRules.filters) && + Objects.equals(this.matches, v1HttpRouteSpecRules.matches); + } - public V1HTTPRouteSpecRules addMatchesItem(V1HTTPRouteSpecMatches matchesItem) { - if (this.matches == null) { - this.matches = new ArrayList<>(); + @Override + public int hashCode() { + return Objects.hash(backendRefs, filters, matches); } - this.matches.add(matchesItem); - return this; - } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; + @Override + public String toString() { + String sb = "class V1HTTPRouteSpecRules {\n" + + " backendRefs: " + toIndentedString(backendRefs) + "\n" + + " filters: " + toIndentedString(filters) + "\n" + + " matches: " + toIndentedString(matches) + "\n" + + "}"; + return sb; } - V1HTTPRouteSpecRules v1HttpRouteSpecRules = (V1HTTPRouteSpecRules) o; - return Objects.equals(this.backendRefs, v1HttpRouteSpecRules.backendRefs) && - Objects.equals(this.filters, v1HttpRouteSpecRules.filters) && - Objects.equals(this.matches, v1HttpRouteSpecRules.matches); - } - - @Override - public int hashCode() { - return Objects.hash(backendRefs, filters, matches); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteSpecRules {\n"); - sb.append(" backendRefs: ").append(toIndentedString(backendRefs)).append("\n"); - sb.append(" filters: ").append(toIndentedString(filters)).append("\n"); - sb.append(" matches: ").append(toIndentedString(matches)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewrite.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewrite.java index 1e615846..4d3a3316 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewrite.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewrite.java @@ -1,21 +1,20 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Objects; @@ -25,55 +24,52 @@ */ @Data public class V1HTTPRouteSpecUrlRewrite { - public static final String SERIALIZED_NAME_HOSTNAME = "hostname"; - @SerializedName(SERIALIZED_NAME_HOSTNAME) - private String hostname; - - public static final String SERIALIZED_NAME_PATH = "path"; - @SerializedName(SERIALIZED_NAME_PATH) - private V1HTTPRouteSpecUrlRewritePath path; - + public static final String SERIALIZED_NAME_HOSTNAME = "hostname"; + public static final String SERIALIZED_NAME_PATH = "path"; + @SerializedName(SERIALIZED_NAME_HOSTNAME) + private String hostname; + @SerializedName(SERIALIZED_NAME_PATH) + private V1HTTPRouteSpecUrlRewritePath path; - @Override - public boolean equals(Object o) { - if (this == o) { - return true; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecUrlRewrite v1HttpRouteSpecUrlRewrite = (V1HTTPRouteSpecUrlRewrite) o; + return Objects.equals(this.hostname, v1HttpRouteSpecUrlRewrite.hostname) && + Objects.equals(this.path, v1HttpRouteSpecUrlRewrite.path); } - if (o == null || getClass() != o.getClass()) { - return false; - } - V1HTTPRouteSpecUrlRewrite v1HttpRouteSpecUrlRewrite = (V1HTTPRouteSpecUrlRewrite) o; - return Objects.equals(this.hostname, v1HttpRouteSpecUrlRewrite.hostname) && - Objects.equals(this.path, v1HttpRouteSpecUrlRewrite.path); - } - @Override - public int hashCode() { - return Objects.hash(hostname, path); - } + @Override + public int hashCode() { + return Objects.hash(hostname, path); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteSpecUrlRewrite {\n"); - sb.append(" hostname: ").append(toIndentedString(hostname)).append("\n"); - sb.append(" path: ").append(toIndentedString(path)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1HTTPRouteSpecUrlRewrite {\n" + + " hostname: " + toIndentedString(hostname) + "\n" + + " path: " + toIndentedString(path) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewritePath.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewritePath.java index 0d662aa1..61d77fcf 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewritePath.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecUrlRewritePath.java @@ -1,13 +1,14 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ @@ -18,8 +19,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.IOException; @@ -30,116 +29,110 @@ */ @Data public class V1HTTPRouteSpecUrlRewritePath { - public static final String SERIALIZED_NAME_REPLACE_FULL_PATH = "replaceFullPath"; - @SerializedName(SERIALIZED_NAME_REPLACE_FULL_PATH) - private String replaceFullPath; - - public static final String SERIALIZED_NAME_REPLACE_PREFIX_MATCH = "replacePrefixMatch"; - @SerializedName(SERIALIZED_NAME_REPLACE_PREFIX_MATCH) - private String replacePrefixMatch; - - /** - * Type defines the type of path modifier. Additional types may be added in a future release of the API. Note that values may be added to this enum, implementations must ensure that unknown values will not cause a crash. Unknown values here must result in the implementation setting the Accepted Condition for the Route to `status: False`, with a Reason of `UnsupportedValue`. - */ - @JsonAdapter(TypeEnum.Adapter.class) - public enum TypeEnum { - /** - * REPLACEFULLPATH replaces the entire path of the incoming request with a new specified path. - * This is useful when you want to completely override the original request path. - */ - REPLACEFULLPATH("ReplaceFullPath"), - - /** - * REPLACEPREFIXMATCH replaces the matching prefix of the path in the incoming request with a new prefix. - * This is commonly used when you need to change the beginning of the path while preserving the rest of the original path. - */ - REPLACEPREFIXMATCH("ReplacePrefixMatch"); + public static final String SERIALIZED_NAME_REPLACE_FULL_PATH = "replaceFullPath"; + public static final String SERIALIZED_NAME_REPLACE_PREFIX_MATCH = "replacePrefixMatch"; + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_REPLACE_FULL_PATH) + private String replaceFullPath; + @SerializedName(SERIALIZED_NAME_REPLACE_PREFIX_MATCH) + private String replacePrefixMatch; + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type; - private String value; - - TypeEnum(String value) { - this.value = value; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteSpecUrlRewritePath v1HttpRouteSpecUrlRewritePath = (V1HTTPRouteSpecUrlRewritePath) o; + return Objects.equals(this.replaceFullPath, v1HttpRouteSpecUrlRewritePath.replaceFullPath) && + Objects.equals(this.replacePrefixMatch, v1HttpRouteSpecUrlRewritePath.replacePrefixMatch) && + Objects.equals(this.type, v1HttpRouteSpecUrlRewritePath.type); } - public String getValue() { - return value; + @Override + public int hashCode() { + return Objects.hash(replaceFullPath, replacePrefixMatch, type); } @Override public String toString() { - return String.valueOf(value); + String sb = "class V1HTTPRouteSpecUrlRewritePath {\n" + + " replaceFullPath: " + toIndentedString(replaceFullPath) + "\n" + + " replacePrefixMatch: " + toIndentedString(replacePrefixMatch) + "\n" + + " type: " + toIndentedString(type) + "\n" + + "}"; + return sb; } - public static TypeEnum fromValue(String value) { - for (TypeEnum b : TypeEnum.values()) { - if (b.value.equals(value)) { - return b; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return o.toString().replace("\n", "\n "); } - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypeEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return TypeEnum.fromValue(value); - } - } - } + /** + * Type defines the type of path modifier. Additional types may be added in a future release of the API. Note that values may be added to this enum, implementations must ensure that unknown values will not cause a crash. Unknown values here must result in the implementation setting the Accepted Condition for the Route to `status: False`, with a Reason of `UnsupportedValue`. + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + /** + * REPLACEFULLPATH replaces the entire path of the incoming request with a new specified path. + * This is useful when you want to completely override the original request path. + */ + REPLACEFULLPATH("ReplaceFullPath"), + + /** + * REPLACEPREFIXMATCH replaces the matching prefix of the path in the incoming request with a new prefix. + * This is commonly used when you need to change the beginning of the path while preserving the rest of the original path. + */ + REPLACEPREFIXMATCH("ReplacePrefixMatch"); + + private final String value; + + TypeEnum(String value) { + this.value = value; + } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) - private TypeEnum type; + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + public String getValue() { + return value; + } + @Override + public String toString() { + return String.valueOf(value); + } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - V1HTTPRouteSpecUrlRewritePath v1HttpRouteSpecUrlRewritePath = (V1HTTPRouteSpecUrlRewritePath) o; - return Objects.equals(this.replaceFullPath, v1HttpRouteSpecUrlRewritePath.replaceFullPath) && - Objects.equals(this.replacePrefixMatch, v1HttpRouteSpecUrlRewritePath.replacePrefixMatch) && - Objects.equals(this.type, v1HttpRouteSpecUrlRewritePath.type); - } - - @Override - public int hashCode() { - return Objects.hash(replaceFullPath, replacePrefixMatch, type); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteSpecUrlRewritePath {\n"); - sb.append(" replaceFullPath: ").append(toIndentedString(replaceFullPath)).append("\n"); - sb.append(" replacePrefixMatch: ").append(toIndentedString(replacePrefixMatch)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatus.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatus.java index f57e6932..8a362f51 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatus.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatus.java @@ -1,21 +1,20 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.ArrayList; @@ -27,53 +26,52 @@ */ @Data public class V1HTTPRouteStatus { - public static final String SERIALIZED_NAME_PARENTS = "parents"; - @SerializedName(SERIALIZED_NAME_PARENTS) - private List parents = new ArrayList<>(); - + public static final String SERIALIZED_NAME_PARENTS = "parents"; + @SerializedName(SERIALIZED_NAME_PARENTS) + private List parents = new ArrayList<>(); - public V1HTTPRouteStatus addParentsItem(V1HTTPRouteStatusParents parentsItem) { - this.parents.add(parentsItem); - return this; - } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; + public V1HTTPRouteStatus addParentsItem(V1HTTPRouteStatusParents parentsItem) { + this.parents.add(parentsItem); + return this; } - if (o == null || getClass() != o.getClass()) { - return false; + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteStatus v1HttpRouteStatus = (V1HTTPRouteStatus) o; + return Objects.equals(this.parents, v1HttpRouteStatus.parents); } - V1HTTPRouteStatus v1HttpRouteStatus = (V1HTTPRouteStatus) o; - return Objects.equals(this.parents, v1HttpRouteStatus.parents); - } - @Override - public int hashCode() { - return Objects.hash(parents); - } + @Override + public int hashCode() { + return Objects.hash(parents); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteStatus {\n"); - sb.append(" parents: ").append(toIndentedString(parents)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1HTTPRouteStatus {\n" + + " parents: " + toIndentedString(parents) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusConditions.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusConditions.java index d2b6043f..16a57217 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusConditions.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusConditions.java @@ -1,13 +1,14 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ @@ -18,8 +19,6 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.IOException; @@ -31,136 +30,128 @@ */ @Data public class V1HTTPRouteStatusConditions { - public static final String SERIALIZED_NAME_LAST_TRANSITION_TIME = "lastTransitionTime"; - @SerializedName(SERIALIZED_NAME_LAST_TRANSITION_TIME) - private OffsetDateTime lastTransitionTime; - - public static final String SERIALIZED_NAME_MESSAGE = "message"; - @SerializedName(SERIALIZED_NAME_MESSAGE) - private String message; - - public static final String SERIALIZED_NAME_OBSERVED_GENERATION = "observedGeneration"; - @SerializedName(SERIALIZED_NAME_OBSERVED_GENERATION) - private Long observedGeneration; - - public static final String SERIALIZED_NAME_REASON = "reason"; - @SerializedName(SERIALIZED_NAME_REASON) - private String reason; - - /** - * status of the condition, one of True, False, Unknown. - */ - @JsonAdapter(StatusEnum.Adapter.class) - public enum StatusEnum { - /** - * Represents the state where the condition is true. - */ - TRUE("True"), + public static final String SERIALIZED_NAME_LAST_TRANSITION_TIME = "lastTransitionTime"; + public static final String SERIALIZED_NAME_MESSAGE = "message"; + public static final String SERIALIZED_NAME_OBSERVED_GENERATION = "observedGeneration"; + public static final String SERIALIZED_NAME_REASON = "reason"; + public static final String SERIALIZED_NAME_STATUS = "status"; + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_LAST_TRANSITION_TIME) + private OffsetDateTime lastTransitionTime; + @SerializedName(SERIALIZED_NAME_MESSAGE) + private String message; + @SerializedName(SERIALIZED_NAME_OBSERVED_GENERATION) + private Long observedGeneration; + @SerializedName(SERIALIZED_NAME_REASON) + private String reason; + @SerializedName(SERIALIZED_NAME_STATUS) + private StatusEnum status; + @SerializedName(SERIALIZED_NAME_TYPE) + private String type; - /** - * Represents the state where the condition is false. - */ - FALSE("False"), - - /** - * Represents an unknown state. - */ - UNKNOWN("Unknown"); - - private String value; - - StatusEnum(String value) { - this.value = value; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteStatusConditions v1HttpRouteStatusConditions = (V1HTTPRouteStatusConditions) o; + return Objects.equals(this.lastTransitionTime, v1HttpRouteStatusConditions.lastTransitionTime) && + Objects.equals(this.message, v1HttpRouteStatusConditions.message) && + Objects.equals(this.observedGeneration, v1HttpRouteStatusConditions.observedGeneration) && + Objects.equals(this.reason, v1HttpRouteStatusConditions.reason) && + Objects.equals(this.status, v1HttpRouteStatusConditions.status) && + Objects.equals(this.type, v1HttpRouteStatusConditions.type); } - public String getValue() { - return value; + @Override + public int hashCode() { + return Objects.hash(lastTransitionTime, message, observedGeneration, reason, status, type); } @Override public String toString() { - return String.valueOf(value); + String sb = "class V1HTTPRouteStatusConditions {\n" + + " lastTransitionTime: " + toIndentedString(lastTransitionTime) + "\n" + + " message: " + toIndentedString(message) + "\n" + + " observedGeneration: " + toIndentedString(observedGeneration) + "\n" + + " reason: " + toIndentedString(reason) + "\n" + + " status: " + toIndentedString(status) + "\n" + + " type: " + toIndentedString(type) + "\n" + + "}"; + return sb; } - public static StatusEnum fromValue(String value) { - for (StatusEnum b : StatusEnum.values()) { - if (b.value.equals(value)) { - return b; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); + return o.toString().replace("\n", "\n "); } - public static class Adapter extends TypeAdapter { - @Override - public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public StatusEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return StatusEnum.fromValue(value); - } - } - } + /** + * status of the condition, one of True, False, Unknown. + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + /** + * Represents the state where the condition is true. + */ + TRUE("True"), + + /** + * Represents the state where the condition is false. + */ + FALSE("False"), + + /** + * Represents an unknown state. + */ + UNKNOWN("Unknown"); + + private final String value; + + StatusEnum(String value) { + this.value = value; + } - public static final String SERIALIZED_NAME_STATUS = "status"; - @SerializedName(SERIALIZED_NAME_STATUS) - private StatusEnum status; + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } - public static final String SERIALIZED_NAME_TYPE = "type"; - @SerializedName(SERIALIZED_NAME_TYPE) - private String type; + public String getValue() { + return value; + } + @Override + public String toString() { + return String.valueOf(value); + } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - V1HTTPRouteStatusConditions v1HttpRouteStatusConditions = (V1HTTPRouteStatusConditions) o; - return Objects.equals(this.lastTransitionTime, v1HttpRouteStatusConditions.lastTransitionTime) && - Objects.equals(this.message, v1HttpRouteStatusConditions.message) && - Objects.equals(this.observedGeneration, v1HttpRouteStatusConditions.observedGeneration) && - Objects.equals(this.reason, v1HttpRouteStatusConditions.reason) && - Objects.equals(this.status, v1HttpRouteStatusConditions.status) && - Objects.equals(this.type, v1HttpRouteStatusConditions.type); - } - - @Override - public int hashCode() { - return Objects.hash(lastTransitionTime, message, observedGeneration, reason, status, type); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteStatusConditions {\n"); - sb.append(" lastTransitionTime: ").append(toIndentedString(lastTransitionTime)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append(" observedGeneration: ").append(toIndentedString(observedGeneration)).append("\n"); - sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParentRef.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParentRef.java index 83306a09..539d57b5 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParentRef.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParentRef.java @@ -1,21 +1,19 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ - package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Objects; @@ -25,78 +23,72 @@ */ @Data public class V1HTTPRouteStatusParentRef { - public static final String SERIALIZED_NAME_GROUP = "group"; - @SerializedName(SERIALIZED_NAME_GROUP) - private String group; - - public static final String SERIALIZED_NAME_KIND = "kind"; - @SerializedName(SERIALIZED_NAME_KIND) - private String kind; - - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) - private String name; - - public static final String SERIALIZED_NAME_NAMESPACE = "namespace"; - @SerializedName(SERIALIZED_NAME_NAMESPACE) - private String namespace; - - public static final String SERIALIZED_NAME_PORT = "port"; - @SerializedName(SERIALIZED_NAME_PORT) - private Integer port; - - public static final String SERIALIZED_NAME_SECTION_NAME = "sectionName"; - @SerializedName(SERIALIZED_NAME_SECTION_NAME) - private String sectionName; - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; + public static final String SERIALIZED_NAME_GROUP = "group"; + public static final String SERIALIZED_NAME_KIND = "kind"; + public static final String SERIALIZED_NAME_NAME = "name"; + public static final String SERIALIZED_NAME_NAMESPACE = "namespace"; + public static final String SERIALIZED_NAME_PORT = "port"; + public static final String SERIALIZED_NAME_SECTION_NAME = "sectionName"; + @SerializedName(SERIALIZED_NAME_GROUP) + private String group; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + @SerializedName(SERIALIZED_NAME_NAMESPACE) + private String namespace; + @SerializedName(SERIALIZED_NAME_PORT) + private Integer port; + @SerializedName(SERIALIZED_NAME_SECTION_NAME) + private String sectionName; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteStatusParentRef v1HttpRouteStatusParentRef = (V1HTTPRouteStatusParentRef) o; + return Objects.equals(this.group, v1HttpRouteStatusParentRef.group) && + Objects.equals(this.kind, v1HttpRouteStatusParentRef.kind) && + Objects.equals(this.name, v1HttpRouteStatusParentRef.name) && + Objects.equals(this.namespace, v1HttpRouteStatusParentRef.namespace) && + Objects.equals(this.port, v1HttpRouteStatusParentRef.port) && + Objects.equals(this.sectionName, v1HttpRouteStatusParentRef.sectionName); } - if (o == null || getClass() != o.getClass()) { - return false; - } - V1HTTPRouteStatusParentRef v1HttpRouteStatusParentRef = (V1HTTPRouteStatusParentRef) o; - return Objects.equals(this.group, v1HttpRouteStatusParentRef.group) && - Objects.equals(this.kind, v1HttpRouteStatusParentRef.kind) && - Objects.equals(this.name, v1HttpRouteStatusParentRef.name) && - Objects.equals(this.namespace, v1HttpRouteStatusParentRef.namespace) && - Objects.equals(this.port, v1HttpRouteStatusParentRef.port) && - Objects.equals(this.sectionName, v1HttpRouteStatusParentRef.sectionName); - } - @Override - public int hashCode() { - return Objects.hash(group, kind, name, namespace, port, sectionName); - } + @Override + public int hashCode() { + return Objects.hash(group, kind, name, namespace, port, sectionName); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteStatusParentRef {\n"); - sb.append(" group: ").append(toIndentedString(group)).append("\n"); - sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); - sb.append(" port: ").append(toIndentedString(port)).append("\n"); - sb.append(" sectionName: ").append(toIndentedString(sectionName)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1HTTPRouteStatusParentRef {\n" + + " group: " + toIndentedString(group) + "\n" + + " kind: " + toIndentedString(kind) + "\n" + + " name: " + toIndentedString(name) + "\n" + + " namespace: " + toIndentedString(namespace) + "\n" + + " port: " + toIndentedString(port) + "\n" + + " sectionName: " + toIndentedString(sectionName) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParents.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParents.java index cc5a6889..ced0d985 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParents.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteStatusParents.java @@ -1,21 +1,20 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.ArrayList; @@ -27,69 +26,64 @@ */ @Data public class V1HTTPRouteStatusParents { - - - public static final String SERIALIZED_NAME_CONDITIONS = "conditions"; - @SerializedName(SERIALIZED_NAME_CONDITIONS) - private List conditions = null; - - public static final String SERIALIZED_NAME_CONTROLLER_NAME = "controllerName"; - @SerializedName(SERIALIZED_NAME_CONTROLLER_NAME) - private String controllerName; - - public static final String SERIALIZED_NAME_PARENT_REF = "parentRef"; - @SerializedName(SERIALIZED_NAME_PARENT_REF) - private V1HTTPRouteStatusParentRef parentRef; - - public V1HTTPRouteStatusParents addConditionsItem(V1HTTPRouteStatusConditions conditionsItem) { - if (this.conditions == null) { - this.conditions = new ArrayList<>(); + public static final String SERIALIZED_NAME_CONDITIONS = "conditions"; + public static final String SERIALIZED_NAME_CONTROLLER_NAME = "controllerName"; + public static final String SERIALIZED_NAME_PARENT_REF = "parentRef"; + @SerializedName(SERIALIZED_NAME_CONDITIONS) + private List conditions = null; + @SerializedName(SERIALIZED_NAME_CONTROLLER_NAME) + private String controllerName; + @SerializedName(SERIALIZED_NAME_PARENT_REF) + private V1HTTPRouteStatusParentRef parentRef; + + public V1HTTPRouteStatusParents addConditionsItem(V1HTTPRouteStatusConditions conditionsItem) { + if (this.conditions == null) { + this.conditions = new ArrayList<>(); + } + this.conditions.add(conditionsItem); + return this; } - this.conditions.add(conditionsItem); - return this; - } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1HTTPRouteStatusParents v1HttpRouteStatusParents = (V1HTTPRouteStatusParents) o; + return Objects.equals(this.conditions, v1HttpRouteStatusParents.conditions) && + Objects.equals(this.controllerName, v1HttpRouteStatusParents.controllerName) && + Objects.equals(this.parentRef, v1HttpRouteStatusParents.parentRef); } - V1HTTPRouteStatusParents v1HttpRouteStatusParents = (V1HTTPRouteStatusParents) o; - return Objects.equals(this.conditions, v1HttpRouteStatusParents.conditions) && - Objects.equals(this.controllerName, v1HttpRouteStatusParents.controllerName) && - Objects.equals(this.parentRef, v1HttpRouteStatusParents.parentRef); - } - @Override - public int hashCode() { - return Objects.hash(conditions, controllerName, parentRef); - } + @Override + public int hashCode() { + return Objects.hash(conditions, controllerName, parentRef); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1HTTPRouteStatusParents {\n"); - sb.append(" conditions: ").append(toIndentedString(conditions)).append("\n"); - sb.append(" controllerName: ").append(toIndentedString(controllerName)).append("\n"); - sb.append(" parentRef: ").append(toIndentedString(parentRef)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1HTTPRouteStatusParents {\n" + + " conditions: " + toIndentedString(conditions) + "\n" + + " controllerName: " + toIndentedString(controllerName) + "\n" + + " parentRef: " + toIndentedString(parentRef) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrant.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrant.java index 30a9b72e..154e901c 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrant.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrant.java @@ -1,13 +1,14 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ @@ -15,8 +16,6 @@ import com.google.gson.annotations.SerializedName; import io.kubernetes.client.openapi.models.V1ObjectMeta; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Objects; @@ -27,72 +26,68 @@ @Data public class V1beta1ReferenceGrant implements io.kubernetes.client.common.KubernetesObject { - public static final String API_GROUP = "gateway.networking.k8s.io"; - public static final String VERSION = "v1"; - public static final String KIND = "ReferenceGrant"; - public static final String PLURAL = "referencegrants"; - - - public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; - @SerializedName(SERIALIZED_NAME_API_VERSION) - private String apiVersion = API_GROUP + "/" + VERSION; - - public static final String SERIALIZED_NAME_KIND = "kind"; - @SerializedName(SERIALIZED_NAME_KIND) - private String kind = KIND; - - public static final String SERIALIZED_NAME_METADATA = "metadata"; - @SerializedName(SERIALIZED_NAME_METADATA) - private V1ObjectMeta metadata = null; + public static final String API_GROUP = "gateway.networking.k8s.io"; + public static final String VERSION = "v1"; + public static final String KIND = "ReferenceGrant"; + public static final String PLURAL = "referencegrants"; + + + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; + public static final String SERIALIZED_NAME_KIND = "kind"; + public static final String SERIALIZED_NAME_METADATA = "metadata"; + public static final String SERIALIZED_NAME_SPEC = "spec"; + @SerializedName(SERIALIZED_NAME_API_VERSION) + private String apiVersion = API_GROUP + "/" + VERSION; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind = KIND; + @SerializedName(SERIALIZED_NAME_METADATA) + private V1ObjectMeta metadata = null; + @SerializedName(SERIALIZED_NAME_SPEC) + private V1beta1ReferenceGrantSpec spec; + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1beta1ReferenceGrant v1beta1ReferenceGrant = (V1beta1ReferenceGrant) o; + return Objects.equals(this.apiVersion, v1beta1ReferenceGrant.apiVersion) && + Objects.equals(this.kind, v1beta1ReferenceGrant.kind) && + Objects.equals(this.metadata, v1beta1ReferenceGrant.metadata) && + Objects.equals(this.spec, v1beta1ReferenceGrant.spec); + } - public static final String SERIALIZED_NAME_SPEC = "spec"; - @SerializedName(SERIALIZED_NAME_SPEC) - private V1beta1ReferenceGrantSpec spec; + @Override + public int hashCode() { + return Objects.hash(apiVersion, kind, metadata, spec); + } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; + @Override + public String toString() { + String sb = "class V1beta1ReferenceGrant {\n" + + " apiVersion: " + toIndentedString(apiVersion) + "\n" + + " kind: " + toIndentedString(kind) + "\n" + + " metadata: " + toIndentedString(metadata) + "\n" + + " spec: " + toIndentedString(spec) + "\n" + + "}"; + return sb; } - if (o == null || getClass() != o.getClass()) { - return false; - } - V1beta1ReferenceGrant v1beta1ReferenceGrant = (V1beta1ReferenceGrant) o; - return Objects.equals(this.apiVersion, v1beta1ReferenceGrant.apiVersion) && - Objects.equals(this.kind, v1beta1ReferenceGrant.kind) && - Objects.equals(this.metadata, v1beta1ReferenceGrant.metadata) && - Objects.equals(this.spec, v1beta1ReferenceGrant.spec); - } - - @Override - public int hashCode() { - return Objects.hash(apiVersion, kind, metadata, spec); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1beta1ReferenceGrant {\n"); - sb.append(" apiVersion: ").append(toIndentedString(apiVersion)).append("\n"); - sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); - sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); - sb.append(" spec: ").append(toIndentedString(spec)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantList.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantList.java index 36c63247..28dd389f 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantList.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantList.java @@ -1,13 +1,14 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ @@ -15,8 +16,6 @@ import com.google.gson.annotations.SerializedName; import io.kubernetes.client.openapi.models.V1ListMeta; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.ArrayList; @@ -28,71 +27,67 @@ */ @Data public class V1beta1ReferenceGrantList implements io.kubernetes.client.common.KubernetesListObject { - public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; - @SerializedName(SERIALIZED_NAME_API_VERSION) - private String apiVersion; - - public static final String SERIALIZED_NAME_ITEMS = "items"; - @SerializedName(SERIALIZED_NAME_ITEMS) - private List items = new ArrayList<>(); - - public static final String SERIALIZED_NAME_KIND = "kind"; - @SerializedName(SERIALIZED_NAME_KIND) - private String kind; - - public static final String SERIALIZED_NAME_METADATA = "metadata"; - @SerializedName(SERIALIZED_NAME_METADATA) - private V1ListMeta metadata = null; - - - public V1beta1ReferenceGrantList addItemsItem(V1beta1ReferenceGrant itemsItem) { - this.items.add(itemsItem); - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; + public static final String SERIALIZED_NAME_ITEMS = "items"; + public static final String SERIALIZED_NAME_KIND = "kind"; + public static final String SERIALIZED_NAME_METADATA = "metadata"; + @SerializedName(SERIALIZED_NAME_API_VERSION) + private String apiVersion; + @SerializedName(SERIALIZED_NAME_ITEMS) + private List items = new ArrayList<>(); + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + @SerializedName(SERIALIZED_NAME_METADATA) + private V1ListMeta metadata = null; + + + public V1beta1ReferenceGrantList addItemsItem(V1beta1ReferenceGrant itemsItem) { + this.items.add(itemsItem); + return this; } - if (o == null || getClass() != o.getClass()) { - return false; + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1beta1ReferenceGrantList v1beta1ReferenceGrantList = (V1beta1ReferenceGrantList) o; + return Objects.equals(this.apiVersion, v1beta1ReferenceGrantList.apiVersion) && + Objects.equals(this.items, v1beta1ReferenceGrantList.items) && + Objects.equals(this.kind, v1beta1ReferenceGrantList.kind) && + Objects.equals(this.metadata, v1beta1ReferenceGrantList.metadata); } - V1beta1ReferenceGrantList v1beta1ReferenceGrantList = (V1beta1ReferenceGrantList) o; - return Objects.equals(this.apiVersion, v1beta1ReferenceGrantList.apiVersion) && - Objects.equals(this.items, v1beta1ReferenceGrantList.items) && - Objects.equals(this.kind, v1beta1ReferenceGrantList.kind) && - Objects.equals(this.metadata, v1beta1ReferenceGrantList.metadata); - } - @Override - public int hashCode() { - return Objects.hash(apiVersion, items, kind, metadata); - } + @Override + public int hashCode() { + return Objects.hash(apiVersion, items, kind, metadata); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1beta1ReferenceGrantList {\n"); - sb.append(" apiVersion: ").append(toIndentedString(apiVersion)).append("\n"); - sb.append(" items: ").append(toIndentedString(items)).append("\n"); - sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); - sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1beta1ReferenceGrantList {\n" + + " apiVersion: " + toIndentedString(apiVersion) + "\n" + + " items: " + toIndentedString(items) + "\n" + + " kind: " + toIndentedString(kind) + "\n" + + " metadata: " + toIndentedString(metadata) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpec.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpec.java index 5258a732..f9d42bbc 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpec.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpec.java @@ -1,21 +1,20 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.referencegrant; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.ArrayList; @@ -27,61 +26,58 @@ */ @Data public class V1beta1ReferenceGrantSpec { - public static final String SERIALIZED_NAME_FROM = "from"; - @SerializedName(SERIALIZED_NAME_FROM) - private List from = new ArrayList<>(); - - public static final String SERIALIZED_NAME_TO = "to"; - @SerializedName(SERIALIZED_NAME_TO) - private List to = new ArrayList<>(); + public static final String SERIALIZED_NAME_FROM = "from"; + public static final String SERIALIZED_NAME_TO = "to"; + @SerializedName(SERIALIZED_NAME_FROM) + private List from = new ArrayList<>(); + @SerializedName(SERIALIZED_NAME_TO) + private List to = new ArrayList<>(); - public V1beta1ReferenceGrantSpec addToItem(V1beta1ReferenceGrantSpecTo toItem) { - this.to.add(toItem); - return this; - } - + public V1beta1ReferenceGrantSpec addToItem(V1beta1ReferenceGrantSpecTo toItem) { + this.to.add(toItem); + return this; + } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1beta1ReferenceGrantSpec v1beta1ReferenceGrantSpec = (V1beta1ReferenceGrantSpec) o; + return Objects.equals(this.from, v1beta1ReferenceGrantSpec.from) && + Objects.equals(this.to, v1beta1ReferenceGrantSpec.to); } - if (o == null || getClass() != o.getClass()) { - return false; - } - V1beta1ReferenceGrantSpec v1beta1ReferenceGrantSpec = (V1beta1ReferenceGrantSpec) o; - return Objects.equals(this.from, v1beta1ReferenceGrantSpec.from) && - Objects.equals(this.to, v1beta1ReferenceGrantSpec.to); - } - @Override - public int hashCode() { - return Objects.hash(from, to); - } + @Override + public int hashCode() { + return Objects.hash(from, to); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1beta1ReferenceGrantSpec {\n"); - sb.append(" from: ").append(toIndentedString(from)).append("\n"); - sb.append(" to: ").append(toIndentedString(to)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1beta1ReferenceGrantSpec {\n" + + " from: " + toIndentedString(from) + "\n" + + " to: " + toIndentedString(to) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpecFrom.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpecFrom.java index c1cd6b3d..59bf16f2 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpecFrom.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpecFrom.java @@ -1,21 +1,20 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.referencegrant; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Objects; @@ -25,60 +24,57 @@ */ @Data public class V1beta1ReferenceGrantSpecFrom { - public static final String SERIALIZED_NAME_GROUP = "group"; - @SerializedName(SERIALIZED_NAME_GROUP) - private String group; - - public static final String SERIALIZED_NAME_KIND = "kind"; - @SerializedName(SERIALIZED_NAME_KIND) - private String kind; - - public static final String SERIALIZED_NAME_NAMESPACE = "namespace"; - @SerializedName(SERIALIZED_NAME_NAMESPACE) - private String namespace; + public static final String SERIALIZED_NAME_GROUP = "group"; + public static final String SERIALIZED_NAME_KIND = "kind"; + public static final String SERIALIZED_NAME_NAMESPACE = "namespace"; + @SerializedName(SERIALIZED_NAME_GROUP) + private String group; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + @SerializedName(SERIALIZED_NAME_NAMESPACE) + private String namespace; - @Override - public boolean equals(Object o) { - if (this == o) { - return true; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1beta1ReferenceGrantSpecFrom v1beta1ReferenceGrantSpecFrom = (V1beta1ReferenceGrantSpecFrom) o; + return Objects.equals(this.group, v1beta1ReferenceGrantSpecFrom.group) && + Objects.equals(this.kind, v1beta1ReferenceGrantSpecFrom.kind) && + Objects.equals(this.namespace, v1beta1ReferenceGrantSpecFrom.namespace); } - if (o == null || getClass() != o.getClass()) { - return false; - } - V1beta1ReferenceGrantSpecFrom v1beta1ReferenceGrantSpecFrom = (V1beta1ReferenceGrantSpecFrom) o; - return Objects.equals(this.group, v1beta1ReferenceGrantSpecFrom.group) && - Objects.equals(this.kind, v1beta1ReferenceGrantSpecFrom.kind) && - Objects.equals(this.namespace, v1beta1ReferenceGrantSpecFrom.namespace); - } - @Override - public int hashCode() { - return Objects.hash(group, kind, namespace); - } + @Override + public int hashCode() { + return Objects.hash(group, kind, namespace); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1beta1ReferenceGrantSpecFrom {\n"); - sb.append(" group: ").append(toIndentedString(group)).append("\n"); - sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); - sb.append(" namespace: ").append(toIndentedString(namespace)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1beta1ReferenceGrantSpecFrom {\n" + + " group: " + toIndentedString(group) + "\n" + + " kind: " + toIndentedString(kind) + "\n" + + " namespace: " + toIndentedString(namespace) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpecTo.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpecTo.java index 02d5f62e..ac0322a0 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpecTo.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrantSpecTo.java @@ -1,21 +1,20 @@ /* - * Kubernetes - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. * - * The version of the OpenAPI document: v1.21.1 - * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. */ package com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.referencegrant; import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Objects; @@ -25,60 +24,57 @@ */ @Data public class V1beta1ReferenceGrantSpecTo { - public static final String SERIALIZED_NAME_GROUP = "group"; - @SerializedName(SERIALIZED_NAME_GROUP) - private String group; - - public static final String SERIALIZED_NAME_KIND = "kind"; - @SerializedName(SERIALIZED_NAME_KIND) - private String kind; - - public static final String SERIALIZED_NAME_NAME = "name"; - @SerializedName(SERIALIZED_NAME_NAME) - private String name; + public static final String SERIALIZED_NAME_GROUP = "group"; + public static final String SERIALIZED_NAME_KIND = "kind"; + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_GROUP) + private String group; + @SerializedName(SERIALIZED_NAME_KIND) + private String kind; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; - @Override - public boolean equals(Object o) { - if (this == o) { - return true; + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + V1beta1ReferenceGrantSpecTo v1beta1ReferenceGrantSpecTo = (V1beta1ReferenceGrantSpecTo) o; + return Objects.equals(this.group, v1beta1ReferenceGrantSpecTo.group) && + Objects.equals(this.kind, v1beta1ReferenceGrantSpecTo.kind) && + Objects.equals(this.name, v1beta1ReferenceGrantSpecTo.name); } - if (o == null || getClass() != o.getClass()) { - return false; - } - V1beta1ReferenceGrantSpecTo v1beta1ReferenceGrantSpecTo = (V1beta1ReferenceGrantSpecTo) o; - return Objects.equals(this.group, v1beta1ReferenceGrantSpecTo.group) && - Objects.equals(this.kind, v1beta1ReferenceGrantSpecTo.kind) && - Objects.equals(this.name, v1beta1ReferenceGrantSpecTo.name); - } - @Override - public int hashCode() { - return Objects.hash(group, kind, name); - } + @Override + public int hashCode() { + return Objects.hash(group, kind, name); + } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class V1beta1ReferenceGrantSpecTo {\n"); - sb.append(" group: ").append(toIndentedString(group)).append("\n"); - sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append("}"); - return sb.toString(); - } + @Override + public String toString() { + String sb = "class V1beta1ReferenceGrantSpecTo {\n" + + " group: " + toIndentedString(group) + "\n" + + " kind: " + toIndentedString(kind) + "\n" + + " name: " + toIndentedString(name) + "\n" + + "}"; + return sb; + } - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); } - return o.toString().replace("\n", "\n "); - } } From 07f7b1e0c9c73522b8d60c670fdcaaedc1e5a07d Mon Sep 17 00:00:00 2001 From: zxlin <860620266@qq.com> Date: Wed, 16 Oct 2024 10:32:52 +0800 Subject: [PATCH 09/24] refactor: when domain is related to a ingress, only update the configmap --- .../higress/sdk/service/DomainService.java | 2 + .../sdk/service/DomainServiceImpl.java | 17 +++++ .../kubernetes/KubernetesClientService.java | 16 ++-- .../kubernetes/KubernetesModelConverter.java | 75 +++++++++++-------- 4 files changed, 72 insertions(+), 38 deletions(-) diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/DomainService.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/DomainService.java index 46781bae..2f10306d 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/DomainService.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/DomainService.java @@ -28,4 +28,6 @@ public interface DomainService { void delete(String domainName) throws BusinessException; Domain put(Domain domain) throws BusinessException; + + Domain addOrUpdate(Domain domain) throws BusinessException; } \ No newline at end of file diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/DomainServiceImpl.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/DomainServiceImpl.java index b1279784..0c1c8135 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/DomainServiceImpl.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/DomainServiceImpl.java @@ -160,6 +160,14 @@ public Domain put(Domain domain) { } if(!kubernetesClientService.isIngressWorkMode()){ + try { + boolean isDomainForIngress = kubernetesClientService.readGateway(domain.getName()) == null; + if (isDomainForIngress) { + return kubernetesModelConverter.configMap2Domain(updatedConfigMap); + } + } catch (ApiException e) { + throw new BusinessException("Error occurs when querying a Gateway", e); + } V1Gateway gateway = kubernetesModelConverter.domain2Gateway(domain); try { kubernetesClientService.replaceGateway(gateway); @@ -169,4 +177,13 @@ public Domain put(Domain domain) { } return kubernetesModelConverter.configMap2Domain(updatedConfigMap); } + public Domain addOrUpdate(Domain domain){ + Domain existingDomain = query(domain.getName()); + if (existingDomain == null) { + return add(domain); + } else { + domain.setVersion(existingDomain.getVersion()); + return put(domain); + } + } } \ No newline at end of file diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java index 86b24348..e8ad9f92 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java @@ -190,7 +190,7 @@ private void initGatewayClass() { } } - private void getIngressOrGatewayMode(){ + private void getIngressOrGatewayMode() { // read config, check if ingress or gateway mode V1ConfigMap higressConfig; try { @@ -201,7 +201,7 @@ private void getIngressOrGatewayMode(){ } Map data = higressConfig.getData(); workMode = "ingress"; - if (data!=null && data.containsKey("workMode")){ + if (data!=null && data.containsKey("workMode")) { workMode = data.get("workMode"); } } @@ -209,7 +209,7 @@ public boolean isIngressV1Supported() { return ingressV1Supported; } - public boolean isIngressWorkMode(){ + public boolean isIngressWorkMode() { return workMode.equals("ingress"); } public boolean isNamespaceProtected(String namespace) { @@ -517,7 +517,7 @@ public List listGateway() { Object response = customObjectsApi.listNamespacedCustomObject(V1Gateway.API_GROUP, V1Gateway.VERSION, controllerNamespace, V1Gateway.PLURAL, null, null, null, null, null, null, null, null, null, null); io.kubernetes.client.openapi.JSON json = new io.kubernetes.client.openapi.JSON(); - V1GatewayList list = json.deserialize(json.serialize(response), V1McpBridgeList.class); + V1GatewayList list = json.deserialize(json.serialize(response), V1GatewayList.class); return sortKubernetesObjects(list.getItems()); } catch (ApiException e) { log.error("listGateway Status code: " + e.getCode() + "Reason: " + e.getResponseBody() @@ -586,13 +586,13 @@ public void modifyLoadBalancerPorts(V1Gateway gatewayOri, V1Gateway gatewayRepla assert ports != null; Map portFrequency = new HashMap<>(); - if(gatewayOri != null){ + if (gatewayOri != null) { List listenersOri = gatewayOri.getSpec().getListeners(); for (V1GatewaySpecListeners listener : listenersOri) { portFrequency.put(listener.getPort(), portFrequency.getOrDefault(listener.getPort(), 0) - 1); } } - if(gatewayReplaced != null){ + if (gatewayReplaced != null) { List listenersReplaced = gatewayReplaced.getSpec().getListeners(); for (V1GatewaySpecListeners listener : listenersReplaced) { portFrequency.put(listener.getPort(), portFrequency.getOrDefault(listener.getPort(), 0) + 1); @@ -602,7 +602,7 @@ public void modifyLoadBalancerPorts(V1Gateway gatewayOri, V1Gateway gatewayRepla for (Map.Entry entry : portFrequency.entrySet()) { Integer port = entry.getKey(); Integer freq = entry.getValue(); - if(port == 80 || port == 443 || freq == 0) { + if (port == 80 || port == 443 || freq == 0) { continue; } int count = Integer.parseInt(portCount.getOrDefault(port.toString(), "0")) + (freq>0?1:-1); @@ -612,7 +612,7 @@ public void modifyLoadBalancerPorts(V1Gateway gatewayOri, V1Gateway gatewayRepla ports.removeIf(p -> p.getPort().equals(port)); } else { portCount.put(port.toString(), Integer.toString(count)); - if(count==1) { + if (count==1) { V1ServicePort servicePort = new V1ServicePort().port(port); servicePort.setProtocol("TCP"); servicePort.setName("port"+Separators.DASH+ port); diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java index 2414a1e3..ab07a93b 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java @@ -185,6 +185,41 @@ public boolean isIngressSupported(V1Ingress ingress) { return true; } + public boolean isGatewaySupported(V1Gateway gateway) { + if (gateway.getMetadata() == null) { + return false; + } + V1GatewaySpec spec = gateway.getSpec(); + if (spec == null) { + return false; + } + if (StringUtils.isEmpty(spec.getGatewayClassName())) { + return false; + } + if (CollectionUtils.isEmpty(spec.getListeners())) { + return false; + } + // Check each listener + for (V1GatewaySpecListeners listener : spec.getListeners()) { + if (StringUtils.isEmpty(listener.getName())) { + return false; + } + if (listener.getProtocol() == null || + (!listener.getProtocol().equals("HTTP") && !listener.getProtocol().equals("HTTPS"))) { + return false; + } + if (listener.getProtocol().equals("HTTPS")) { + V1GatewaySpecTls tls = listener.getTls(); + if (tls == null || CollectionUtils.isEmpty(tls.getCertificateRefs())) { + return false; + } + } + if (listener.getPort() == null || listener.getPort() <= 0) { + return false; + } + } + return true; + } public Route ingress2Route(V1Ingress ingress) { Route route = new Route(); fillRouteMetadata(route, ingress.getMetadata()); @@ -222,11 +257,13 @@ public V1Gateway domain2Gateway(Domain domain){ } domain.getPortAndCertMap().forEach((port, cert) -> { V1GatewaySpecListeners listener = new V1GatewaySpecListeners(); - listener.setName(domain.getName()+Separators.DASH+port); + listener.setName(KubernetesUtil.normalizeDomainName(domain.getName())+Separators.DASH+port); listener.setPort(port); - listener.setHostname(domain.getName()); + if (!Separators.ASTERISK.equals(domain.getName())) { + listener.setHostname(domain.getName()); + } listener.setProtocol("HTTP"); - if(!"".equals(cert)){ //tls is not null + if (!"".equals(cert)){ listener.setProtocol("HTTPS"); V1GatewaySpecTls tls = V1GatewaySpecListeners.getDefaultTls(cert); listener.setTls(tls); @@ -239,30 +276,6 @@ public V1Gateway domain2Gateway(Domain domain){ return gateway; } - - - public Domain gateway2Domain(V1Gateway gateway){ - Domain domain = new Domain(); - V1ObjectMeta metadata = gateway.getMetadata(); - if (metadata != null) { - domain.setVersion(metadata.getResourceVersion()); - } - List listeners = gateway.getSpec().getListeners(); - domain.setName(listeners.get(0).getHostname()); - domain.setEnableHttps("OFF"); - for (V1GatewaySpecListeners listener:listeners){ - if(listener.getTls() == null){ - domain.getPortAndCertMap().put(listener.getPort(),""); - }else{ - domain.setEnableHttps("ON"); - domain.getPortAndCertMap().put(listener.getPort(), - listener.getTls().getCertificateRefs().get(0).getName()); - } - } - // TODO: find HTTPRoute named "port-xxx-tls-redirect", if domain in hostnames -> domain.setEnableHttps("FORCE"); - return domain; - } - private static void fillRouteCors(Route route, V1ObjectMeta metadata) { if (metadata == null || metadata.getAnnotations() == null) { return; @@ -330,11 +343,10 @@ public Domain configMap2Domain(V1ConfigMap configMap) { } domain.setName(configMapData.get(CommonKey.DOMAIN)); String certData = configMapData.get(KubernetesConstants.K8S_CERT); - // try { domain.setPortAndCertMap(JSON.parseObject(certData, Map.class)); }catch(JSONException e){ - // ingress-left cert + // ingress-style cert (Only String) -> turn to map[443:certName] Map portCertMap = new HashMap<>(); portCertMap.put(443, certData); domain.setPortAndCertMap(portCertMap); @@ -349,9 +361,12 @@ public String domainName2ConfigMapName(String domainName) { } public String domainName2GatewayName(String domainName) { - return domainName.replace('.', '-'); + return KubernetesUtil.normalizeDomainName(domainName).replace('.', '-'); } + public String gatewayName2DomainName(String gatewayName) { + return gatewayName.replace('-', '.'); + } public V1Secret tlsCertificate2Secret(TlsCertificate certificate) { V1Secret secret = new V1Secret(); From 3f4a56d08b15aa6cb93348b23989f5fbad653732 Mon Sep 17 00:00:00 2001 From: zxlin <860620266@qq.com> Date: Wed, 16 Oct 2024 18:39:42 +0800 Subject: [PATCH 10/24] feat: add httproute functions --- .../higress/sdk/constant/Separators.java | 2 + .../sdk/service/DomainServiceImpl.java | 2 - .../higress/sdk/service/RouteServiceImpl.java | 147 +++- .../WasmPluginInstanceServiceImpl.java | 43 +- .../kubernetes/KubernetesClientService.java | 218 +++++- .../kubernetes/KubernetesModelConverter.java | 633 +++++++++++++++++- .../gatewayapi/httproute/V1HTTPRouteSpec.java | 8 + .../httproute/V1HTTPRouteSpecMatches.java | 7 +- .../referencegrant/V1beta1ReferenceGrant.java | 2 +- 9 files changed, 995 insertions(+), 67 deletions(-) diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/constant/Separators.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/constant/Separators.java index 6c2bc36a..f42fc44a 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/constant/Separators.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/constant/Separators.java @@ -31,4 +31,6 @@ public class Separators { public static final String UNDERSCORE = "_"; public static final String COLON = ":"; + + public static final String SLASH = "/"; } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/DomainServiceImpl.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/DomainServiceImpl.java index 0c1c8135..4c68e96d 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/DomainServiceImpl.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/DomainServiceImpl.java @@ -69,7 +69,6 @@ public Domain add(Domain domain) { throw new BusinessException("Error occurs when adding a new domain.", e); } // if gateway mode, create a gateway named "domain_name" - // TODO: should consider the gateway's spec here. if(!kubernetesClientService.isIngressWorkMode()){ V1Gateway gateway = kubernetesModelConverter.domain2Gateway(domain); try { @@ -128,7 +127,6 @@ public void delete(String domainName) { throw new BusinessException("Error occurs when delete a Gateway", e); } } - //TODO: should consider delete instance wasm plugins when delete gateway wasmPluginInstanceService.deleteAll(WasmPluginInstanceScope.DOMAIN, domainName); } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/RouteServiceImpl.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/RouteServiceImpl.java index c8e8f7f3..d3bda5c4 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/RouteServiceImpl.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/RouteServiceImpl.java @@ -12,9 +12,13 @@ */ package com.alibaba.higress.sdk.service; +import java.util.ArrayList; import java.util.Collections; import java.util.List; +import com.alibaba.higress.sdk.constant.HigressConstants; +import com.alibaba.higress.sdk.constant.Separators; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRoute; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -48,18 +52,38 @@ public RouteServiceImpl(KubernetesClientService kubernetesClientService, @Override public PaginatedResult list(RoutePageQuery query) { + // list ingress List ingresses; if (query != null && StringUtils.isNotEmpty(query.getDomainName())) { ingresses = kubernetesClientService.listIngressByDomain(query.getDomainName()); } else { ingresses = kubernetesClientService.listIngress(); } - if (CollectionUtils.isEmpty(ingresses)) { + List supportedIngresses = + ingresses.stream().filter(kubernetesModelConverter::isIngressSupported).toList(); + List ingressResult = supportedIngresses.stream().map(kubernetesModelConverter::ingress2Route).toList(); + // list httpRoute + List httpRoutes; + if (query != null && StringUtils.isNotEmpty(query.getDomainName())) { + httpRoutes = kubernetesClientService.listHttpRouteByDomain(query.getDomainName()); + } else { + httpRoutes = kubernetesClientService.listHttpRoute(); + } + List supportedHttpRoutes = + httpRoutes.stream().filter(kubernetesModelConverter::isHttpRouteSupported).toList(); + List httpRouteResult = supportedHttpRoutes.stream().map(kubernetesModelConverter::httpRoute2Route).toList(); + if (CollectionUtils.isEmpty(ingressResult) && CollectionUtils.isEmpty(httpRouteResult)) { return PaginatedResult.createFromFullList(Collections.emptyList(), query); } - List supportedIngresses = - ingresses.stream().filter(kubernetesModelConverter::isIngressSupported).toList(); - return PaginatedResult.createFromFullList(supportedIngresses, query, kubernetesModelConverter::ingress2Route); + if(!ingressResult.isEmpty()){ + if(!httpRouteResult.isEmpty()){ + ingressResult = new ArrayList<>(ingressResult); + ingressResult.addAll(httpRouteResult); + } + }else{ + ingressResult = httpRouteResult; + } + return PaginatedResult.createFromFullList(ingressResult, query); } @Override @@ -70,50 +94,121 @@ public Route query(String routeName) { } catch (ApiException e) { throw new BusinessException("Error occurs when reading the Ingress with name: " + routeName, e); } - return ingress != null ? kubernetesModelConverter.ingress2Route(ingress) : null; + if (ingress != null) { + return kubernetesModelConverter.ingress2Route(ingress); + } + V1HTTPRoute httpRoute; + try { + httpRoute = kubernetesClientService.readHttpRoute(routeName); + } catch (ApiException e) { + throw new BusinessException("Error occurs when reading the HttpRoute with name: " + routeName, e); + } + if (httpRoute != null) { + return kubernetesModelConverter.httpRoute2Route(httpRoute); + } + return null; } @Override public Route add(Route route) { - V1Ingress ingress = kubernetesModelConverter.route2Ingress(route); - V1Ingress newIngress; - try { - newIngress = kubernetesClientService.createIngress(ingress); - } catch (ApiException e) { - if (e.getCode() == HttpStatus.CONFLICT) { - throw new ResourceConflictException(); + if(kubernetesClientService.isIngressWorkMode()){ + V1Ingress ingress = kubernetesModelConverter.route2Ingress(route); + V1Ingress newIngress; + try { + newIngress = kubernetesClientService.createIngress(ingress); + } catch (ApiException e) { + if (e.getCode() == HttpStatus.CONFLICT) { + throw new ResourceConflictException(); + } + throw new BusinessException( + "Error occurs when adding the ingress generated by route with name: " + route.getName(), e); } - throw new BusinessException( - "Error occurs when updating the ingress generated by route with name: " + route.getName(), e); + return kubernetesModelConverter.ingress2Route(newIngress); + } else { + V1HTTPRoute httpRoute = kubernetesModelConverter.route2HttpRoute(route); + V1HTTPRoute newHttpRoute; + try { + newHttpRoute = kubernetesClientService.createHttpRoute(httpRoute); + } catch (ApiException e) { + if (e.getCode() == HttpStatus.CONFLICT) { + throw new ResourceConflictException(); + } + throw new BusinessException( + "Error occurs when adding the httproute generated by route with name: " + route.getName(), e); + } + return kubernetesModelConverter.httpRoute2Route(newHttpRoute); } - return kubernetesModelConverter.ingress2Route(newIngress); + } @Override public Route update(Route route) { - V1Ingress ingress = kubernetesModelConverter.route2Ingress(route); - - V1Ingress updatedIngress; + String name = route.getName(); + if (StringUtils.isEmpty(name)) { + throw new IllegalArgumentException("Route name must not be null"); + } + V1Ingress findIngress; try { - updatedIngress = kubernetesClientService.replaceIngress(ingress); + findIngress = kubernetesClientService.readIngress(name); } catch (ApiException e) { - if (e.getCode() == HttpStatus.CONFLICT) { - throw new ResourceConflictException(); + throw new BusinessException( + "Error occurs when read ingress by route with name: " + route.getName(), e); + } + if (findIngress != null) { + V1Ingress ingress = kubernetesModelConverter.route2Ingress(route); + V1Ingress updatedIngress; + try { + updatedIngress = kubernetesClientService.replaceIngress(ingress); + } catch (ApiException e) { + if (e.getCode() == HttpStatus.CONFLICT) { + throw new ResourceConflictException(); + } + throw new BusinessException( + "Error occurs when updating the ingress generated by route with name: " + route.getName(), e); } + return kubernetesModelConverter.ingress2Route(updatedIngress); + } + V1HTTPRoute findHttpRoute; + try { + findHttpRoute = kubernetesClientService.readHttpRoute(name); + } catch (ApiException e) { throw new BusinessException( - "Error occurs when updating the ingress generated by route with name: " + route.getName(), e); + "Error occurs when read httpRoute generated by route with name: " + route.getName(), e); } - return kubernetesModelConverter.ingress2Route(updatedIngress); + if (findHttpRoute != null) { + V1HTTPRoute httpRoute = kubernetesModelConverter.route2HttpRoute(route); + V1HTTPRoute updatedHttpRoute; + try { + updatedHttpRoute = kubernetesClientService.replaceHttpRoute(httpRoute); + } catch (ApiException e) { + if (e.getCode() == HttpStatus.CONFLICT) { + throw new ResourceConflictException(); + } + throw new BusinessException( + "Error occurs when updating the httpRoute generated by route with name: " + route.getName(), e); + } + return kubernetesModelConverter.httpRoute2Route(updatedHttpRoute); + } + return null; } @Override public void delete(String name) { + Boolean isIngress = Boolean.TRUE; try { - kubernetesClientService.deleteIngress(name); + V1Ingress ingress = kubernetesClientService.readIngress(name); + if (ingress != null) { + kubernetesClientService.deleteIngress(name); + } else { + isIngress = Boolean.FALSE; + kubernetesClientService.deleteHttpRoute(name); + if (!HigressConstants.NS_DEFAULT.equals(kubernetesClientService.httpRouteNameSpace)) { + name = kubernetesClientService.httpRouteNameSpace + Separators.SLASH + name; + } + } } catch (ApiException e) { - throw new BusinessException("Error occurs when deleting ingress with name: " + name, e); + throw new BusinessException("Error occurs when deleting"+ (isIngress?"ingress":"httpRoute") +"with name: " + name, e); } - wasmPluginInstanceService.deleteAll(WasmPluginInstanceScope.ROUTE, name); } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/WasmPluginInstanceServiceImpl.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/WasmPluginInstanceServiceImpl.java index c5f01ef9..4f18873a 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/WasmPluginInstanceServiceImpl.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/WasmPluginInstanceServiceImpl.java @@ -12,17 +12,8 @@ */ package com.alibaba.higress.sdk.service; -import java.io.IOException; -import java.io.StringReader; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import io.swagger.v3.core.util.Yaml; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.StringUtils; - +import com.alibaba.higress.sdk.constant.HigressConstants; +import com.alibaba.higress.sdk.constant.Separators; import com.alibaba.higress.sdk.exception.BusinessException; import com.alibaba.higress.sdk.exception.ResourceConflictException; import com.alibaba.higress.sdk.exception.ValidationException; @@ -34,9 +25,18 @@ import com.alibaba.higress.sdk.service.kubernetes.KubernetesClientService; import com.alibaba.higress.sdk.service.kubernetes.KubernetesModelConverter; import com.alibaba.higress.sdk.service.kubernetes.crd.wasm.V1alpha1WasmPlugin; - import io.kubernetes.client.openapi.ApiException; +import io.swagger.v3.core.util.Yaml; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.io.IOException; +import java.io.StringReader; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Objects; @Slf4j class WasmPluginInstanceServiceImpl implements WasmPluginInstanceService { @@ -46,7 +46,7 @@ class WasmPluginInstanceServiceImpl implements WasmPluginInstanceService { private final KubernetesModelConverter kubernetesModelConverter; public WasmPluginInstanceServiceImpl(WasmPluginService wasmPluginService, - KubernetesClientService kubernetesClientService, KubernetesModelConverter kubernetesModelConverter) { + KubernetesClientService kubernetesClientService, KubernetesModelConverter kubernetesModelConverter) { this.wasmPluginService = wasmPluginService; this.kubernetesClientService = kubernetesClientService; this.kubernetesModelConverter = kubernetesModelConverter; @@ -64,7 +64,7 @@ public List list(WasmPluginInstanceScope scope, String targe return Collections.emptyList(); } return plugins.stream().map(p -> kubernetesModelConverter.getWasmPluginInstanceFromCr(p, scope, target)) - .filter(Objects::nonNull).toList(); + .filter(Objects::nonNull).toList(); } @Override @@ -100,7 +100,12 @@ public WasmPluginInstance addOrUpdate(WasmPluginInstance instance) { } else { if (StringUtils.isEmpty(target)) { throw new IllegalArgumentException( - "instance.target must not be null or empty when scope is not GLOBAL."); + "instance.target must not be null or empty when scope is not GLOBAL."); + } + if (!kubernetesClientService.isIngressWorkMode()) { + if (!HigressConstants.NS_DEFAULT.equals(kubernetesClientService.httpRouteNameSpace)) { + target = kubernetesClientService.httpRouteNameSpace + Separators.SLASH + target; + } } } @@ -125,11 +130,11 @@ public WasmPluginInstance addOrUpdate(WasmPluginInstance instance) { if (instance.getConfigurations() == null && StringUtils.isNotEmpty(instance.getRawConfigurations())) { try { Map configurations = (Map) Yaml.mapper() - .readValue(new StringReader(instance.getRawConfigurations()), Map.class); + .readValue(new StringReader(instance.getRawConfigurations()), Map.class); instance.setConfigurations(configurations); } catch (IOException e) { throw new ValidationException( - "Error occurs when parsing raw configurations: " + instance.getRawConfigurations(), e); + "Error occurs when parsing raw configurations: " + instance.getRawConfigurations(), e); } } @@ -159,7 +164,7 @@ public WasmPluginInstance addOrUpdate(WasmPluginInstance instance) { throw new ResourceConflictException(); } throw new BusinessException( - "Error occurs when adding or updating the WasmPlugin CR with name: " + plugin.getName(), e); + "Error occurs when adding or updating the WasmPlugin CR with name: " + plugin.getName(), e); } return kubernetesModelConverter.getWasmPluginInstanceFromCr(result, scope, target); } @@ -197,7 +202,7 @@ private void deletePluginInstances(List crs, WasmPluginInsta kubernetesClientService.replaceWasmPlugin(cr); } catch (ApiException e) { throw new BusinessException( - "Error occurs when trying to updating WasmPlugin with name " + cr.getMetadata().getName(), e); + "Error occurs when trying to updating WasmPlugin with name " + cr.getMetadata().getName(), e); } } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java index e8ad9f92..1988f681 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java @@ -37,6 +37,12 @@ import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways.V1GatewayList; import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways.V1GatewaySpecListeners; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRoute; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteList; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.referencegrant.V1beta1ReferenceGrant; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.referencegrant.V1beta1ReferenceGrantSpec; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.referencegrant.V1beta1ReferenceGrantSpecFrom; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.referencegrant.V1beta1ReferenceGrantSpecTo; import io.kubernetes.client.openapi.models.V1APIResource; import io.kubernetes.client.openapi.models.V1ConfigMap; import io.kubernetes.client.openapi.models.V1ConfigMapList; @@ -120,6 +126,10 @@ public class KubernetesClientService { private String workMode; + public String httpRouteNameSpace; + + public String gatewayNameSpace; + public KubernetesClientService(HigressServiceConfig config) throws IOException { validateConfig(config); @@ -132,6 +142,8 @@ public KubernetesClientService(HigressServiceConfig config) throws IOException { this.controllerJwtPolicy = config.getControllerJwtPolicy(); this.controllerAccessToken = config.getControllerAccessToken(); this.inCluster = isInCluster(); + this.httpRouteNameSpace = controllerNamespace; + this.gatewayNameSpace = controllerNamespace; if (inCluster) { client = ClientBuilder.cluster().build(); @@ -147,6 +159,11 @@ public KubernetesClientService(HigressServiceConfig config) throws IOException { initializeK8sCapabilities(); initGatewayClass(); getIngressOrGatewayMode(); + try { + createSecretReferenceGrantForGateway(); + } catch (ApiException e) { + log.error("Failed to create secret referenceGrant for gateway", e); + } } private void initializeK8sCapabilities() { @@ -208,7 +225,6 @@ private void getIngressOrGatewayMode() { public boolean isIngressV1Supported() { return ingressV1Supported; } - public boolean isIngressWorkMode() { return workMode.equals("ingress"); } @@ -216,6 +232,34 @@ public boolean isNamespaceProtected(String namespace) { return KubernetesConstants.KUBE_SYSTEM_NS.equals(namespace) || controllerNamespace.equals(namespace); } + private void createSecretReferenceGrantForGateway() throws ApiException { + if (isIngressWorkMode() || controllerNamespace.equals(gatewayNameSpace)) { + return; + } + String referenceGrantName = KubernetesUtil.getReferenceGrantName(controllerNamespace, "gateway2secret"); + V1beta1ReferenceGrant v1beta1ReferenceGrant = readReferenceGrant(referenceGrantName, controllerNamespace); + if (v1beta1ReferenceGrant == null) { + v1beta1ReferenceGrant = new V1beta1ReferenceGrant(); + V1ObjectMeta metadata = new V1ObjectMeta(); + metadata.setName(referenceGrantName); + metadata.setNamespace(controllerNamespace); + v1beta1ReferenceGrant.setMetadata(metadata); + V1beta1ReferenceGrantSpec spec = new V1beta1ReferenceGrantSpec(); + V1beta1ReferenceGrantSpecFrom from = new V1beta1ReferenceGrantSpecFrom(); + from.setNamespace(gatewayNameSpace); + from.setKind(V1Gateway.KIND); + from.setGroup(V1Gateway.API_GROUP); + spec.getFrom().add(from); + V1beta1ReferenceGrantSpecTo to = new V1beta1ReferenceGrantSpecTo(); + to.setKind("Secret"); + to.setGroup(""); + spec.getTo().add(to); + v1beta1ReferenceGrant.setSpec(spec); + createReferenceGrant(v1beta1ReferenceGrant); + } + + } + public List gatewayServiceList() throws IOException { Request request = buildControllerRequest("/debug/registryz"); log.info("gatewayServiceList url {}", request.url()); @@ -515,7 +559,7 @@ public List listGateway() { CustomObjectsApi customObjectsApi = new CustomObjectsApi(client); try { Object response = customObjectsApi.listNamespacedCustomObject(V1Gateway.API_GROUP, V1Gateway.VERSION, - controllerNamespace, V1Gateway.PLURAL, null, null, null, null, null, null, null, null, null, null); + gatewayNameSpace, V1Gateway.PLURAL, null, null, null, null, null, null, null, null, null, null); io.kubernetes.client.openapi.JSON json = new io.kubernetes.client.openapi.JSON(); V1GatewayList list = json.deserialize(json.serialize(response), V1GatewayList.class); return sortKubernetesObjects(list.getItems()); @@ -530,7 +574,7 @@ public V1Gateway createGateway(V1Gateway gateway) throws ApiException { modifyLoadBalancerPorts(null, gateway); CustomObjectsApi customObjectsApi = new CustomObjectsApi(client); Object response = customObjectsApi.createNamespacedCustomObject(V1Gateway.API_GROUP, V1Gateway.VERSION, - controllerNamespace, V1Gateway.PLURAL, gateway, null, null, null); + gatewayNameSpace, V1Gateway.PLURAL, gateway, null, null, null); return client.getJSON().deserialize(client.getJSON().serialize(response), V1Gateway.class); } @@ -542,11 +586,10 @@ public V1Gateway replaceGateway(V1Gateway gateway) throws ApiException { V1Gateway gatewayOri = readGateway(metadata.getName()); modifyLoadBalancerPorts(gatewayOri, gateway); gateway.getMetadata().setResourceVersion(gatewayOri.getMetadata().getResourceVersion()); - //TODO: consider different ns - metadata.setNamespace(controllerNamespace); + metadata.setNamespace(gatewayNameSpace); CustomObjectsApi customObjectsApi = new CustomObjectsApi(client); Object response = customObjectsApi.replaceNamespacedCustomObject(V1Gateway.API_GROUP, V1Gateway.VERSION, - controllerNamespace, V1Gateway.PLURAL, metadata.getName(), gateway, null, null); + gatewayNameSpace, V1Gateway.PLURAL, metadata.getName(), gateway, null, null); return client.getJSON().deserialize(client.getJSON().serialize(response), V1Gateway.class); } @@ -554,7 +597,7 @@ public void deleteGateway(String name) throws ApiException { V1Gateway gateway = readGateway(name); modifyLoadBalancerPorts(gateway, null); CustomObjectsApi customObjectsApi = new CustomObjectsApi(client); - customObjectsApi.deleteNamespacedCustomObject(V1Gateway.API_GROUP, V1Gateway.VERSION, controllerNamespace, + customObjectsApi.deleteNamespacedCustomObject(V1Gateway.API_GROUP, V1Gateway.VERSION, gatewayNameSpace, V1Gateway.PLURAL, name, null, null, null, null, null); } @@ -562,7 +605,7 @@ public V1Gateway readGateway(String name) throws ApiException { CustomObjectsApi customObjectsApi = new CustomObjectsApi(client); try { Object response = customObjectsApi.getNamespacedCustomObject(V1Gateway.API_GROUP, V1Gateway.VERSION, - controllerNamespace, V1Gateway.PLURAL, name); + gatewayNameSpace, V1Gateway.PLURAL, name); return client.getJSON().deserialize(client.getJSON().serialize(response), V1Gateway.class); } catch (ApiException e) { if (e.getCode() == HttpStatus.NOT_FOUND) { @@ -581,7 +624,7 @@ public void modifyLoadBalancerPorts(V1Gateway gatewayOri, V1Gateway gatewayRepla if (portCount == null) { portCount = new HashMap<>(); } - V1Service service = coreV1Api.readNamespacedService(V1GatewayClass.DEFAULT_NAME, controllerNamespace, null); + V1Service service = coreV1Api.readNamespacedService(V1GatewayClass.DEFAULT_NAME, gatewayNameSpace, null); List ports = Objects.requireNonNull(service.getSpec()).getPorts(); assert ports != null; @@ -624,12 +667,167 @@ public void modifyLoadBalancerPorts(V1Gateway gatewayOri, V1Gateway gatewayRepla portConfig.setData(portCount); replaceConfigMap(portConfig); service.getSpec().setPorts(ports); - coreV1Api.replaceNamespacedService(V1GatewayClass.DEFAULT_NAME, controllerNamespace, service, null, null, null, null); + coreV1Api.replaceNamespacedService(V1GatewayClass.DEFAULT_NAME, gatewayNameSpace, service, null, null, null, null); } catch (ApiException e) { log.error("Error when modifying LoadBalancer ports ", e); } } + public List listHttpRouteByDomain(String domainName) { + CustomObjectsApi customObjectsApi = new CustomObjectsApi(client); + String labelSelectors = joinLabelSelectors(DEFAULT_LABEL_SELECTORS, buildDomainLabelSelector(domainName)); + try { + Object response = customObjectsApi.listNamespacedCustomObject(V1HTTPRoute.API_GROUP, V1HTTPRoute.VERSION, + httpRouteNameSpace, V1HTTPRoute.PLURAL, null, null, null, null, labelSelectors, null, null, null, null, null); + io.kubernetes.client.openapi.JSON json = new io.kubernetes.client.openapi.JSON(); + V1HTTPRouteList list = json.deserialize(json.serialize(response), V1HTTPRouteList.class); + if (list == null) { + return Collections.emptyList(); + } + return sortKubernetesObjects(list.getItems()); + } catch (ApiException e) { + log.error("listHttpRouteByDomain Status code: " + e.getCode() + "Reason: " + e.getResponseBody() + + "Response headers: " + e.getResponseHeaders(), e); + return null; + } + } + + public List listHttpRoute() { + CustomObjectsApi customObjectsApi = new CustomObjectsApi(client); + try { + Object response = customObjectsApi.listNamespacedCustomObject(V1HTTPRoute.API_GROUP, V1HTTPRoute.VERSION, + httpRouteNameSpace, V1HTTPRoute.PLURAL, null, null, null, null, null, null, null, null, null, null); + io.kubernetes.client.openapi.JSON json = new io.kubernetes.client.openapi.JSON(); + V1HTTPRouteList list = json.deserialize(json.serialize(response), V1HTTPRouteList.class); + if (list == null) { + return Collections.emptyList(); + } + return sortKubernetesObjects(list.getItems()); + } catch (ApiException e) { + log.error("listHttpRouteByDomain Status code: " + e.getCode() + "Reason: " + e.getResponseBody() + + "Response headers: " + e.getResponseHeaders(), e); + return null; + } + } + + public V1HTTPRoute readHttpRoute(String name) throws ApiException { + CustomObjectsApi customObjectsApi = new CustomObjectsApi(client); + try { + Object response = customObjectsApi.getNamespacedCustomObject(V1HTTPRoute.API_GROUP, V1HTTPRoute.VERSION, + httpRouteNameSpace, V1HTTPRoute.PLURAL, name); + return client.getJSON().deserialize(client.getJSON().serialize(response), V1HTTPRoute.class); + } catch (ApiException e) { + if (e.getCode() == HttpStatus.NOT_FOUND) { + return null; + } + throw e; + } + } + + public V1HTTPRoute createHttpRoute(V1HTTPRoute httpRoute) throws ApiException { + CustomObjectsApi customObjectsApi = new CustomObjectsApi(client); + Object response = customObjectsApi.createNamespacedCustomObject(V1HTTPRoute.API_GROUP, V1HTTPRoute.VERSION, + httpRouteNameSpace, V1HTTPRoute.PLURAL, httpRoute, null, null, null); + return client.getJSON().deserialize(client.getJSON().serialize(response), V1HTTPRoute.class); + } + + public void deleteHttpRoute(String name) throws ApiException { + CustomObjectsApi customObjectsApi = new CustomObjectsApi(client); + customObjectsApi.deleteNamespacedCustomObject(V1HTTPRoute.API_GROUP, V1HTTPRoute.VERSION, httpRouteNameSpace, + V1HTTPRoute.PLURAL, name, null, null, null, null, null); + } + + public V1HTTPRoute replaceHttpRoute(V1HTTPRoute httpRoute) throws ApiException { + V1ObjectMeta metadata = httpRoute.getMetadata(); + if (metadata == null) { + throw new IllegalArgumentException("httpRoute doesn't have a valid metadata."); + } + metadata.setNamespace(httpRouteNameSpace); + CustomObjectsApi customObjectsApi = new CustomObjectsApi(client); + Object response = customObjectsApi.replaceNamespacedCustomObject(V1HTTPRoute.API_GROUP, V1HTTPRoute.VERSION, + httpRouteNameSpace, V1HTTPRoute.PLURAL, metadata.getName(), httpRoute, null, null); + return client.getJSON().deserialize(client.getJSON().serialize(response), V1HTTPRoute.class); + } + + public V1beta1ReferenceGrant addReferenceGrantForHttpRoute2Service(String fromNamespace, String toNamespace) throws ApiException { + if (fromNamespace.equals(toNamespace)) { + return null; + } + String referenceGrantName = KubernetesUtil.getReferenceGrantName(toNamespace, "httproute2service"); + V1beta1ReferenceGrant v1beta1ReferenceGrant = readReferenceGrant(referenceGrantName, toNamespace); + if (v1beta1ReferenceGrant == null) { + v1beta1ReferenceGrant = new V1beta1ReferenceGrant(); + V1ObjectMeta metadata = new V1ObjectMeta(); + metadata.setName(referenceGrantName); + metadata.setNamespace(toNamespace); + v1beta1ReferenceGrant.setMetadata(metadata); + V1beta1ReferenceGrantSpec spec = new V1beta1ReferenceGrantSpec(); + V1beta1ReferenceGrantSpecFrom from = new V1beta1ReferenceGrantSpecFrom(); + from.setNamespace(fromNamespace); + from.setKind(V1HTTPRoute.KIND); + from.setGroup(V1HTTPRoute.API_GROUP); + spec.getFrom().add(from); + V1beta1ReferenceGrantSpecTo to = new V1beta1ReferenceGrantSpecTo(); + to.setKind("Service"); + to.setGroup(""); + spec.getTo().add(to); + v1beta1ReferenceGrant.setSpec(spec); + return createReferenceGrant(v1beta1ReferenceGrant); + } else { + List froms = v1beta1ReferenceGrant.getSpec().getFrom(); + for (V1beta1ReferenceGrantSpecFrom from : froms) { + if (fromNamespace.equals(from.getNamespace())) { + return v1beta1ReferenceGrant; + } + } + V1beta1ReferenceGrantSpecFrom from = new V1beta1ReferenceGrantSpecFrom(); + from.setNamespace(fromNamespace); + from.setKind(V1HTTPRoute.KIND); + from.setGroup(V1HTTPRoute.API_GROUP); + froms.add(from); + return replaceReferenceGrant(v1beta1ReferenceGrant); + } + } + public V1beta1ReferenceGrant readReferenceGrant(String name, String nameSpace) throws ApiException { + CustomObjectsApi customObjectsApi = new CustomObjectsApi(client); + try { + Object response = customObjectsApi.getNamespacedCustomObject(V1beta1ReferenceGrant.API_GROUP, V1beta1ReferenceGrant.VERSION, + nameSpace, V1beta1ReferenceGrant.PLURAL, name); + return client.getJSON().deserialize(client.getJSON().serialize(response), V1beta1ReferenceGrant.class); + } catch (ApiException e) { + if (e.getCode() == HttpStatus.NOT_FOUND) { + return null; + } + throw e; + } + } + public V1beta1ReferenceGrant createReferenceGrant(V1beta1ReferenceGrant referenceGrant) throws ApiException { + CustomObjectsApi customObjectsApi = new CustomObjectsApi(client); + String namespace = controllerNamespace; + if (referenceGrant.getMetadata()!=null && referenceGrant.getMetadata().getNamespace() != null) { + namespace = referenceGrant.getMetadata().getNamespace(); + } + Object response = customObjectsApi.createNamespacedCustomObject(V1beta1ReferenceGrant.API_GROUP, V1beta1ReferenceGrant.VERSION, + namespace, V1beta1ReferenceGrant.PLURAL, referenceGrant, null, null, null); + return client.getJSON().deserialize(client.getJSON().serialize(response), V1beta1ReferenceGrant.class); + } + + public V1beta1ReferenceGrant replaceReferenceGrant(V1beta1ReferenceGrant referenceGrant) throws ApiException{ + V1ObjectMeta metadata = referenceGrant.getMetadata(); + if (metadata == null) { + throw new IllegalArgumentException("gateway doesn't have a valid metadata."); + } + String namespace = controllerNamespace; + if (metadata.getNamespace() != null) { + namespace = referenceGrant.getMetadata().getNamespace(); + } + CustomObjectsApi customObjectsApi = new CustomObjectsApi(client); + Object response = customObjectsApi.replaceNamespacedCustomObject(V1beta1ReferenceGrant.API_GROUP, V1beta1ReferenceGrant.VERSION, + namespace, V1beta1ReferenceGrant.PLURAL, metadata.getName(), referenceGrant, null, null); + return client.getJSON().deserialize(client.getJSON().serialize(response), V1beta1ReferenceGrant.class); + } + + public List listWasmPlugin() throws ApiException { return listWasmPlugin(null, null, null); } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java index ab07a93b..24ad7203 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java @@ -44,6 +44,22 @@ import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways.V1GatewaySpec; import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways.V1GatewaySpecListeners; import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways.V1GatewaySpecTls; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRoute; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpec; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecBackendRefs; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecFilters; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecHeaders; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecMatches; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecParentRefs; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecPath; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecQueryParams; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecRequestHeaderModifier; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecRequestHeaderModifierAdd; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecResponseHeaderModifier; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecRules; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecUrlRewrite; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecUrlRewritePath; +import io.kubernetes.client.common.KubernetesObject; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.ObjectUtils; @@ -205,7 +221,7 @@ public boolean isGatewaySupported(V1Gateway gateway) { return false; } if (listener.getProtocol() == null || - (!listener.getProtocol().equals("HTTP") && !listener.getProtocol().equals("HTTPS"))) { + !listener.getProtocol().equals("HTTP") && !listener.getProtocol().equals("HTTPS")) { return false; } if (listener.getProtocol().equals("HTTPS")) { @@ -220,6 +236,38 @@ public boolean isGatewaySupported(V1Gateway gateway) { } return true; } + + public boolean isHttpRouteSupported(V1HTTPRoute httpRoute) { + if (httpRoute.getMetadata() == null) { + return false; + } + V1HTTPRouteSpec spec = httpRoute.getSpec(); + if (spec == null) { + return false; + } + if (CollectionUtils.isEmpty(spec.getParentRefs())) { + return false; + } + if (CollectionUtils.isEmpty(spec.getRules())) { + return false; + } + if (!CollectionUtils.isEmpty(spec.getHostnames()) && spec.getHostnames().size() > 1) { + return false; + } + for (V1HTTPRouteSpecRules rule : spec.getRules()) { + if (CollectionUtils.isEmpty(rule.getBackendRefs())) { + return false; + } + for (V1HTTPRouteSpecBackendRefs backendRef : rule.getBackendRefs()) { + if (backendRef.getKind()!=null && !"Service".equals(backendRef.getKind())) { + return false; + } + } + } + return true; + } + + public Route ingress2Route(V1Ingress ingress) { Route route = new Route(); fillRouteMetadata(route, ingress.getMetadata()); @@ -239,13 +287,31 @@ public V1Ingress route2Ingress(Route route) { return ingress; } + public Route httpRoute2Route(V1HTTPRoute httpRoute){ + Route route = new Route(); + fillRouteMetadata(route, httpRoute.getMetadata()); + fillRouteInfoFromHttpRoute(route, httpRoute.getSpec(), httpRoute.getMetadata()); + fillCustomConfigs(route, httpRoute.getMetadata()); + return route; + } + + public V1HTTPRoute route2HttpRoute(Route route){ + V1HTTPRoute httpRoute = new V1HTTPRoute(); + httpRoute.setMetadata(new V1ObjectMeta()); + httpRoute.setSpec(new V1HTTPRouteSpec()); + fillHttpRouteMetadata(httpRoute, route); + fillHttpRouteSpec(httpRoute, route); + fillIngressCors(httpRoute, route); + fillIngressAnnotations(httpRoute, route); + return httpRoute; + } + public V1Gateway domain2Gateway(Domain domain){ V1Gateway gateway = new V1Gateway(); V1ObjectMeta metadata = new V1ObjectMeta(); metadata.setName(domainName2GatewayName(domain.getName())); metadata.setResourceVersion(domain.getVersion()); - // TODO: consider the gateway's spec here. - metadata.setNamespace(HigressConstants.NS_DEFAULT); + metadata.setNamespace(kubernetesClientService.gatewayNameSpace); gateway.setMetadata(metadata); // set the gateway address to higress-gateway V1GatewaySpec spec = new V1GatewaySpec().addDefaultAddress(); @@ -887,13 +953,12 @@ private static void fillPathRoute(Route route, V1ObjectMeta metadata, V1HTTPIngr fillRouteDestinations(route, metadata, path.getBackend()); } - private void fillIngressCors(V1Ingress ingress, Route route) { + private void fillIngressCors(KubernetesObject object, Route route) { CorsConfig cors = route.getCors(); if (Objects.isNull(cors)) { return; } - - V1ObjectMeta metadata = Objects.requireNonNull(ingress.getMetadata()); + V1ObjectMeta metadata = Objects.requireNonNull(object.getMetadata()); if (!Objects.isNull(cors.getEnabled())) { KubernetesUtil.setAnnotation(metadata, KubernetesConstants.Annotation.CORS_ENABLED_KEY, cors.getEnabled().toString()); @@ -924,7 +989,7 @@ private void fillIngressCors(V1Ingress ingress, Route route) { } } - private void fillIngressAnnotations(V1Ingress ingress, Route route) { + private void fillIngressAnnotations(KubernetesObject object, Route route) { if (MapUtils.isEmpty(route.getCustomConfigs())) { return; } @@ -942,7 +1007,7 @@ private void fillIngressAnnotations(V1Ingress ingress, Route route) { + "Please configure it in the corresponding section instead of using custom annotations."); } } - KubernetesUtil.setAnnotation(ingress, config.getKey(), config.getValue()); + KubernetesUtil.setAnnotation(object, config.getKey(), config.getValue()); } } @@ -1468,6 +1533,558 @@ private static void fillIngressDestination(V1ObjectMeta metadata, Route route) { } } + private void fillHttpRouteMetadata(V1HTTPRoute httpRoute, Route route) { + V1ObjectMeta metadata = Objects.requireNonNull(httpRoute.getMetadata()); + metadata.setName(route.getName()); + metadata.setResourceVersion(route.getVersion()); + metadata.setNamespace(kubernetesClientService.httpRouteNameSpace); + List routeDomains = route.getDomains(); + if (CollectionUtils.isNotEmpty(routeDomains)) { + for (String domainName : routeDomains) { + setDomainLabel(metadata, domainName); + if (Strings.isNullOrEmpty(domainName)) { + continue; + } + V1ConfigMap configMap; + try { + configMap = kubernetesClientService.readConfigMap(domainName2ConfigMapName(domainName)); + } catch (ApiException e) { + throw new BusinessException("Error occurs when reading config map associated with domain " + domainName, + e); + } + if (configMap == null) { + continue; + } + Domain domain = configMap2Domain(configMap); + if (Domain.EnableHttps.FORCE.equals(domain.getEnableHttps())) { + KubernetesUtil.setAnnotation(metadata, KubernetesConstants.Annotation.SSL_REDIRECT_KEY, + KubernetesConstants.Annotation.TRUE_VALUE); + } + } + } + fillIngressProxyNextUpstreamConfig(metadata, route.getProxyNextUpstream()); + } + private void fillHttpRouteSpec(V1HTTPRoute httpRoute, Route route) { + V1HTTPRouteSpec spec = Objects.requireNonNull(httpRoute.getSpec()); + List domains = route.getDomains(); + if(domains.size() > 1) { + throw new IllegalArgumentException("Only one domain is allowed, domain size: " + domains.size()); + } + V1HTTPRouteSpecParentRefs parentRef = new V1HTTPRouteSpecParentRefs(); + if (!domains.isEmpty()) { + if (!Separators.ASTERISK.equals(domains.get(0))) { + spec.addHostnamesItem(domains.get(0)); + } + parentRef.setName(domainName2GatewayName(domains.get(0))); + parentRef.setNamespace(kubernetesClientService.gatewayNameSpace); + } + spec.addParentRefsItem(parentRef); + V1HTTPRouteSpecRules specRule = new V1HTTPRouteSpecRules(); + fillHttpRouteMatches(httpRoute.getMetadata(), specRule, route); + fillHttpRouteDestination(specRule, route); + fillHttpRouteFilters(specRule, route); + spec.addRulesItem(specRule); + } + + private void fillHttpRouteMatches(V1ObjectMeta metadata, V1HTTPRouteSpecRules specRule, Route route){ + V1HTTPRouteSpecMatches matchesItem = new V1HTTPRouteSpecMatches(); + // path + V1HTTPRouteSpecPath path = new V1HTTPRouteSpecPath(); + RoutePredicate pathPredicate = route.getPath(); + if (pathPredicate != null) { + String matchType = pathPredicate.getMatchType(); + if (StringUtils.isNotEmpty(matchType)) { + if (RoutePredicateTypeEnum.EQUAL.toString().equals(matchType)) { + path.setType(V1HTTPRouteSpecPath.TypeEnum.EXACT); + } else if (RoutePredicateTypeEnum.PRE.toString().equals(matchType)) { + path.setType(V1HTTPRouteSpecPath.TypeEnum.PATHPREFIX); + } else if (RoutePredicateTypeEnum.REGULAR.toString().equals(matchType)) { + path.setType(V1HTTPRouteSpecPath.TypeEnum.REGULAREXPRESSION); + } else { + throw new IllegalArgumentException("Unsupported path match type: " + matchType); + } + path.setValue(pathPredicate.getMatchValue()); + } + if (null != pathPredicate.getCaseSensitive()) { + KubernetesUtil.setAnnotation(metadata, KubernetesConstants.Annotation.IGNORE_PATH_CASE_KEY, + String.valueOf(!pathPredicate.getCaseSensitive())); + } + } + matchesItem.setPath(path); + // header + List specHeaders = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(route.getHeaders())) { + for (KeyedRoutePredicate header : route.getHeaders()) { + V1HTTPRouteSpecHeaders specHeader = new V1HTTPRouteSpecHeaders(); + String matchType = header.getMatchType(); + specHeader.setName(header.getKey()); + specHeader.setValue(header.getMatchValue()); + if (RoutePredicateTypeEnum.EQUAL.toString().equals(matchType)) { + specHeader.setType(V1HTTPRouteSpecHeaders.TypeEnum.EXACT); + specHeaders.add(specHeader); + } else if (RoutePredicateTypeEnum.PRE.toString().equals(matchType)) { + specHeader.setType(V1HTTPRouteSpecHeaders.TypeEnum.REGULAREXPRESSION); + specHeader.setValue("^"+Pattern.quote(header.getMatchValue())+".*"); + specHeaders.add(specHeader); + } else if (RoutePredicateTypeEnum.REGULAR.toString().equals(matchType)) { + specHeader.setType(V1HTTPRouteSpecHeaders.TypeEnum.REGULAREXPRESSION); + specHeaders.add(specHeader); + } else { + throw new IllegalArgumentException("Unsupported header match type: " + matchType); + } + } + } + if (CollectionUtils.isNotEmpty(specHeaders)) { + matchesItem.setHeaders(specHeaders); + } + // param + List queryParams = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(route.getUrlParams())) { + for (KeyedRoutePredicate param : route.getUrlParams()) { + V1HTTPRouteSpecQueryParams queryParam = new V1HTTPRouteSpecQueryParams(); + String matchType = param.getMatchType(); + queryParam.setName(param.getKey()); + queryParam.setValue(param.getMatchValue()); + if (RoutePredicateTypeEnum.EQUAL.toString().equals(matchType)) { + queryParam.setType(V1HTTPRouteSpecQueryParams.TypeEnum.EXACT); + queryParams.add(queryParam); + } else if (RoutePredicateTypeEnum.PRE.toString().equals(matchType)) { + queryParam.setType(V1HTTPRouteSpecQueryParams.TypeEnum.REGULAREXPRESSION); + queryParam.setValue("^"+Pattern.quote(param.getMatchValue())+".*"); + queryParams.add(queryParam); + } else if (RoutePredicateTypeEnum.REGULAR.toString().equals(matchType)) { + queryParam.setType(V1HTTPRouteSpecQueryParams.TypeEnum.REGULAREXPRESSION); + queryParams.add(queryParam); + } else { + throw new IllegalArgumentException("Unsupported header match type: " + matchType); + } + } + } + if (CollectionUtils.isNotEmpty(queryParams)) { + matchesItem.setQueryParams(queryParams); + } + // method + // one matchesItem only have one method, need to copy + if (CollectionUtils.isNotEmpty(route.getMethods())) { + for (String method : route.getMethods()) { + V1HTTPRouteSpecMatches matchesItemCopy; + try{ + matchesItemCopy= (V1HTTPRouteSpecMatches) matchesItem.clone(); + } catch (CloneNotSupportedException e) { + throw new RuntimeException("Error when clone matches", e); + } + if (V1HTTPRouteSpecMatches.MethodEnum.GET.toString().equals(method)) { + matchesItemCopy.setMethod(V1HTTPRouteSpecMatches.MethodEnum.GET); + } else if (V1HTTPRouteSpecMatches.MethodEnum.POST.toString().equals(method)) { + matchesItemCopy.setMethod(V1HTTPRouteSpecMatches.MethodEnum.POST); + } else if (V1HTTPRouteSpecMatches.MethodEnum.PUT.toString().equals(method)) { + matchesItemCopy.setMethod(V1HTTPRouteSpecMatches.MethodEnum.PUT); + } else if (V1HTTPRouteSpecMatches.MethodEnum.DELETE.toString().equals(method)) { + matchesItemCopy.setMethod(V1HTTPRouteSpecMatches.MethodEnum.DELETE); + } else if (V1HTTPRouteSpecMatches.MethodEnum.PATCH.toString().equals(method)) { + matchesItemCopy.setMethod(V1HTTPRouteSpecMatches.MethodEnum.PATCH); + } else if (V1HTTPRouteSpecMatches.MethodEnum.HEAD.toString().equals(method)) { + matchesItemCopy.setMethod(V1HTTPRouteSpecMatches.MethodEnum.HEAD); + } else if (V1HTTPRouteSpecMatches.MethodEnum.OPTIONS.toString().equals(method)) { + matchesItemCopy.setMethod(V1HTTPRouteSpecMatches.MethodEnum.OPTIONS); + } else if (V1HTTPRouteSpecMatches.MethodEnum.CONNECT.toString().equals(method)) { + matchesItemCopy.setMethod(V1HTTPRouteSpecMatches.MethodEnum.CONNECT); + } else if (V1HTTPRouteSpecMatches.MethodEnum.TRACE.toString().equals(method)) { + matchesItemCopy.setMethod(V1HTTPRouteSpecMatches.MethodEnum.TRACE); + } else { + throw new IllegalArgumentException("Unsupported method type: " + method); + } + specRule.addMatchesItem(matchesItemCopy); + } + } else { + specRule.addMatchesItem(matchesItem); + } + } + + private void fillHttpRouteDestination(V1HTTPRouteSpecRules specRule, Route route){ + List services = route.getServices(); + if (CollectionUtils.isEmpty(services)) { + return; + } + List backendRefs = new ArrayList<>(); + for(UpstreamService service : services){ + String name = service.getName(); + V1HTTPRouteSpecBackendRefs backend = new V1HTTPRouteSpecBackendRefs(); + if (name.contains("cluster.local")){ + String[] split = name.split("\\."); + if (split.length!=5) { + throw new IllegalArgumentException("Illegal svc name: " + name); + } + + backend.setName(split[0]); + + if (split[4].split(":").length>1) { + backend.setPort(Integer.parseInt(split[4].split(":")[1])); + } + String httpRouteNs = HigressConstants.NS_DEFAULT; + if (StringUtils.isNotEmpty(kubernetesClientService.httpRouteNameSpace)) { + httpRouteNs = kubernetesClientService.httpRouteNameSpace; + } + if(!httpRouteNs.equals(split[1])){ + // namespaces of httpRoute and service are different, create referenceGrant + String fromNs = kubernetesClientService.httpRouteNameSpace; + String toNs = split[1]; + try { + kubernetesClientService.addReferenceGrantForHttpRoute2Service(fromNs, toNs); + } catch (Exception ex) { + log.error("Failed to create ReferenceGrant:\nfrom:" + fromNs + " to:" + toNs, ex); + } + backend.setNamespace(split[1]); + } + } else { + // mcp + backend.setName(name); + backend.setGroup(V1McpBridge.API_GROUP); + } + if(service.getWeight()!= null){ + backend.setWeight(service.getWeight()); + } + backendRefs.add(backend); + } + if (CollectionUtils.isNotEmpty(backendRefs)) { + specRule.setBackendRefs(backendRefs); + } else { + specRule.setBackendRefs(Collections.singletonList(new V1HTTPRouteSpecBackendRefs())); + } + } + + private void fillHttpRouteFilters(V1HTTPRouteSpecRules specRule, Route route){ + List filters = new ArrayList<>(); + // url rewrite + RewriteConfig rewrite = route.getRewrite(); + if (rewrite!=null && rewrite.getEnabled()) { + V1HTTPRouteSpecFilters filter = new V1HTTPRouteSpecFilters(); + V1HTTPRouteSpecUrlRewrite urlRewrite = new V1HTTPRouteSpecUrlRewrite(); + if (StringUtils.isNotEmpty(rewrite.getHost())) { + urlRewrite.setHostname(rewrite.getHost()); + } else { + urlRewrite.setHostname(route.getDomains().get(0)); + } + V1HTTPRouteSpecUrlRewritePath path = new V1HTTPRouteSpecUrlRewritePath(); + String matchType = route.getPath().getMatchType(); + if (RoutePredicateTypeEnum.PRE.toString().equals(matchType)) { + // pre: REPLACEPREFIXMATCH + path.setReplacePrefixMatch(rewrite.getPath()); + path.setType(V1HTTPRouteSpecUrlRewritePath.TypeEnum.REPLACEPREFIXMATCH); + } else if (RoutePredicateTypeEnum.REGULAR.toString().equals(matchType) || RoutePredicateTypeEnum.EQUAL.toString().equals(matchType)) { + // regular or exact: REPLACEFULLPATH + path.setReplaceFullPath(rewrite.getPath()); + path.setType(V1HTTPRouteSpecUrlRewritePath.TypeEnum.REPLACEFULLPATH); + } + urlRewrite.setPath(path); + filter.setUrlRewrite(urlRewrite); + filter.setType(V1HTTPRouteSpecFilters.TypeEnum.URLREWRITE); + filters.add(filter); + } + // headerModifier + HeaderControlConfig headerControl = route.getHeaderControl(); + if (headerControl != null && headerControl.getEnabled()) { + if (headerControl.getRequest() != null) { + V1HTTPRouteSpecFilters filter = new V1HTTPRouteSpecFilters(); + HeaderControlStageConfig config = headerControl.getRequest(); + V1HTTPRouteSpecRequestHeaderModifier requestHeaderModifier = new V1HTTPRouteSpecRequestHeaderModifier(); + fillHeaderModifier(config, requestHeaderModifier, null, true); + filter.setRequestHeaderModifier(requestHeaderModifier); + filter.setType(V1HTTPRouteSpecFilters.TypeEnum.REQUESTHEADERMODIFIER); + filters.add(filter); + } + if (headerControl.getResponse() != null) { + V1HTTPRouteSpecFilters filter = new V1HTTPRouteSpecFilters(); + V1HTTPRouteSpecResponseHeaderModifier responseHeaderModifier = new V1HTTPRouteSpecResponseHeaderModifier(); + HeaderControlStageConfig config = headerControl.getRequest(); + fillHeaderModifier(config, null, responseHeaderModifier, false); + filter.setResponseHeaderModifier(responseHeaderModifier); + filter.setType(V1HTTPRouteSpecFilters.TypeEnum.RESPONSEHEADERMODIFIER); + filters.add(filter); + } + } + if (CollectionUtils.isNotEmpty(filters)) { + specRule.setFilters(filters); + } + } + + private void fillHeaderModifier(HeaderControlStageConfig config, V1HTTPRouteSpecRequestHeaderModifier requestHeader, V1HTTPRouteSpecResponseHeaderModifier responseHeader, Boolean isRequest){ + if (CollectionUtils.isNotEmpty(config.getAdd())) { + for (Header header : config.getAdd()) { + V1HTTPRouteSpecRequestHeaderModifierAdd add = new V1HTTPRouteSpecRequestHeaderModifierAdd(); + add.setName(header.getKey()); + add.setValue(header.getValue()); + if (isRequest) { + requestHeader.addAddItem(add); + } else { + responseHeader.addAddItem(add); + } + } + } + if (CollectionUtils.isNotEmpty(config.getSet())) { + for (Header header : config.getSet()) { + V1HTTPRouteSpecRequestHeaderModifierAdd set = new V1HTTPRouteSpecRequestHeaderModifierAdd(); + set.setName(header.getKey()); + set.setValue(header.getValue()); + if (isRequest) { + requestHeader.addSetItem(set); + } else { + responseHeader.addSetItem(set); + } + } + } + if (CollectionUtils.isNotEmpty(config.getRemove())) { + for (String key : config.getRemove()) { + if (isRequest) { + requestHeader.addRemoveItem(key); + } else { + responseHeader.addRemoveItem(key); + } + } + } + } + + private void fillRouteInfoFromHttpRoute(Route route, V1HTTPRouteSpec spec, V1ObjectMeta metadata) { + if (spec == null) { + return; + } + // domains + List parentRefs = spec.getParentRefs(); + if (CollectionUtils.isNotEmpty(parentRefs)) { + String gatewayName = parentRefs.get(0).getName(); + if (StringUtils.isNotEmpty(gatewayName)) { + String host = gatewayName2DomainName(gatewayName); + route.setDomains(Collections.singletonList(host)); + } else { + route.setDomains(Collections.emptyList()); + } + } else { + route.setDomains(Collections.emptyList()); + } + // paths + List rules = spec.getRules(); + if (CollectionUtils.isNotEmpty(rules)) { + fillPathRouteFromHttpRoute(route, metadata, rules.get(0)); + List filters = rules.get(0).getFilters(); + if (CollectionUtils.isNotEmpty(filters)) { + for (V1HTTPRouteSpecFilters filter : filters) { + if (V1HTTPRouteSpecFilters.TypeEnum.URLREWRITE == filter.getType()) { + fillRewriteConfigFromHttpRoute(route, filter); + } else if (V1HTTPRouteSpecFilters.TypeEnum.REQUESTHEADERMODIFIER == filter.getType() || V1HTTPRouteSpecFilters.TypeEnum.RESPONSEHEADERMODIFIER == filter.getType()) { + fillHeaderConfigFromHttpRoute(route, filter); + } + } + } + fillHeaderAndQueryConfigFromHttpRoute(route, rules.get(0)); + fillMethodConfigFromHttpRoute(route, rules.get(0)); + } + + // retry & cors + Map annotations = metadata.getAnnotations(); + if (MapUtils.isNotEmpty(annotations)) { + fillProxyNextUpstreamConfig(annotations, route); + fillHeaderConfigConfig(annotations, route); + } + fillRouteCors(route, metadata); + } + + private void fillPathRouteFromHttpRoute(Route route, V1ObjectMeta metadata, V1HTTPRouteSpecRules rule) { + // route.path && services + List matches = rule.getMatches(); + RoutePredicate routePredicate = new RoutePredicate(); + if (CollectionUtils.isNotEmpty(matches)) { + V1HTTPRouteSpecPath path = matches.get(0).getPath(); + if (path != null) { + routePredicate.setMatchValue(path.getValue()); + V1HTTPRouteSpecPath.TypeEnum type = path.getType(); + if (type == V1HTTPRouteSpecPath.TypeEnum.EXACT) { + routePredicate.setMatchType(RoutePredicateTypeEnum.EQUAL.toString()); + } else if (type == V1HTTPRouteSpecPath.TypeEnum.REGULAREXPRESSION) { + routePredicate.setMatchType(RoutePredicateTypeEnum.REGULAR.toString()); + } else if (type == V1HTTPRouteSpecPath.TypeEnum.PATHPREFIX) { + routePredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + } + } + } + if (metadata != null && metadata.getAnnotations() != null) { + String ignorePathCase = metadata.getAnnotations().get(KubernetesConstants.Annotation.IGNORE_PATH_CASE_KEY); + if (StringUtils.isNotEmpty(ignorePathCase)) { + routePredicate.setCaseSensitive(!Boolean.parseBoolean(ignorePathCase)); + } + } + route.setPath(routePredicate); + List backendRefs = rule.getBackendRefs(); + if (CollectionUtils.isNotEmpty(backendRefs)) { + List services = new ArrayList<>(); + for (V1HTTPRouteSpecBackendRefs backendRef : backendRefs) { + UpstreamService service = new UpstreamService(); + String name = backendRef.getName(); + if (!V1McpBridge.API_GROUP.equals(backendRef.getGroup())) { + if(StringUtils.isNotEmpty(name)) { + if (backendRef.getNamespace()!=null && !backendRef.getNamespace().isEmpty()) { + name = name + "." + backendRef.getNamespace() + ".svc.cluster.local"; + } else { + name = name + ".default.svc.cluster.local"; + } + if (backendRef.getPort() != null) { + name = name + ":" + backendRef.getPort(); + } + } + } + service.setName(name); + service.setWeight(backendRef.getWeight()); + services.add(service); + } + route.setServices(services); + } + } + + private void fillRewriteConfigFromHttpRoute(Route route, V1HTTPRouteSpecFilters filter) { + V1HTTPRouteSpecUrlRewrite urlRewrite = filter.getUrlRewrite(); + if (urlRewrite == null) { + return; + } + RewriteConfig rewrite = new RewriteConfig(); + rewrite.setEnabled(Boolean.TRUE); + rewrite.setHost(urlRewrite.getHostname()); + rewrite.setPath(urlRewrite.getPath().getReplacePrefixMatch()); + route.setRewrite(rewrite); + } + + private void fillHeaderConfigFromHttpRoute(Route route, V1HTTPRouteSpecFilters filter) { + if (V1HTTPRouteSpecFilters.TypeEnum.REQUESTHEADERMODIFIER == filter.getType()) { + HeaderControlConfig headerControl = new HeaderControlConfig(); + headerControl.setEnabled(Boolean.TRUE); + HeaderControlStageConfig config = new HeaderControlStageConfig(); + headerControl.setRequest(config); + V1HTTPRouteSpecRequestHeaderModifier requestHeaderModifier = filter.getRequestHeaderModifier(); + if (requestHeaderModifier != null) { + List adds = requestHeaderModifier.getAdd(); + if (adds != null) { + for (V1HTTPRouteSpecRequestHeaderModifierAdd add : adds) { + List
configAdd = new ArrayList<>(); + config.setAdd(configAdd); + configAdd.add(new Header(add.getName(), add.getValue())); + } + } + List sets = requestHeaderModifier.getSet(); + if (sets != null) { + for (V1HTTPRouteSpecRequestHeaderModifierAdd set : sets) { + List
configSet = new ArrayList<>(); + config.setSet(configSet); + configSet.add(new Header(set.getName(), set.getValue())); + } + } + List removes = requestHeaderModifier.getRemove(); + if (removes != null) { + config.setRemove(new ArrayList<>(removes)); + } + } + route.setHeaderControl(headerControl); + } else if (V1HTTPRouteSpecFilters.TypeEnum.RESPONSEHEADERMODIFIER == filter.getType()) { + HeaderControlConfig headerControl = new HeaderControlConfig(); + headerControl.setEnabled(Boolean.TRUE); + HeaderControlStageConfig config = new HeaderControlStageConfig(); + headerControl.setResponse(config); + V1HTTPRouteSpecResponseHeaderModifier responseHeaderModifier = filter.getResponseHeaderModifier(); + if (responseHeaderModifier != null) { + List adds = responseHeaderModifier.getAdd(); + if (adds != null) { + for (V1HTTPRouteSpecRequestHeaderModifierAdd add : adds) { + List
configAdd = new ArrayList<>(); + config.setAdd(configAdd); + configAdd.add(new Header(add.getName(), add.getValue())); + } + } + List sets = responseHeaderModifier.getSet(); + if (sets != null) { + for (V1HTTPRouteSpecRequestHeaderModifierAdd set : sets) { + List
configSet = new ArrayList<>(); + config.setSet(configSet); + configSet.add(new Header(set.getName(), set.getValue())); + } + } + List removes = responseHeaderModifier.getRemove(); + if (removes != null) { + config.setRemove(new ArrayList<>(removes)); + } + } + route.setHeaderControl(headerControl); + } + } + + private void fillHeaderAndQueryConfigFromHttpRoute(Route route, V1HTTPRouteSpecRules rule) { + List headers = new ArrayList<>(); + List urlParams = new ArrayList<>(); + List matches = rule.getMatches(); + if (CollectionUtils.isEmpty(matches)) { + return; + } + V1HTTPRouteSpecMatches match = matches.get(0); + List httpRouteHeaders = match.getHeaders(); + if (CollectionUtils.isNotEmpty(httpRouteHeaders)){ + for (V1HTTPRouteSpecHeaders httpRouteHeader: httpRouteHeaders) { + KeyedRoutePredicate header = new KeyedRoutePredicate(); + header.setKey(httpRouteHeader.getName()); + header.setMatchValue(httpRouteHeader.getValue()); + if (V1HTTPRouteSpecHeaders.TypeEnum.EXACT == httpRouteHeader.getType()){ + header.setMatchType(RoutePredicateTypeEnum.EQUAL.toString()); + } else if (V1HTTPRouteSpecHeaders.TypeEnum.REGULAREXPRESSION == httpRouteHeader.getType()) { + String regex = httpRouteHeader.getValue(); + if (regex.startsWith("^\\Q") && regex.endsWith("\\E.*")) { + header.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + header.setMatchValue(regex.substring(3, regex.length() - 4)); + } else { + header.setMatchType(RoutePredicateTypeEnum.REGULAR.toString()); + } + } + headers.add(header); + } + } + List queryParams = match.getQueryParams(); + if (CollectionUtils.isNotEmpty(queryParams)) { + for (V1HTTPRouteSpecQueryParams queryParam : queryParams) { + KeyedRoutePredicate param = new KeyedRoutePredicate(); + param.setKey(queryParam.getName()); + param.setMatchValue(queryParam.getValue()); + if (V1HTTPRouteSpecQueryParams.TypeEnum.EXACT == queryParam.getType()) { + param.setMatchType(RoutePredicateTypeEnum.EQUAL.toString()); + } else if (V1HTTPRouteSpecQueryParams.TypeEnum.REGULAREXPRESSION == queryParam.getType()) { + String regex = queryParam.getValue(); + if (regex.startsWith("^\\Q") && regex.endsWith("\\E.*")) { + param.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + param.setMatchValue(regex.substring(3, regex.length() - 4)); + } else { + param.setMatchType(RoutePredicateTypeEnum.REGULAR.toString()); + } + } + urlParams.add(param); + } + } + if (CollectionUtils.isNotEmpty(headers)) { + route.setHeaders(headers); + } + if (CollectionUtils.isNotEmpty(urlParams)) { + route.setUrlParams(urlParams); + } + } + + private void fillMethodConfigFromHttpRoute(Route route, V1HTTPRouteSpecRules rule) { + List matches = rule.getMatches(); + if (CollectionUtils.isEmpty(matches)) { + return; + } + List methods = new ArrayList<>(); + for (V1HTTPRouteSpecMatches match : matches) { + if(match.getMethod() != null) { + methods.add(match.getMethod().toString()); + } + } + if (CollectionUtils.isNotEmpty(methods)) { + route.setMethods(methods); + } + } + public ServiceSource v1RegistryConfig2ServiceSource(V1RegistryConfig v1RegistryConfig) { ServiceSource serviceSource = new ServiceSource(); fillServiceSourceInfo(serviceSource, v1RegistryConfig); diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpec.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpec.java index 6a346697..ed4c9679 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpec.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpec.java @@ -52,6 +52,14 @@ public V1HTTPRouteSpec addParentRefsItem(V1HTTPRouteSpecParentRefs parentRefsIte return this; } + public V1HTTPRouteSpec addRulesItem(V1HTTPRouteSpecRules rulesItem) { + if (this.rules == null) { + this.rules = new ArrayList<>(); + } + this.rules.add(rulesItem); + return this; + } + @Override public boolean equals(Object o) { diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecMatches.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecMatches.java index 0cd788f9..ba85db52 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecMatches.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/httproute/V1HTTPRouteSpecMatches.java @@ -30,7 +30,7 @@ * HTTPRouteMatch defines the predicate used to match requests to a given action. Multiple match types are ANDed together, i.e. the match will evaluate to true only if all conditions are satisfied. For example, the match below will match a HTTP request only if its path starts with `/foo` AND it contains the `version: v1` header: ``` match: path: value: \"/foo\" headers: - name: \"version\" value \"v1\" ``` */ @Data -public class V1HTTPRouteSpecMatches { +public class V1HTTPRouteSpecMatches implements Cloneable{ public static final String SERIALIZED_NAME_HEADERS = "headers"; public static final String SERIALIZED_NAME_METHOD = "method"; public static final String SERIALIZED_NAME_PATH = "path"; @@ -60,6 +60,11 @@ public V1HTTPRouteSpecMatches addQueryParamsItem(V1HTTPRouteSpecQueryParams quer return this; } + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + @Override public boolean equals(Object o) { if (this == o) { diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrant.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrant.java index 154e901c..441515c8 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrant.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/crd/gatewayapi/referencegrant/V1beta1ReferenceGrant.java @@ -27,7 +27,7 @@ @Data public class V1beta1ReferenceGrant implements io.kubernetes.client.common.KubernetesObject { public static final String API_GROUP = "gateway.networking.k8s.io"; - public static final String VERSION = "v1"; + public static final String VERSION = "v1beta1"; public static final String KIND = "ReferenceGrant"; public static final String PLURAL = "referencegrants"; From ba61e1934d65b10453a99111314ca5fcb1597ab9 Mon Sep 17 00:00:00 2001 From: zxlin <860620266@qq.com> Date: Wed, 16 Oct 2024 18:40:32 +0800 Subject: [PATCH 11/24] test: add unit test case for gateway and httproute converter --- .../KubernetesModelConverterTest.java | 1220 ++++++++++++++++- 1 file changed, 1219 insertions(+), 1 deletion(-) diff --git a/backend/sdk/src/test/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverterTest.java b/backend/sdk/src/test/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverterTest.java index 16953a1f..eb405c40 100644 --- a/backend/sdk/src/test/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverterTest.java +++ b/backend/sdk/src/test/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverterTest.java @@ -17,7 +17,37 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; - +import java.util.Map; +import java.util.regex.Pattern; + +import com.alibaba.higress.sdk.constant.HigressConstants; +import com.alibaba.higress.sdk.model.Domain; +import com.alibaba.higress.sdk.model.route.Header; +import com.alibaba.higress.sdk.model.route.HeaderControlConfig; +import com.alibaba.higress.sdk.model.route.HeaderControlStageConfig; +import com.alibaba.higress.sdk.model.route.KeyedRoutePredicate; +import com.alibaba.higress.sdk.model.route.RewriteConfig; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gatewayclass.V1GatewayClass; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways.V1Gateway; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways.V1GatewaySpec; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways.V1GatewaySpecListeners; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways.V1GatewaySpecTls; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRoute; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpec; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecBackendRefs; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecFilters; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecHeaders; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecMatches; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecParentRefs; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecPath; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecQueryParams; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecRequestHeaderModifier; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecRequestHeaderModifierAdd; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecResponseHeaderModifier; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecRules; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecUrlRewrite; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecUrlRewritePath; +import org.apache.commons.collections4.CollectionUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; @@ -584,4 +614,1192 @@ private static Route buildBasicRoute() { route.setCustomConfigs(new HashMap<>()); return route; } + + @Test + public void isGatewaySupportedTestMissingMetadata() { + V1Gateway gateway = buildBasicSupportedGateway(); + gateway.setMetadata(null); + Assertions.assertFalse(converter.isGatewaySupported(gateway)); + } + + @Test + public void isGatewaySupportedTestMissingSpec() { + V1Gateway gateway = buildBasicSupportedGateway(); + gateway.setSpec(null); + Assertions.assertFalse(converter.isGatewaySupported(gateway)); + } + + @Test + public void isGatewaySupportedTestMissingGatewayClass() { + V1Gateway gateway = buildBasicSupportedGateway(); + gateway.getSpec().setGatewayClassName(null); + Assertions.assertFalse(converter.isGatewaySupported(gateway)); + } + + @Test + public void isGatewaySupportedTestMissingListeners() { + V1Gateway gateway = buildBasicSupportedGateway(); + gateway.getSpec().setListeners(null); + Assertions.assertFalse(converter.isGatewaySupported(gateway)); + + gateway.getSpec().setListeners(Collections.emptyList()); + Assertions.assertFalse(converter.isGatewaySupported(gateway)); + } + + @Test + public void isGatewaySupportedTestInvalidListener() { + V1Gateway gateway = buildBasicSupportedGateway(); + V1GatewaySpecListeners listener = gateway.getSpec().getListeners().get(0); + + listener.setPort(null); + Assertions.assertFalse(converter.isGatewaySupported(gateway)); + + listener.setPort(0); + Assertions.assertFalse(converter.isGatewaySupported(gateway)); + + listener.setPort(80); + + listener.setName(null); + Assertions.assertFalse(converter.isGatewaySupported(gateway)); + + listener.setName("valid-name"); + listener.setProtocol("INVALID"); + Assertions.assertFalse(converter.isGatewaySupported(gateway)); + + listener.setProtocol("HTTPS"); + listener.setTls(null); + Assertions.assertFalse(converter.isGatewaySupported(gateway)); + V1GatewaySpecTls v1GatewaySpecTls = new V1GatewaySpecTls(); + v1GatewaySpecTls.setCertificateRefs(Collections.emptyList()); + listener.setTls(v1GatewaySpecTls); + Assertions.assertFalse(converter.isGatewaySupported(gateway)); + + + } + + @Test + public void isGatewaySupportedTestAllGood() { + V1Gateway gateway = buildBasicSupportedGateway(); + Assertions.assertTrue(converter.isGatewaySupported(gateway)); + } + + @Test + public void isHttpRouteSupportedTestMissingMetadata() { + V1HTTPRoute httpRoute = buildBasicSupportedHttpRoute(); + httpRoute.setMetadata(null); + Assertions.assertFalse(converter.isHttpRouteSupported(httpRoute)); + } + + @Test + public void isHttpRouteSupportedTestMissingSpec() { + V1HTTPRoute httpRoute = buildBasicSupportedHttpRoute(); + httpRoute.setSpec(null); + Assertions.assertFalse(converter.isHttpRouteSupported(httpRoute)); + } + + @Test + public void isHttpRouteSupportedTestMissingParentRefs() { + V1HTTPRoute httpRoute = buildBasicSupportedHttpRoute(); + httpRoute.getSpec().setParentRefs(null); + Assertions.assertFalse(converter.isHttpRouteSupported(httpRoute)); + + httpRoute.getSpec().setParentRefs(Collections.emptyList()); + Assertions.assertFalse(converter.isHttpRouteSupported(httpRoute)); + } + + @Test + public void isHttpRouteSupportedTestMissingRules() { + V1HTTPRoute httpRoute = buildBasicSupportedHttpRoute(); + httpRoute.getSpec().setRules(null); + Assertions.assertFalse(converter.isHttpRouteSupported(httpRoute)); + + httpRoute.getSpec().setRules(Collections.emptyList()); + Assertions.assertFalse(converter.isHttpRouteSupported(httpRoute)); + } + + @Test + public void isHttpRouteSupportedTestTooManyHostnames() { + V1HTTPRoute httpRoute = buildBasicSupportedHttpRoute(); + httpRoute.getSpec().setHostnames(Arrays.asList("host1.com", "host2.com")); + Assertions.assertFalse(converter.isHttpRouteSupported(httpRoute)); + } + + @Test + public void isHttpRouteSupportedTestInvalidBackendRefs() { + V1HTTPRoute httpRoute = buildBasicSupportedHttpRoute(); + V1HTTPRouteSpecRules rule = httpRoute.getSpec().getRules().get(0); + + rule.setBackendRefs(null); + Assertions.assertFalse(converter.isHttpRouteSupported(httpRoute)); + + rule.setBackendRefs(Collections.emptyList()); + Assertions.assertFalse(converter.isHttpRouteSupported(httpRoute)); + + V1HTTPRouteSpecBackendRefs backendRef = new V1HTTPRouteSpecBackendRefs(); + backendRef.setKind("InvalidKind"); + rule.setBackendRefs(Collections.singletonList(backendRef)); + Assertions.assertFalse(converter.isHttpRouteSupported(httpRoute)); + } + + @Test + public void isHttpRouteSupportedTestAllGood() { + V1HTTPRoute httpRoute = buildBasicSupportedHttpRoute(); + Assertions.assertTrue(converter.isHttpRouteSupported(httpRoute)); + } + + private V1HTTPRoute buildBasicSupportedHttpRoute() { + V1HTTPRoute httpRoute = new V1HTTPRoute(); + httpRoute.setMetadata(new V1ObjectMeta()); + V1HTTPRouteSpec spec = new V1HTTPRouteSpec(); + spec.setParentRefs(Collections.singletonList(new V1HTTPRouteSpecParentRefs())); + V1HTTPRouteSpecRules rule = new V1HTTPRouteSpecRules(); + V1HTTPRouteSpecMatches match = new V1HTTPRouteSpecMatches(); + V1HTTPRouteSpecPath path = new V1HTTPRouteSpecPath(); + path.setType(V1HTTPRouteSpecPath.TypeEnum.PATHPREFIX); + path.setValue("/"); + match.setPath(path); + rule.setMatches(Collections.singletonList(match)); + V1HTTPRouteSpecBackendRefs backendRef = new V1HTTPRouteSpecBackendRefs(); + backendRef.setKind("Service"); + rule.setBackendRefs(Collections.singletonList(backendRef)); + spec.setRules(Collections.singletonList(rule)); + httpRoute.setSpec(spec); + return httpRoute; + } + + private V1Gateway buildBasicSupportedGateway() { + V1Gateway gateway = new V1Gateway(); + gateway.setMetadata(new V1ObjectMeta()); + V1GatewaySpec spec = new V1GatewaySpec(); + spec.setGatewayClassName(V1GatewayClass.DEFAULT_NAME); + V1GatewaySpecListeners listener = new V1GatewaySpecListeners(); + listener.setName("http"); + listener.setProtocol("HTTP"); + listener.setPort(80); + spec.setListeners(Collections.singletonList(listener)); + gateway.setSpec(spec); + return gateway; + } + + @Test + public void httpRoute2RouteTestBasic() { + V1HTTPRoute httpRoute = buildBasicSupportedHttpRoute(); + httpRoute.getMetadata().setName("test-route"); + + Route route = converter.httpRoute2Route(httpRoute); + + Route expectedRoute = buildBasicRoute(); + expectedRoute.setName("test-route"); + expectedRoute.setServices(Collections.singletonList(new UpstreamService())); + expectedRoute.setCors(null); + expectedRoute.setCustomConfigs(null); + RoutePredicate pathPredicate = expectedRoute.getPath(); + pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + pathPredicate.setMatchValue("/"); + pathPredicate.setCaseSensitive(null); + + Assertions.assertEquals(expectedRoute, route); + } + @Test + public void httpRoute2RouteTestWithDomain() { + V1HTTPRoute httpRoute = buildBasicSupportedHttpRoute(); + V1HTTPRouteSpecParentRefs parentRefs = new V1HTTPRouteSpecParentRefs(); + parentRefs.setName(converter.domainName2GatewayName("example.com")); + httpRoute.getSpec().setParentRefs(Collections.singletonList(parentRefs)); + httpRoute.getSpec().addHostnamesItem("example.com"); + + Route route = converter.httpRoute2Route(httpRoute); + + Route expectedRoute = buildBasicRoute(); + expectedRoute.setDomains(Collections.singletonList("example.com")); + expectedRoute.setServices(Collections.singletonList(new UpstreamService())); + expectedRoute.setCors(null); + expectedRoute.setCustomConfigs(null); + RoutePredicate pathPredicate = expectedRoute.getPath(); + pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + pathPredicate.setMatchValue("/"); + pathPredicate.setCaseSensitive(null); + + Assertions.assertEquals(expectedRoute, route); + } + + @Test + public void httpRoute2RouteTestWithSinglePath() { + V1HTTPRoute httpRoute = buildBasicSupportedHttpRoute(); + V1HTTPRouteSpecPath path = new V1HTTPRouteSpecPath(); + path.setType(V1HTTPRouteSpecPath.TypeEnum.EXACT); + path.setValue("/exact"); + V1HTTPRouteSpecMatches match = new V1HTTPRouteSpecMatches(); + match.setPath(path); + httpRoute.getSpec().getRules().get(0).setMatches(Collections.singletonList(match)); + + Route route = converter.httpRoute2Route(httpRoute); + + Route expectedRoute = buildBasicRoute(); + expectedRoute.setServices(Collections.singletonList(new UpstreamService())); + expectedRoute.setCors(null); + expectedRoute.setCustomConfigs(null); + RoutePredicate predicate1 = new RoutePredicate(); + predicate1.setMatchType(RoutePredicateTypeEnum.EQUAL.toString()); + predicate1.setMatchValue("/exact"); + predicate1.setCaseSensitive(null); + expectedRoute.setPath(predicate1); + + Assertions.assertEquals(expectedRoute, route); + } + + @Test + public void httpRoute2RouteTestWithHeaders() { + V1HTTPRoute httpRoute = buildBasicSupportedHttpRoute(); + V1HTTPRouteSpecHeaders header = new V1HTTPRouteSpecHeaders(); + header.setName("X-Test"); + header.setType(V1HTTPRouteSpecHeaders.TypeEnum.EXACT); + header.setValue("test-value"); + httpRoute.getSpec().getRules().get(0).getMatches().get(0).addHeadersItem(header); + + Route route = converter.httpRoute2Route(httpRoute); + + Route expectedRoute = buildBasicRoute(); + expectedRoute.setServices(Collections.singletonList(new UpstreamService())); + expectedRoute.setCors(null); + expectedRoute.setCustomConfigs(null); + RoutePredicate pathPredicate = expectedRoute.getPath(); + pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + pathPredicate.setMatchValue("/"); + pathPredicate.setCaseSensitive(null); + + KeyedRoutePredicate headerPredicate = new KeyedRoutePredicate(); + headerPredicate.setKey("X-Test"); + headerPredicate.setMatchType(RoutePredicateTypeEnum.EQUAL.toString()); + headerPredicate.setMatchValue("test-value"); + expectedRoute.setHeaders(Collections.singletonList(headerPredicate)); + + Assertions.assertEquals(expectedRoute, route); + } + + @Test + public void httpRoute2RouteTestWithQueryParams() { + V1HTTPRoute httpRoute = buildBasicSupportedHttpRoute(); + V1HTTPRouteSpecQueryParams param = new V1HTTPRouteSpecQueryParams(); + param.setName("q"); + param.setType(V1HTTPRouteSpecQueryParams.TypeEnum.EXACT); + param.setValue("search"); + httpRoute.getSpec().getRules().get(0).getMatches().get(0).addQueryParamsItem(param); + + Route route = converter.httpRoute2Route(httpRoute); + + Route expectedRoute = buildBasicRoute(); + expectedRoute.setServices(Collections.singletonList(new UpstreamService())); + expectedRoute.setCors(null); + expectedRoute.setCustomConfigs(null); + RoutePredicate pathPredicate = expectedRoute.getPath(); + pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + pathPredicate.setMatchValue("/"); + pathPredicate.setCaseSensitive(null); + + KeyedRoutePredicate queryParamPredicate = new KeyedRoutePredicate(); + queryParamPredicate.setKey("q"); + queryParamPredicate.setMatchType(RoutePredicateTypeEnum.EQUAL.toString()); + queryParamPredicate.setMatchValue("search"); + expectedRoute.setUrlParams(Collections.singletonList(queryParamPredicate)); + + Assertions.assertEquals(expectedRoute, route); + } + + @Test + public void httpRoute2RouteTestWithMethods() { + List methods = Arrays.asList("GET", "POST", "DELETE", "TRACE"); + V1HTTPRoute httpRoute = buildBasicSupportedHttpRoute(); + V1HTTPRouteSpecMatches matchesItem = new V1HTTPRouteSpecMatches(); + + V1HTTPRouteSpecPath path = new V1HTTPRouteSpecPath(); + path.setType(V1HTTPRouteSpecPath.TypeEnum.EXACT); + path.setValue("/exact"); + + matchesItem.setPath(path); + List matches = new ArrayList<>(); + for (String method: methods) { + V1HTTPRouteSpecMatches matchesItemCopy; + try{ + matchesItemCopy= (V1HTTPRouteSpecMatches) matchesItem.clone(); + } catch (CloneNotSupportedException e) { + throw new RuntimeException("Error when clone matches", e); + } + if (V1HTTPRouteSpecMatches.MethodEnum.GET.toString().equals(method)) { + matchesItemCopy.setMethod(V1HTTPRouteSpecMatches.MethodEnum.GET); + } else if (V1HTTPRouteSpecMatches.MethodEnum.POST.toString().equals(method)) { + matchesItemCopy.setMethod(V1HTTPRouteSpecMatches.MethodEnum.POST); + } else if (V1HTTPRouteSpecMatches.MethodEnum.PUT.toString().equals(method)) { + matchesItemCopy.setMethod(V1HTTPRouteSpecMatches.MethodEnum.PUT); + } else if (V1HTTPRouteSpecMatches.MethodEnum.DELETE.toString().equals(method)) { + matchesItemCopy.setMethod(V1HTTPRouteSpecMatches.MethodEnum.DELETE); + } else if (V1HTTPRouteSpecMatches.MethodEnum.PATCH.toString().equals(method)) { + matchesItemCopy.setMethod(V1HTTPRouteSpecMatches.MethodEnum.PATCH); + } else if (V1HTTPRouteSpecMatches.MethodEnum.HEAD.toString().equals(method)) { + matchesItemCopy.setMethod(V1HTTPRouteSpecMatches.MethodEnum.HEAD); + } else if (V1HTTPRouteSpecMatches.MethodEnum.OPTIONS.toString().equals(method)) { + matchesItemCopy.setMethod(V1HTTPRouteSpecMatches.MethodEnum.OPTIONS); + } else if (V1HTTPRouteSpecMatches.MethodEnum.CONNECT.toString().equals(method)) { + matchesItemCopy.setMethod(V1HTTPRouteSpecMatches.MethodEnum.CONNECT); + } else if (V1HTTPRouteSpecMatches.MethodEnum.TRACE.toString().equals(method)) { + matchesItemCopy.setMethod(V1HTTPRouteSpecMatches.MethodEnum.TRACE); + } else { + throw new IllegalArgumentException("Unsupported method type: " + method); + } + matches.add(matchesItemCopy); + } + + httpRoute.getSpec().getRules().get(0).setMatches(matches); + Route route = converter.httpRoute2Route(httpRoute); + + Route expectedRoute = buildBasicRoute(); + expectedRoute.setServices(Collections.singletonList(new UpstreamService())); + expectedRoute.setCors(null); + expectedRoute.setCustomConfigs(null); + RoutePredicate predicate1 = new RoutePredicate(); + predicate1.setMatchType(RoutePredicateTypeEnum.EQUAL.toString()); + predicate1.setMatchValue("/exact"); + predicate1.setCaseSensitive(null); + expectedRoute.setPath(predicate1); + + expectedRoute.setMethods(methods); + + Assertions.assertEquals(expectedRoute, route); + } + + @Test + public void httpRoute2RouteTestWithUrlRewrite() { + V1HTTPRoute httpRoute = buildBasicSupportedHttpRoute(); + V1HTTPRouteSpecFilters filter = new V1HTTPRouteSpecFilters(); + filter.setType(V1HTTPRouteSpecFilters.TypeEnum.URLREWRITE); + V1HTTPRouteSpecUrlRewrite urlRewrite = new V1HTTPRouteSpecUrlRewrite(); + urlRewrite.setHostname("example.com"); + V1HTTPRouteSpecUrlRewritePath path = new V1HTTPRouteSpecUrlRewritePath(); + path.setType(V1HTTPRouteSpecUrlRewritePath.TypeEnum.REPLACEPREFIXMATCH); + path.setReplacePrefixMatch("/new"); + urlRewrite.setPath(path); + filter.setUrlRewrite(urlRewrite); + httpRoute.getSpec().getRules().get(0).addFiltersItem(filter); + + Route route = converter.httpRoute2Route(httpRoute); + + Route expectedRoute = buildBasicRoute(); + RoutePredicate pathPredicate = expectedRoute.getPath(); + pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + pathPredicate.setMatchValue("/"); + pathPredicate.setCaseSensitive(null); + expectedRoute.setServices(Collections.singletonList(new UpstreamService())); + expectedRoute.setCors(null); + expectedRoute.setCustomConfigs(null); + RewriteConfig rewriteConfig = new RewriteConfig(); + rewriteConfig.setEnabled(true); + rewriteConfig.setHost("example.com"); + rewriteConfig.setPath("/new"); + expectedRoute.setRewrite(rewriteConfig); + + Assertions.assertEquals(expectedRoute, route); + } + + + @Test + public void httpRoute2RouteTestWithRequestHeaderModifier() { + V1HTTPRoute httpRoute = buildBasicSupportedHttpRoute(); + V1HTTPRouteSpecFilters filter = new V1HTTPRouteSpecFilters(); + filter.setType(V1HTTPRouteSpecFilters.TypeEnum.REQUESTHEADERMODIFIER); + V1HTTPRouteSpecRequestHeaderModifier headerModifier = new V1HTTPRouteSpecRequestHeaderModifier(); + V1HTTPRouteSpecRequestHeaderModifierAdd addHeader = new V1HTTPRouteSpecRequestHeaderModifierAdd(); + addHeader.setName("X-Custom-Header"); + addHeader.setValue("CustomValue"); + headerModifier.addAddItem(addHeader); + headerModifier.addSetItem(addHeader); + headerModifier.addRemoveItem("X-Remove-Header"); + filter.setRequestHeaderModifier(headerModifier); + httpRoute.getSpec().getRules().get(0).addFiltersItem(filter); + + Route route = converter.httpRoute2Route(httpRoute); + + Route expectedRoute = buildBasicRoute(); + RoutePredicate pathPredicate = expectedRoute.getPath(); + pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + pathPredicate.setMatchValue("/"); + pathPredicate.setCaseSensitive(null); + expectedRoute.setServices(Collections.singletonList(new UpstreamService())); + expectedRoute.setCors(null); + expectedRoute.setCustomConfigs(null); + HeaderControlConfig headerControl = new HeaderControlConfig(); + headerControl.setEnabled(true); + HeaderControlStageConfig requestConfig = new HeaderControlStageConfig(); + List
configAdd = new ArrayList<>(); + requestConfig.setAdd(configAdd); + List
configSet = new ArrayList<>(); + requestConfig.setSet(configSet); + List remove = new ArrayList<>(); + requestConfig.setRemove(remove); + configAdd.add(new Header("X-Custom-Header", "CustomValue")); + configSet.add(new Header("X-Custom-Header", "CustomValue")); + remove.add("X-Remove-Header"); + headerControl.setRequest(requestConfig); + expectedRoute.setHeaderControl(headerControl); + + Assertions.assertEquals(expectedRoute, route); + } + + @Test + public void httpRoute2RouteTestWithResponseHeaderModifier() { + V1HTTPRoute httpRoute = buildBasicSupportedHttpRoute(); + V1HTTPRouteSpecFilters filter = new V1HTTPRouteSpecFilters(); + filter.setType(V1HTTPRouteSpecFilters.TypeEnum.RESPONSEHEADERMODIFIER); + V1HTTPRouteSpecResponseHeaderModifier headerModifier = new V1HTTPRouteSpecResponseHeaderModifier(); + V1HTTPRouteSpecRequestHeaderModifierAdd addHeader = new V1HTTPRouteSpecRequestHeaderModifierAdd(); + addHeader.setName("X-Custom-Response-Header"); + addHeader.setValue("CustomResponseValue"); + headerModifier.addAddItem(addHeader); + headerModifier.addSetItem(addHeader); + headerModifier.addRemoveItem("X-Remove-Response-Header"); + filter.setResponseHeaderModifier(headerModifier); + httpRoute.getSpec().getRules().get(0).addFiltersItem(filter); + + Route route = converter.httpRoute2Route(httpRoute); + + Route expectedRoute = buildBasicRoute(); + RoutePredicate pathPredicate = expectedRoute.getPath(); + pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + pathPredicate.setMatchValue("/"); + pathPredicate.setCaseSensitive(null); + expectedRoute.setServices(Collections.singletonList(new UpstreamService())); + expectedRoute.setCors(null); + expectedRoute.setCustomConfigs(null); + HeaderControlConfig headerControl = new HeaderControlConfig(); + headerControl.setEnabled(true); + HeaderControlStageConfig responseConfig = new HeaderControlStageConfig(); + List
configAdd = new ArrayList<>(); + responseConfig.setAdd(configAdd); + List
configSet = new ArrayList<>(); + responseConfig.setSet(configSet); + List remove = new ArrayList<>(); + responseConfig.setRemove(remove); + configAdd.add(new Header("X-Custom-Response-Header", "CustomResponseValue")); + configSet.add(new Header("X-Custom-Response-Header", "CustomResponseValue")); + remove.add("X-Remove-Response-Header"); + headerControl.setResponse(responseConfig); + expectedRoute.setHeaderControl(headerControl); + + Assertions.assertEquals(expectedRoute, route); + } + + @Test + public void httpRoute2RouteTestWithBothFilters() { + V1HTTPRoute httpRoute = buildBasicSupportedHttpRoute(); + + // URL Rewrite filter + V1HTTPRouteSpecFilters urlRewriteFilter = new V1HTTPRouteSpecFilters(); + urlRewriteFilter.setType(V1HTTPRouteSpecFilters.TypeEnum.URLREWRITE); + V1HTTPRouteSpecUrlRewrite urlRewrite = new V1HTTPRouteSpecUrlRewrite(); + urlRewrite.setHostname("example.com"); + V1HTTPRouteSpecUrlRewritePath path = new V1HTTPRouteSpecUrlRewritePath(); + path.setType(V1HTTPRouteSpecUrlRewritePath.TypeEnum.REPLACEPREFIXMATCH); + path.setReplacePrefixMatch("/new"); + urlRewrite.setPath(path); + urlRewriteFilter.setUrlRewrite(urlRewrite); + + // Request Header Modifier filter + V1HTTPRouteSpecFilters headerModifierFilter = new V1HTTPRouteSpecFilters(); + headerModifierFilter.setType(V1HTTPRouteSpecFilters.TypeEnum.REQUESTHEADERMODIFIER); + V1HTTPRouteSpecRequestHeaderModifier headerModifier = new V1HTTPRouteSpecRequestHeaderModifier(); + V1HTTPRouteSpecRequestHeaderModifierAdd addHeader = new V1HTTPRouteSpecRequestHeaderModifierAdd(); + addHeader.setName("X-Custom-Header"); + addHeader.setValue("CustomValue"); + headerModifier.addAddItem(addHeader); + headerModifier.addSetItem(addHeader); + headerModifier.addRemoveItem("X-Remove-Header"); + headerModifierFilter.setRequestHeaderModifier(headerModifier); + + httpRoute.getSpec().getRules().get(0).setFilters(Arrays.asList(urlRewriteFilter, headerModifierFilter)); + + Route route = converter.httpRoute2Route(httpRoute); + + Route expectedRoute = buildBasicRoute(); + RoutePredicate pathPredicate = expectedRoute.getPath(); + pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + pathPredicate.setMatchValue("/"); + pathPredicate.setCaseSensitive(null); + expectedRoute.setServices(Collections.singletonList(new UpstreamService())); + expectedRoute.setCors(null); + expectedRoute.setCustomConfigs(null); + + // Expected URL Rewrite config + RewriteConfig rewriteConfig = new RewriteConfig(); + rewriteConfig.setEnabled(true); + rewriteConfig.setHost("example.com"); + rewriteConfig.setPath("/new"); + expectedRoute.setRewrite(rewriteConfig); + + // Expected Header Control config + HeaderControlConfig headerControl = new HeaderControlConfig(); + headerControl.setEnabled(true); + HeaderControlStageConfig requestConfig = new HeaderControlStageConfig(); + List
configAdd = new ArrayList<>(); + requestConfig.setAdd(configAdd); + List
configSet = new ArrayList<>(); + requestConfig.setSet(configSet); + List remove = new ArrayList<>(); + requestConfig.setRemove(remove); + configAdd.add(new Header("X-Custom-Header", "CustomValue")); + configSet.add(new Header("X-Custom-Header", "CustomValue")); + remove.add("X-Remove-Header"); + headerControl.setRequest(requestConfig); + expectedRoute.setHeaderControl(headerControl); + + Assertions.assertEquals(expectedRoute, route); + } + + @Test + public void httpRoute2RouteTestWithRegularExpressionHeaders() { + V1HTTPRoute httpRoute = buildBasicSupportedHttpRoute(); + + // Case 1: Regex starts with "^\Q" and ends with "\E.*" -> PREFIX + V1HTTPRouteSpecHeaders header1 = new V1HTTPRouteSpecHeaders(); + header1.setName("X-Prefix-Header"); + header1.setType(V1HTTPRouteSpecHeaders.TypeEnum.REGULAREXPRESSION); + header1.setValue("^"+ Pattern.quote("prefix")+".*"); + + // Case 2: Other regex pattern + V1HTTPRouteSpecHeaders header2 = new V1HTTPRouteSpecHeaders(); + header2.setName("X-Regex-Header"); + header2.setType(V1HTTPRouteSpecHeaders.TypeEnum.REGULAREXPRESSION); + header2.setValue("regex-pattern"); + + httpRoute.getSpec().getRules().get(0).getMatches().get(0).setHeaders(Arrays.asList(header1, header2)); + + Route route = converter.httpRoute2Route(httpRoute); + + Route expectedRoute = buildBasicRoute(); + RoutePredicate pathPredicate = expectedRoute.getPath(); + pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + pathPredicate.setMatchValue("/"); + pathPredicate.setCaseSensitive(null); + expectedRoute.setServices(Collections.singletonList(new UpstreamService())); + expectedRoute.setCors(null); + expectedRoute.setCustomConfigs(null); + + List expectedHeaders = new ArrayList<>(); + + // Expected result for Case 1 + KeyedRoutePredicate expectedHeader1 = new KeyedRoutePredicate(); + expectedHeader1.setKey("X-Prefix-Header"); + expectedHeader1.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + expectedHeader1.setMatchValue("prefix"); + expectedHeaders.add(expectedHeader1); + + // Expected result for Case 2 + KeyedRoutePredicate expectedHeader2 = new KeyedRoutePredicate(); + expectedHeader2.setKey("X-Regex-Header"); + expectedHeader2.setMatchType(RoutePredicateTypeEnum.REGULAR.toString()); + expectedHeader2.setMatchValue("regex-pattern"); + expectedHeaders.add(expectedHeader2); + + expectedRoute.setHeaders(expectedHeaders); + + Assertions.assertEquals(expectedRoute, route); + } + + @Test + public void httpRoute2RouteTestWithRegularExpressionQueryParams() { + V1HTTPRoute httpRoute = buildBasicSupportedHttpRoute(); + + // Case 1: Regex starts with "^" and ends with ".*" + V1HTTPRouteSpecQueryParams param1 = new V1HTTPRouteSpecQueryParams(); + param1.setName("prefix_param"); + param1.setType(V1HTTPRouteSpecQueryParams.TypeEnum.REGULAREXPRESSION); + param1.setValue("^"+ Pattern.quote("prefix")+".*"); + + // Case 2: Other regex pattern + V1HTTPRouteSpecQueryParams param2 = new V1HTTPRouteSpecQueryParams(); + param2.setName("regex_param"); + param2.setType(V1HTTPRouteSpecQueryParams.TypeEnum.REGULAREXPRESSION); + param2.setValue("regex-pattern"); + + httpRoute.getSpec().getRules().get(0).getMatches().get(0).setQueryParams(Arrays.asList(param1, param2)); + + Route route = converter.httpRoute2Route(httpRoute); + + Route expectedRoute = buildBasicRoute(); + RoutePredicate pathPredicate = expectedRoute.getPath(); + pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + pathPredicate.setMatchValue("/"); + pathPredicate.setCaseSensitive(null); + expectedRoute.setServices(Collections.singletonList(new UpstreamService())); + expectedRoute.setCors(null); + expectedRoute.setCustomConfigs(null); + + List expectedUrlParams = new ArrayList<>(); + + // Expected result for Case 1 + KeyedRoutePredicate expectedParam1 = new KeyedRoutePredicate(); + expectedParam1.setKey("prefix_param"); + expectedParam1.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + expectedParam1.setMatchValue("prefix"); + expectedUrlParams.add(expectedParam1); + + // Expected result for Case 2 + KeyedRoutePredicate expectedParam2 = new KeyedRoutePredicate(); + expectedParam2.setKey("regex_param"); + expectedParam2.setMatchType(RoutePredicateTypeEnum.REGULAR.toString()); + expectedParam2.setMatchValue("regex-pattern"); + expectedUrlParams.add(expectedParam2); + + expectedRoute.setUrlParams(expectedUrlParams); + + Assertions.assertEquals(expectedRoute, route); + } + @Test + public void httpRoute2RouteTestWithBackendRefs() { + V1HTTPRoute httpRoute = buildBasicSupportedHttpRoute(); + + // Case 1: BackendRef with namespace and port and weight + V1HTTPRouteSpecBackendRefs backendRef1 = new V1HTTPRouteSpecBackendRefs(); + backendRef1.setName("service1"); + backendRef1.setNamespace("custom-namespace"); + backendRef1.setPort(8080); + backendRef1.setWeight(20); + + // Case 2: BackendRef with namespace but no port + V1HTTPRouteSpecBackendRefs backendRef2 = new V1HTTPRouteSpecBackendRefs(); + backendRef2.setName("service2"); + backendRef2.setNamespace("another-namespace"); + + // Case 3: BackendRef without namespace but with port + V1HTTPRouteSpecBackendRefs backendRef3 = new V1HTTPRouteSpecBackendRefs(); + backendRef3.setName("service3"); + backendRef3.setPort(9090); + + // Case 4: BackendRef without namespace and port + V1HTTPRouteSpecBackendRefs backendRef4 = new V1HTTPRouteSpecBackendRefs(); + backendRef4.setName("service4"); + + // Case 5: Mcp Bridge + V1HTTPRouteSpecBackendRefs backendRef5 = new V1HTTPRouteSpecBackendRefs(); + backendRef5.setName("service5-provider.DEFAULT-GROUP.public.nacos"); + backendRef5.setGroup(V1McpBridge.API_GROUP); + + httpRoute.getSpec().getRules().get(0).setBackendRefs(Arrays.asList(backendRef1, backendRef2, backendRef3, backendRef4, backendRef5)); + + Route route = converter.httpRoute2Route(httpRoute); + + Route expectedRoute = buildBasicRoute(); + RoutePredicate pathPredicate = expectedRoute.getPath(); + pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + pathPredicate.setMatchValue("/"); + pathPredicate.setCaseSensitive(null); + expectedRoute.setCors(null); + expectedRoute.setCustomConfigs(null); + + List expectedServices = new ArrayList<>(); + expectedServices.add(new UpstreamService("service1.custom-namespace.svc.cluster.local:8080", null, null, 20)); + expectedServices.add(new UpstreamService("service2.another-namespace.svc.cluster.local", null, null, null)); + expectedServices.add(new UpstreamService("service3.default.svc.cluster.local:9090", null, null, null)); + expectedServices.add(new UpstreamService("service4.default.svc.cluster.local", null, null, null)); + expectedServices.add(new UpstreamService("service5-provider.DEFAULT-GROUP.public.nacos", null, null, null)); + + expectedRoute.setServices(expectedServices); + + Assertions.assertEquals(expectedRoute, route); + } + + @Test + public void route2HttpRouteTestBasic() { + Route route = buildBasicRoute(); + route.setName("test-route"); + RoutePredicate pathPredicate = route.getPath(); + pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + pathPredicate.setMatchValue("/"); + pathPredicate.setCaseSensitive(null); + route.setCors(null); + route.setCustomConfigs(null); + + V1HTTPRoute httpRoute = converter.route2HttpRoute(route); + + V1HTTPRoute expectedHttpRoute = buildBasicSupportedHttpRoute(); + + expectedHttpRoute.getMetadata().setName("test-route"); + expectedHttpRoute.getSpec().getRules().get(0).setBackendRefs(null); + + Assertions.assertEquals(expectedHttpRoute, httpRoute); + } + + @Test + public void route2HttpRouteTestWithDomain() { + Route route = buildBasicRoute(); + route.setDomains(Collections.singletonList("example.com")); + RoutePredicate pathPredicate = route.getPath(); + pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + pathPredicate.setMatchValue("/"); + pathPredicate.setCaseSensitive(null); + route.setCors(null); + route.setCustomConfigs(null); + + V1HTTPRoute httpRoute = converter.route2HttpRoute(route); + + V1HTTPRoute expectedHttpRoute = buildBasicSupportedHttpRoute(); + expectedHttpRoute.getMetadata().setLabels(Collections.singletonMap("higress.io/domain_example.com", "true")); + + expectedHttpRoute.getSpec().setHostnames(Collections.singletonList("example.com")); + V1HTTPRouteSpecParentRefs parentRefs = new V1HTTPRouteSpecParentRefs(); + parentRefs.setName(converter.domainName2GatewayName("example.com")); + expectedHttpRoute.getSpec().setParentRefs(Collections.singletonList(parentRefs)); + expectedHttpRoute.getSpec().getRules().get(0).setBackendRefs(null); + + Assertions.assertEquals(expectedHttpRoute, httpRoute); + } + + @Test + public void route2HttpRouteTestWithSinglePath() { + Route route = buildBasicRoute(); + RoutePredicate pathPredicate = new RoutePredicate(); + pathPredicate.setMatchType(RoutePredicateTypeEnum.EQUAL.toString()); + pathPredicate.setMatchValue("/exact"); + pathPredicate.setCaseSensitive(null); + route.setPath(pathPredicate); + route.setCors(null); + route.setCustomConfigs(null); + + V1HTTPRoute httpRoute = converter.route2HttpRoute(route); + + V1HTTPRoute expectedHttpRoute = buildBasicSupportedHttpRoute(); + + V1HTTPRouteSpecPath path = new V1HTTPRouteSpecPath(); + path.setType(V1HTTPRouteSpecPath.TypeEnum.EXACT); + path.setValue("/exact"); + V1HTTPRouteSpecMatches match = new V1HTTPRouteSpecMatches(); + match.setPath(path); + expectedHttpRoute.getSpec().getRules().get(0).setMatches(Collections.singletonList(match)); + expectedHttpRoute.getSpec().getRules().get(0).setBackendRefs(null); + + Assertions.assertEquals(expectedHttpRoute, httpRoute); + } + + @Test + public void route2HttpRouteTestWithHeaders() { + Route route = buildBasicRoute(); + RoutePredicate pathPredicate = route.getPath(); + pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + pathPredicate.setMatchValue("/"); + pathPredicate.setCaseSensitive(null); + + List headers = new ArrayList<>(); + + // Case 1: Exact match + KeyedRoutePredicate header1 = new KeyedRoutePredicate(); + header1.setKey("X-Exact-Header"); + header1.setMatchType(RoutePredicateTypeEnum.EQUAL.toString()); + header1.setMatchValue("exact-value"); + headers.add(header1); + + // Case 2: Prefix match + KeyedRoutePredicate header2 = new KeyedRoutePredicate(); + header2.setKey("X-Prefix-Header"); + header2.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + header2.setMatchValue("prefix"); + headers.add(header2); + + // Case 3: Regular expression match + KeyedRoutePredicate header3 = new KeyedRoutePredicate(); + header3.setKey("X-Regex-Header"); + header3.setMatchType(RoutePredicateTypeEnum.REGULAR.toString()); + header3.setMatchValue("regex-pattern"); + headers.add(header3); + + route.setHeaders(headers); + route.setCors(null); + route.setCustomConfigs(null); + + V1HTTPRoute httpRoute = converter.route2HttpRoute(route); + + V1HTTPRoute expectedHttpRoute = buildBasicSupportedHttpRoute(); + + + List expectedHeaders = new ArrayList<>(); + + // Expected result for Case 1 + V1HTTPRouteSpecHeaders expectedHeader1 = new V1HTTPRouteSpecHeaders(); + expectedHeader1.setName("X-Exact-Header"); + expectedHeader1.setType(V1HTTPRouteSpecHeaders.TypeEnum.EXACT); + expectedHeader1.setValue("exact-value"); + expectedHeaders.add(expectedHeader1); + + // Expected result for Case 2 + V1HTTPRouteSpecHeaders expectedHeader2 = new V1HTTPRouteSpecHeaders(); + expectedHeader2.setName("X-Prefix-Header"); + expectedHeader2.setType(V1HTTPRouteSpecHeaders.TypeEnum.REGULAREXPRESSION); + expectedHeader2.setValue("^" + Pattern.quote("prefix") + ".*"); + expectedHeaders.add(expectedHeader2); + + // Expected result for Case 3 + V1HTTPRouteSpecHeaders expectedHeader3 = new V1HTTPRouteSpecHeaders(); + expectedHeader3.setName("X-Regex-Header"); + expectedHeader3.setType(V1HTTPRouteSpecHeaders.TypeEnum.REGULAREXPRESSION); + expectedHeader3.setValue("regex-pattern"); + expectedHeaders.add(expectedHeader3); + + expectedHttpRoute.getSpec().getRules().get(0).getMatches().get(0).setHeaders(expectedHeaders); + expectedHttpRoute.getSpec().getRules().get(0).setBackendRefs(null); + + Assertions.assertEquals(expectedHttpRoute, httpRoute); + } + + @Test + public void route2HttpRouteTestWithQueryParams() { + Route route = buildBasicRoute(); + RoutePredicate pathPredicate = route.getPath(); + pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + pathPredicate.setMatchValue("/"); + pathPredicate.setCaseSensitive(null); + + List urlParams = new ArrayList<>(); + + // Case 1: Exact match + KeyedRoutePredicate param1 = new KeyedRoutePredicate(); + param1.setKey("exact_param"); + param1.setMatchType(RoutePredicateTypeEnum.EQUAL.toString()); + param1.setMatchValue("exact-value"); + urlParams.add(param1); + + // Case 2: Prefix match + KeyedRoutePredicate param2 = new KeyedRoutePredicate(); + param2.setKey("prefix_param"); + param2.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + param2.setMatchValue("prefix"); + urlParams.add(param2); + + // Case 3: Regular expression match + KeyedRoutePredicate param3 = new KeyedRoutePredicate(); + param3.setKey("regex_param"); + param3.setMatchType(RoutePredicateTypeEnum.REGULAR.toString()); + param3.setMatchValue("regex-pattern"); + urlParams.add(param3); + + route.setUrlParams(urlParams); + route.setCors(null); + route.setCustomConfigs(null); + + V1HTTPRoute httpRoute = converter.route2HttpRoute(route); + + V1HTTPRoute expectedHttpRoute = buildBasicSupportedHttpRoute(); + + + List expectedParams = new ArrayList<>(); + + // Expected result for Case 1 + V1HTTPRouteSpecQueryParams expectedParam1 = new V1HTTPRouteSpecQueryParams(); + expectedParam1.setName("exact_param"); + expectedParam1.setType(V1HTTPRouteSpecQueryParams.TypeEnum.EXACT); + expectedParam1.setValue("exact-value"); + expectedParams.add(expectedParam1); + + // Expected result for Case 2 + V1HTTPRouteSpecQueryParams expectedParam2 = new V1HTTPRouteSpecQueryParams(); + expectedParam2.setName("prefix_param"); + expectedParam2.setType(V1HTTPRouteSpecQueryParams.TypeEnum.REGULAREXPRESSION); + expectedParam2.setValue("^" + Pattern.quote("prefix") + ".*"); + expectedParams.add(expectedParam2); + + // Expected result for Case 3 + V1HTTPRouteSpecQueryParams expectedParam3 = new V1HTTPRouteSpecQueryParams(); + expectedParam3.setName("regex_param"); + expectedParam3.setType(V1HTTPRouteSpecQueryParams.TypeEnum.REGULAREXPRESSION); + expectedParam3.setValue("regex-pattern"); + expectedParams.add(expectedParam3); + + expectedHttpRoute.getSpec().getRules().get(0).getMatches().get(0).setQueryParams(expectedParams); + expectedHttpRoute.getSpec().getRules().get(0).setBackendRefs(null); + + Assertions.assertEquals(expectedHttpRoute, httpRoute); + } + + @Test + public void route2HttpRouteTestWithUrlRewrite() { + Route route = buildBasicRoute(); + RoutePredicate pathPredicate = route.getPath(); + pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + pathPredicate.setMatchValue("/"); + pathPredicate.setCaseSensitive(null); + RewriteConfig rewriteConfig = new RewriteConfig(); + rewriteConfig.setEnabled(true); + rewriteConfig.setHost("example.com"); + rewriteConfig.setPath("/new"); + route.setRewrite(rewriteConfig); + route.setCors(null); + route.setCustomConfigs(null); + + V1HTTPRoute httpRoute = converter.route2HttpRoute(route); + + V1HTTPRoute expectedHttpRoute = buildBasicSupportedHttpRoute(); + + V1HTTPRouteSpecFilters filter = new V1HTTPRouteSpecFilters(); + filter.setType(V1HTTPRouteSpecFilters.TypeEnum.URLREWRITE); + V1HTTPRouteSpecUrlRewrite urlRewrite = new V1HTTPRouteSpecUrlRewrite(); + urlRewrite.setHostname("example.com"); + V1HTTPRouteSpecUrlRewritePath path = new V1HTTPRouteSpecUrlRewritePath(); + path.setType(V1HTTPRouteSpecUrlRewritePath.TypeEnum.REPLACEPREFIXMATCH); + path.setReplacePrefixMatch("/new"); + urlRewrite.setPath(path); + filter.setUrlRewrite(urlRewrite); + expectedHttpRoute.getSpec().getRules().get(0).addFiltersItem(filter); + expectedHttpRoute.getSpec().getRules().get(0).setBackendRefs(null); + + Assertions.assertEquals(expectedHttpRoute, httpRoute); + } + + @Test + public void route2HttpRouteTestWithMethods() { + Route route = buildBasicRoute(); + RoutePredicate pathPredicate = route.getPath(); + pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + pathPredicate.setMatchValue("/"); + pathPredicate.setCaseSensitive(null); + route.setMethods(Arrays.asList("GET", "POST", "TRACE")); + route.setCors(null); + route.setCustomConfigs(null); + + V1HTTPRoute httpRoute = converter.route2HttpRoute(route); + + V1HTTPRoute expectedHttpRoute = buildBasicSupportedHttpRoute(); + + V1HTTPRouteSpecPath path = new V1HTTPRouteSpecPath(); + path.setType(V1HTTPRouteSpecPath.TypeEnum.PATHPREFIX); + path.setValue("/"); + + V1HTTPRouteSpecMatches match1 = new V1HTTPRouteSpecMatches(); + match1.setMethod(V1HTTPRouteSpecMatches.MethodEnum.GET); + match1.setPath(path); + V1HTTPRouteSpecMatches match2 = new V1HTTPRouteSpecMatches(); + match2.setMethod(V1HTTPRouteSpecMatches.MethodEnum.POST); + match2.setPath(path); + V1HTTPRouteSpecMatches match3 = new V1HTTPRouteSpecMatches(); + match3.setMethod(V1HTTPRouteSpecMatches.MethodEnum.TRACE); + match3.setPath(path); + expectedHttpRoute.getSpec().getRules().get(0).setMatches(Arrays.asList(match1, match2, match3)); + expectedHttpRoute.getSpec().getRules().get(0).setBackendRefs(null); + + Assertions.assertEquals(expectedHttpRoute, httpRoute); + } + + @Test + public void route2HttpRouteTestWithHeaderControl() { + Route route = buildBasicRoute(); + RoutePredicate pathPredicate = route.getPath(); + pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + pathPredicate.setMatchValue("/"); + pathPredicate.setCaseSensitive(null); + HeaderControlConfig headerControl = new HeaderControlConfig(); + headerControl.setEnabled(true); + HeaderControlStageConfig requestConfig = new HeaderControlStageConfig(); + requestConfig.setAdd(Collections.singletonList(new Header("X-Custom-Header", "CustomValue"))); + requestConfig.setSet(Collections.singletonList(new Header("X-Custom-Header", "CustomValue"))); + requestConfig.setRemove(Collections.singletonList("X-Remove-Header")); + headerControl.setRequest(requestConfig); + route.setHeaderControl(headerControl); + route.setCors(null); + route.setCustomConfigs(null); + + V1HTTPRoute httpRoute = converter.route2HttpRoute(route); + + V1HTTPRoute expectedHttpRoute = buildBasicSupportedHttpRoute(); + + V1HTTPRouteSpecFilters filter = new V1HTTPRouteSpecFilters(); + filter.setType(V1HTTPRouteSpecFilters.TypeEnum.REQUESTHEADERMODIFIER); + V1HTTPRouteSpecRequestHeaderModifier headerModifier = new V1HTTPRouteSpecRequestHeaderModifier(); + V1HTTPRouteSpecRequestHeaderModifierAdd addHeader = new V1HTTPRouteSpecRequestHeaderModifierAdd(); + addHeader.setName("X-Custom-Header"); + addHeader.setValue("CustomValue"); + headerModifier.addAddItem(addHeader); + headerModifier.addSetItem(addHeader); + headerModifier.addRemoveItem("X-Remove-Header"); + filter.setRequestHeaderModifier(headerModifier); + expectedHttpRoute.getSpec().getRules().get(0).addFiltersItem(filter); + expectedHttpRoute.getSpec().getRules().get(0).setBackendRefs(null); + + Assertions.assertEquals(expectedHttpRoute, httpRoute); + } + + @Test + public void route2HttpRouteTestWithBackendRefs() { + Route route = buildBasicRoute(); + RoutePredicate pathPredicate = route.getPath(); + pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); + pathPredicate.setMatchValue("/"); + pathPredicate.setCaseSensitive(null); + + List services = new ArrayList<>(); + + // Case 1: Normal Kubernetes service in default namespace + UpstreamService service1 = new UpstreamService(); + service1.setName("service1.default.svc.cluster.local:8080"); + service1.setWeight(50); + services.add(service1); + + // Case 2: Kubernetes service in different namespace + UpstreamService service2 = new UpstreamService(); + service2.setName("service2.custom-namespace.svc.cluster.local"); + services.add(service2); + + // Case 3: MCP service + UpstreamService service3 = new UpstreamService(); + service3.setName("mcp-service.DEFAULT-GROUP.public.nacos"); + services.add(service3); + + route.setServices(services); + route.setCors(null); + route.setCustomConfigs(null); + + V1HTTPRoute httpRoute = converter.route2HttpRoute(route); + + V1HTTPRoute expectedHttpRoute = buildBasicSupportedHttpRoute(); + + + List expectedBackendRefs = new ArrayList<>(); + + // Expected result for Case 1 + V1HTTPRouteSpecBackendRefs expectedBackend1 = new V1HTTPRouteSpecBackendRefs(); + expectedBackend1.setName("service1"); + expectedBackend1.setPort(8080); + expectedBackend1.setWeight(50); + expectedBackend1.setNamespace("default"); + expectedBackendRefs.add(expectedBackend1); + + // Expected result for Case 2 + V1HTTPRouteSpecBackendRefs expectedBackend2 = new V1HTTPRouteSpecBackendRefs(); + expectedBackend2.setName("service2"); + expectedBackend2.setNamespace("custom-namespace"); + expectedBackendRefs.add(expectedBackend2); + + // Expected result for Case 3 + V1HTTPRouteSpecBackendRefs expectedBackend3 = new V1HTTPRouteSpecBackendRefs(); + expectedBackend3.setName("mcp-service.DEFAULT-GROUP.public.nacos"); + expectedBackend3.setGroup(V1McpBridge.API_GROUP); + expectedBackendRefs.add(expectedBackend3); + + expectedHttpRoute.getSpec().getRules().get(0).setBackendRefs(expectedBackendRefs); + + Assertions.assertEquals(expectedHttpRoute, httpRoute); + + } + + @Test + public void domain2GatewayTestWithHttpDomain() { + Domain domain = new Domain(); + domain.setName("example.com"); + domain.setVersion("1"); + Map portAndCertMap = new HashMap<>(); + portAndCertMap.put(80, ""); + domain.setPortAndCertMap(portAndCertMap); + + V1Gateway gateway = converter.domain2Gateway(domain); + + V1Gateway expectedGateway = new V1Gateway(); + V1ObjectMeta metadata = new V1ObjectMeta(); + metadata.setName("example-com"); + metadata.setResourceVersion("1"); + expectedGateway.setMetadata(metadata); + + V1GatewaySpec spec = new V1GatewaySpec().addDefaultAddress(); + spec.setGatewayClassName(V1GatewayClass.DEFAULT_NAME); + V1GatewaySpecListeners listener = new V1GatewaySpecListeners(); + listener.setName("example.com-80"); + listener.setPort(80); + listener.setHostname("example.com"); + listener.setProtocol("HTTP"); + listener.setAllowedRoutes(V1GatewaySpecListeners.getDefaultAllowedRoutes()); + spec.setListeners(Collections.singletonList(listener)); + expectedGateway.setSpec(spec); + + Assertions.assertEquals(expectedGateway, gateway); + } + + @Test + public void domain2GatewayTestWithHttpsDomain() { + Domain domain = new Domain(); + domain.setName("secure.example.com"); + domain.setVersion("2"); + Map portAndCertMap = new HashMap<>(); + portAndCertMap.put(443, "test-cert"); + domain.setPortAndCertMap(portAndCertMap); + + V1Gateway gateway = converter.domain2Gateway(domain); + + V1Gateway expectedGateway = new V1Gateway(); + V1ObjectMeta metadata = new V1ObjectMeta(); + metadata.setName("secure-example-com"); + metadata.setResourceVersion("2"); + expectedGateway.setMetadata(metadata); + + V1GatewaySpec spec = new V1GatewaySpec().addDefaultAddress(); + spec.setGatewayClassName(V1GatewayClass.DEFAULT_NAME); + V1GatewaySpecListeners listener = new V1GatewaySpecListeners(); + listener.setName("secure.example.com-443"); + listener.setPort(443); + listener.setHostname("secure.example.com"); + listener.setProtocol("HTTPS"); + listener.setTls(V1GatewaySpecListeners.getDefaultTls("test-cert")); + listener.setAllowedRoutes(V1GatewaySpecListeners.getDefaultAllowedRoutes()); + spec.setListeners(Collections.singletonList(listener)); + expectedGateway.setSpec(spec); + + Assertions.assertEquals(expectedGateway, gateway); + } + + @Test + public void domain2GatewayTestWithWildcardDomain() { + Domain domain = new Domain(); + domain.setName("*"); + domain.setVersion("3"); + Map portAndCertMap = new HashMap<>(); + portAndCertMap.put(80, ""); + portAndCertMap.put(443, "wildcard-cert"); + domain.setPortAndCertMap(portAndCertMap); + + V1Gateway gateway = converter.domain2Gateway(domain); + + V1Gateway expectedGateway = new V1Gateway(); + V1ObjectMeta metadata = new V1ObjectMeta(); + metadata.setName("wildcard"); + metadata.setResourceVersion("3"); + expectedGateway.setMetadata(metadata); + + V1GatewaySpec spec = new V1GatewaySpec().addDefaultAddress(); + spec.setGatewayClassName(V1GatewayClass.DEFAULT_NAME); + List listeners = new ArrayList<>(); + + V1GatewaySpecListeners httpListener = new V1GatewaySpecListeners(); + httpListener.setName("wildcard-80"); + httpListener.setPort(80); + httpListener.setProtocol("HTTP"); + httpListener.setAllowedRoutes(V1GatewaySpecListeners.getDefaultAllowedRoutes()); + listeners.add(httpListener); + + V1GatewaySpecListeners httpsListener = new V1GatewaySpecListeners(); + httpsListener.setName("wildcard-443"); + httpsListener.setPort(443); + httpsListener.setProtocol("HTTPS"); + httpsListener.setTls(V1GatewaySpecListeners.getDefaultTls("wildcard-cert")); + httpsListener.setAllowedRoutes(V1GatewaySpecListeners.getDefaultAllowedRoutes()); + listeners.add(httpsListener); + + spec.setListeners(listeners); + expectedGateway.setSpec(spec); + + Assertions.assertEquals(expectedGateway, gateway); + } + + @Test + public void domain2GatewayTestWithEmptyPortAndCertMap() { + Domain domain = new Domain(); + domain.setName("empty.example.com"); + domain.setVersion("4"); + domain.setPortAndCertMap(new HashMap<>()); + + V1Gateway gateway = converter.domain2Gateway(domain); + + Assertions.assertNull(gateway); + } } From c8cbc027f1c6256dfe377a25d4df823dce1f005b Mon Sep 17 00:00:00 2001 From: zxlin <860620266@qq.com> Date: Wed, 16 Oct 2024 18:45:26 +0800 Subject: [PATCH 12/24] feat: translate openapi specification to higress domain&route --- .../higress/console/config/SdkConfig.java | 6 + .../console/controller/OpenAPIController.java | 39 ++ .../sdk/model/OpenAPISpecification.java | 42 ++ .../sdk/model/openapi/OpenAPIComponents.java | 33 ++ .../model/openapi/OpenAPIContactDetails.java | 28 ++ .../sdk/model/openapi/OpenAPIEncoding.java | 26 + .../model/openapi/OpenAPIExternalDocs.java | 27 ++ .../sdk/model/openapi/OpenAPIInfo.java | 30 ++ .../sdk/model/openapi/OpenAPILicense.java | 27 ++ .../sdk/model/openapi/OpenAPIMediaType.java | 30 ++ .../sdk/model/openapi/OpenAPIOperation.java | 41 ++ .../sdk/model/openapi/OpenAPIParameter.java | 35 ++ .../model/openapi/OpenAPIPathDescription.java | 44 ++ .../sdk/model/openapi/OpenAPIRequestBody.java | 34 ++ .../sdk/model/openapi/OpenAPIResponse.java | 33 ++ .../sdk/model/openapi/OpenAPISchema.java | 40 ++ .../sdk/model/openapi/OpenAPIServer.java | 31 ++ .../model/openapi/OpenAPIServerVariable.java | 35 ++ .../higress/sdk/model/openapi/OpenAPITag.java | 28 ++ .../sdk/service/HigressServiceProvider.java | 2 + .../service/HigressServiceProviderImpl.java | 7 + .../higress/sdk/service/OpenAPIService.java | 20 + .../sdk/service/OpenAPIServiceImpl.java | 443 ++++++++++++++++++ .../service/kubernetes/KubernetesUtil.java | 33 +- 24 files changed, 1105 insertions(+), 9 deletions(-) create mode 100644 backend/console/src/main/java/com/alibaba/higress/console/controller/OpenAPIController.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/model/OpenAPISpecification.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIComponents.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIContactDetails.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIEncoding.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIExternalDocs.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIInfo.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPILicense.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIMediaType.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIOperation.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIParameter.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIPathDescription.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIRequestBody.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIResponse.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPISchema.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIServer.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIServerVariable.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPITag.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/OpenAPIService.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/OpenAPIServiceImpl.java diff --git a/backend/console/src/main/java/com/alibaba/higress/console/config/SdkConfig.java b/backend/console/src/main/java/com/alibaba/higress/console/config/SdkConfig.java index 21b9a815..bc574c17 100644 --- a/backend/console/src/main/java/com/alibaba/higress/console/config/SdkConfig.java +++ b/backend/console/src/main/java/com/alibaba/higress/console/config/SdkConfig.java @@ -16,6 +16,7 @@ import javax.annotation.PostConstruct; +import com.alibaba.higress.sdk.service.OpenAPIService; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -121,4 +122,9 @@ public WasmPluginService wasmPluginService() { public WasmPluginInstanceService wasmPluginInstanceService() { return serviceProvider.wasmPluginInstanceService(); } + + @Bean + public OpenAPIService openApiService() { + return serviceProvider.openApiService(); + } } diff --git a/backend/console/src/main/java/com/alibaba/higress/console/controller/OpenAPIController.java b/backend/console/src/main/java/com/alibaba/higress/console/controller/OpenAPIController.java new file mode 100644 index 00000000..5cee10bf --- /dev/null +++ b/backend/console/src/main/java/com/alibaba/higress/console/controller/OpenAPIController.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.alibaba.higress.console.controller; + +import com.alibaba.higress.console.controller.dto.Response; +import com.alibaba.higress.console.controller.util.ControllerUtil; +import com.alibaba.higress.sdk.model.OpenAPISpecification; +import com.alibaba.higress.sdk.service.OpenAPIService; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +@RestController("OpenAPIController") +@RequestMapping("/v1/openapi") +@Validated +public class OpenAPIController { + @Resource + private OpenAPIService openApiService; + + @PostMapping + public ResponseEntity> add(@RequestBody OpenAPISpecification oas) { + return ControllerUtil.buildResponseEntity(openApiService.add(oas)); + } +} diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/OpenAPISpecification.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/OpenAPISpecification.java new file mode 100644 index 00000000..51987c62 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/OpenAPISpecification.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.alibaba.higress.sdk.model; + +import com.alibaba.higress.sdk.model.openapi.OpenAPIComponents; +import com.alibaba.higress.sdk.model.openapi.OpenAPIInfo; +import com.alibaba.higress.sdk.model.openapi.OpenAPIPathDescription; +import com.alibaba.higress.sdk.model.openapi.OpenAPIServer; +import com.alibaba.higress.sdk.model.openapi.OpenAPITag; +import io.swagger.annotations.ApiModel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@ApiModel("OpenAPI") +public class OpenAPISpecification { + private String openapi; + private OpenAPIInfo info; + private List servers; + private Map paths; + private List components; + private List tags; +} diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIComponents.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIComponents.java new file mode 100644 index 00000000..fc091d6a --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIComponents.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.alibaba.higress.sdk.model.openapi; + + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OpenAPIComponents { + private Map schemas; + private Map responses; + private Map parameters; + private Map requestBodies; + private Map extensions; +} diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIContactDetails.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIContactDetails.java new file mode 100644 index 00000000..a92dbdb9 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIContactDetails.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.alibaba.higress.sdk.model.openapi; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OpenAPIContactDetails { + private String name; + private String url; + private String email; +} diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIEncoding.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIEncoding.java new file mode 100644 index 00000000..2b32270e --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIEncoding.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.alibaba.higress.sdk.model.openapi; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OpenAPIEncoding { + private String contentType; +} diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIExternalDocs.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIExternalDocs.java new file mode 100644 index 00000000..7c48ad43 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIExternalDocs.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.alibaba.higress.sdk.model.openapi; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OpenAPIExternalDocs { + private String description; + private String url; +} diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIInfo.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIInfo.java new file mode 100644 index 00000000..18619ea3 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIInfo.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.alibaba.higress.sdk.model.openapi; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OpenAPIInfo { + private String title; + private String description; + private OpenAPIContactDetails contact; + private OpenAPILicense license; + private String version; +} diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPILicense.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPILicense.java new file mode 100644 index 00000000..4d105742 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPILicense.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.alibaba.higress.sdk.model.openapi; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OpenAPILicense { + private String name; + private String url; +} diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIMediaType.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIMediaType.java new file mode 100644 index 00000000..9246d48b --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIMediaType.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.alibaba.higress.sdk.model.openapi; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OpenAPIMediaType { + private OpenAPISchema schema; + private Map encoding; + private Map extensions; +} diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIOperation.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIOperation.java new file mode 100644 index 00000000..507d4664 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIOperation.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.alibaba.higress.sdk.model.openapi; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OpenAPIOperation { + private List tags; + private String summary; + private String description; + private OpenAPIExternalDocs externalDocs; + private String operationId; + private List parameters; + private OpenAPIRequestBody requestBody; + private Map responses; + private boolean deprecated = false; + private Map> security; + private List servers; + private Map extensions; + +} diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIParameter.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIParameter.java new file mode 100644 index 00000000..71749b05 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIParameter.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.alibaba.higress.sdk.model.openapi; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OpenAPIParameter { + private String name; + private String description; + private String in; + private boolean required = true; + private boolean deprecated = false; + private boolean allowEmptyValue = false; + @JsonProperty("$ref") + private String ref; + private OpenAPISchema schema; +} diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIPathDescription.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIPathDescription.java new file mode 100644 index 00000000..a5914a38 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIPathDescription.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.alibaba.higress.sdk.model.openapi; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OpenAPIPathDescription { + private String summary; + private String description; + private OpenAPIOperation get; + private OpenAPIOperation put; + private OpenAPIOperation post; + private OpenAPIOperation delete; + private OpenAPIOperation options; + private OpenAPIOperation head; + private OpenAPIOperation patch; + private OpenAPIOperation trace; + private List servers; + private List parameters; + @JsonProperty("$ref") + private String ref; + private Map extensions; +} diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIRequestBody.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIRequestBody.java new file mode 100644 index 00000000..9610ef15 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIRequestBody.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.alibaba.higress.sdk.model.openapi; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OpenAPIRequestBody { + private String description; + private Map content; + private boolean required = true; + private Map extensions; + @JsonProperty("$ref") + private String ref; +} diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIResponse.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIResponse.java new file mode 100644 index 00000000..41e1300d --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIResponse.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.alibaba.higress.sdk.model.openapi; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OpenAPIResponse { + private String description; + private Map content; + private Map extensions; + @JsonProperty("$ref") + private String ref; +} diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPISchema.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPISchema.java new file mode 100644 index 00000000..93d5490b --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPISchema.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.alibaba.higress.sdk.model.openapi; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OpenAPISchema { + private String name; + private String title; + private List required; + private String type; + private String description; + private String format; + private boolean nullable = false; + private boolean readOnly = false; + private boolean writeOnly = false; + private boolean deprecated = false; + private OpenAPIExternalDocs externalDocs; + private Map extensions; +} diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIServer.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIServer.java new file mode 100644 index 00000000..bbe844e6 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIServer.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.alibaba.higress.sdk.model.openapi; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Map; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OpenAPIServer { + private String description; + private String url; + private Map variables; + private Map extensions; +} diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIServerVariable.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIServerVariable.java new file mode 100644 index 00000000..cd08ba1a --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPIServerVariable.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.alibaba.higress.sdk.model.openapi; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OpenAPIServerVariable { + @JsonProperty("enum") + private List enums; + + @JsonProperty("default") + private String defaultValue; + + private String description; +} diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPITag.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPITag.java new file mode 100644 index 00000000..5b283b08 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/openapi/OpenAPITag.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.alibaba.higress.sdk.model.openapi; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class OpenAPITag { + private String name; + private String description; + private OpenAPIExternalDocs externalDocs; +} diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressServiceProvider.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressServiceProvider.java index 41a26367..476fc5ba 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressServiceProvider.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressServiceProvider.java @@ -44,4 +44,6 @@ static HigressServiceProvider create(HigressServiceConfig config) throws IOExcep WasmPluginService wasmPluginService(); WasmPluginInstanceService wasmPluginInstanceService(); + + OpenAPIService openApiService(); } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressServiceProviderImpl.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressServiceProviderImpl.java index 0c8aa6e1..d27b4c4e 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressServiceProviderImpl.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressServiceProviderImpl.java @@ -32,6 +32,7 @@ class HigressServiceProviderImpl implements HigressServiceProvider { private final TlsCertificateService tlsCertificateService; private final WasmPluginService wasmPluginService; private final WasmPluginInstanceService wasmPluginInstanceService; + private final OpenAPIService openApiService; HigressServiceProviderImpl(HigressServiceConfig config) throws IOException { kubernetesClientService = new KubernetesClientService(config); @@ -46,6 +47,7 @@ class HigressServiceProviderImpl implements HigressServiceProvider { new RouteServiceImpl(kubernetesClientService, kubernetesModelConverter, wasmPluginInstanceService); domainService = new DomainServiceImpl(kubernetesClientService, kubernetesModelConverter, routeService, wasmPluginInstanceService); + openApiService = new OpenAPIServiceImpl(kubernetesClientService, domainService, routeService); } @Override @@ -92,4 +94,9 @@ public WasmPluginService wasmPluginService() { public WasmPluginInstanceService wasmPluginInstanceService() { return wasmPluginInstanceService; } + + @Override + public OpenAPIService openApiService() { + return openApiService; + } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/OpenAPIService.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/OpenAPIService.java new file mode 100644 index 00000000..b34aa95e --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/OpenAPIService.java @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.alibaba.higress.sdk.service; + +import com.alibaba.higress.sdk.model.OpenAPISpecification; + + +public interface OpenAPIService { + OpenAPISpecification add(OpenAPISpecification oas); +} diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/OpenAPIServiceImpl.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/OpenAPIServiceImpl.java new file mode 100644 index 00000000..a24e8073 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/OpenAPIServiceImpl.java @@ -0,0 +1,443 @@ +/* + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.alibaba.higress.sdk.service; + +import com.alibaba.higress.sdk.model.Domain; +import com.alibaba.higress.sdk.model.OpenAPISpecification; +import com.alibaba.higress.sdk.model.Route; +import com.alibaba.higress.sdk.model.openapi.OpenAPIParameter; +import com.alibaba.higress.sdk.model.openapi.OpenAPIPathDescription; +import com.alibaba.higress.sdk.model.openapi.OpenAPIServer; +import com.alibaba.higress.sdk.model.openapi.OpenAPIServerVariable; +import com.alibaba.higress.sdk.model.route.RoutePredicate; +import com.alibaba.higress.sdk.model.route.RoutePredicateTypeEnum; +import com.alibaba.higress.sdk.model.route.UpstreamService; +import com.alibaba.higress.sdk.service.kubernetes.KubernetesClientService; +import com.alibaba.higress.sdk.service.kubernetes.KubernetesUtil; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecMatches; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Pattern; + +@Slf4j +public class OpenAPIServiceImpl implements OpenAPIService{ + private final KubernetesClientService kubernetesClientService; + private final DomainService domainService; + private final RouteService routeService; + + public OpenAPIServiceImpl(KubernetesClientService kubernetesClientService, DomainService domainService, RouteService routeService) { + this.kubernetesClientService = kubernetesClientService; + this.domainService = domainService; + this.routeService = routeService; + } + + + @Override + public OpenAPISpecification add(OpenAPISpecification openApi) { + + List domainInfos = processDomains(openApi); + addOrUpdateDomains(domainInfos); + + List routes = processRoutes(openApi); + addRoutes(routes, openApi.getPaths(), domainInfos); + + return null; + } + private static class PathAndType { + String pathPrefix; + Boolean isExact; + + PathAndType(String pathPrefix, Boolean isExact) { + this.pathPrefix = pathPrefix; + this.isExact = isExact; + } + } + private static class DomainInfo { + Domain domain; + PathAndType pathAndType; + + DomainInfo(Domain domain, PathAndType pathAndType) { + this.domain = domain; + this.pathAndType = pathAndType; + } + } + + private List processDomains(OpenAPISpecification openApi) { + List domainInfos = new ArrayList<>(); + List servers = openApi.getServers(); + + if (servers == null || servers.isEmpty()) { + domainInfos.add(createDefaultDomainInfo()); + } else { + for (OpenAPIServer server : servers) { + domainInfos.addAll(createDomainInfoFromServer(server)); + } + } + + return domainInfos; + } + + private DomainInfo createDefaultDomainInfo() { + Domain domain = new Domain(); + domain.setName("*"); + return new DomainInfo(domain, new PathAndType("/", Boolean.TRUE)); + } + + private List createDomainInfoFromServer(OpenAPIServer server) { + String url = server.getUrl(); + Map variables = server.getVariables(); + List domainInfos = new ArrayList<>(); + + PathAndType pathAndType = extractPathPrefix(url, variables); + List schemes = extractSchemes(url, variables); + List hosts = extractHosts(url, variables); + + for (String host : hosts) { + Domain domain = new Domain(); + domain.setName(host); + // For absolute URLs, create a DomainInfo for each scheme + domain.setEnableHttps(Domain.EnableHttps.OFF); + Map portAndCertMap = new HashMap<>(); + for (String scheme : schemes) { + if ("http".equalsIgnoreCase(scheme)) { + portAndCertMap.put(80, ""); + } else if ("https".equalsIgnoreCase(scheme)) { + domain.setEnableHttps(Domain.EnableHttps.ON); + // TODO: change the default tls name + String tls = "default_tls"; + if (server.getExtensions()!=null && server.getExtensions().containsKey("tls_name")) { + tls= (String) server.getExtensions().get("tls_name"); + } + portAndCertMap.put(443, tls); + } + } + domain.setPortAndCertMap(portAndCertMap); + domainInfos.add(new DomainInfo(domain, pathAndType)); + } + + return domainInfos; + } + + private PathAndType extractPathPrefix(String url, Map variables) { + String path; + String processedUrl = renderDefaultSchemes(url, variables); + try { + path = new URL(processedUrl).getPath(); + } catch (MalformedURLException e) { + // If URL is relative, it's the path prefix itself + path = url; + } + return processPathVariables(path, variables); + } + + private List extractSchemes(String url, Map variables) { + List schemes = new ArrayList<>(); + + if (url.startsWith("{")) { + int endIndex = url.indexOf("}"); + if (endIndex != -1) { + String schemePlaceholder = url.substring(1, endIndex); + OpenAPIServerVariable schemeVar = variables.get(schemePlaceholder); + if (schemeVar != null && schemeVar.getEnums() != null) { + schemes.addAll(schemeVar.getEnums()); + } else { + schemes.add("http"); + } + } + } else { + try { + URL parsedUrl = new URL(url); + schemes.add(parsedUrl.getProtocol()); + } catch (MalformedURLException e) { + // If URL is relative, only http + schemes.add("http"); + } + } + + return schemes; + } + + private List extractHosts(String url, Map variables) { + List hosts = new ArrayList<>(); + String processedUrl = renderDefaultSchemes(url, variables); + + try { + URL parsedUrl = new URL(processedUrl); + String host = parsedUrl.getHost(); + + if (host.contains("{")) { + String[] parts = host.split("\\."); + List hostVariations = new ArrayList<>(); + hostVariations.add(host); + + for (String part : parts) { + if (part.startsWith("{") && part.endsWith("}")) { + String varName = part.substring(1, part.length() - 1); + OpenAPIServerVariable var = variables.get(varName); + if (var != null) { + List values = var.getEnums() != null ? var.getEnums() : + (var.getDefaultValue() != null ? Arrays.asList(var.getDefaultValue()) : + Arrays.asList("*")); + List newVariations = new ArrayList<>(); + for (String variation : hostVariations) { + for (String value : values) { + newVariations.add(variation.replace("{" + varName + "}", value)); + } + } + hostVariations = newVariations; + } + } + } + hosts.addAll(hostVariations); + } else { + hosts.add(host); + } + } catch (MalformedURLException e) { + // If URL is relative, return wildcard + hosts.add("*"); + } + + return hosts; + } + + private String renderDefaultSchemes(String url, Map variables) { + if (variables == null) { + return url; + } + if (url.startsWith("{")) { + int endIndex = url.indexOf("}"); + if (endIndex != -1) { + String schemePlaceholder = url.substring(1, endIndex); + OpenAPIServerVariable schemeVar = variables.get(schemePlaceholder); + if (schemeVar == null) { + return url; + } + String value = schemeVar.getDefaultValue() != null ? schemeVar.getDefaultValue() : + (schemeVar.getEnums() != null && !schemeVar.getEnums().isEmpty() ? schemeVar.getEnums().get(0) : ""); + url = url.replace("{" + schemePlaceholder + "}", value); + } + } + return url; + } + + private PathAndType processPathVariables(String path, Map variables) { + // "^/(v2|v3)$" + if (variables == null) { + return new PathAndType(path, Boolean.TRUE); + } + + StringBuilder regex = new StringBuilder("^"); + String[] segments = path.split("/"); + + Boolean isExact = Boolean.TRUE; + + for (String segment : segments) { + if (segment.startsWith("{") && segment.endsWith("}")) { + isExact = Boolean.FALSE; + String varName = segment.substring(1, segment.length() - 1); + OpenAPIServerVariable var = variables.get(varName); + if (var != null && var.getEnums() != null && !var.getEnums().isEmpty()) { + regex.append("/(" + String.join("|", var.getEnums()) + ")"); + } else { + regex.append("/[^/]+"); + } + } else { + regex.append("/" + Pattern.quote(segment)); + } + } + if(!isExact) { + regex.append("$"); + } + return new PathAndType(regex.toString(), isExact); + } + + + private List processRoutes(OpenAPISpecification openApi) { + List routes = new ArrayList<>(); + Map paths = openApi.getPaths(); + + for (Map.Entry entry : paths.entrySet()) { + String path = entry.getKey(); + OpenAPIPathDescription pathItem = entry.getValue(); + + Route route = new Route(); + route.setName(path); + RoutePredicate routePath = new RoutePredicate(RoutePredicateTypeEnum.EQUAL.toString(), path, false); + route.setPath(routePath); + + boolean hasPathParameter = path.contains("{") && path.contains("}"); + + if (hasPathParameter) { + String regexPath = convertPathToRegex(path, getFirstOperationParameters(pathItem)); + routePath.setMatchValue(regexPath); + routePath.setMatchType(RoutePredicateTypeEnum.REGULAR.toString()); + } + setRouteProperties(route, pathItem); + routes.add(route); + } + + return routes; + } + + private List getFirstOperationParameters(OpenAPIPathDescription pathItem) { + if (pathItem.getGet() != null && pathItem.getGet().getParameters() != null) { + return pathItem.getGet().getParameters(); + } else if (pathItem.getPost() != null && pathItem.getPost().getParameters() != null) { + return pathItem.getPost().getParameters(); + } else if (pathItem.getPut() != null && pathItem.getPut().getParameters() != null) { + return pathItem.getPut().getParameters(); + } else if (pathItem.getDelete() != null && pathItem.getDelete().getParameters() != null) { + return pathItem.getDelete().getParameters(); + } else if (pathItem.getPatch() != null && pathItem.getPatch().getParameters() != null) { + return pathItem.getPatch().getParameters(); + } else if (pathItem.getOptions() != null && pathItem.getOptions().getParameters() != null) { + return pathItem.getOptions().getParameters(); + } else if (pathItem.getHead() != null && pathItem.getHead().getParameters() != null) { + return pathItem.getHead().getParameters(); + } else if (pathItem.getTrace() != null && pathItem.getTrace().getParameters() != null) { + return pathItem.getTrace().getParameters(); + } + return null; + } + + private String convertPathToRegex(String path, List parameters) { + if (parameters == null) { + return path; + } + StringBuilder regex = new StringBuilder("^"); + String[] segments = path.split("/"); + + for (String segment : segments) { + if (segment.startsWith("{") && segment.endsWith("}")) { + String paramName = segment.substring(1, segment.length() - 1); + OpenAPIParameter param = parameters.stream() + .filter(p -> p.getName().equals(paramName) && "path".equals(p.getIn())) + .findFirst() + .orElse(null); + + if (param != null && param.getSchema() != null) { + String format = param.getSchema().getFormat(); + String type = param.getSchema().getType(); + if ("integer".equals(type) || "int32".equals(format) || "int64".equals(format)) { + regex.append("/([0-9]+)"); + } else if ("float".equals(type) || "double".equals(type)) { + regex.append("/([0-9]*\\.?[0-9]+)"); + } else { + regex.append("/([^/]+)"); + } + } else { + regex.append("/([^/]+)"); + } + } else { + regex.append("/" + Pattern.quote(segment)); + } + } + regex.append("$"); + + return regex.toString(); + } + + private void setRouteProperties(Route route, OpenAPIPathDescription pathItem) { + List methods = new ArrayList<>(); + if (pathItem.getGet() != null) { + methods.add(V1HTTPRouteSpecMatches.MethodEnum.GET.toString()); + } + if (pathItem.getPut() != null) { + methods.add(V1HTTPRouteSpecMatches.MethodEnum.PUT.toString()); + } + if (pathItem.getPost() != null) { + methods.add(V1HTTPRouteSpecMatches.MethodEnum.POST.toString()); + } + if (pathItem.getDelete() != null) { + methods.add(V1HTTPRouteSpecMatches.MethodEnum.DELETE.toString()); + } + if (pathItem.getOptions() != null) { + methods.add(V1HTTPRouteSpecMatches.MethodEnum.OPTIONS.toString()); + } + if (pathItem.getHead() != null) { + methods.add(V1HTTPRouteSpecMatches.MethodEnum.HEAD.toString()); + } + if (pathItem.getPatch() != null) { + methods.add(V1HTTPRouteSpecMatches.MethodEnum.PATCH.toString()); + } + if (pathItem.getTrace() != null) { + methods.add(V1HTTPRouteSpecMatches.MethodEnum.TRACE.toString()); + } + + route.setMethods(methods); + // backend + if (pathItem.getExtensions()!=null && pathItem.getExtensions().containsKey("x-backend")) { + String backendInfo = (String) pathItem.getExtensions().get("x-backend"); + if (backendInfo != null) { + route.setServices(Collections.singletonList(new UpstreamService(backendInfo, null, null, null))); + } + } + // TODO: wasm + } + + private void addOrUpdateDomains(List domainInfos) { + for (DomainInfo domainInfo : domainInfos) { + domainService.addOrUpdate(domainInfo.domain); + } + } + + private void addRoutes(List routes, Map paths, List domainInfos) { + for (Route route : routes){ + String path = route.getName(); + String matchType = route.getPath().getMatchType(); + String matchValue = route.getPath().getMatchValue(); + List servers = paths.get(path).getServers(); + if (CollectionUtils.isNotEmpty(servers)) { + for (OpenAPIServer server : servers) { + String url = server.getUrl(); + Map variables = server.getVariables(); + PathAndType pathAndType = extractPathPrefix(url, variables); + List hosts = extractHosts(url, variables); + route.getPath().setMatchValue(pathAndType.pathPrefix+matchValue); + if (pathAndType.isExact) { + route.getPath().setMatchType(matchType); + } else { + route.getPath().setMatchType(RoutePredicateTypeEnum.REGULAR.toString()); + } + for (String host: hosts) { + route.setName(KubernetesUtil.normalizeRouteName(host+path)); + route.setDomains(Collections.singletonList(host)); + routeService.add(route); + } + } + } else { + // DomainInfos + for (DomainInfo domainInfo : domainInfos) { + route.setName(KubernetesUtil.normalizeRouteName(domainInfo.domain.getName()+path)); + route.setDomains(Collections.singletonList(domainInfo.domain.getName())); + route.getPath().setMatchValue(domainInfo.pathAndType.pathPrefix+matchValue); + if (domainInfo.pathAndType.isExact) { + route.getPath().setMatchType(matchType); + } else { + route.getPath().setMatchType(RoutePredicateTypeEnum.REGULAR.toString()); + } + routeService.add(route); + } + } + } + } +} diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesUtil.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesUtil.java index a3a67053..96c31e8b 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesUtil.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesUtil.java @@ -12,12 +12,6 @@ */ package com.alibaba.higress.sdk.service.kubernetes; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -import org.apache.commons.lang3.StringUtils; - import com.alibaba.higress.sdk.constant.CommonKey; import com.alibaba.higress.sdk.constant.KubernetesConstants; import com.alibaba.higress.sdk.constant.Separators; @@ -25,14 +19,18 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; - import io.kubernetes.client.common.KubernetesObject; import io.kubernetes.client.openapi.models.V1ObjectMeta; +import org.apache.commons.lang3.StringUtils; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; public class KubernetesUtil { private static final ObjectMapper YAML = - new ObjectMapper(new YAMLFactory().enable(YAMLGenerator.Feature.LITERAL_BLOCK_STYLE)); + new ObjectMapper(new YAMLFactory().enable(YAMLGenerator.Feature.LITERAL_BLOCK_STYLE)); public static String toYaml(Object obj) { try { @@ -91,6 +89,23 @@ public static String normalizeDomainName(String name) { return name; } + public static String normalizeRouteName(String name) { + // for openapi + // domain and path: foo.bar.com/user/{userId} + // turns to : foo.bar.com-user-userId + if (StringUtils.isNotBlank(name) && name.startsWith(Separators.ASTERISK)) { + name = CommonKey.WILDCARD + name.substring(Separators.ASTERISK.length()); + } + name = name.replace("/", "-") + .replaceAll("-\\{", "-") + .replaceAll("\\{", "-") + .replaceAll("}", "").toLowerCase(); + return name; + } + + public static String getReferenceGrantName(String name, String type) { + return name+Separators.DASH+type; + } public static String joinLabelSelectors(String... selectors) { return String.join(Separators.COMMA, selectors); @@ -98,7 +113,7 @@ public static String joinLabelSelectors(String... selectors) { public static String buildDomainLabelSelector(String domainName) { return buildLabelSelector(KubernetesConstants.Label.DOMAIN_KEY_PREFIX + normalizeDomainName(domainName), - KubernetesConstants.Label.DOMAIN_VALUE_DUMMY); + KubernetesConstants.Label.DOMAIN_VALUE_DUMMY); } public static String buildLabelSelector(String name, String value) { From 0ca75c898bf7106bc59a30d83942033b5112fc20 Mon Sep 17 00:00:00 2001 From: zxlin <860620266@qq.com> Date: Fri, 8 Nov 2024 17:05:30 +0800 Subject: [PATCH 13/24] feat: add frontend code --- .../higress/console/config/SdkConfig.java | 6 + .../console/controller/HigressController.java | 42 +++ .../sdk/constant/KubernetesConstants.java | 8 + .../com/alibaba/higress/sdk/model/Domain.java | 1 + .../com/alibaba/higress/sdk/model/Route.java | 2 + .../sdk/service/DomainServiceImpl.java | 15 +- .../sdk/service/HigressConfigService.java | 18 ++ .../sdk/service/HigressConfigServiceImpl.java | 43 +++ .../sdk/service/HigressServiceProvider.java | 2 + .../service/HigressServiceProviderImpl.java | 10 +- .../sdk/service/OpenAPIServiceImpl.java | 106 +++++-- .../higress/sdk/service/RouteServiceImpl.java | 67 +++-- .../WasmPluginInstanceServiceImpl.java | 26 +- .../kubernetes/KubernetesClientService.java | 24 ++ .../kubernetes/KubernetesModelConverter.java | 24 +- .../KubernetesModelConverterTest.java | 24 +- .../src/components/AvatarDropdown/index.tsx | 13 +- frontend/src/interfaces/domain.ts | 4 +- frontend/src/interfaces/route.ts | 1 + frontend/src/locales/en-US/translation.json | 30 +- frontend/src/locales/zh-CN/translation.json | 30 +- frontend/src/pages/_defaultProps.tsx | 12 + .../domain/components/DomainForm/index.tsx | 79 ++++- .../domain/components/DomainGroup/index.tsx | 281 ++++++++++++++++++ frontend/src/pages/domain/index.tsx | 50 +++- frontend/src/pages/higress-config/index.tsx | 90 ++++++ .../route/components/RouteForm/index.tsx | 94 +++++- frontend/src/pages/route/index.tsx | 55 ++-- frontend/src/services/higress-config.ts | 9 + frontend/src/services/index.ts | 1 + 30 files changed, 1047 insertions(+), 120 deletions(-) create mode 100644 backend/console/src/main/java/com/alibaba/higress/console/controller/HigressController.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressConfigService.java create mode 100644 backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressConfigServiceImpl.java create mode 100644 frontend/src/pages/domain/components/DomainGroup/index.tsx create mode 100644 frontend/src/pages/higress-config/index.tsx create mode 100644 frontend/src/services/higress-config.ts diff --git a/backend/console/src/main/java/com/alibaba/higress/console/config/SdkConfig.java b/backend/console/src/main/java/com/alibaba/higress/console/config/SdkConfig.java index bc574c17..cde65921 100644 --- a/backend/console/src/main/java/com/alibaba/higress/console/config/SdkConfig.java +++ b/backend/console/src/main/java/com/alibaba/higress/console/config/SdkConfig.java @@ -34,6 +34,7 @@ import com.alibaba.higress.sdk.service.WasmPluginService; import com.alibaba.higress.sdk.service.kubernetes.KubernetesClientService; import com.alibaba.higress.sdk.service.kubernetes.KubernetesModelConverter; +import com.alibaba.higress.sdk.service.HigressConfigService; @Configuration public class SdkConfig { @@ -127,4 +128,9 @@ public WasmPluginInstanceService wasmPluginInstanceService() { public OpenAPIService openApiService() { return serviceProvider.openApiService(); } + + @Bean + public HigressConfigService higressConfigService() { + return serviceProvider.higressConfigService(); + } } diff --git a/backend/console/src/main/java/com/alibaba/higress/console/controller/HigressController.java b/backend/console/src/main/java/com/alibaba/higress/console/controller/HigressController.java new file mode 100644 index 00000000..67f1af0b --- /dev/null +++ b/backend/console/src/main/java/com/alibaba/higress/console/controller/HigressController.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.alibaba.higress.console.controller; + +import com.alibaba.higress.sdk.service.HigressConfigService; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +@RestController("HigressController") +@RequestMapping("/v1/workmode") +@Validated +public class HigressController { + @Resource + HigressConfigService higressConfigService; + + @GetMapping + public Boolean get() { + return higressConfigService.get(); + } + + @PutMapping + public Boolean update(@RequestParam Boolean mode) { + return higressConfigService.put(mode); + } + +} diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/constant/KubernetesConstants.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/constant/KubernetesConstants.java index 7c36e2d9..5e1d7f22 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/constant/KubernetesConstants.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/constant/KubernetesConstants.java @@ -25,6 +25,14 @@ public class KubernetesConstants { public static final String SECRET_TLS_KEY_FIELD = "tls.key"; public static final String YAML_SEPARATOR = "---\n"; + public static class WorkMode { + public static final String KEY = "workMode"; + public static final String GATEWAY = "gateway"; + public static final String INGRESS = "ingress"; + } + + + public static class Annotation { public static final String KEY_PREFIX = "higress.io/"; public static final String NGINX_INGRESS_KEY_PREFIX = "nginx.ingress.kubernetes.io/"; diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/Domain.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/Domain.java index 90ab65e8..d7b30c04 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/Domain.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/Domain.java @@ -32,6 +32,7 @@ public static class EnableHttps { public static final String ON = "on"; public static final String FORCE = "force"; } + private Boolean isIngressMode; private String name; diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/Route.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/Route.java index 1e505ed7..054cae61 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/Route.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/model/Route.java @@ -41,6 +41,8 @@ public class Route implements VersionedDto { private String name; + private Boolean isIngressMode; + private String version; private List domains; diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/DomainServiceImpl.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/DomainServiceImpl.java index 4c68e96d..b7285b72 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/DomainServiceImpl.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/DomainServiceImpl.java @@ -69,7 +69,7 @@ public Domain add(Domain domain) { throw new BusinessException("Error occurs when adding a new domain.", e); } // if gateway mode, create a gateway named "domain_name" - if(!kubernetesClientService.isIngressWorkMode()){ + if(!domain.getIsIngressMode()){ V1Gateway gateway = kubernetesModelConverter.domain2Gateway(domain); try { kubernetesClientService.createGateway(gateway); @@ -108,6 +108,7 @@ public Domain query(String domainName) { @Override public void delete(String domainName) { + Domain domain = query(domainName); PaginatedResult routes = routeService.list(new RoutePageQuery(domainName)); if (CollectionUtils.isNotEmpty(routes.getData())) { throw new IllegalArgumentException("The domain has routes. Please delete them first."); @@ -119,7 +120,7 @@ public void delete(String domainName) { } catch (ApiException e) { throw new BusinessException("Error occurs when deleting the ConfigMap with name: " + configMapName, e); } - if(!kubernetesClientService.isIngressWorkMode()){ + if(!domain.getIsIngressMode()){ String gatewayName = kubernetesModelConverter.domainName2GatewayName(domainName); try { kubernetesClientService.deleteGateway(gatewayName); @@ -157,15 +158,7 @@ public Domain put(Domain domain) { routes.forEach(routeService::update); } - if(!kubernetesClientService.isIngressWorkMode()){ - try { - boolean isDomainForIngress = kubernetesClientService.readGateway(domain.getName()) == null; - if (isDomainForIngress) { - return kubernetesModelConverter.configMap2Domain(updatedConfigMap); - } - } catch (ApiException e) { - throw new BusinessException("Error occurs when querying a Gateway", e); - } + if(!domain.getIsIngressMode()){ V1Gateway gateway = kubernetesModelConverter.domain2Gateway(domain); try { kubernetesClientService.replaceGateway(gateway); diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressConfigService.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressConfigService.java new file mode 100644 index 00000000..7efadcff --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressConfigService.java @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.alibaba.higress.sdk.service; + +public interface HigressConfigService { + Boolean get(); + Boolean put(Boolean isIngressMode); +} diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressConfigServiceImpl.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressConfigServiceImpl.java new file mode 100644 index 00000000..8921d0b7 --- /dev/null +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressConfigServiceImpl.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022-2023 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.alibaba.higress.sdk.service; + +import com.alibaba.higress.sdk.exception.BusinessException; +import com.alibaba.higress.sdk.service.kubernetes.KubernetesClientService; +import io.kubernetes.client.openapi.ApiException; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class HigressConfigServiceImpl implements HigressConfigService{ + private final KubernetesClientService kubernetesClientService; + + public HigressConfigServiceImpl(KubernetesClientService kubernetesClientService) { + this.kubernetesClientService = kubernetesClientService; + } + + @Override + public Boolean get() { + return kubernetesClientService.isIngressWorkMode(); + } + + @Override + public Boolean put(Boolean isIngressMode) { + Boolean updatedIsIngressMode = isIngressMode; + try { + updatedIsIngressMode = kubernetesClientService.setIngressMode(isIngressMode); + } catch (ApiException e) { + throw new BusinessException("Error occurs when updating the Higress workmode: ", e); + } + return updatedIsIngressMode; + } +} diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressServiceProvider.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressServiceProvider.java index 476fc5ba..62756982 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressServiceProvider.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressServiceProvider.java @@ -46,4 +46,6 @@ static HigressServiceProvider create(HigressServiceConfig config) throws IOExcep WasmPluginInstanceService wasmPluginInstanceService(); OpenAPIService openApiService(); + + HigressConfigService higressConfigService(); } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressServiceProviderImpl.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressServiceProviderImpl.java index d27b4c4e..6a965624 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressServiceProviderImpl.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/HigressServiceProviderImpl.java @@ -34,6 +34,8 @@ class HigressServiceProviderImpl implements HigressServiceProvider { private final WasmPluginInstanceService wasmPluginInstanceService; private final OpenAPIService openApiService; + private final HigressConfigService higressConfigService; + HigressServiceProviderImpl(HigressServiceConfig config) throws IOException { kubernetesClientService = new KubernetesClientService(config); kubernetesModelConverter = new KubernetesModelConverter(kubernetesClientService); @@ -47,7 +49,8 @@ class HigressServiceProviderImpl implements HigressServiceProvider { new RouteServiceImpl(kubernetesClientService, kubernetesModelConverter, wasmPluginInstanceService); domainService = new DomainServiceImpl(kubernetesClientService, kubernetesModelConverter, routeService, wasmPluginInstanceService); - openApiService = new OpenAPIServiceImpl(kubernetesClientService, domainService, routeService); + openApiService = new OpenAPIServiceImpl(kubernetesClientService, domainService, routeService, wasmPluginInstanceService); + higressConfigService = new HigressConfigServiceImpl(kubernetesClientService); } @Override @@ -99,4 +102,9 @@ public WasmPluginInstanceService wasmPluginInstanceService() { public OpenAPIService openApiService() { return openApiService; } + + @Override + public HigressConfigService higressConfigService() { + return higressConfigService; + } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/OpenAPIServiceImpl.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/OpenAPIServiceImpl.java index a24e8073..945e49db 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/OpenAPIServiceImpl.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/OpenAPIServiceImpl.java @@ -12,9 +12,12 @@ */ package com.alibaba.higress.sdk.service; +import com.alibaba.higress.sdk.exception.BusinessException; import com.alibaba.higress.sdk.model.Domain; import com.alibaba.higress.sdk.model.OpenAPISpecification; import com.alibaba.higress.sdk.model.Route; +import com.alibaba.higress.sdk.model.WasmPluginInstance; +import com.alibaba.higress.sdk.model.WasmPluginInstanceScope; import com.alibaba.higress.sdk.model.openapi.OpenAPIParameter; import com.alibaba.higress.sdk.model.openapi.OpenAPIPathDescription; import com.alibaba.higress.sdk.model.openapi.OpenAPIServer; @@ -44,10 +47,14 @@ public class OpenAPIServiceImpl implements OpenAPIService{ private final DomainService domainService; private final RouteService routeService; - public OpenAPIServiceImpl(KubernetesClientService kubernetesClientService, DomainService domainService, RouteService routeService) { + private final WasmPluginInstanceService wasmPluginInstanceService; + + public OpenAPIServiceImpl(KubernetesClientService kubernetesClientService, DomainService domainService, + RouteService routeService, WasmPluginInstanceService wasmPluginInstanceService) { this.kubernetesClientService = kubernetesClientService; this.domainService = domainService; this.routeService = routeService; + this.wasmPluginInstanceService = wasmPluginInstanceService; } @@ -57,8 +64,8 @@ public OpenAPISpecification add(OpenAPISpecification openApi) { List domainInfos = processDomains(openApi); addOrUpdateDomains(domainInfos); - List routes = processRoutes(openApi); - addRoutes(routes, openApi.getPaths(), domainInfos); + List routeInfos = processRoutes(openApi); + addRoutes(routeInfos, openApi.getPaths(), domainInfos); return null; } @@ -81,6 +88,16 @@ private static class DomainInfo { } } + private static class RouteInfo { + Route route; + List instances; + + RouteInfo(Route route, List instances) { + this.route = route; + this.instances = instances; + } + } + private List processDomains(OpenAPISpecification openApi) { List domainInfos = new ArrayList<>(); List servers = openApi.getServers(); @@ -113,6 +130,7 @@ private List createDomainInfoFromServer(OpenAPIServer server) { for (String host : hosts) { Domain domain = new Domain(); + domain.setIsIngressMode(kubernetesClientService.isIngressWorkMode()); domain.setName(host); // For absolute URLs, create a DomainInfo for each scheme domain.setEnableHttps(Domain.EnableHttps.OFF); @@ -123,9 +141,11 @@ private List createDomainInfoFromServer(OpenAPIServer server) { } else if ("https".equalsIgnoreCase(scheme)) { domain.setEnableHttps(Domain.EnableHttps.ON); // TODO: change the default tls name - String tls = "default_tls"; + String tls; if (server.getExtensions()!=null && server.getExtensions().containsKey("tls_name")) { tls= (String) server.getExtensions().get("tls_name"); + } else { + throw new BusinessException("error openapi specification: protocol is https but without cert"); } portAndCertMap.put(443, tls); } @@ -271,8 +291,8 @@ private PathAndType processPathVariables(String path, Map processRoutes(OpenAPISpecification openApi) { - List routes = new ArrayList<>(); + private List processRoutes(OpenAPISpecification openApi) { + List routeInfos = new ArrayList<>(); Map paths = openApi.getPaths(); for (Map.Entry entry : paths.entrySet()) { @@ -280,6 +300,7 @@ private List processRoutes(OpenAPISpecification openApi) { OpenAPIPathDescription pathItem = entry.getValue(); Route route = new Route(); + route.setIsIngressMode(kubernetesClientService.isIngressWorkMode()); route.setName(path); RoutePredicate routePath = new RoutePredicate(RoutePredicateTypeEnum.EQUAL.toString(), path, false); route.setPath(routePath); @@ -291,11 +312,12 @@ private List processRoutes(OpenAPISpecification openApi) { routePath.setMatchValue(regexPath); routePath.setMatchType(RoutePredicateTypeEnum.REGULAR.toString()); } - setRouteProperties(route, pathItem); - routes.add(route); + List instances = new ArrayList<>(); + setRouteProperties(route, pathItem, instances); + routeInfos.add(new RouteInfo(route, instances)); } - return routes; + return routeInfos; } private List getFirstOperationParameters(OpenAPIPathDescription pathItem) { @@ -356,7 +378,7 @@ private String convertPathToRegex(String path, List parameters return regex.toString(); } - private void setRouteProperties(Route route, OpenAPIPathDescription pathItem) { + private void setRouteProperties(Route route, OpenAPIPathDescription pathItem, List instances) { List methods = new ArrayList<>(); if (pathItem.getGet() != null) { methods.add(V1HTTPRouteSpecMatches.MethodEnum.GET.toString()); @@ -384,14 +406,48 @@ private void setRouteProperties(Route route, OpenAPIPathDescription pathItem) { } route.setMethods(methods); - // backend - if (pathItem.getExtensions()!=null && pathItem.getExtensions().containsKey("x-backend")) { - String backendInfo = (String) pathItem.getExtensions().get("x-backend"); - if (backendInfo != null) { - route.setServices(Collections.singletonList(new UpstreamService(backendInfo, null, null, null))); + // TODO: backend -> weight + if (pathItem.getExtensions()!=null && pathItem.getExtensions().containsKey("x-backends")) { + @SuppressWarnings("unchecked") + Map> backends = (Map>) pathItem.getExtensions().get("x-backends"); + List services = new ArrayList<>(); + if (backends.get("name")!=null && backends.get("weight")!=null) { + List names = backends.get("name"); + List weights = backends.get("weight"); + for (int i = 0; i < names.size(); i++) { + UpstreamService service = new UpstreamService(); + service.setName(names.get(i)); + if (i < weights.size()) { + service.setWeight(Integer.parseInt(weights.get(i))); + } + services.add(service); + } + } + route.setServices(services); + } + // TODO: wasm -> + if (pathItem.getExtensions()!=null && pathItem.getExtensions().containsKey("policy")) { + @SuppressWarnings("unchecked") + Map> wasm = (Map>) pathItem.getExtensions().get("wasm"); + if (wasm.get("pluginName")!=null && wasm.get("enabled")!=null && wasm.get("rawConfigurations")!=null) { + List pluginNames = wasm.get("pluginName"); + List enabled = wasm.get("enabled"); + List rawConfigs = wasm.get("rawConfigurations"); + for (int i = 0; i < pluginNames.size(); i++) { + WasmPluginInstance instance = new WasmPluginInstance(); + instance.setScope(WasmPluginInstanceScope.ROUTE); + instance.setPluginName(pluginNames.get(i)); + if (i < enabled.size()) { + instance.setEnabled(Boolean.parseBoolean(enabled.get(i))); + } + if (i < rawConfigs.size()) { + instance.setRawConfigurations(rawConfigs.get(i)); + } + instances.add(instance); + } } } - // TODO: wasm + } private void addOrUpdateDomains(List domainInfos) { @@ -400,8 +456,10 @@ private void addOrUpdateDomains(List domainInfos) { } } - private void addRoutes(List routes, Map paths, List domainInfos) { - for (Route route : routes){ + private void addRoutes(List routeInfos, Map paths, List domainInfos) { + for (RouteInfo routeInfo : routeInfos){ + Route route = routeInfo.route; + List instances = routeInfo.instances; String path = route.getName(); String matchType = route.getPath().getMatchType(); String matchValue = route.getPath().getMatchValue(); @@ -422,6 +480,12 @@ private void addRoutes(List routes, Map p route.setName(KubernetesUtil.normalizeRouteName(host+path)); route.setDomains(Collections.singletonList(host)); routeService.add(route); + if (CollectionUtils.isNotEmpty(instances)) { + for (WasmPluginInstance instance: instances) { + instance.setTarget(KubernetesUtil.normalizeRouteName(host+path)); + wasmPluginInstanceService.addOrUpdate(instance); + } + } } } } else { @@ -436,6 +500,12 @@ private void addRoutes(List routes, Map p route.getPath().setMatchType(RoutePredicateTypeEnum.REGULAR.toString()); } routeService.add(route); + if (CollectionUtils.isNotEmpty(instances)) { + for (WasmPluginInstance instance: instances) { + instance.setTarget(KubernetesUtil.normalizeRouteName(domainInfo.domain.getName()+path)); + wasmPluginInstanceService.addOrUpdate(instance); + } + } } } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/RouteServiceImpl.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/RouteServiceImpl.java index d3bda5c4..81a104ae 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/RouteServiceImpl.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/RouteServiceImpl.java @@ -18,7 +18,10 @@ import com.alibaba.higress.sdk.constant.HigressConstants; import com.alibaba.higress.sdk.constant.Separators; +import com.alibaba.higress.sdk.model.Domain; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.gateways.V1Gateway; import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRoute; +import io.kubernetes.client.openapi.models.V1ConfigMap; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -111,7 +114,7 @@ public Route query(String routeName) { @Override public Route add(Route route) { - if(kubernetesClientService.isIngressWorkMode()){ + if(route.getIsIngressMode()){ V1Ingress ingress = kubernetesModelConverter.route2Ingress(route); V1Ingress newIngress; try { @@ -125,6 +128,7 @@ public Route add(Route route) { } return kubernetesModelConverter.ingress2Route(newIngress); } else { + createIfDomainIsNotGateway(route.getDomains()); V1HTTPRoute httpRoute = kubernetesModelConverter.route2HttpRoute(route); V1HTTPRoute newHttpRoute; try { @@ -147,14 +151,7 @@ public Route update(Route route) { if (StringUtils.isEmpty(name)) { throw new IllegalArgumentException("Route name must not be null"); } - V1Ingress findIngress; - try { - findIngress = kubernetesClientService.readIngress(name); - } catch (ApiException e) { - throw new BusinessException( - "Error occurs when read ingress by route with name: " + route.getName(), e); - } - if (findIngress != null) { + if (route.getIsIngressMode()) { V1Ingress ingress = kubernetesModelConverter.route2Ingress(route); V1Ingress updatedIngress; try { @@ -167,15 +164,8 @@ public Route update(Route route) { "Error occurs when updating the ingress generated by route with name: " + route.getName(), e); } return kubernetesModelConverter.ingress2Route(updatedIngress); - } - V1HTTPRoute findHttpRoute; - try { - findHttpRoute = kubernetesClientService.readHttpRoute(name); - } catch (ApiException e) { - throw new BusinessException( - "Error occurs when read httpRoute generated by route with name: " + route.getName(), e); - } - if (findHttpRoute != null) { + } else { + createIfDomainIsNotGateway(route.getDomains()); V1HTTPRoute httpRoute = kubernetesModelConverter.route2HttpRoute(route); V1HTTPRoute updatedHttpRoute; try { @@ -189,7 +179,6 @@ public Route update(Route route) { } return kubernetesModelConverter.httpRoute2Route(updatedHttpRoute); } - return null; } @Override @@ -211,4 +200,44 @@ public void delete(String name) { } wasmPluginInstanceService.deleteAll(WasmPluginInstanceScope.ROUTE, name); } + public void createIfDomainIsNotGateway(List domains) { + if (domains.isEmpty()) { + return; + } + // if domain is ingress-style, create a gateway cr + String domainName = domains.get(0); + V1ConfigMap configMap; + try { + configMap = kubernetesClientService.readConfigMap(kubernetesModelConverter.domainName2ConfigMapName(domainName)); + } catch (ApiException e) { + throw new BusinessException("Error occurs when reading config map associated with domain " + domainName, + e); + } + if (configMap == null) { + return; + } + Domain domain = kubernetesModelConverter.configMap2Domain(configMap); + if (domain.getIsIngressMode()) { + domain.setIsIngressMode(Boolean.FALSE); + V1ConfigMap domainConfigMap = kubernetesModelConverter.domain2ConfigMap(domain); + V1ConfigMap updatedConfigMap; + try { + updatedConfigMap = kubernetesClientService.replaceConfigMap(domainConfigMap); + } catch (ApiException e) { + if (e.getCode() == HttpStatus.CONFLICT) { + throw new ResourceConflictException(); + } + throw new BusinessException( + "Error occurs when replacing the ConfigMap generated by domain: " + domain.getName(), e); + } + domain = kubernetesModelConverter.configMap2Domain(updatedConfigMap); + V1Gateway gateway = kubernetesModelConverter.domain2Gateway(domain); + gateway.getMetadata().setResourceVersion(StringUtils.EMPTY); + try { + kubernetesClientService.createGateway(gateway); + } catch (ApiException e) { + throw new BusinessException("Error occurs when creating a Gateway", e); + } + } + } } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/WasmPluginInstanceServiceImpl.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/WasmPluginInstanceServiceImpl.java index 4f18873a..07bd93d0 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/WasmPluginInstanceServiceImpl.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/WasmPluginInstanceServiceImpl.java @@ -24,8 +24,10 @@ import com.alibaba.higress.sdk.model.WasmPluginInstanceScope; import com.alibaba.higress.sdk.service.kubernetes.KubernetesClientService; import com.alibaba.higress.sdk.service.kubernetes.KubernetesModelConverter; +import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRoute; import com.alibaba.higress.sdk.service.kubernetes.crd.wasm.V1alpha1WasmPlugin; import io.kubernetes.client.openapi.ApiException; +import io.kubernetes.client.openapi.models.V1Ingress; import io.swagger.v3.core.util.Yaml; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; @@ -102,7 +104,7 @@ public WasmPluginInstance addOrUpdate(WasmPluginInstance instance) { throw new IllegalArgumentException( "instance.target must not be null or empty when scope is not GLOBAL."); } - if (!kubernetesClientService.isIngressWorkMode()) { + if (!isTargetIngressWorkMode(target)) { if (!HigressConstants.NS_DEFAULT.equals(kubernetesClientService.httpRouteNameSpace)) { target = kubernetesClientService.httpRouteNameSpace + Separators.SLASH + target; } @@ -169,6 +171,28 @@ public WasmPluginInstance addOrUpdate(WasmPluginInstance instance) { return kubernetesModelConverter.getWasmPluginInstanceFromCr(result, scope, target); } + public Boolean isTargetIngressWorkMode(String target) { + V1Ingress ingress; + try { + ingress = kubernetesClientService.readIngress(target); + } catch (ApiException e) { + throw new BusinessException("Error occurs when reading the Ingress with name: " + target, e); + } + if (ingress != null) { + return Boolean.TRUE; + } + V1HTTPRoute httpRoute; + try { + httpRoute = kubernetesClientService.readHttpRoute(target); + } catch (ApiException e) { + throw new BusinessException("Error occurs when reading the HttpRoute with name: " + target, e); + } + if (httpRoute != null) { + return Boolean.FALSE; + } + return Boolean.TRUE; + } + @Override public void delete(WasmPluginInstanceScope scope, String target, String pluginName) { List existedCrs; diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java index 1988f681..7c2c600b 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesClientService.java @@ -228,6 +228,30 @@ public boolean isIngressV1Supported() { public boolean isIngressWorkMode() { return workMode.equals("ingress"); } + + public Boolean setIngressMode(Boolean isIngressMode) throws ApiException { + if (isIngressMode == null) { + isIngressMode = true; // default to ingress mode + } + + V1ConfigMap higressConfig = readConfigMap(HigressConstants.DEFAULT_CONFIG); + if (higressConfig == null) { + throw new BusinessException("ConfigMap not found: " + HigressConstants.DEFAULT_CONFIG); + } + + Map data = higressConfig.getData(); + if (data == null) { + data = new HashMap<>(); + higressConfig.setData(data); + } + + data.put("workMode", isIngressMode ? "ingress" : "gateway"); + + replaceConfigMap(higressConfig); + getIngressOrGatewayMode(); + return isIngressWorkMode(); + } + public boolean isNamespaceProtected(String namespace) { return KubernetesConstants.KUBE_SYSTEM_NS.equals(namespace) || controllerNamespace.equals(namespace); } diff --git a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java index 24ad7203..54190c31 100644 --- a/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java +++ b/backend/sdk/src/main/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverter.java @@ -270,6 +270,7 @@ public boolean isHttpRouteSupported(V1HTTPRoute httpRoute) { public Route ingress2Route(V1Ingress ingress) { Route route = new Route(); + route.setIsIngressMode(Boolean.TRUE); fillRouteMetadata(route, ingress.getMetadata()); fillRouteInfo(route, ingress.getMetadata(), ingress.getSpec()); fillCustomConfigs(route, ingress.getMetadata()); @@ -289,6 +290,7 @@ public V1Ingress route2Ingress(Route route) { public Route httpRoute2Route(V1HTTPRoute httpRoute){ Route route = new Route(); + route.setIsIngressMode(Boolean.FALSE); fillRouteMetadata(route, httpRoute.getMetadata()); fillRouteInfoFromHttpRoute(route, httpRoute.getSpec(), httpRoute.getMetadata()); fillCustomConfigs(route, httpRoute.getMetadata()); @@ -390,6 +392,8 @@ public V1ConfigMap domain2ConfigMap(Domain domain) { configMap.put(CommonKey.DOMAIN, domain.getName()); configMap.put(KubernetesConstants.K8S_CERT, JSON.toJSONString(domain.getPortAndCertMap())); configMap.put(KubernetesConstants.K8S_ENABLE_HTTPS, domain.getEnableHttps()); + configMap.put(KubernetesConstants.WorkMode.KEY, + domain.getIsIngressMode() ? KubernetesConstants.WorkMode.INGRESS : KubernetesConstants.WorkMode.GATEWAY); domainConfigMap.data(configMap); return domainConfigMap; @@ -409,12 +413,18 @@ public Domain configMap2Domain(V1ConfigMap configMap) { } domain.setName(configMapData.get(CommonKey.DOMAIN)); String certData = configMapData.get(KubernetesConstants.K8S_CERT); + domain.setIsIngressMode(Boolean.TRUE); try { domain.setPortAndCertMap(JSON.parseObject(certData, Map.class)); + String workMode = configMapData.get(KubernetesConstants.WorkMode.KEY); + // if workMode is null -> set to true(ingress) + domain.setIsIngressMode(!KubernetesConstants.WorkMode.GATEWAY.equals(workMode)); }catch(JSONException e){ // ingress-style cert (Only String) -> turn to map[443:certName] Map portCertMap = new HashMap<>(); - portCertMap.put(443, certData); + if (StringUtils.isNotEmpty(certData)) { + portCertMap.put(443, certData); + } domain.setPortAndCertMap(portCertMap); } @@ -1572,10 +1582,11 @@ private void fillHttpRouteSpec(V1HTTPRoute httpRoute, Route route) { } V1HTTPRouteSpecParentRefs parentRef = new V1HTTPRouteSpecParentRefs(); if (!domains.isEmpty()) { - if (!Separators.ASTERISK.equals(domains.get(0))) { - spec.addHostnamesItem(domains.get(0)); + String domainName = domains.get(0); + if (!Separators.ASTERISK.equals(domainName)) { + spec.addHostnamesItem(domainName); } - parentRef.setName(domainName2GatewayName(domains.get(0))); + parentRef.setName(domainName2GatewayName(domainName)); parentRef.setNamespace(kubernetesClientService.gatewayNameSpace); } spec.addParentRefsItem(parentRef); @@ -1796,7 +1807,7 @@ private void fillHttpRouteFilters(V1HTTPRouteSpecRules specRule, Route route){ if (headerControl.getResponse() != null) { V1HTTPRouteSpecFilters filter = new V1HTTPRouteSpecFilters(); V1HTTPRouteSpecResponseHeaderModifier responseHeaderModifier = new V1HTTPRouteSpecResponseHeaderModifier(); - HeaderControlStageConfig config = headerControl.getRequest(); + HeaderControlStageConfig config = headerControl.getResponse(); fillHeaderModifier(config, null, responseHeaderModifier, false); filter.setResponseHeaderModifier(responseHeaderModifier); filter.setType(V1HTTPRouteSpecFilters.TypeEnum.RESPONSEHEADERMODIFIER); @@ -1809,6 +1820,9 @@ private void fillHttpRouteFilters(V1HTTPRouteSpecRules specRule, Route route){ } private void fillHeaderModifier(HeaderControlStageConfig config, V1HTTPRouteSpecRequestHeaderModifier requestHeader, V1HTTPRouteSpecResponseHeaderModifier responseHeader, Boolean isRequest){ + if (config == null) { + return; + } if (CollectionUtils.isNotEmpty(config.getAdd())) { for (Header header : config.getAdd()) { V1HTTPRouteSpecRequestHeaderModifierAdd add = new V1HTTPRouteSpecRequestHeaderModifierAdd(); diff --git a/backend/sdk/src/test/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverterTest.java b/backend/sdk/src/test/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverterTest.java index eb405c40..5efb8fda 100644 --- a/backend/sdk/src/test/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverterTest.java +++ b/backend/sdk/src/test/java/com/alibaba/higress/sdk/service/kubernetes/KubernetesModelConverterTest.java @@ -20,7 +20,7 @@ import java.util.Map; import java.util.regex.Pattern; -import com.alibaba.higress.sdk.constant.HigressConstants; + import com.alibaba.higress.sdk.model.Domain; import com.alibaba.higress.sdk.model.route.Header; import com.alibaba.higress.sdk.model.route.HeaderControlConfig; @@ -47,7 +47,7 @@ import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecRules; import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecUrlRewrite; import com.alibaba.higress.sdk.service.kubernetes.crd.gatewayapi.httproute.V1HTTPRouteSpecUrlRewritePath; -import org.apache.commons.collections4.CollectionUtils; + import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; @@ -203,6 +203,7 @@ public void ingress2RouteTestPrefixPathSingleService() { Route route = converter.ingress2Route(ingress); Route expectedRoute = buildBasicRoute(); + expectedRoute.setIsIngressMode(true); expectedRoute.setName(metadata.getName()); RoutePredicate pathPredicate = expectedRoute.getPath(); pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); @@ -229,6 +230,7 @@ public void ingress2RouteTestPrefixPathSingleServiceWithWeight() { Route route = converter.ingress2Route(ingress); Route expectedRoute = buildBasicRoute(); + expectedRoute.setIsIngressMode(true); expectedRoute.setName(metadata.getName()); RoutePredicate pathPredicate = expectedRoute.getPath(); pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); @@ -255,6 +257,7 @@ public void ingress2RouteTestPrefixPathSingleServiceWithPort() { Route route = converter.ingress2Route(ingress); Route expectedRoute = buildBasicRoute(); + expectedRoute.setIsIngressMode(true); expectedRoute.setName(metadata.getName()); RoutePredicate pathPredicate = expectedRoute.getPath(); pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); @@ -281,6 +284,7 @@ public void ingress2RouteTestPrefixPathSingleServiceWithPortAndVersion() { Route route = converter.ingress2Route(ingress); Route expectedRoute = buildBasicRoute(); + expectedRoute.setIsIngressMode(true); expectedRoute.setName(metadata.getName()); RoutePredicate pathPredicate = expectedRoute.getPath(); pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); @@ -308,6 +312,7 @@ public void ingress2RouteTestPrefixPathMultipleServices() { Route route = converter.ingress2Route(ingress); Route expectedRoute = buildBasicRoute(); + expectedRoute.setIsIngressMode(true); expectedRoute.setName(metadata.getName()); RoutePredicate pathPredicate = expectedRoute.getPath(); pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); @@ -336,6 +341,7 @@ public void ingress2RouteTestExactPathSingleService() { Route route = converter.ingress2Route(ingress); Route expectedRoute = buildBasicRoute(); + expectedRoute.setIsIngressMode(true); expectedRoute.setName(metadata.getName()); RoutePredicate pathPredicate = expectedRoute.getPath(); pathPredicate.setMatchType(RoutePredicateTypeEnum.EQUAL.toString()); @@ -364,6 +370,7 @@ public void ingress2RouteTestRegularPathSingleService() { Route route = converter.ingress2Route(ingress); Route expectedRoute = buildBasicRoute(); + expectedRoute.setIsIngressMode(true); expectedRoute.setName(metadata.getName()); RoutePredicate pathPredicate = expectedRoute.getPath(); pathPredicate.setMatchType(RoutePredicateTypeEnum.REGULAR.toString()); @@ -789,6 +796,7 @@ public void httpRoute2RouteTestBasic() { Route route = converter.httpRoute2Route(httpRoute); Route expectedRoute = buildBasicRoute(); + expectedRoute.setIsIngressMode(false); expectedRoute.setName("test-route"); expectedRoute.setServices(Collections.singletonList(new UpstreamService())); expectedRoute.setCors(null); @@ -811,6 +819,7 @@ public void httpRoute2RouteTestWithDomain() { Route route = converter.httpRoute2Route(httpRoute); Route expectedRoute = buildBasicRoute(); + expectedRoute.setIsIngressMode(false); expectedRoute.setDomains(Collections.singletonList("example.com")); expectedRoute.setServices(Collections.singletonList(new UpstreamService())); expectedRoute.setCors(null); @@ -836,6 +845,7 @@ public void httpRoute2RouteTestWithSinglePath() { Route route = converter.httpRoute2Route(httpRoute); Route expectedRoute = buildBasicRoute(); + expectedRoute.setIsIngressMode(false); expectedRoute.setServices(Collections.singletonList(new UpstreamService())); expectedRoute.setCors(null); expectedRoute.setCustomConfigs(null); @@ -860,6 +870,7 @@ public void httpRoute2RouteTestWithHeaders() { Route route = converter.httpRoute2Route(httpRoute); Route expectedRoute = buildBasicRoute(); + expectedRoute.setIsIngressMode(false); expectedRoute.setServices(Collections.singletonList(new UpstreamService())); expectedRoute.setCors(null); expectedRoute.setCustomConfigs(null); @@ -889,6 +900,7 @@ public void httpRoute2RouteTestWithQueryParams() { Route route = converter.httpRoute2Route(httpRoute); Route expectedRoute = buildBasicRoute(); + expectedRoute.setIsIngressMode(false); expectedRoute.setServices(Collections.singletonList(new UpstreamService())); expectedRoute.setCors(null); expectedRoute.setCustomConfigs(null); @@ -953,6 +965,7 @@ public void httpRoute2RouteTestWithMethods() { Route route = converter.httpRoute2Route(httpRoute); Route expectedRoute = buildBasicRoute(); + expectedRoute.setIsIngressMode(false); expectedRoute.setServices(Collections.singletonList(new UpstreamService())); expectedRoute.setCors(null); expectedRoute.setCustomConfigs(null); @@ -984,6 +997,7 @@ public void httpRoute2RouteTestWithUrlRewrite() { Route route = converter.httpRoute2Route(httpRoute); Route expectedRoute = buildBasicRoute(); + expectedRoute.setIsIngressMode(false); RoutePredicate pathPredicate = expectedRoute.getPath(); pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); pathPredicate.setMatchValue("/"); @@ -1019,6 +1033,7 @@ public void httpRoute2RouteTestWithRequestHeaderModifier() { Route route = converter.httpRoute2Route(httpRoute); Route expectedRoute = buildBasicRoute(); + expectedRoute.setIsIngressMode(false); RoutePredicate pathPredicate = expectedRoute.getPath(); pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); pathPredicate.setMatchValue("/"); @@ -1062,6 +1077,7 @@ public void httpRoute2RouteTestWithResponseHeaderModifier() { Route route = converter.httpRoute2Route(httpRoute); Route expectedRoute = buildBasicRoute(); + expectedRoute.setIsIngressMode(false); RoutePredicate pathPredicate = expectedRoute.getPath(); pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); pathPredicate.setMatchValue("/"); @@ -1119,6 +1135,7 @@ public void httpRoute2RouteTestWithBothFilters() { Route route = converter.httpRoute2Route(httpRoute); Route expectedRoute = buildBasicRoute(); + expectedRoute.setIsIngressMode(false); RoutePredicate pathPredicate = expectedRoute.getPath(); pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); pathPredicate.setMatchValue("/"); @@ -1174,6 +1191,7 @@ public void httpRoute2RouteTestWithRegularExpressionHeaders() { Route route = converter.httpRoute2Route(httpRoute); Route expectedRoute = buildBasicRoute(); + expectedRoute.setIsIngressMode(false); RoutePredicate pathPredicate = expectedRoute.getPath(); pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); pathPredicate.setMatchValue("/"); @@ -1224,6 +1242,7 @@ public void httpRoute2RouteTestWithRegularExpressionQueryParams() { Route route = converter.httpRoute2Route(httpRoute); Route expectedRoute = buildBasicRoute(); + expectedRoute.setIsIngressMode(false); RoutePredicate pathPredicate = expectedRoute.getPath(); pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); pathPredicate.setMatchValue("/"); @@ -1287,6 +1306,7 @@ public void httpRoute2RouteTestWithBackendRefs() { Route route = converter.httpRoute2Route(httpRoute); Route expectedRoute = buildBasicRoute(); + expectedRoute.setIsIngressMode(false); RoutePredicate pathPredicate = expectedRoute.getPath(); pathPredicate.setMatchType(RoutePredicateTypeEnum.PRE.toString()); pathPredicate.setMatchValue("/"); diff --git a/frontend/src/components/AvatarDropdown/index.tsx b/frontend/src/components/AvatarDropdown/index.tsx index 2334854e..3d089ba3 100644 --- a/frontend/src/components/AvatarDropdown/index.tsx +++ b/frontend/src/components/AvatarDropdown/index.tsx @@ -1,6 +1,6 @@ import { logout } from '@/services'; import store from '@/store'; -import { LockOutlined, LogoutOutlined } from '@ant-design/icons'; +import { LockOutlined, LogoutOutlined, SettingOutlined } from '@ant-design/icons'; import { Avatar, Dropdown } from 'antd'; import { definePageConfig, history } from 'ice'; import type { MenuInfo } from 'rc-menu/lib/interface'; @@ -36,6 +36,10 @@ const AvatarDropdown: React.FC = ({ name, avatar }) => { history?.push(`/user/changePassword`); }, []); + const onHigressConfigClick = useCallback((event: MenuInfo) => { + history?.push(`/higress-config`); + }, []); + const menu = { items: [ { @@ -52,6 +56,13 @@ const AvatarDropdown: React.FC = ({ name, avatar }) => { onClick: onLogoutClick, className: styles.menu, }, + { + key: 'higressConfig', + label: t('higressConfig.title'), + icon: , + onClick: onHigressConfigClick, + className: styles.menu, + }, ], }; return ( diff --git a/frontend/src/interfaces/domain.ts b/frontend/src/interfaces/domain.ts index ea425877..404c8e35 100644 --- a/frontend/src/interfaces/domain.ts +++ b/frontend/src/interfaces/domain.ts @@ -1,14 +1,16 @@ export interface Domain { name: string; version?: string; - certIdentifier?: string; + isIngressMode?: boolean; enableHttps?: string; + portAndCertMap?: Record; [propName: string]: any; } export const Protocol = { http: 'HTTP', https: 'HTTPS', + both: 'HTTP', }; export enum EnableHttpsValue { diff --git a/frontend/src/interfaces/route.ts b/frontend/src/interfaces/route.ts index 335dcbf3..843d376e 100644 --- a/frontend/src/interfaces/route.ts +++ b/frontend/src/interfaces/route.ts @@ -69,6 +69,7 @@ export interface Route { version?: string; domains: string[]; path: RoutePredicate; + isIngressMode?: boolean; methods?: string[]; headers?: KeyedRoutePredicate[]; urlParams?: KeyedRoutePredicate[]; diff --git a/frontend/src/locales/en-US/translation.json b/frontend/src/locales/en-US/translation.json index 0e9ac1c1..6426fa2b 100644 --- a/frontend/src/locales/en-US/translation.json +++ b/frontend/src/locales/en-US/translation.json @@ -15,7 +15,8 @@ "routeConfig": "Route Config", "domainManagement": "Domain Management", "certManagement": "Certificate Management", - "pluginManagement": "Plugin Management" + "pluginManagement": "Plugin Management", + "config": "Higress Config" }, "index": { "title": "Higress Console" @@ -51,7 +52,8 @@ "name": "Domain", "protocol": "Protocol", "certificate": "Certificate", - "action": "Action" + "action": "Action", + "port": "Port" }, "defaultDomain": "Default Domain", "createDomain": "Create Domain", @@ -71,7 +73,15 @@ "certificatePlaceholder": "Please input the certificate identifier.", "mustHttps": "Force HTTPS", "mustHttpsTooltip": "Only certificates provided by SSL Certificates Service of Alibaba Clound are supported now.", - "mustHttpsCheckboxTooltip": "Only HTTPS (port 443) service is available. Requests sent to HTTP (port 80) service will be redirected to the corresponding HTTPS (port 443) service" + "mustHttpsCheckboxTooltip": "Only HTTPS (port 443) service is available. Requests sent to HTTP (port 80) service will be redirected to the corresponding HTTPS (port 443) service", + "portAndCertMap": "Port and Certificate Mapping", + "portAndCertMapTooltip": "The port and certificate mapping is used to specify the port and certificate for each port. If the port is not specified, the default certificate will be used.", + "addPortAndCert": "add", + "portAndCertMapRequired": "Please add at least one port and certificate mapping.", + "portRequired": "Port cannot be empty", + "portDuplicate": "Port cannot be duplicated", + "certificateRequiredWhenHttps": "Certificate is required when using HTTPS protocol", + "ingressModeConstraint": "Ingress mode only supports port 80 (HTTP) or port 443 (HTTPS)" } }, "dashboard": { @@ -350,7 +360,9 @@ "customConfigsTip": "Click this \"?\" to view the configuration guide.", "targetService": "Target Service", "targetServiceRequired": "Please choose the target service.", - "targetServiceNamedPlaceholder": "Search target service by name. Multiple selections are allowed." + "targetServiceNamedPlaceholder": "Search target service by name. Multiple selections are allowed.", + "weightTip": "Weight of the target service", + "weightMustBeNumber": "Weight must be a number" } }, "chart": { @@ -498,5 +510,15 @@ "tbd": "Still in development. To be released soon...", "yes": "Yes", "no": "No" + }, + "higressConfig": { + "title": "Work Mode Configuration", + "higressWorkMode": "Higress Work Mode", + "modeRequired": "Please select Higress Work Mode", + "gatewayMode": "Gateway API Mode", + "ingressMode": "Ingress Mode", + "fetchError": "Failed to fetch Higress Work Mode", + "updateSuccess": "Successfully updated Higress Work Mode", + "updateError": "Failed to update Higress Work Mode" } } diff --git a/frontend/src/locales/zh-CN/translation.json b/frontend/src/locales/zh-CN/translation.json index 6dd0a786..2dda0d98 100644 --- a/frontend/src/locales/zh-CN/translation.json +++ b/frontend/src/locales/zh-CN/translation.json @@ -15,7 +15,8 @@ "routeConfig": "路由配置", "domainManagement": "域名管理", "certManagement": "证书管理", - "pluginManagement": "插件配置" + "pluginManagement": "插件配置", + "config": "Higress 配置" }, "index": { "title": "Higress Console" @@ -51,7 +52,8 @@ "name": "域名", "protocol": "协议", "certificate": "证书", - "action": "操作" + "action": "操作", + "port": "端口" }, "defaultDomain": "缺省域名", "createDomain": "创建域名", @@ -71,7 +73,15 @@ "certificatePlaceholder": "请输入证书", "mustHttps": "是否强制HTTPS", "mustHttpsTooltip": "目前支持阿里云SSL证书服务上的证书", - "mustHttpsCheckboxTooltip": "只生效 HTTPS(443端口),HTTP(80端口)访问将被重定向至 HTTPS(443端口)" + "mustHttpsCheckboxTooltip": "只生效 HTTPS(443端口),HTTP(80端口)访问将被重定向至 HTTPS(443端口)", + "portAndCertMap": "端口和证书映射", + "portAndCertMapTooltip": "端口和证书映射用于指定每个端口的证书。如果是ingress模式,默认对80端口使用HTTP协议,443端口使用HTTPS协议。", + "addPortAndCert": "添加", + "portAndCertMapRequired": "请至少添加一个端口和证书映射", + "portRequired": "端口号不能为空", + "portDuplicate": "不能有重复的端口号", + "certificateRequiredWhenHttps": "使用HTTPS协议时必须选择证书", + "ingressModeConstraint": "Ingress模式下只能使用80端口(HTTP)或443端口(HTTPS)" } }, "dashboard": { @@ -350,7 +360,9 @@ "customConfigsTip": "点击问号查看注解配置说明", "targetService": "目标服务", "targetServiceRequired": "请选择目标服务", - "targetServiceNamedPlaceholder": "搜索服务名称选择服务,可多选" + "targetServiceNamedPlaceholder": "搜索服务名称选择服务,可多选", + "weightTip": "目标服务的权重", + "weightMustBeNumber": "权重必须为数字" } }, "chart": { @@ -498,5 +510,15 @@ "tbd": "页面开发中,即将推出...", "yes": "是", "no": "否" + }, + "higressConfig": { + "title": "配置工作模式", + "higressWorkMode": "Higress 工作模式", + "modeRequired": "请选择 HigressWorkMode 工作模式", + "gatewayMode": "gateway api模式", + "ingressMode": "ingress模式", + "fetchError": "获取 Higress 工作模式失败", + "updateSuccess": "更新 Higress 工作模式成功", + "updateError": "更新 Higress 工作模式失败" } } \ No newline at end of file diff --git a/frontend/src/pages/_defaultProps.tsx b/frontend/src/pages/_defaultProps.tsx index e1387880..6765887e 100644 --- a/frontend/src/pages/_defaultProps.tsx +++ b/frontend/src/pages/_defaultProps.tsx @@ -6,6 +6,7 @@ import { UnorderedListOutlined, SafetyCertificateOutlined, WindowsOutlined, + SettingOutlined, } from '@ant-design/icons'; export default { @@ -35,6 +36,17 @@ export default { }, ], }, + { + name: 'higressConfig.title', + path: '/higress-config', + hideFromMenu: true, + routes: [ + { + name: 'higressConfig.title', + path: '/higress-config', + }, + ], + }, { name: 'menu.dashboard', path: '/dashboard', diff --git a/frontend/src/pages/domain/components/DomainForm/index.tsx b/frontend/src/pages/domain/components/DomainForm/index.tsx index b56583a4..38b57036 100644 --- a/frontend/src/pages/domain/components/DomainForm/index.tsx +++ b/frontend/src/pages/domain/components/DomainForm/index.tsx @@ -7,13 +7,19 @@ import { useRequest } from 'ahooks'; import { Checkbox, Form, Input, Select, Tooltip } from 'antd'; import React, { forwardRef, useEffect, useImperativeHandle, useState } from 'react'; import { useTranslation } from 'react-i18next'; +import DomainGroup from '../DomainGroup'; const { Option } = Select; -const DomainForm: React.FC = forwardRef((props, ref) => { +interface DomainFormProps { + value?: any; + isIngressMode?: boolean; +} + +const DomainForm = forwardRef((props: DomainFormProps, ref) => { const { t } = useTranslation(); - const { value } = props; + const { value, isIngressMode } = props; const [form] = Form.useForm(); const [protocol, setProtocol] = useState(Protocol.http); const [certificateOptions, setCertificateOptions] = useState([]); @@ -32,12 +38,12 @@ const DomainForm: React.FC = forwardRef((props, ref) => { setCertificateOptions(_certificateOptions); if (value) { - const { name, enableHttps } = value; + const { name, enableHttps, portAndCertMap } = value; const protocolValue = enableHttps !== EnableHttpsValue.off ? Protocol.https : Protocol.http; setProtocol(protocolValue); const values = { name, protocol: protocolValue }; - if (value.certIdentifier) { - Object.assign(values, { certIdentifier: value.certIdentifier }); + if (portAndCertMap) { + Object.assign(values, { portAndCertMap }); } if (enableHttps === EnableHttpsValue.force) { Object.assign(values, { mustHttps: [true] }); @@ -90,7 +96,7 @@ const DomainForm: React.FC = forwardRef((props, ref) => { ) } - { ) : null - } - + } */} + { + if (!portAndCertMapValue || portAndCertMapValue.length === 0) { + return Promise.reject(new Error(String(t('domain.domainForm.portAndCertMapRequired')))); + } + + // Check for empty ports + const hasEmptyPort = portAndCertMapValue.some(item => !item.port); + if (hasEmptyPort) { + return Promise.reject(new Error(String(t('domain.domainForm.portRequired')))); + } + + // Check for duplicate ports + const ports = portAndCertMapValue.map(item => item.port); + const hasDuplicates = ports.length !== new Set(ports).size; + if (hasDuplicates) { + return Promise.reject(new Error(String(t('domain.domainForm.portDuplicate')))); + } + + // Check if HTTPS protocol has certificate + const hasHttpsWithoutCert = portAndCertMapValue.some((item) => { + return item.protocol === 'HTTPS' && !item.certificate; + }); + if (hasHttpsWithoutCert) { + return Promise.reject(new Error(String(t('domain.domainForm.certificateRequiredWhenHttps')))); + } + + // Validate ingress mode constraints + if (isIngressMode) { + const invalidPorts = portAndCertMapValue.some((item) => { + return (item.port !== 80 && item.port !== 443) || + (item.port === 80 && item.protocol !== 'HTTP') || + (item.port === 443 && item.protocol !== 'HTTPS'); + }); + if (invalidPorts) { + return Promise.reject(new Error(String(t('domain.domainForm.ingressModeConstraint')))); + } + } + + return Promise.resolve(); + }, + }, + ]} + > + + + ); }); diff --git a/frontend/src/pages/domain/components/DomainGroup/index.tsx b/frontend/src/pages/domain/components/DomainGroup/index.tsx new file mode 100644 index 00000000..4fe6b6b6 --- /dev/null +++ b/frontend/src/pages/domain/components/DomainGroup/index.tsx @@ -0,0 +1,281 @@ +import React, { useContext, useState } from 'react'; +import { Table, Form, InputNumber, Select, Button, message, Checkbox, Tooltip } from 'antd'; +import { PlusOutlined, DeleteOutlined, QuestionCircleOutlined } from '@ant-design/icons'; +import { useTranslation } from 'react-i18next'; +import { uniqueId } from 'lodash'; + +const { Option } = Select; + +const EditableContext = React.createContext(null); + +interface DomainGroupProps { + value?: Record; + onChange?: (value: any[]) => void; + certificateOptions: Array<{ label: string; value: string }>; + isIngressMode?: boolean; + mustHttps?: boolean[]; + onMustHttpsChange?: (value: boolean[]) => void; +} + +interface DataType { + uid: string; + port: number; + protocol: 'HTTP' | 'HTTPS'; + certificate: string; +} + +const EditableRow: React.FC = ({ ...props }) => { + const [form] = Form.useForm(); + return ( +
+ + + +
+ ); +}; + +interface EditableCellProps { + title: React.ReactNode; + editable: boolean; + children: React.ReactNode; + dataIndex: keyof DataType; + record: DataType; + handleSave: (record: DataType) => void; + inputType: 'number' | 'select'; + selectOptions?: Array<{ label: string; value: string }>; + isIngressMode?: boolean; +} + +const EditableCell: React.FC = ({ + title, + editable, + children, + dataIndex, + record, + handleSave, + inputType, + selectOptions, + isIngressMode, + ...restProps +}) => { + const form = useContext(EditableContext); + + const save = async () => { + try { + const values = await form.validateFields(); + if (values.protocol === 'HTTP') { + values.certificate = ''; + } + if (isIngressMode) { + if (values.port === 80) { + values.protocol = 'HTTP'; + values.certificate = ''; + } + } + handleSave({ ...record, ...values }); + } catch (errInfo) { + // eslint-disable-next-line no-console + console.log('Save failed:', errInfo); + } + }; + + let childNode = children; + + if (editable) { + const isDisabled = dataIndex === 'certificate' && record.protocol === 'HTTP'; + + childNode = ( + + {inputType === 'number' ? ( + + ) : ( + + )} + + ); + } + + return {childNode}; +}; + +const DomainGroup: React.FC = ({ value, onChange, certificateOptions, isIngressMode, mustHttps, onMustHttpsChange }) => { + const { t } = useTranslation(); + + // change value to array + const valueArray: DataType[] = value ? Object.keys(value).map((port): DataType => ({ + uid: uniqueId(), + port: Number(port), + protocol: value[Number(port)] ? 'HTTPS' : 'HTTP' as const, + certificate: value[Number(port)] || '', + })) : []; + + const [dataSource, setDataSource] = useState(valueArray); + + const handleDelete = (uid: string) => { + const newData = dataSource.filter((item) => item.uid !== uid); + setDataSource(newData); + onChange?.(newData); + }; + + const handleAdd = () => { + const newData: DataType = { + uid: uniqueId(), + port: isIngressMode ? 80 : 80, + protocol: 'HTTP', + certificate: '', + }; + setDataSource([...dataSource, newData]); + onChange?.([...dataSource, newData]); + }; + + const handleSave = (row: DataType) => { + const newData = [...dataSource]; + const index = newData.findIndex((item) => row.uid === item.uid); + const item = newData[index]; + newData.splice(index, 1, { ...item, ...row }); + setDataSource(newData); + onChange?.(newData); + }; + + const hasHttp80AndHttps443 = dataSource.some(item => item.port === 80 && item.protocol === 'HTTP') && + dataSource.some(item => item.port === 443 && item.protocol === 'HTTPS'); + + const columns = [ + { + title: t('domain.columns.port'), + dataIndex: 'port', + width: '30%', + editable: true, + }, + { + title: t('domain.columns.protocol'), + dataIndex: 'protocol', + width: '30%', + editable: true, + }, + { + title: t('domain.columns.certificate'), + dataIndex: 'certificate', + width: '30%', + editable: true, + }, + { + title: t('domain.columns.action'), + dataIndex: 'action', + render: (_: any, record: DataType) => { + return dataSource.length >= 1 ? ( + handleDelete(record.uid)} /> + ) : null; + }, + }, + ]; + + const components = { + body: { + row: EditableRow, + cell: EditableCell, + }, + }; + + const columnsWithProps = columns.map((col) => { + if (!col.editable) { + return col; + } + return { + ...col, + onCell: (record: DataType) => ({ + record, + editable: col.editable, + dataIndex: col.dataIndex, + title: col.title, + inputType: col.dataIndex === 'port' ? 'number' : 'select', + selectOptions: (() => { + if (col.dataIndex === 'protocol') { + return [ + { label: 'HTTP', value: 'HTTP' }, + { label: 'HTTPS', value: 'HTTPS' }, + ]; + } + if (col.dataIndex === 'certificate') { + return certificateOptions; + } + return undefined; + })(), + handleSave, + isIngressMode, + }), + }; + }); + + return ( +
+ 'editable-row'} + bordered + dataSource={dataSource} + columns={columnsWithProps as any} + pagination={false} + /> + + {hasHttp80AndHttps443 && ( + + + {t('domain.domainForm.mustHttps')} + + + + + ), + value: true, + }, + ]} + /> + + )} + + ); +}; + +export default DomainGroup; diff --git a/frontend/src/pages/domain/index.tsx b/frontend/src/pages/domain/index.tsx index 2a339295..bedd28f8 100644 --- a/frontend/src/pages/domain/index.tsx +++ b/frontend/src/pages/domain/index.tsx @@ -1,11 +1,11 @@ /* eslint-disable */ // @ts-nocheck import { DEFAULT_DOMAIN, Domain, DomainResponse, EnableHttpsValue, Protocol } from '@/interfaces/domain'; -import { addGatewayDomain, deleteGatewayDomain, getGatewayDomains, updateGatewayDomain } from '@/services'; +import { getIngressWorkMode, addGatewayDomain, deleteGatewayDomain, getGatewayDomains, updateGatewayDomain } from '@/services'; import { ExclamationCircleOutlined, RedoOutlined } from '@ant-design/icons'; import { PageContainer } from '@ant-design/pro-layout'; import { useRequest } from 'ahooks'; -import { Button, Col, Drawer, Form, Modal, Row, Space, Table } from 'antd'; +import { Button, Col, Drawer, Form, Modal, Row, Space, Table, message } from 'antd'; import React, { useEffect, useRef, useState } from 'react'; import { useTranslation, Trans } from 'react-i18next'; import DomainForm from './components/DomainForm'; @@ -20,7 +20,7 @@ interface DomainFormProps { const DomainList: React.FC = () => { const { t } = useTranslation(); - + const { data: currentIngressMode } = useRequest(getIngressWorkMode); const columns = [ { title: t('domain.columns.name'), @@ -38,9 +38,13 @@ const DomainList: React.FC = () => { }, { title: t('domain.columns.certificate'), - dataIndex: 'certIdentifier', - key: 'certIdentifier', - render: (value) => value || '-', + dataIndex: 'portAndCertMap', + key: 'portAndCertMap', + render: (value) => { + if (!value) return '-'; + const certs = Object.values(value).filter(cert => cert !== ''); + return certs.length ? certs.join(', ') : '-'; + }, }, { title: t('domain.columns.action'), @@ -68,7 +72,7 @@ const DomainList: React.FC = () => { const [openDrawer, setOpenDrawer] = useState(false); const [openModal, setOpenModal] = useState(false); const [confirmLoading, setConfirmLoading] = useState(false); - + const [ingressMode, setIngressMode] = useState(false); const getDomainList = async (factor): Promise => getGatewayDomains(factor); const { loading, run, refresh } = useRequest(getDomainList, { manual: true, @@ -119,31 +123,45 @@ const DomainList: React.FC = () => { const onEditDrawer = (domain: Domain) => { setCurrentDomain(domain); + setIngressMode(domain.isIngressMode); setOpenDrawer(true); }; const onShowDrawer = () => { setOpenDrawer(true); setCurrentDomain(null); + setIngressMode(currentIngressMode); }; const handleDrawerOK = async () => { try { const values: DomainFormProps = formRef.current && (await formRef.current.handleSubmit()); - const { name, certIdentifier } = values; + // message.info(JSON.stringify(values)); + const { name, portAndCertMap } = values; const data = { name: name || currentDomain?.name }; let enableHttps = EnableHttpsValue.off; - if (values.protocol === Protocol.https) { - if (values.certIdentifier) { - Object.assign(data, { certIdentifier }); + + if (portAndCertMap) { + // Convert array format to Record + const portCertRecord: Record = {}; + portAndCertMap.forEach((item: any) => { + portCertRecord[item.port] = item.certificate; + }); + Object.assign(data, { portAndCertMap: portCertRecord }); + + // Check if any port uses HTTPS + const hasHttps = Object.values(portCertRecord).some(cert => cert); + if (hasHttps) { + enableHttps = values.mustHttps?.length ? EnableHttpsValue.force : EnableHttpsValue.on; } - enableHttps = values.mustHttps?.length ? EnableHttpsValue.force : EnableHttpsValue.on; } + Object.assign(data, { enableHttps }); if (currentDomain?.version) { - await updateGatewayDomain({ version: currentDomain.version, ...data } as Domain); + await updateGatewayDomain({ version: currentDomain.version, isIngressMode: currentDomain.isIngressMode, ...data } as Domain); } else { - await addGatewayDomain(data as Domain); + // set domain isIngressMode + await addGatewayDomain({ ...data, isIngressMode: currentIngressMode } as Domain); } setOpenDrawer(false); refresh(); @@ -155,6 +173,7 @@ const DomainList: React.FC = () => { const handleDrawerCancel = () => { setOpenDrawer(false); setCurrentDomain(null); + setIngressMode(currentIngressMode); }; const onShowModal = (domain: Domain) => { @@ -176,6 +195,7 @@ const DomainList: React.FC = () => { const handleModalCancel = () => { setOpenModal(false); setCurrentDomain(null); + setIngressMode(currentIngressMode); }; return ( @@ -240,7 +260,7 @@ const DomainList: React.FC = () => { } > - + ); diff --git a/frontend/src/pages/higress-config/index.tsx b/frontend/src/pages/higress-config/index.tsx new file mode 100644 index 00000000..da7210d1 --- /dev/null +++ b/frontend/src/pages/higress-config/index.tsx @@ -0,0 +1,90 @@ +/* eslint-disable */ +// @ts-nocheck +import React from 'react'; +import { PageContainer } from '@ant-design/pro-layout'; +import { Form, Select, Button, message } from 'antd'; +import { useTranslation } from 'react-i18next'; +import { useRequest } from 'ahooks'; +import { getIngressWorkMode, setIngressWorkMode } from '@/services'; + +const { Option } = Select; + +interface IngressWorkModeConfig { + mode: boolean; +} + +const HigressConfig: React.FC = () => { + const { t } = useTranslation(); + const [form] = Form.useForm(); + + const getIngressWorkModeConfig = async (): Promise => { + const mode = await getIngressWorkMode(); + return { mode }; + }; + const { loading, data, refresh } = useRequest(getIngressWorkModeConfig, { + manual: false, + onSuccess: (result) => { + form.setFieldsValue({ ingressWorkMode: result.mode }); + }, + }); + + const { run: updateIngressWorkMode, loading: updateLoading } = useRequest(setIngressWorkMode, { + manual: true, + onSuccess: () => { + message.success(t('higressConfig.updateSuccess')); + refresh(); + }, + onError: () => { + message.error(t('higressConfig.updateError')); + }, + }); + + const onFinish = (values: { ingressWorkMode: boolean }) => { + updateIngressWorkMode(values.ingressWorkMode); + }; + + return ( + +
+
+ + + + + + + +
+
+ ); +}; + +export default HigressConfig; \ No newline at end of file diff --git a/frontend/src/pages/route/components/RouteForm/index.tsx b/frontend/src/pages/route/components/RouteForm/index.tsx index 656eee97..3bf435a2 100644 --- a/frontend/src/pages/route/components/RouteForm/index.tsx +++ b/frontend/src/pages/route/components/RouteForm/index.tsx @@ -5,7 +5,7 @@ import { upstreamServiceToString } from '@/interfaces/route'; import { getGatewayDomains, getGatewayServices } from '@/services'; import { InfoCircleOutlined, QuestionCircleFilled, QuestionCircleOutlined } from '@ant-design/icons'; import { useRequest } from 'ahooks'; -import { Checkbox, Form, Input, Select, Tooltip } from 'antd'; +import { Checkbox, Form, Input, message, Select, Tooltip, InputNumber } from 'antd'; import { uniqueId } from "lodash"; import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react'; import { useTranslation } from 'react-i18next'; @@ -26,16 +26,23 @@ const MethodOptions = [ { label: "CONNECT", value: "CONNECT" }, ]; -const RouteForm: React.FC = forwardRef((props, ref) => { +interface RouteFormProps { + value?: any; + isIngressMode?: boolean; +} + +const RouteForm: React.FC = forwardRef((props: RouteFormProps, ref) => { const { t } = useTranslation(); - const { value } = props; + const { value, isIngressMode } = props; const [form] = Form.useForm(); const [serviceOptions, setServiceOptions] = useState([]); const [domainOptions, setDomainOptions] = useState([]); const servicesRef = useRef(new Map()); + const serviceWeightsRef = useRef(new Map()); const { data: _services = [] } = useRequest(getGatewayServices); const { data: _domains = [] } = useRequest(getGatewayDomains); + const [serviceWeights, setServiceWeights] = useState>(new Map()); useEffect(() => { form.resetFields(); @@ -72,6 +79,14 @@ const RouteForm: React.FC = forwardRef((props, ref) => { const customConfigArray = customConfigs ? Object.keys(customConfigs).map((key) => { return { uid: uniqueId(), key, value: customConfigs[key] }; }) : []; + + if (services) { + services.forEach(service => { + const key = upstreamServiceToString(service).split(':')[0]; + serviceWeightsRef.current.set(key, service.weight); + }); + } + form.setFieldsValue({ name, domains: domains || [], @@ -86,7 +101,10 @@ const RouteForm: React.FC = forwardRef((props, ref) => { }, [_services, _domains, value]); useImperativeHandle(ref, () => ({ - reset: () => form.resetFields(), + reset: () => { + form.resetFields(); + setServiceWeights(new Map()); + }, handleSubmit: async () => { const values = await form.validateFields(); if (values.domains && !Array.isArray(values.domains)) { @@ -101,6 +119,16 @@ const RouteForm: React.FC = forwardRef((props, ref) => { } values.customConfigs = customConfigsObj; } + if (values.services) { + values.services = values.services.map(service => { + const serviceKey = service.split(':')[0]; + const weight = serviceWeights.get(serviceKey); + return { + service, + weight: weight || 1, + }; + }); + } return values; }, })); @@ -252,13 +280,57 @@ const RouteForm: React.FC = forwardRef((props, ref) => { }, ]} > - + ) : ( +