From 8455a42b61b273daa368198a4fa13acc75016f63 Mon Sep 17 00:00:00 2001 From: justinsb Date: Wed, 18 Dec 2024 12:39:20 -0500 Subject: [PATCH 01/10] DiscoveryEngineTargetSite: initial types --- .../v1alpha1/targetsite_reference.go | 118 +++++++++++++++++ .../v1alpha1/targetsite_types.go | 121 ++++++++++++++++++ .../v1alpha1/types.generated.go | 60 +++++++++ dev/tools/controllerbuilder/generate.sh | 1 + .../datastoretargetsite_fuzzer.go | 46 +++++++ .../discoveryengine/mapper.generated.go | 120 +++++++++++++++++ 6 files changed, 466 insertions(+) create mode 100644 apis/discoveryengine/v1alpha1/targetsite_reference.go create mode 100644 apis/discoveryengine/v1alpha1/targetsite_types.go create mode 100644 pkg/controller/direct/discoveryengine/datastoretargetsite_fuzzer.go diff --git a/apis/discoveryengine/v1alpha1/targetsite_reference.go b/apis/discoveryengine/v1alpha1/targetsite_reference.go new file mode 100644 index 0000000000..25525e49f5 --- /dev/null +++ b/apis/discoveryengine/v1alpha1/targetsite_reference.go @@ -0,0 +1,118 @@ +// Copyright 2024 Google LLC +// +// 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 v1alpha1 + +import ( + "context" + "fmt" + "strings" + + refsv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/apis/refs/v1beta1" + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/k8s" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +var _ refsv1beta1.ExternalNormalizer = &TargetSiteRef{} + +// TargetSiteRef defines the resource reference to DiscoveryEngineDataStoreTargetSite, which "External" field +// holds the GCP identifier for the KRM object. +type TargetSiteRef struct { + // A reference to an externally managed DiscoveryEngineDataStoreTargetSite resource. + // Should be in the format "projects//locations//targetsites/". + External string `json:"external,omitempty"` + + // The name of a DiscoveryEngineDataStoreTargetSite resource. + Name string `json:"name,omitempty"` + + // The namespace of a DiscoveryEngineDataStoreTargetSite resource. + Namespace string `json:"namespace,omitempty"` +} + +// TargetStoreLink defines the full identity for a DataStoreTargetSite +// +// +k8s:deepcopy-gen=false +type TargetStoreLink struct { + *DiscoveryEngineDataStoreID + DataStore string +} + +// NormalizedExternal provision the "External" value for other resource that depends on DiscoveryEngineDataStoreTargetSite. +// If the "External" is given in the other resource's spec.DiscoveryEngineDataStoreTargetSiteRef, the given value will be used. +// Otherwise, the "Name" and "Namespace" will be used to query the actual DiscoveryEngineDataStoreTargetSite object from the cluster. +func (r *TargetSiteRef) NormalizedExternal(ctx context.Context, reader client.Reader, otherNamespace string) (string, error) { + if r.External != "" && r.Name != "" { + return "", fmt.Errorf("cannot specify both name and external on %s reference", DiscoveryEngineDataStoreTargetSiteGVK.Kind) + } + // From given External + if r.External != "" { + if _, err := ParseTargetSiteExternal(r.External); err != nil { + return "", err + } + return r.External, nil + } + + // From the Config Connector object + if r.Namespace == "" { + r.Namespace = otherNamespace + } + key := types.NamespacedName{Name: r.Name, Namespace: r.Namespace} + u := &unstructured.Unstructured{} + u.SetGroupVersionKind(DiscoveryEngineDataStoreTargetSiteGVK) + if err := reader.Get(ctx, key, u); err != nil { + if apierrors.IsNotFound(err) { + return "", k8s.NewReferenceNotFoundError(u.GroupVersionKind(), key) + } + return "", fmt.Errorf("reading referenced %s %s: %w", DiscoveryEngineDataStoreTargetSiteGVK, key, err) + } + // Get external from status.externalRef. This is the most trustworthy place. + actualExternalRef, _, err := unstructured.NestedString(u.Object, "status", "externalRef") + if err != nil { + return "", fmt.Errorf("reading status.externalRef: %w", err) + } + if actualExternalRef == "" { + return "", k8s.NewReferenceNotReadyError(u.GroupVersionKind(), key) + } + r.External = actualExternalRef + return r.External, nil +} + +func ParseTargetSiteExternal(external string) (*TargetStoreLink, error) { + s := strings.TrimPrefix(external, "//discoveryengine.googleapis.com/") + s = strings.TrimPrefix(s, "/") + tokens := strings.Split(s, "/") + if len(tokens) == 10 && tokens[0] == "projects" && tokens[2] == "locations" && tokens[4] == "collections" && tokens[6] == "dataStores" && tokens[8] == "targetSites" { + projectAndLocation := &ProjectAndLocation{ + ProjectID: tokens[1], + Location: tokens[3], + } + collection := &CollectionLink{ + ProjectAndLocation: projectAndLocation, + Collection: tokens[5], + } + dataStoreLink := &DiscoveryEngineDataStoreID{ + CollectionLink: collection, + DataStore: tokens[7], + } + targetStoreLink := &TargetStoreLink{ + DiscoveryEngineDataStoreID: dataStoreLink, + DataStore: tokens[9], + } + return targetStoreLink, nil + } + return nil, fmt.Errorf("format of DiscoveryEngineDataStoreTargetSite external=%q was not known (use projects/{{projectId}}/locations/{{location}}/collections/{{collectionID}}/dataStores/{{dataStoreID}}/targetSites/{{targetSiteID}})", external) +} diff --git a/apis/discoveryengine/v1alpha1/targetsite_types.go b/apis/discoveryengine/v1alpha1/targetsite_types.go new file mode 100644 index 0000000000..459b950558 --- /dev/null +++ b/apis/discoveryengine/v1alpha1/targetsite_types.go @@ -0,0 +1,121 @@ +// Copyright 2024 Google LLC +// +// 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 v1alpha1 + +import ( + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/apis/k8s/v1alpha1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +var DiscoveryEngineDataStoreTargetSiteGVK = GroupVersion.WithKind("DiscoveryEngineDataStoreTargetSite") + +// DiscoveryEngineDataStoreTargetSiteSpec defines the desired state of DiscoveryEngineDataStoreTargetSite +// +kcc:proto=google.cloud.discoveryengine.v1.TargetSite +type DiscoveryEngineDataStoreTargetSiteSpec struct { + // The DataStore this target site should be part of. + DataStoreRef *DiscoveryEngineDataStoreRef `json:"dataStoreRef,omitempty"` + + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable" + // Immutable. + // The DiscoveryEngineDataStoreTargetSite name. If not given, the metadata.name will be used. + ResourceID *string `json:"resourceID,omitempty"` + + // Required. Input only. The user provided URI pattern from which the + // `generated_uri_pattern` is generated. + ProvidedUriPattern *string `json:"providedUriPattern,omitempty"` + + // The type of the target site, e.g., whether the site is to be included or + // excluded. + Type *string `json:"type,omitempty"` + + // Input only. If set to false, a uri_pattern is generated to include all + // pages whose address contains the provided_uri_pattern. If set to true, an + // uri_pattern is generated to try to be an exact match of the + // provided_uri_pattern or just the specific page if the provided_uri_pattern + // is a specific one. provided_uri_pattern is always normalized to + // generate the URI pattern to be used by the search engine. + ExactMatch *bool `json:"exactMatch,omitempty"` +} + +// DiscoveryEngineDataStoreTargetSiteStatus defines the config connector machine state of DiscoveryEngineDataStoreTargetSite +type DiscoveryEngineDataStoreTargetSiteStatus struct { + /* Conditions represent the latest available observations of the + object's current state. */ + Conditions []v1alpha1.Condition `json:"conditions,omitempty"` + + // ObservedGeneration is the generation of the resource that was most recently observed by the Config Connector controller. If this is equal to metadata.generation, then that means that the current reported status reflects the most recent desired state of the resource. + ObservedGeneration *int64 `json:"observedGeneration,omitempty"` + + // A unique specifier for the DiscoveryEngineDataStoreTargetSite resource in GCP. + ExternalRef *string `json:"externalRef,omitempty"` + + // ObservedState is the state of the resource as most recently observed in GCP. + ObservedState *DiscoveryEngineDataStoreTargetSiteObservedState `json:"observedState,omitempty"` +} + +// DiscoveryEngineDataStoreTargetSiteObservedState is the state of the DiscoveryEngineDataStoreTargetSite resource as most recently observed in GCP. +// +kcc:proto=google.cloud.discoveryengine.v1.TargetSite +type DiscoveryEngineDataStoreTargetSiteObservedState struct { + // Output only. This is system-generated based on the provided_uri. + GeneratedUriPattern *string `json:"generatedUriPattern,omitempty"` + + // Output only. Root domain of the provided_uri. + RootDomainUri *string `json:"rootDomainUri,omitempty"` + + // Output only. Site ownership and validity verification status. + SiteVerificationInfo *SiteVerificationInfo `json:"siteVerificationInfo,omitempty"` + + // Output only. Indexing status. + IndexingStatus *string `json:"indexingStatus,omitempty"` + + // Output only. The target site's last updated time. + UpdateTime *string `json:"updateTime,omitempty"` + + // Output only. Failure reason. + FailureReason *TargetSite_FailureReason `json:"failureReason,omitempty"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:categories=gcp,shortName=gcpdiscoveryenginedatastoretargetsite;gcpdiscoveryenginedatastoretargetsites +// +kubebuilder:subresource:status +// +kubebuilder:metadata:labels="cnrm.cloud.google.com/managed-by-kcc=true";"cnrm.cloud.google.com/system=true" +// +kubebuilder:printcolumn:name="Age",JSONPath=".metadata.creationTimestamp",type="date" +// +kubebuilder:printcolumn:name="Ready",JSONPath=".status.conditions[?(@.type=='Ready')].status",type="string",description="When 'True', the most recent reconcile of the resource succeeded" +// +kubebuilder:printcolumn:name="Status",JSONPath=".status.conditions[?(@.type=='Ready')].reason",type="string",description="The reason for the value in 'Ready'" +// +kubebuilder:printcolumn:name="Status Age",JSONPath=".status.conditions[?(@.type=='Ready')].lastTransitionTime",type="date",description="The last transition time for the value in 'Status'" + +// DiscoveryEngineDataStoreTargetSite is the Schema for the DiscoveryEngineDataStoreTargetSite API +// +k8s:openapi-gen=true +type DiscoveryEngineDataStoreTargetSite struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +required + Spec DiscoveryEngineDataStoreTargetSiteSpec `json:"spec,omitempty"` + Status DiscoveryEngineDataStoreTargetSiteStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// DiscoveryEngineDataStoreTargetSiteList contains a list of DiscoveryEngineDataStoreTargetSite +type DiscoveryEngineDataStoreTargetSiteList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []DiscoveryEngineDataStoreTargetSite `json:"items"` +} + +func init() { + SchemeBuilder.Register(&DiscoveryEngineDataStoreTargetSite{}, &DiscoveryEngineDataStoreTargetSiteList{}) +} diff --git a/apis/discoveryengine/v1alpha1/types.generated.go b/apis/discoveryengine/v1alpha1/types.generated.go index ca40cd1282..154bcaf115 100644 --- a/apis/discoveryengine/v1alpha1/types.generated.go +++ b/apis/discoveryengine/v1alpha1/types.generated.go @@ -17,21 +17,27 @@ package v1alpha1 // +kcc:proto=google.cloud.discoveryengine.v1.DataStore.BillingEstimation type DataStore_BillingEstimation struct { // Data size for structured data in terms of bytes. + // +kcc:proto=google.cloud.discoveryengine.v1.DataStore.BillingEstimation.structured_data_size StructuredDataSize *int64 `json:"structuredDataSize,omitempty"` // Data size for unstructured data in terms of bytes. + // +kcc:proto=google.cloud.discoveryengine.v1.DataStore.BillingEstimation.unstructured_data_size UnstructuredDataSize *int64 `json:"unstructuredDataSize,omitempty"` // Data size for websites in terms of bytes. + // +kcc:proto=google.cloud.discoveryengine.v1.DataStore.BillingEstimation.website_data_size WebsiteDataSize *int64 `json:"websiteDataSize,omitempty"` // Last updated timestamp for structured data. + // +kcc:proto=google.cloud.discoveryengine.v1.DataStore.BillingEstimation.structured_data_update_time StructuredDataUpdateTime *string `json:"structuredDataUpdateTime,omitempty"` // Last updated timestamp for unstructured data. + // +kcc:proto=google.cloud.discoveryengine.v1.DataStore.BillingEstimation.unstructured_data_update_time UnstructuredDataUpdateTime *string `json:"unstructuredDataUpdateTime,omitempty"` // Last updated timestamp for websites. + // +kcc:proto=google.cloud.discoveryengine.v1.DataStore.BillingEstimation.website_data_update_time WebsiteDataUpdateTime *string `json:"websiteDataUpdateTime,omitempty"` } @@ -40,15 +46,18 @@ type DocumentProcessingConfig struct { // The full resource name of the Document Processing Config. // Format: // `projects/*/locations/*/collections/*/dataStores/*/documentProcessingConfig`. + // +kcc:proto=google.cloud.discoveryengine.v1.DocumentProcessingConfig.name Name *string `json:"name,omitempty"` // Whether chunking mode is enabled. + // +kcc:proto=google.cloud.discoveryengine.v1.DocumentProcessingConfig.chunking_config ChunkingConfig *DocumentProcessingConfig_ChunkingConfig `json:"chunkingConfig,omitempty"` // Configurations for default Document parser. // If not specified, we will configure it as default DigitalParsingConfig, and // the default parsing config will be applied to all file types for Document // parsing. + // +kcc:proto=google.cloud.discoveryengine.v1.DocumentProcessingConfig.default_parsing_config DefaultParsingConfig *DocumentProcessingConfig_ParsingConfig `json:"defaultParsingConfig,omitempty"` // TODO: map type string message for parsing_config_overrides @@ -58,6 +67,7 @@ type DocumentProcessingConfig struct { // +kcc:proto=google.cloud.discoveryengine.v1.DocumentProcessingConfig.ChunkingConfig type DocumentProcessingConfig_ChunkingConfig struct { // Configuration for the layout based chunking. + // +kcc:proto=google.cloud.discoveryengine.v1.DocumentProcessingConfig.ChunkingConfig.layout_based_chunking_config LayoutBasedChunkingConfig *DocumentProcessingConfig_ChunkingConfig_LayoutBasedChunkingConfig `json:"layoutBasedChunkingConfig,omitempty"` } @@ -67,25 +77,30 @@ type DocumentProcessingConfig_ChunkingConfig_LayoutBasedChunkingConfig struct { // // Supported values: 100-500 (inclusive). // Default value: 500. + // +kcc:proto=google.cloud.discoveryengine.v1.DocumentProcessingConfig.ChunkingConfig.LayoutBasedChunkingConfig.chunk_size ChunkSize *int32 `json:"chunkSize,omitempty"` // Whether to include appending different levels of headings to chunks // from the middle of the document to prevent context loss. // // Default value: False. + // +kcc:proto=google.cloud.discoveryengine.v1.DocumentProcessingConfig.ChunkingConfig.LayoutBasedChunkingConfig.include_ancestor_headings IncludeAncestorHeadings *bool `json:"includeAncestorHeadings,omitempty"` } // +kcc:proto=google.cloud.discoveryengine.v1.DocumentProcessingConfig.ParsingConfig type DocumentProcessingConfig_ParsingConfig struct { // Configurations applied to digital parser. + // +kcc:proto=google.cloud.discoveryengine.v1.DocumentProcessingConfig.ParsingConfig.digital_parsing_config DigitalParsingConfig *DocumentProcessingConfig_ParsingConfig_DigitalParsingConfig `json:"digitalParsingConfig,omitempty"` // Configurations applied to OCR parser. Currently it only applies to // PDFs. + // +kcc:proto=google.cloud.discoveryengine.v1.DocumentProcessingConfig.ParsingConfig.ocr_parsing_config OcrParsingConfig *DocumentProcessingConfig_ParsingConfig_OcrParsingConfig `json:"ocrParsingConfig,omitempty"` // Configurations applied to layout parser. + // +kcc:proto=google.cloud.discoveryengine.v1.DocumentProcessingConfig.ParsingConfig.layout_parsing_config LayoutParsingConfig *DocumentProcessingConfig_ParsingConfig_LayoutParsingConfig `json:"layoutParsingConfig,omitempty"` } @@ -101,10 +116,12 @@ type DocumentProcessingConfig_ParsingConfig_LayoutParsingConfig struct { type DocumentProcessingConfig_ParsingConfig_OcrParsingConfig struct { // [DEPRECATED] This field is deprecated. To use the additional enhanced // document elements processing, please switch to `layout_parsing_config`. + // +kcc:proto=google.cloud.discoveryengine.v1.DocumentProcessingConfig.ParsingConfig.OcrParsingConfig.enhanced_document_elements EnhancedDocumentElements []string `json:"enhancedDocumentElements,omitempty"` // If true, will use native text instead of OCR text on pages containing // native text. + // +kcc:proto=google.cloud.discoveryengine.v1.DocumentProcessingConfig.ParsingConfig.OcrParsingConfig.use_native_text UseNativeText *bool `json:"useNativeText,omitempty"` } @@ -119,6 +136,7 @@ type Engine_ChatEngineConfig struct { // or // [EngineService.ListEngines][google.cloud.discoveryengine.v1.EngineService.ListEngines] // API after engine creation. + // +kcc:proto=google.cloud.discoveryengine.v1.Engine.ChatEngineConfig.agent_creation_config AgentCreationConfig *Engine_ChatEngineConfig_AgentCreationConfig `json:"agentCreationConfig,omitempty"` // The resource name of an exist Dialogflow agent to link to this Chat @@ -136,6 +154,7 @@ type Engine_ChatEngineConfig struct { // API after engine creation. Use // [ChatEngineMetadata.dialogflow_agent][google.cloud.discoveryengine.v1.Engine.ChatEngineMetadata.dialogflow_agent] // for actual agent association after Engine is created. + // +kcc:proto=google.cloud.discoveryengine.v1.Engine.ChatEngineConfig.dialogflow_agent_to_link DialogflowAgentToLink *string `json:"dialogflowAgentToLink,omitempty"` } @@ -144,22 +163,26 @@ type Engine_ChatEngineConfig_AgentCreationConfig struct { // Name of the company, organization or other entity that the agent // represents. Used for knowledge connector LLM prompt and for knowledge // search. + // +kcc:proto=google.cloud.discoveryengine.v1.Engine.ChatEngineConfig.AgentCreationConfig.business Business *string `json:"business,omitempty"` // Required. The default language of the agent as a language tag. // See [Language // Support](https://cloud.google.com/dialogflow/docs/reference/language) // for a list of the currently supported language codes. + // +kcc:proto=google.cloud.discoveryengine.v1.Engine.ChatEngineConfig.AgentCreationConfig.default_language_code DefaultLanguageCode *string `json:"defaultLanguageCode,omitempty"` // Required. The time zone of the agent from the [time zone // database](https://www.iana.org/time-zones), e.g., America/New_York, // Europe/Paris. + // +kcc:proto=google.cloud.discoveryengine.v1.Engine.ChatEngineConfig.AgentCreationConfig.time_zone TimeZone *string `json:"timeZone,omitempty"` // Agent location for Agent creation, supported values: global/us/eu. // If not provided, us Engine will create Agent using us-central-1 by // default; eu Engine will create Agent using eu-west-1 by default. + // +kcc:proto=google.cloud.discoveryengine.v1.Engine.ChatEngineConfig.AgentCreationConfig.location Location *string `json:"location,omitempty"` } @@ -170,6 +193,7 @@ type Engine_ChatEngineMetadata struct { // // Format: `projects//locations//agents/`. + // +kcc:proto=google.cloud.discoveryengine.v1.Engine.ChatEngineMetadata.dialogflow_agent DialogflowAgent *string `json:"dialogflowAgent,omitempty"` } @@ -177,6 +201,7 @@ type Engine_ChatEngineMetadata struct { type Engine_CommonConfig struct { // The name of the company, business or entity that is associated with the // engine. Setting this may help improve LLM related features. + // +kcc:proto=google.cloud.discoveryengine.v1.Engine.CommonConfig.company_name CompanyName *string `json:"companyName,omitempty"` } @@ -190,18 +215,22 @@ type Engine_SearchEngineConfig struct { // Defaults to // [SearchTier.SEARCH_TIER_STANDARD][google.cloud.discoveryengine.v1.SearchTier.SEARCH_TIER_STANDARD] // if not specified. + // +kcc:proto=google.cloud.discoveryengine.v1.Engine.SearchEngineConfig.search_tier SearchTier *string `json:"searchTier,omitempty"` // The add-on that this search engine enables. + // +kcc:proto=google.cloud.discoveryengine.v1.Engine.SearchEngineConfig.search_add_ons SearchAddOns []string `json:"searchAddOns,omitempty"` } // +kcc:proto=google.cloud.discoveryengine.v1.Schema type Schema struct { // The structured representation of the schema. + // +kcc:proto=google.cloud.discoveryengine.v1.Schema.struct_schema StructSchema map[string]string `json:"structSchema,omitempty"` // The JSON representation of the schema. + // +kcc:proto=google.cloud.discoveryengine.v1.Schema.json_schema JsonSchema *string `json:"jsonSchema,omitempty"` // Immutable. The full resource name of the schema, in the format of @@ -209,24 +238,55 @@ type Schema struct { // // This field must be a UTF-8 encoded string with a length limit of 1024 // characters. + // +kcc:proto=google.cloud.discoveryengine.v1.Schema.name Name *string `json:"name,omitempty"` } +// +kcc:proto=google.cloud.discoveryengine.v1.SiteVerificationInfo +type SiteVerificationInfo struct { + // Site verification state indicating the ownership and validity. + // +kcc:proto=google.cloud.discoveryengine.v1.SiteVerificationInfo.site_verification_state + SiteVerificationState *string `json:"siteVerificationState,omitempty"` + + // Latest site verification time. + // +kcc:proto=google.cloud.discoveryengine.v1.SiteVerificationInfo.verify_time + VerifyTime *string `json:"verifyTime,omitempty"` +} + +// +kcc:proto=google.cloud.discoveryengine.v1.TargetSite.FailureReason +type TargetSite_FailureReason struct { + // Failed due to insufficient quota. + // +kcc:proto=google.cloud.discoveryengine.v1.TargetSite.FailureReason.quota_failure + QuotaFailure *TargetSite_FailureReason_QuotaFailure `json:"quotaFailure,omitempty"` +} + +// +kcc:proto=google.cloud.discoveryengine.v1.TargetSite.FailureReason.QuotaFailure +type TargetSite_FailureReason_QuotaFailure struct { + // This number is an estimation on how much total quota this project needs + // to successfully complete indexing. + // +kcc:proto=google.cloud.discoveryengine.v1.TargetSite.FailureReason.QuotaFailure.total_required_quota + TotalRequiredQuota *int64 `json:"totalRequiredQuota,omitempty"` +} + // +kcc:proto=google.cloud.discoveryengine.v1.WorkspaceConfig type WorkspaceConfig struct { // The Google Workspace data source. + // +kcc:proto=google.cloud.discoveryengine.v1.WorkspaceConfig.type Type *string `json:"type,omitempty"` // Obfuscated Dasher customer ID. + // +kcc:proto=google.cloud.discoveryengine.v1.WorkspaceConfig.dasher_customer_id DasherCustomerID *string `json:"dasherCustomerID,omitempty"` // Optional. The super admin service account for the workspace that will be // used for access token generation. For now we only use it for Native Google // Drive connector data ingestion. + // +kcc:proto=google.cloud.discoveryengine.v1.WorkspaceConfig.super_admin_service_account SuperAdminServiceAccount *string `json:"superAdminServiceAccount,omitempty"` // Optional. The super admin email address for the workspace that will be used // for access token generation. For now we only use it for Native Google Drive // connector data ingestion. + // +kcc:proto=google.cloud.discoveryengine.v1.WorkspaceConfig.super_admin_email_address SuperAdminEmailAddress *string `json:"superAdminEmailAddress,omitempty"` } diff --git a/dev/tools/controllerbuilder/generate.sh b/dev/tools/controllerbuilder/generate.sh index af084ea513..a97263f3dd 100755 --- a/dev/tools/controllerbuilder/generate.sh +++ b/dev/tools/controllerbuilder/generate.sh @@ -29,6 +29,7 @@ go run . generate-types \ --service google.cloud.discoveryengine.v1 \ --api-version discoveryengine.cnrm.cloud.google.com/v1alpha1 \ --resource DiscoveryEngineDataStore:DataStore \ + --resource DiscoveryEngineDataStoreTargetSite:TargetSite \ --resource DiscoveryEngineEngine:Engine # go run . prompt --src-dir ~/kcc/k8s-config-connector --proto-dir ~/kcc/k8s-config-connector/dev/tools/proto-to-mapper/third_party/googleapis/ < Date: Wed, 18 Dec 2024 12:39:41 -0500 Subject: [PATCH 02/10] DiscoveryEngineTargetSite: generated apimachinery --- .../v1alpha1/zz_generated.deepcopy.go | 259 ++++++++++++++++++ ...discoveryengine.cnrm.cloud.google.com.yaml | 210 ++++++++++++++ dev/tools/controllerbuilder/go.mod | 56 ++-- dev/tools/controllerbuilder/go.sum | 106 +++---- .../pkg/toolbot/extracttoolmarkers.go | 2 +- .../pkg/typeupdater/typeupdater.go | 2 +- .../discoveryengine/mapper.generated.go | 54 ++-- 7 files changed, 571 insertions(+), 118 deletions(-) create mode 100644 config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_discoveryenginedatastoretargetsites.discoveryengine.cnrm.cloud.google.com.yaml diff --git a/apis/discoveryengine/v1alpha1/zz_generated.deepcopy.go b/apis/discoveryengine/v1alpha1/zz_generated.deepcopy.go index 7bd52d6577..803509e45e 100644 --- a/apis/discoveryengine/v1alpha1/zz_generated.deepcopy.go +++ b/apis/discoveryengine/v1alpha1/zz_generated.deepcopy.go @@ -298,6 +298,185 @@ func (in *DiscoveryEngineDataStoreStatus) DeepCopy() *DiscoveryEngineDataStoreSt return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DiscoveryEngineDataStoreTargetSite) DeepCopyInto(out *DiscoveryEngineDataStoreTargetSite) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DiscoveryEngineDataStoreTargetSite. +func (in *DiscoveryEngineDataStoreTargetSite) DeepCopy() *DiscoveryEngineDataStoreTargetSite { + if in == nil { + return nil + } + out := new(DiscoveryEngineDataStoreTargetSite) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *DiscoveryEngineDataStoreTargetSite) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DiscoveryEngineDataStoreTargetSiteList) DeepCopyInto(out *DiscoveryEngineDataStoreTargetSiteList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]DiscoveryEngineDataStoreTargetSite, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DiscoveryEngineDataStoreTargetSiteList. +func (in *DiscoveryEngineDataStoreTargetSiteList) DeepCopy() *DiscoveryEngineDataStoreTargetSiteList { + if in == nil { + return nil + } + out := new(DiscoveryEngineDataStoreTargetSiteList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *DiscoveryEngineDataStoreTargetSiteList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DiscoveryEngineDataStoreTargetSiteObservedState) DeepCopyInto(out *DiscoveryEngineDataStoreTargetSiteObservedState) { + *out = *in + if in.GeneratedUriPattern != nil { + in, out := &in.GeneratedUriPattern, &out.GeneratedUriPattern + *out = new(string) + **out = **in + } + if in.RootDomainUri != nil { + in, out := &in.RootDomainUri, &out.RootDomainUri + *out = new(string) + **out = **in + } + if in.SiteVerificationInfo != nil { + in, out := &in.SiteVerificationInfo, &out.SiteVerificationInfo + *out = new(SiteVerificationInfo) + (*in).DeepCopyInto(*out) + } + if in.IndexingStatus != nil { + in, out := &in.IndexingStatus, &out.IndexingStatus + *out = new(string) + **out = **in + } + if in.UpdateTime != nil { + in, out := &in.UpdateTime, &out.UpdateTime + *out = new(string) + **out = **in + } + if in.FailureReason != nil { + in, out := &in.FailureReason, &out.FailureReason + *out = new(TargetSite_FailureReason) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DiscoveryEngineDataStoreTargetSiteObservedState. +func (in *DiscoveryEngineDataStoreTargetSiteObservedState) DeepCopy() *DiscoveryEngineDataStoreTargetSiteObservedState { + if in == nil { + return nil + } + out := new(DiscoveryEngineDataStoreTargetSiteObservedState) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DiscoveryEngineDataStoreTargetSiteSpec) DeepCopyInto(out *DiscoveryEngineDataStoreTargetSiteSpec) { + *out = *in + if in.DataStoreRef != nil { + in, out := &in.DataStoreRef, &out.DataStoreRef + *out = new(DiscoveryEngineDataStoreRef) + **out = **in + } + if in.ResourceID != nil { + in, out := &in.ResourceID, &out.ResourceID + *out = new(string) + **out = **in + } + if in.ProvidedUriPattern != nil { + in, out := &in.ProvidedUriPattern, &out.ProvidedUriPattern + *out = new(string) + **out = **in + } + if in.Type != nil { + in, out := &in.Type, &out.Type + *out = new(string) + **out = **in + } + if in.ExactMatch != nil { + in, out := &in.ExactMatch, &out.ExactMatch + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DiscoveryEngineDataStoreTargetSiteSpec. +func (in *DiscoveryEngineDataStoreTargetSiteSpec) DeepCopy() *DiscoveryEngineDataStoreTargetSiteSpec { + if in == nil { + return nil + } + out := new(DiscoveryEngineDataStoreTargetSiteSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DiscoveryEngineDataStoreTargetSiteStatus) DeepCopyInto(out *DiscoveryEngineDataStoreTargetSiteStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]k8sv1alpha1.Condition, len(*in)) + copy(*out, *in) + } + if in.ObservedGeneration != nil { + in, out := &in.ObservedGeneration, &out.ObservedGeneration + *out = new(int64) + **out = **in + } + if in.ExternalRef != nil { + in, out := &in.ExternalRef, &out.ExternalRef + *out = new(string) + **out = **in + } + if in.ObservedState != nil { + in, out := &in.ObservedState, &out.ObservedState + *out = new(DiscoveryEngineDataStoreTargetSiteObservedState) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DiscoveryEngineDataStoreTargetSiteStatus. +func (in *DiscoveryEngineDataStoreTargetSiteStatus) DeepCopy() *DiscoveryEngineDataStoreTargetSiteStatus { + if in == nil { + return nil + } + out := new(DiscoveryEngineDataStoreTargetSiteStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DiscoveryEngineEngine) DeepCopyInto(out *DiscoveryEngineEngine) { *out = *in @@ -845,6 +1024,86 @@ func (in *Schema) DeepCopy() *Schema { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SiteVerificationInfo) DeepCopyInto(out *SiteVerificationInfo) { + *out = *in + if in.SiteVerificationState != nil { + in, out := &in.SiteVerificationState, &out.SiteVerificationState + *out = new(string) + **out = **in + } + if in.VerifyTime != nil { + in, out := &in.VerifyTime, &out.VerifyTime + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SiteVerificationInfo. +func (in *SiteVerificationInfo) DeepCopy() *SiteVerificationInfo { + if in == nil { + return nil + } + out := new(SiteVerificationInfo) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TargetSiteRef) DeepCopyInto(out *TargetSiteRef) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetSiteRef. +func (in *TargetSiteRef) DeepCopy() *TargetSiteRef { + if in == nil { + return nil + } + out := new(TargetSiteRef) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TargetSite_FailureReason) DeepCopyInto(out *TargetSite_FailureReason) { + *out = *in + if in.QuotaFailure != nil { + in, out := &in.QuotaFailure, &out.QuotaFailure + *out = new(TargetSite_FailureReason_QuotaFailure) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetSite_FailureReason. +func (in *TargetSite_FailureReason) DeepCopy() *TargetSite_FailureReason { + if in == nil { + return nil + } + out := new(TargetSite_FailureReason) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TargetSite_FailureReason_QuotaFailure) DeepCopyInto(out *TargetSite_FailureReason_QuotaFailure) { + *out = *in + if in.TotalRequiredQuota != nil { + in, out := &in.TotalRequiredQuota, &out.TotalRequiredQuota + *out = new(int64) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetSite_FailureReason_QuotaFailure. +func (in *TargetSite_FailureReason_QuotaFailure) DeepCopy() *TargetSite_FailureReason_QuotaFailure { + if in == nil { + return nil + } + out := new(TargetSite_FailureReason_QuotaFailure) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *WorkspaceConfig) DeepCopyInto(out *WorkspaceConfig) { *out = *in diff --git a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_discoveryenginedatastoretargetsites.discoveryengine.cnrm.cloud.google.com.yaml b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_discoveryenginedatastoretargetsites.discoveryengine.cnrm.cloud.google.com.yaml new file mode 100644 index 0000000000..8ebc9ea6ad --- /dev/null +++ b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_discoveryenginedatastoretargetsites.discoveryengine.cnrm.cloud.google.com.yaml @@ -0,0 +1,210 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + cnrm.cloud.google.com/version: 0.0.0-dev + creationTimestamp: null + labels: + cnrm.cloud.google.com/managed-by-kcc: "true" + cnrm.cloud.google.com/system: "true" + name: discoveryenginedatastoretargetsites.discoveryengine.cnrm.cloud.google.com +spec: + group: discoveryengine.cnrm.cloud.google.com + names: + categories: + - gcp + kind: DiscoveryEngineDataStoreTargetSite + listKind: DiscoveryEngineDataStoreTargetSiteList + plural: discoveryenginedatastoretargetsites + shortNames: + - gcpdiscoveryenginedatastoretargetsite + - gcpdiscoveryenginedatastoretargetsites + singular: discoveryenginedatastoretargetsite + preserveUnknownFields: false + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + - description: When 'True', the most recent reconcile of the resource succeeded + jsonPath: .status.conditions[?(@.type=='Ready')].status + name: Ready + type: string + - description: The reason for the value in 'Ready' + jsonPath: .status.conditions[?(@.type=='Ready')].reason + name: Status + type: string + - description: The last transition time for the value in 'Status' + jsonPath: .status.conditions[?(@.type=='Ready')].lastTransitionTime + name: Status Age + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: DiscoveryEngineDataStoreTargetSite is the Schema for the DiscoveryEngineDataStoreTargetSite + API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: DiscoveryEngineDataStoreTargetSiteSpec defines the desired + state of DiscoveryEngineDataStoreTargetSite + properties: + dataStoreRef: + description: The DataStore this target site should be part of. + oneOf: + - not: + required: + - external + required: + - name + - not: + anyOf: + - required: + - name + - required: + - namespace + required: + - external + properties: + external: + description: A reference to an externally managed DiscoveryEngineDataStore + resource. Should be in the format "projects/{{projectID}}/locations/{{location}}/datastores/{{datastoreID}}". + type: string + name: + description: The name of a DiscoveryEngineDataStore resource. + type: string + namespace: + description: The namespace of a DiscoveryEngineDataStore resource. + type: string + type: object + exactMatch: + description: Input only. If set to false, a uri_pattern is generated + to include all pages whose address contains the provided_uri_pattern. + If set to true, an uri_pattern is generated to try to be an exact + match of the provided_uri_pattern or just the specific page if the + provided_uri_pattern is a specific one. provided_uri_pattern is + always normalized to generate the URI pattern to be used by the + search engine. + type: boolean + providedUriPattern: + description: Required. Input only. The user provided URI pattern from + which the `generated_uri_pattern` is generated. + type: string + resourceID: + description: Immutable. The DiscoveryEngineDataStoreTargetSite name. + If not given, the metadata.name will be used. + type: string + x-kubernetes-validations: + - message: ResourceID field is immutable + rule: self == oldSelf + type: + description: The type of the target site, e.g., whether the site is + to be included or excluded. + type: string + type: object + status: + description: DiscoveryEngineDataStoreTargetSiteStatus defines the config + connector machine state of DiscoveryEngineDataStoreTargetSite + properties: + conditions: + description: Conditions represent the latest available observations + of the object's current state. + items: + properties: + lastTransitionTime: + description: Last time the condition transitioned from one status + to another. + type: string + message: + description: Human-readable message indicating details about + last transition. + type: string + reason: + description: Unique, one-word, CamelCase reason for the condition's + last transition. + type: string + status: + description: Status is the status of the condition. Can be True, + False, Unknown. + type: string + type: + description: Type is the type of the condition. + type: string + type: object + type: array + externalRef: + description: A unique specifier for the DiscoveryEngineDataStoreTargetSite + resource in GCP. + type: string + observedGeneration: + description: ObservedGeneration is the generation of the resource + that was most recently observed by the Config Connector controller. + If this is equal to metadata.generation, then that means that the + current reported status reflects the most recent desired state of + the resource. + format: int64 + type: integer + observedState: + description: ObservedState is the state of the resource as most recently + observed in GCP. + properties: + failureReason: + description: Output only. Failure reason. + properties: + quotaFailure: + description: Failed due to insufficient quota. + properties: + totalRequiredQuota: + description: This number is an estimation on how much + total quota this project needs to successfully complete + indexing. + format: int64 + type: integer + type: object + type: object + generatedUriPattern: + description: Output only. This is system-generated based on the + provided_uri. + type: string + indexingStatus: + description: Output only. Indexing status. + type: string + rootDomainUri: + description: Output only. Root domain of the provided_uri. + type: string + siteVerificationInfo: + description: Output only. Site ownership and validity verification + status. + properties: + siteVerificationState: + description: Site verification state indicating the ownership + and validity. + type: string + verifyTime: + description: Latest site verification time. + type: string + type: object + updateTime: + description: Output only. The target site's last updated time. + type: string + type: object + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/dev/tools/controllerbuilder/go.mod b/dev/tools/controllerbuilder/go.mod index bf8153b62a..544b7ba063 100644 --- a/dev/tools/controllerbuilder/go.mod +++ b/dev/tools/controllerbuilder/go.mod @@ -5,52 +5,52 @@ go 1.22.0 toolchain go1.23.2 require ( + github.com/GoogleCloudPlatform/k8s-config-connector v1.125.0 github.com/fatih/color v1.17.0 github.com/google/generative-ai-go v0.17.0 github.com/spf13/cobra v1.8.0 - golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d - google.golang.org/api v0.186.0 - google.golang.org/protobuf v1.34.2 + github.com/spf13/pflag v1.0.5 + golang.org/x/tools v0.24.0 + google.golang.org/api v0.203.0 + google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9 + google.golang.org/protobuf v1.35.1 k8s.io/apimachinery v0.27.11 k8s.io/klog/v2 v2.130.1 ) require ( - cloud.google.com/go v0.115.0 // indirect + cloud.google.com/go v0.116.0 // indirect cloud.google.com/go/ai v0.8.0 // indirect - cloud.google.com/go/auth v0.6.0 // indirect - cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect - cloud.google.com/go/compute/metadata v0.3.0 // indirect - cloud.google.com/go/longrunning v0.5.7 // indirect + cloud.google.com/go/auth v0.9.9 // indirect + cloud.google.com/go/auth/oauth2adapt v0.2.4 // indirect + cloud.google.com/go/compute/metadata v0.5.2 // indirect + cloud.google.com/go/longrunning v0.6.1 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/protobuf v1.5.4 // indirect - github.com/google/s2a-go v0.1.7 // indirect + github.com/google/s2a-go v0.1.8 // indirect github.com/google/uuid v1.6.0 // indirect - github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect - github.com/googleapis/gax-go/v2 v2.12.5 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect + github.com/googleapis/gax-go/v2 v2.13.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/spf13/pflag v1.0.5 // indirect go.opencensus.io v0.24.0 // indirect - go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0 // indirect - go.opentelemetry.io/otel v1.26.0 // indirect - go.opentelemetry.io/otel/metric v1.26.0 // indirect - go.opentelemetry.io/otel/trace v1.26.0 // indirect - golang.org/x/crypto v0.24.0 // indirect - golang.org/x/mod v0.17.0 // indirect - golang.org/x/net v0.26.0 // indirect - golang.org/x/oauth2 v0.21.0 // indirect + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect + go.opentelemetry.io/otel v1.29.0 // indirect + go.opentelemetry.io/otel/metric v1.29.0 // indirect + go.opentelemetry.io/otel/trace v1.29.0 // indirect + golang.org/x/crypto v0.28.0 // indirect + golang.org/x/mod v0.20.0 // indirect + golang.org/x/net v0.30.0 // indirect + golang.org/x/oauth2 v0.23.0 // indirect golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect - golang.org/x/time v0.5.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240617180043-68d350f18fd4 // indirect - google.golang.org/grpc v1.64.1 // indirect + golang.org/x/sys v0.26.0 // indirect + golang.org/x/text v0.19.0 // indirect + golang.org/x/time v0.7.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect + google.golang.org/grpc v1.67.1 // indirect ) diff --git a/dev/tools/controllerbuilder/go.sum b/dev/tools/controllerbuilder/go.sum index 44f5620003..6b54ec2e29 100644 --- a/dev/tools/controllerbuilder/go.sum +++ b/dev/tools/controllerbuilder/go.sum @@ -1,17 +1,19 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.115.0 h1:CnFSK6Xo3lDYRoBKEcAtia6VSC837/ZkJuRduSFnr14= -cloud.google.com/go v0.115.0/go.mod h1:8jIM5vVgoAEoiVxQ/O4BFTfHqulPZgs/ufEzMcFMdWU= +cloud.google.com/go v0.116.0 h1:B3fRrSDkLRt5qSHWe40ERJvhvnQwdZiHu0bJOpldweE= +cloud.google.com/go v0.116.0/go.mod h1:cEPSRWPzZEswwdr9BxE6ChEn01dWlTaF05LiC2Xs70U= cloud.google.com/go/ai v0.8.0 h1:rXUEz8Wp2OlrM8r1bfmpF2+VKqc1VJpafE3HgzRnD/w= cloud.google.com/go/ai v0.8.0/go.mod h1:t3Dfk4cM61sytiggo2UyGsDVW3RF1qGZaUKDrZFyqkE= -cloud.google.com/go/auth v0.6.0 h1:5x+d6b5zdezZ7gmLWD1m/xNjnaQ2YDhmIz/HH3doy1g= -cloud.google.com/go/auth v0.6.0/go.mod h1:b4acV+jLQDyjwm4OXHYjNvRi4jvGBzHWJRtJcy+2P4g= -cloud.google.com/go/auth/oauth2adapt v0.2.2 h1:+TTV8aXpjeChS9M+aTtN/TjdQnzJvmzKFt//oWu7HX4= -cloud.google.com/go/auth/oauth2adapt v0.2.2/go.mod h1:wcYjgpZI9+Yu7LyYBg4pqSiaRkfEK3GQcpb7C/uyF1Q= -cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc= -cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= -cloud.google.com/go/longrunning v0.5.7 h1:WLbHekDbjK1fVFD3ibpFFVoyizlLRl73I7YKuAKilhU= -cloud.google.com/go/longrunning v0.5.7/go.mod h1:8GClkudohy1Fxm3owmBGid8W0pSgodEMwEAztp38Xng= +cloud.google.com/go/auth v0.9.9 h1:BmtbpNQozo8ZwW2t7QJjnrQtdganSdmqeIBxHxNkEZQ= +cloud.google.com/go/auth v0.9.9/go.mod h1:xxA5AqpDrvS+Gkmo9RqrGGRh6WSNKKOXhY3zNOr38tI= +cloud.google.com/go/auth/oauth2adapt v0.2.4 h1:0GWE/FUsXhf6C+jAkWgYm7X9tK8cuEIfy19DBn6B6bY= +cloud.google.com/go/auth/oauth2adapt v0.2.4/go.mod h1:jC/jOpwFP6JBxhB3P5Rr0a9HLMC/Pe3eaL4NmdvqPtc= +cloud.google.com/go/compute/metadata v0.5.2 h1:UxK4uu/Tn+I3p2dYWTfiX4wva7aYlKixAHn3fyqngqo= +cloud.google.com/go/compute/metadata v0.5.2/go.mod h1:C66sj2AluDcIqakBq/M8lw8/ybHgOZqin2obFxa/E5k= +cloud.google.com/go/longrunning v0.6.1 h1:lOLTFxYpr8hcRtcwWir5ITh1PAKUD/sG2lKrTSYjyMc= +cloud.google.com/go/longrunning v0.6.1/go.mod h1:nHISoOZpBcmlwbJmiVk5oDRz0qG/ZxPynEGs1iZ79s0= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/GoogleCloudPlatform/k8s-config-connector v1.125.0 h1:oGWpJITjVgJ+ocATyf6BedTwK5tJ5KuOe+yhOyQ+oFU= +github.com/GoogleCloudPlatform/k8s-config-connector v1.125.0/go.mod h1:RX/TZs88Bbp3verrymNfRUnrNUYx9goLY5dMh0yqLjc= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= @@ -60,15 +62,15 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o= -github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw= +github.com/google/s2a-go v0.1.8 h1:zZDs9gcbt9ZPLV0ndSyQk6Kacx2g/X+SKYovpnz3SMM= +github.com/google/s2a-go v0.1.8/go.mod h1:6iNWHTpQ+nfNRN5E00MSdfDwVesa8hhS32PhPO8deJA= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/enterprise-certificate-proxy v0.3.2 h1:Vie5ybvEvT75RniqhfFxPRy3Bf7vr3h0cechB90XaQs= -github.com/googleapis/enterprise-certificate-proxy v0.3.2/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0= -github.com/googleapis/gax-go/v2 v2.12.5 h1:8gw9KZK8TiVKB6q3zHY3SBzLnrGp6HQjyfYBYGmXdxA= -github.com/googleapis/gax-go/v2 v2.12.5/go.mod h1:BUDKcWo+RaKq5SC9vVYL0wLADa3VcfswbOMMRmB9H3E= +github.com/googleapis/enterprise-certificate-proxy v0.3.4 h1:XYIDZApgAnrN1c855gTgghdIA6Stxb52D5RnLI1SLyw= +github.com/googleapis/enterprise-certificate-proxy v0.3.4/go.mod h1:YKe7cfqYXjKGpGvmSg28/fFvhNzinZQm8DGnaburhGA= +github.com/googleapis/gax-go/v2 v2.13.0 h1:yitjD5f7jQHhyDsnhKEBU52NdvvdSeGzlAnDPT0hH1s= +github.com/googleapis/gax-go/v2 v2.13.0/go.mod h1:Z/fvTZXF8/uw7Xu5GuslPw+bplx6SS338j1Is2S+B7A= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= @@ -98,29 +100,29 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0 h1:A3SayB3rNyt+1S6qpI9mHPkeHTZbD7XILEqWnYZb2l0= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.51.0/go.mod h1:27iA5uvhuRNmalO+iEUdVn5ZMj2qy10Mm+XRIpRmyuU= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0 h1:Xs2Ncz0gNihqu9iosIZ5SkBbWo5T8JhhLJFMQL1qmLI= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0/go.mod h1:vy+2G/6NvVMpwGX/NyLqcC41fxepnuKHk16E6IZUcJc= -go.opentelemetry.io/otel v1.26.0 h1:LQwgL5s/1W7YiiRwxf03QGnWLb2HW4pLiAhaA5cZXBs= -go.opentelemetry.io/otel v1.26.0/go.mod h1:UmLkJHUAidDval2EICqBMbnAd0/m2vmpf/dAM+fvFs4= -go.opentelemetry.io/otel/metric v1.26.0 h1:7S39CLuY5Jgg9CrnA9HHiEjGMF/X2VHvoXGgSllRz30= -go.opentelemetry.io/otel/metric v1.26.0/go.mod h1:SY+rHOI4cEawI9a7N1A4nIg/nTQXe1ccCNWYOJUrpX4= -go.opentelemetry.io/otel/trace v1.26.0 h1:1ieeAUb4y0TE26jUFrCIXKpTuVK7uJGN9/Z/2LP5sQA= -go.opentelemetry.io/otel/trace v1.26.0/go.mod h1:4iDxvGDQuUkHve82hJJ8UqrwswHYsZuWCBllGV2U2y0= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 h1:r6I7RJCN86bpD/FQwedZ0vSixDpwuWREjW9oRMsmqDc= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0/go.mod h1:B9yO6b04uB80CzjedvewuqDhxJxi11s7/GtiGa8bAjI= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 h1:TT4fX+nBOA/+LUkobKGW1ydGcn+G3vRw9+g5HwCphpk= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0/go.mod h1:L7UH0GbB0p47T4Rri3uHjbpCFYrVrwc1I25QhNPiGK8= +go.opentelemetry.io/otel v1.29.0 h1:PdomN/Al4q/lN6iBJEN3AwPvUiHPMlt93c8bqTG5Llw= +go.opentelemetry.io/otel v1.29.0/go.mod h1:N/WtXPs1CNCUEx+Agz5uouwCba+i+bJGFicT8SR4NP8= +go.opentelemetry.io/otel/metric v1.29.0 h1:vPf/HFWTNkPu1aYeIsc98l4ktOQaL6LeSoeV2g+8YLc= +go.opentelemetry.io/otel/metric v1.29.0/go.mod h1:auu/QWieFVWx+DmQOUMgj0F8LHWdgalxXqvp7BII/W8= +go.opentelemetry.io/otel/trace v1.29.0 h1:J/8ZNK4XgR7a21DZUAsbF8pZ5Jcw1VhACmnYt39JTi4= +go.opentelemetry.io/otel/trace v1.29.0/go.mod h1:eHl3w0sp3paPkYstJOmAimxhiFXPg+MMTlEh3nsQgWQ= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= +golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= +golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= +golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -130,11 +132,11 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= -golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= +golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -148,14 +150,14 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= -golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= -golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= +golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -164,30 +166,30 @@ golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBn golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= +golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= +golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/api v0.186.0 h1:n2OPp+PPXX0Axh4GuSsL5QL8xQCTb2oDwyzPnQvqUug= -google.golang.org/api v0.186.0/go.mod h1:hvRbBmgoje49RV3xqVXrmP6w93n6ehGgIVPYrGtBFFc= +google.golang.org/api v0.203.0 h1:SrEeuwU3S11Wlscsn+LA1kb/Y5xT8uggJSkIhD08NAU= +google.golang.org/api v0.203.0/go.mod h1:BuOVyCSYEPwJb3npWvDnNmFI92f3GeRnHNkETneT3SI= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4 h1:MuYw1wJzT+ZkybKfaOXKp5hJiZDn2iHaXRw0mRYdHSc= -google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4/go.mod h1:px9SlOOZBg1wM1zdnr8jEL4CNGUBZ+ZKYtNPApNQc4c= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240617180043-68d350f18fd4 h1:Di6ANFilr+S60a4S61ZM00vLdw0IrQOSMS2/6mrnOU0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240617180043-68d350f18fd4/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= +google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9 h1:T6rh4haD3GVYsgEfWExoCZA2o2FmbNyKpTuAxbEFPTg= +google.golang.org/genproto/googleapis/api v0.0.0-20241007155032-5fefd90f89a9/go.mod h1:wp2WsuBYj6j8wUdo3ToZsdxxixbvQNAHqVJrTgi5E5M= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 h1:X58yt85/IXCx0Y3ZwN6sEIKZzQtDEYaBWrDvErdXrRE= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA= -google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0= +google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= +google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -197,8 +199,8 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= +google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/dev/tools/controllerbuilder/pkg/toolbot/extracttoolmarkers.go b/dev/tools/controllerbuilder/pkg/toolbot/extracttoolmarkers.go index 1787bc2508..3f5866057c 100644 --- a/dev/tools/controllerbuilder/pkg/toolbot/extracttoolmarkers.go +++ b/dev/tools/controllerbuilder/pkg/toolbot/extracttoolmarkers.go @@ -22,7 +22,7 @@ import ( "io" "strings" - "k8s.io/klog" + "k8s.io/klog/v2" ) // ExtractToolMarkers extracts tool markers from source code. diff --git a/dev/tools/controllerbuilder/pkg/typeupdater/typeupdater.go b/dev/tools/controllerbuilder/pkg/typeupdater/typeupdater.go index 6f70b0ca93..8d72811101 100644 --- a/dev/tools/controllerbuilder/pkg/typeupdater/typeupdater.go +++ b/dev/tools/controllerbuilder/pkg/typeupdater/typeupdater.go @@ -27,7 +27,7 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/types/descriptorpb" "k8s.io/apimachinery/pkg/util/sets" - "k8s.io/klog" + "k8s.io/klog/v2" ) const kccProtoPrefix = "+kcc:proto=" diff --git a/pkg/controller/direct/discoveryengine/mapper.generated.go b/pkg/controller/direct/discoveryengine/mapper.generated.go index 0a278d7b94..bf080648c2 100644 --- a/pkg/controller/direct/discoveryengine/mapper.generated.go +++ b/pkg/controller/direct/discoveryengine/mapper.generated.go @@ -108,15 +108,12 @@ func DiscoveryEngineDataStoreTargetSiteObservedState_FromProto(mapCtx *direct.Ma } out := &krm.DiscoveryEngineDataStoreTargetSiteObservedState{} // MISSING: Name - // MISSING: ProvidedUriPattern - // MISSING: Type - // MISSING: ExactMatch - // MISSING: GeneratedUriPattern - // MISSING: RootDomainUri - // MISSING: SiteVerificationInfo - // MISSING: IndexingStatus - // MISSING: UpdateTime - // MISSING: FailureReason + out.GeneratedUriPattern = direct.LazyPtr(in.GetGeneratedUriPattern()) + out.RootDomainUri = direct.LazyPtr(in.GetRootDomainUri()) + out.SiteVerificationInfo = SiteVerificationInfo_FromProto(mapCtx, in.GetSiteVerificationInfo()) + out.IndexingStatus = direct.Enum_FromProto(mapCtx, in.GetIndexingStatus()) + out.UpdateTime = direct.StringTimestamp_FromProto(mapCtx, in.GetUpdateTime()) + out.FailureReason = TargetSite_FailureReason_FromProto(mapCtx, in.GetFailureReason()) return out } func DiscoveryEngineDataStoreTargetSiteObservedState_ToProto(mapCtx *direct.MapContext, in *krm.DiscoveryEngineDataStoreTargetSiteObservedState) *pb.TargetSite { @@ -125,15 +122,12 @@ func DiscoveryEngineDataStoreTargetSiteObservedState_ToProto(mapCtx *direct.MapC } out := &pb.TargetSite{} // MISSING: Name - // MISSING: ProvidedUriPattern - // MISSING: Type - // MISSING: ExactMatch - // MISSING: GeneratedUriPattern - // MISSING: RootDomainUri - // MISSING: SiteVerificationInfo - // MISSING: IndexingStatus - // MISSING: UpdateTime - // MISSING: FailureReason + out.GeneratedUriPattern = direct.ValueOf(in.GeneratedUriPattern) + out.RootDomainUri = direct.ValueOf(in.RootDomainUri) + out.SiteVerificationInfo = SiteVerificationInfo_ToProto(mapCtx, in.SiteVerificationInfo) + out.IndexingStatus = direct.Enum_ToProto[pb.TargetSite_IndexingStatus](mapCtx, in.IndexingStatus) + out.UpdateTime = direct.StringTimestamp_ToProto(mapCtx, in.UpdateTime) + out.FailureReason = TargetSite_FailureReason_ToProto(mapCtx, in.FailureReason) return out } func DiscoveryEngineDataStoreTargetSiteSpec_FromProto(mapCtx *direct.MapContext, in *pb.TargetSite) *krm.DiscoveryEngineDataStoreTargetSiteSpec { @@ -142,15 +136,9 @@ func DiscoveryEngineDataStoreTargetSiteSpec_FromProto(mapCtx *direct.MapContext, } out := &krm.DiscoveryEngineDataStoreTargetSiteSpec{} // MISSING: Name - // MISSING: ProvidedUriPattern - // MISSING: Type - // MISSING: ExactMatch - // MISSING: GeneratedUriPattern - // MISSING: RootDomainUri - // MISSING: SiteVerificationInfo - // MISSING: IndexingStatus - // MISSING: UpdateTime - // MISSING: FailureReason + out.ProvidedUriPattern = direct.LazyPtr(in.GetProvidedUriPattern()) + out.Type = direct.Enum_FromProto(mapCtx, in.GetType()) + out.ExactMatch = direct.LazyPtr(in.GetExactMatch()) return out } func DiscoveryEngineDataStoreTargetSiteSpec_ToProto(mapCtx *direct.MapContext, in *krm.DiscoveryEngineDataStoreTargetSiteSpec) *pb.TargetSite { @@ -159,15 +147,9 @@ func DiscoveryEngineDataStoreTargetSiteSpec_ToProto(mapCtx *direct.MapContext, i } out := &pb.TargetSite{} // MISSING: Name - // MISSING: ProvidedUriPattern - // MISSING: Type - // MISSING: ExactMatch - // MISSING: GeneratedUriPattern - // MISSING: RootDomainUri - // MISSING: SiteVerificationInfo - // MISSING: IndexingStatus - // MISSING: UpdateTime - // MISSING: FailureReason + out.ProvidedUriPattern = direct.ValueOf(in.ProvidedUriPattern) + out.Type = direct.Enum_ToProto[pb.TargetSite_Type](mapCtx, in.Type) + out.ExactMatch = direct.ValueOf(in.ExactMatch) return out } func DiscoveryEngineEngineObservedState_FromProto(mapCtx *direct.MapContext, in *pb.Engine) *krm.DiscoveryEngineEngineObservedState { From b1a2cce3610c455ad44444e63d1825ce9c9f1f3f Mon Sep 17 00:00:00 2001 From: justinsb Date: Wed, 18 Dec 2024 21:48:28 -0500 Subject: [PATCH 03/10] DiscoveryEngineDataStoreTargetSite: create test --- .../create.yaml | 24 +++++++++++++++++ .../dependencies.yaml | 26 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 pkg/test/resourcefixture/testdata/basic/discoveryengine/v1alpha1/discoveryenginedatastoretargetsite/discoveryenginedatastoretargetsiteminimal/create.yaml create mode 100644 pkg/test/resourcefixture/testdata/basic/discoveryengine/v1alpha1/discoveryenginedatastoretargetsite/discoveryenginedatastoretargetsiteminimal/dependencies.yaml diff --git a/pkg/test/resourcefixture/testdata/basic/discoveryengine/v1alpha1/discoveryenginedatastoretargetsite/discoveryenginedatastoretargetsiteminimal/create.yaml b/pkg/test/resourcefixture/testdata/basic/discoveryengine/v1alpha1/discoveryenginedatastoretargetsite/discoveryenginedatastoretargetsiteminimal/create.yaml new file mode 100644 index 0000000000..4ab9504faa --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/discoveryengine/v1alpha1/discoveryenginedatastoretargetsite/discoveryenginedatastoretargetsiteminimal/create.yaml @@ -0,0 +1,24 @@ +# Copyright 2024 Google LLC +# +# 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. + +apiVersion: discoveryengine.cnrm.cloud.google.com/v1alpha1 +kind: DiscoveryEngineDataStoreTargetSite +metadata: + name: targetsite-${uniqueId} +spec: + dataStoreRef: + name: datastore-${uniqueId} + providedUriPattern: "cloud.google.com/generative-ai-app-builder/*" + type: INCLUDE + exactMatch: true diff --git a/pkg/test/resourcefixture/testdata/basic/discoveryengine/v1alpha1/discoveryenginedatastoretargetsite/discoveryenginedatastoretargetsiteminimal/dependencies.yaml b/pkg/test/resourcefixture/testdata/basic/discoveryengine/v1alpha1/discoveryenginedatastoretargetsite/discoveryenginedatastoretargetsiteminimal/dependencies.yaml new file mode 100644 index 0000000000..09236da9ab --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/discoveryengine/v1alpha1/discoveryenginedatastoretargetsite/discoveryenginedatastoretargetsiteminimal/dependencies.yaml @@ -0,0 +1,26 @@ +# Copyright 2024 Google LLC +# +# 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. + +apiVersion: discoveryengine.cnrm.cloud.google.com/v1alpha1 +kind: DiscoveryEngineDataStore +metadata: + name: datastore-${uniqueId} +spec: + projectRef: + external: projects/${projectId} + location: global + collection: default_collection + contentConfig: PUBLIC_WEBSITE + displayName: "KCC Test DisplayName" + industryVertical: GENERIC From 0a2a4a51c29b5c0ed7fe224e63dcd9d90da7ae37 Mon Sep 17 00:00:00 2001 From: justinsb Date: Wed, 18 Dec 2024 21:48:41 -0500 Subject: [PATCH 04/10] tests: golden output --- ...ginedatastoretargetsiteminimal.golden.yaml | 30 +++ .../_http.log | 230 ++++++++++++++++++ 2 files changed, 260 insertions(+) create mode 100644 pkg/test/resourcefixture/testdata/basic/discoveryengine/v1alpha1/discoveryenginedatastoretargetsite/discoveryenginedatastoretargetsiteminimal/_generated_object_discoveryenginedatastoretargetsiteminimal.golden.yaml create mode 100644 pkg/test/resourcefixture/testdata/basic/discoveryengine/v1alpha1/discoveryenginedatastoretargetsite/discoveryenginedatastoretargetsiteminimal/_http.log diff --git a/pkg/test/resourcefixture/testdata/basic/discoveryengine/v1alpha1/discoveryenginedatastoretargetsite/discoveryenginedatastoretargetsiteminimal/_generated_object_discoveryenginedatastoretargetsiteminimal.golden.yaml b/pkg/test/resourcefixture/testdata/basic/discoveryengine/v1alpha1/discoveryenginedatastoretargetsite/discoveryenginedatastoretargetsiteminimal/_generated_object_discoveryenginedatastoretargetsiteminimal.golden.yaml new file mode 100644 index 0000000000..8b68d6890b --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/discoveryengine/v1alpha1/discoveryenginedatastoretargetsite/discoveryenginedatastoretargetsiteminimal/_generated_object_discoveryenginedatastoretargetsiteminimal.golden.yaml @@ -0,0 +1,30 @@ +apiVersion: discoveryengine.cnrm.cloud.google.com/v1alpha1 +kind: DiscoveryEngineDataStoreTargetSite +metadata: + finalizers: + - cnrm.cloud.google.com/finalizer + - cnrm.cloud.google.com/deletion-defender + generation: 1 + labels: + cnrm-test: "true" + name: targetsite-${uniqueId} + namespace: ${uniqueId} +spec: + dataStoreRef: + name: datastore-${uniqueId} + exactMatch: true + providedUriPattern: cloud.google.com/generative-ai-app-builder/* + type: INCLUDE +status: + conditions: + - lastTransitionTime: "1970-01-01T00:00:00Z" + message: The resource is up to date + reason: UpToDate + status: "True" + type: Ready + externalRef: projects/${projectId}/locations/global/collections/default_collection/dataStores/datastore-${uniqueId}/siteSearchEngine/targetSites/${targetSiteID} + observedGeneration: 1 + observedState: + generatedUriPattern: cloud.google.com/generative-ai-app-builder/* + rootDomainUri: google.com + updateTime: "1970-01-01T00:00:00Z" diff --git a/pkg/test/resourcefixture/testdata/basic/discoveryengine/v1alpha1/discoveryenginedatastoretargetsite/discoveryenginedatastoretargetsiteminimal/_http.log b/pkg/test/resourcefixture/testdata/basic/discoveryengine/v1alpha1/discoveryenginedatastoretargetsite/discoveryenginedatastoretargetsiteminimal/_http.log new file mode 100644 index 0000000000..f85431c810 --- /dev/null +++ b/pkg/test/resourcefixture/testdata/basic/discoveryengine/v1alpha1/discoveryenginedatastoretargetsite/discoveryenginedatastoretargetsiteminimal/_http.log @@ -0,0 +1,230 @@ +GET https://discoveryengine.googleapis.com/v1/projects/${projectId}/locations/global/collections/default_collection/dataStores/${dataStoreID}?%24alt=json%3Benum-encoding%3Dint +Content-Type: application/json +User-Agent: kcc/controller-manager +X-Goog-User-Project: ${projectId} +x-goog-request-params: name=projects%2F${projectId}%2Flocations%2Fglobal%2Fcollections%2Fdefault_collection%2FdataStores%2F${dataStoreID} + +404 Not Found +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "error": { + "code": 404, + "message": "DataStore projects/${projectNumber}/locations/global/collections/default_collection/dataStores/datastore-${uniqueId} not found.", + "status": "NOT_FOUND" + } +} + +--- + +POST https://discoveryengine.googleapis.com/v1/projects/${projectId}/locations/global/collections/default_collection/dataStores?%24alt=json%3Benum-encoding%3Dint&dataStoreId=${dataStoreID} +Content-Type: application/json +User-Agent: kcc/controller-manager +X-Goog-User-Project: ${projectId} +x-goog-request-params: parent=projects%2F${projectId}%2Flocations%2Fglobal%2Fcollections%2Fdefault_collection + +{ + "contentConfig": 3, + "displayName": "KCC Test DisplayName", + "industryVertical": 1, + "name": "projects/${projectId}/locations/global/collections/default_collection/dataStores/datastore-${uniqueId}" +} + +200 OK +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "done": true, + "name": "projects/${projectNumber}/locations/global/collections/default_collection/operations/${operationID}", + "response": { + "@type": "type.googleapis.com/google.cloud.discoveryengine.v1.DataStore", + "contentConfig": 3, + "defaultSchemaId": "default_schema", + "displayName": "KCC Test DisplayName", + "industryVertical": 1, + "name": "projects/${projectNumber}/locations/global/collections/default_collection/dataStores/datastore-${uniqueId}", + "servingConfigDataStore": {} + } +} + +--- + +POST https://discoveryengine.googleapis.com/v1/projects/${projectId}/locations/global/collections/default_collection/dataStores/${dataStoreID}/siteSearchEngine/targetSites?%24alt=json%3Benum-encoding%3Dint +Content-Type: application/json +User-Agent: kcc/controller-manager +X-Goog-User-Project: ${projectId} +x-goog-request-params: parent=projects%2F${projectId}%2Flocations%2Fglobal%2Fcollections%2Fdefault_collection%2FdataStores%2F${dataStoreID}%2FsiteSearchEngine + +{ + "exactMatch": true, + "providedUriPattern": "cloud.google.com/generative-ai-app-builder/*", + "type": 1 +} + +200 OK +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "done": true, + "response": { + "@type": "type.googleapis.com/google.cloud.discoveryengine.v1.TargetSite", + "generatedUriPattern": "cloud.google.com/generative-ai-app-builder/*", + "name": "projects/${projectNumber}/locations/global/collections/default_collection/dataStores/datastore-${uniqueId}/siteSearchEngine/targetSites/${targetSiteID}", + "providedUriPattern": "cloud.google.com/generative-ai-app-builder/*", + "rootDomainUri": "google.com", + "type": 1, + "updateTime": "2024-04-01T12:34:56.123456Z" + } +} + +--- + +GET https://cloudresourcemanager.googleapis.com/v3/projects/${projectNumber}?%24alt=json%3Benum-encoding%3Dint +Content-Type: application/json +User-Agent: kcc/controller-manager +x-goog-request-params: name=projects%2F${projectNumber} + +200 OK +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "createTime": "2024-04-01T12:34:56.123456Z", + "displayName": "${projectId}", + "etag": "abcdef0123A=", + "labels": { + "cnrm-test": "true", + "managed-by-cnrm": "true" + }, + "name": "projects/${projectNumber}", + "parent": "folders/${folderID}", + "projectId": "${projectId}", + "state": 1, + "updateTime": "2024-04-01T12:34:56.123456Z" +} + +--- + +GET https://discoveryengine.googleapis.com/v1/projects/${projectId}/locations/global/collections/default_collection/dataStores/${dataStoreID}/siteSearchEngine/targetSites/${targetSiteID}?%24alt=json%3Benum-encoding%3Dint +Content-Type: application/json +User-Agent: kcc/controller-manager +X-Goog-User-Project: ${projectId} +x-goog-request-params: name=projects%2F${projectId}%2Flocations%2Fglobal%2Fcollections%2Fdefault_collection%2FdataStores%2F${dataStoreID}%2FsiteSearchEngine%2FtargetSites%2F${targetSiteID} + +200 OK +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "generatedUriPattern": "cloud.google.com/generative-ai-app-builder/*", + "name": "projects/${projectNumber}/locations/global/collections/default_collection/dataStores/datastore-${uniqueId}/siteSearchEngine/targetSites/${targetSiteID}", + "rootDomainUri": "google.com", + "type": 1, + "updateTime": "2024-04-01T12:34:56.123456Z" +} + +--- + +DELETE https://discoveryengine.googleapis.com/v1/projects/${projectId}/locations/global/collections/default_collection/dataStores/${dataStoreID}/siteSearchEngine/targetSites/${targetSiteID}?%24alt=json%3Benum-encoding%3Dint +Content-Type: application/json +User-Agent: kcc/controller-manager +X-Goog-User-Project: ${projectId} +x-goog-request-params: name=projects%2F${projectId}%2Flocations%2Fglobal%2Fcollections%2Fdefault_collection%2FdataStores%2F${dataStoreID}%2FsiteSearchEngine%2FtargetSites%2F${targetSiteID} + +200 OK +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "done": true +} + +--- + +GET https://discoveryengine.googleapis.com/v1/projects/${projectId}/locations/global/collections/default_collection/dataStores/${dataStoreID}?%24alt=json%3Benum-encoding%3Dint +Content-Type: application/json +User-Agent: kcc/controller-manager +X-Goog-User-Project: ${projectId} +x-goog-request-params: name=projects%2F${projectId}%2Flocations%2Fglobal%2Fcollections%2Fdefault_collection%2FdataStores%2F${dataStoreID} + +200 OK +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "contentConfig": 3, + "createTime": "2024-04-01T12:34:56.123456Z", + "defaultSchemaId": "default_schema", + "displayName": "KCC Test DisplayName", + "industryVertical": 1, + "name": "projects/${projectNumber}/locations/global/collections/default_collection/dataStores/datastore-${uniqueId}", + "servingConfigDataStore": {} +} + +--- + +DELETE https://discoveryengine.googleapis.com/v1/projects/${projectId}/locations/global/collections/default_collection/dataStores/${dataStoreID}?%24alt=json%3Benum-encoding%3Dint +Content-Type: application/json +User-Agent: kcc/controller-manager +X-Goog-User-Project: ${projectId} +x-goog-request-params: name=projects%2F${projectId}%2Flocations%2Fglobal%2Fcollections%2Fdefault_collection%2FdataStores%2F${dataStoreID} + +200 OK +Content-Type: application/json; charset=UTF-8 +Server: ESF +Vary: Origin +Vary: X-Origin +Vary: Referer +X-Content-Type-Options: nosniff +X-Frame-Options: SAMEORIGIN +X-Xss-Protection: 0 + +{ + "done": true, + "name": "projects/${projectNumber}/locations/global/collections/default_collection/operations/${operationID}" +} \ No newline at end of file From 73aaaa4697dd60c3166950b935f0f31075b70d68 Mon Sep 17 00:00:00 2001 From: justinsb Date: Wed, 18 Dec 2024 21:49:38 -0500 Subject: [PATCH 05/10] Fixes to API (should go into previous PR) --- .../v1alpha1/targetsite_reference.go | 53 ++++++++++++++++--- .../v1alpha1/targetsite_types.go | 5 +- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/apis/discoveryengine/v1alpha1/targetsite_reference.go b/apis/discoveryengine/v1alpha1/targetsite_reference.go index 25525e49f5..7961c6689e 100644 --- a/apis/discoveryengine/v1alpha1/targetsite_reference.go +++ b/apis/discoveryengine/v1alpha1/targetsite_reference.go @@ -43,12 +43,16 @@ type TargetSiteRef struct { Namespace string `json:"namespace,omitempty"` } -// TargetStoreLink defines the full identity for a DataStoreTargetSite +// TargetSiteLink defines the full identity for a DataStoreTargetSite // // +k8s:deepcopy-gen=false -type TargetStoreLink struct { +type TargetSiteLink struct { *DiscoveryEngineDataStoreID - DataStore string + TargetSite string +} + +func (l *TargetSiteLink) String() string { + return l.DiscoveryEngineDataStoreID.String() + "/siteSearchEngine/targetSites/" + l.TargetSite } // NormalizedExternal provision the "External" value for other resource that depends on DiscoveryEngineDataStoreTargetSite. @@ -91,11 +95,44 @@ func (r *TargetSiteRef) NormalizedExternal(ctx context.Context, reader client.Re return r.External, nil } -func ParseTargetSiteExternal(external string) (*TargetStoreLink, error) { +// NewTargetSiteLinkFromObject builds a TargetSiteLink from the Config Connector object. +func NewTargetSiteLinkFromObject(ctx context.Context, reader client.Reader, obj *DiscoveryEngineDataStoreTargetSite) (*DiscoveryEngineDataStoreID, *TargetSiteLink, error) { + if obj.Spec.DataStoreRef == nil { + return nil, nil, fmt.Errorf("spec.dataStoreRef not set") + } + dataStoreRef := *obj.Spec.DataStoreRef + if _, err := dataStoreRef.NormalizedExternal(ctx, reader, obj.GetNamespace()); err != nil { + return nil, nil, fmt.Errorf("resolving spec.dataStoreRef: %w", err) + } + dataStoreLink, err := ParseDiscoveryEngineDataStoreExternal(dataStoreRef.External) + if err != nil { + return nil, nil, fmt.Errorf("parsing dataStoreRef.external=%q: %w", dataStoreRef.External, err) + } + + var link *TargetSiteLink + + // Validate the status.externalRef, if set + externalRef := valueOf(obj.Status.ExternalRef) + if externalRef != "" { + // Validate desired with actual + externalLink, err := ParseTargetSiteExternal(externalRef) + if err != nil { + return nil, nil, err + } + if externalLink.DiscoveryEngineDataStoreID.String() != dataStoreLink.String() { + return nil, nil, fmt.Errorf("cannot change object key after creation; status=%q, new=%q", + externalLink.DiscoveryEngineDataStoreID.String(), dataStoreLink.String()) + } + link = externalLink + } + return dataStoreLink, link, nil +} + +func ParseTargetSiteExternal(external string) (*TargetSiteLink, error) { s := strings.TrimPrefix(external, "//discoveryengine.googleapis.com/") s = strings.TrimPrefix(s, "/") tokens := strings.Split(s, "/") - if len(tokens) == 10 && tokens[0] == "projects" && tokens[2] == "locations" && tokens[4] == "collections" && tokens[6] == "dataStores" && tokens[8] == "targetSites" { + if len(tokens) == 11 && tokens[0] == "projects" && tokens[2] == "locations" && tokens[4] == "collections" && tokens[6] == "dataStores" && tokens[8] == "siteSearchEngine" && tokens[9] == "targetSites" { projectAndLocation := &ProjectAndLocation{ ProjectID: tokens[1], Location: tokens[3], @@ -108,11 +145,11 @@ func ParseTargetSiteExternal(external string) (*TargetStoreLink, error) { CollectionLink: collection, DataStore: tokens[7], } - targetStoreLink := &TargetStoreLink{ + targetStoreLink := &TargetSiteLink{ DiscoveryEngineDataStoreID: dataStoreLink, - DataStore: tokens[9], + TargetSite: tokens[10], } return targetStoreLink, nil } - return nil, fmt.Errorf("format of DiscoveryEngineDataStoreTargetSite external=%q was not known (use projects/{{projectId}}/locations/{{location}}/collections/{{collectionID}}/dataStores/{{dataStoreID}}/targetSites/{{targetSiteID}})", external) + return nil, fmt.Errorf("format of DiscoveryEngineDataStoreTargetSite external=%q was not known (use projects/{{projectId}}/locations/{{location}}/collections/{{collectionID}}/dataStores/{{dataStoreID}}/siteSearchEngine/targetSites/{{targetSiteID}})", external) } diff --git a/apis/discoveryengine/v1alpha1/targetsite_types.go b/apis/discoveryengine/v1alpha1/targetsite_types.go index 459b950558..ae83972482 100644 --- a/apis/discoveryengine/v1alpha1/targetsite_types.go +++ b/apis/discoveryengine/v1alpha1/targetsite_types.go @@ -27,10 +27,7 @@ type DiscoveryEngineDataStoreTargetSiteSpec struct { // The DataStore this target site should be part of. DataStoreRef *DiscoveryEngineDataStoreRef `json:"dataStoreRef,omitempty"` - // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable" - // Immutable. - // The DiscoveryEngineDataStoreTargetSite name. If not given, the metadata.name will be used. - ResourceID *string `json:"resourceID,omitempty"` + // The resource ID is server-generated, so no ResourceID field // Required. Input only. The user provided URI pattern from which the // `generated_uri_pattern` is generated. From a7d80e54606ff34483edc4d5bb29f67a6afec931 Mon Sep 17 00:00:00 2001 From: justinsb Date: Wed, 18 Dec 2024 21:49:51 -0500 Subject: [PATCH 06/10] Autogen fixes (should go into previous PR) --- apis/discoveryengine/v1alpha1/zz_generated.deepcopy.go | 5 ----- ...etargetsites.discoveryengine.cnrm.cloud.google.com.yaml | 7 ------- 2 files changed, 12 deletions(-) diff --git a/apis/discoveryengine/v1alpha1/zz_generated.deepcopy.go b/apis/discoveryengine/v1alpha1/zz_generated.deepcopy.go index 803509e45e..2ecf3d4ebe 100644 --- a/apis/discoveryengine/v1alpha1/zz_generated.deepcopy.go +++ b/apis/discoveryengine/v1alpha1/zz_generated.deepcopy.go @@ -410,11 +410,6 @@ func (in *DiscoveryEngineDataStoreTargetSiteSpec) DeepCopyInto(out *DiscoveryEng *out = new(DiscoveryEngineDataStoreRef) **out = **in } - if in.ResourceID != nil { - in, out := &in.ResourceID, &out.ResourceID - *out = new(string) - **out = **in - } if in.ProvidedUriPattern != nil { in, out := &in.ProvidedUriPattern, &out.ProvidedUriPattern *out = new(string) diff --git a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_discoveryenginedatastoretargetsites.discoveryengine.cnrm.cloud.google.com.yaml b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_discoveryenginedatastoretargetsites.discoveryengine.cnrm.cloud.google.com.yaml index 8ebc9ea6ad..fd88ad7aa9 100644 --- a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_discoveryenginedatastoretargetsites.discoveryengine.cnrm.cloud.google.com.yaml +++ b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_discoveryenginedatastoretargetsites.discoveryengine.cnrm.cloud.google.com.yaml @@ -102,13 +102,6 @@ spec: description: Required. Input only. The user provided URI pattern from which the `generated_uri_pattern` is generated. type: string - resourceID: - description: Immutable. The DiscoveryEngineDataStoreTargetSite name. - If not given, the metadata.name will be used. - type: string - x-kubernetes-validations: - - message: ResourceID field is immutable - rule: self == oldSelf type: description: The type of the target site, e.g., whether the site is to be included or excluded. From 9d0f59cfff50ddcf78117fc137d045fa0df4625b Mon Sep 17 00:00:00 2001 From: justinsb Date: Wed, 18 Dec 2024 22:02:51 -0500 Subject: [PATCH 07/10] tests: normalization for DiscoveryEngineDataStoreTargetSite --- tests/e2e/normalize.go | 17 +++++++++++++++++ tests/e2e/replacements.go | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/tests/e2e/normalize.go b/tests/e2e/normalize.go index b21e6662af..1952cd6148 100644 --- a/tests/e2e/normalize.go +++ b/tests/e2e/normalize.go @@ -228,7 +228,24 @@ func normalizeKRMObject(t *testing.T, u *unstructured.Unstructured, project test return r.ReplaceAllLiteralString(s, "deleted:serviceAccount:gsa-${uniqueId}@${projectId}.iam.gserviceaccount.com?uid=12345678") }) + // Try to extract resource IDs from status.externalRef and replace them + { + r := NewReplacements() + + externalRef, _, _ := unstructured.NestedString(u.Object, "status", "externalRef") + if externalRef != "" { + r.ExtractIDsFromLinks(externalRef) + + for k, v := range r.PathIDs { + visitor.stringTransforms = append(visitor.stringTransforms, func(path string, s string) string { + return strings.ReplaceAll(s, k, v) + }) + } + } + } + // Try to extract resource IDs from links and replace them + // Note: these might now be handled by status.externalLink above { name, _, _ := unstructured.NestedString(u.Object, "status", "observedState", "name") if name == "" { diff --git a/tests/e2e/replacements.go b/tests/e2e/replacements.go index 98d8813078..393177f48c 100644 --- a/tests/e2e/replacements.go +++ b/tests/e2e/replacements.go @@ -146,6 +146,13 @@ func (r *Replacements) placeholderForGCPResource(resource string) string { return "${targetHttpsProxyID}" case "targetSslProxies": return "${targetSslProxyID}" + + // discoveryengine + case "dataStores": + return "${dataStoreID}" + case "targetSites": + return "${targetSiteID}" + default: return "" } From 9f214143670af96889ebb6026918e1548e47d87b Mon Sep 17 00:00:00 2001 From: justinsb Date: Wed, 18 Dec 2024 22:03:37 -0500 Subject: [PATCH 08/10] DiscoveryStoreDataStoreTargetSite: controller --- .../discoveryengine/datastore_controller.go | 3 + .../datastoretargetsite_controller.go | 325 ++++++++++++++++++ 2 files changed, 328 insertions(+) create mode 100644 pkg/controller/direct/discoveryengine/datastoretargetsite_controller.go diff --git a/pkg/controller/direct/discoveryengine/datastore_controller.go b/pkg/controller/direct/discoveryengine/datastore_controller.go index fda715dc6a..83279c6ed6 100644 --- a/pkg/controller/direct/discoveryengine/datastore_controller.go +++ b/pkg/controller/direct/discoveryengine/datastore_controller.go @@ -256,6 +256,9 @@ func (a *dataStoreAdapter) Delete(ctx context.Context, deleteOp *directbase.Dele req := &pb.DeleteDataStoreRequest{Name: a.id.String()} op, err := a.gcpClient.DeleteDataStore(ctx, req) if err != nil { + if direct.IsNotFound(err) { + return false, nil + } return false, fmt.Errorf("deleting discoveryengine datastore %s: %w", a.id.String(), err) } log.V(2).Info("successfully deleted discoveryengine datastore", "name", a.id) diff --git a/pkg/controller/direct/discoveryengine/datastoretargetsite_controller.go b/pkg/controller/direct/discoveryengine/datastoretargetsite_controller.go new file mode 100644 index 0000000000..8e83b45f33 --- /dev/null +++ b/pkg/controller/direct/discoveryengine/datastoretargetsite_controller.go @@ -0,0 +1,325 @@ +// Copyright 2024 Google LLC +// +// 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 discoveryengine + +import ( + "context" + "fmt" + "reflect" + "strings" + + gcp "cloud.google.com/go/discoveryengine/apiv1" + pb "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb" + "google.golang.org/api/option" + "google.golang.org/protobuf/types/known/fieldmaskpb" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/klog/v2" + "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/GoogleCloudPlatform/k8s-config-connector/apis/common/projects" + krm "github.com/GoogleCloudPlatform/k8s-config-connector/apis/discoveryengine/v1alpha1" + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/config" + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct" + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/directbase" + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/registry" +) + +func init() { + registry.RegisterModel(krm.DiscoveryEngineDataStoreTargetSiteGVK, NewDataStoreTargetSiteModel) +} + +func NewDataStoreTargetSiteModel(ctx context.Context, config *config.ControllerConfig) (directbase.Model, error) { + return &dataStoreTargetSiteModel{config: *config}, nil +} + +var _ directbase.Model = &dataStoreTargetSiteModel{} + +type dataStoreTargetSiteModel struct { + config config.ControllerConfig +} + +func (m *dataStoreTargetSiteModel) client(ctx context.Context, projectID string) (*gcp.SiteSearchEngineClient, error) { + var opts []option.ClientOption + + config := m.config + + // Workaround for an unusual behaviour (bug?): + // the service requires that a quota project be set + if !config.UserProjectOverride || config.BillingProject == "" { + config.UserProjectOverride = true + config.BillingProject = projectID + } + + opts, err := config.RESTClientOptions() + if err != nil { + return nil, err + } + + gcpClient, err := gcp.NewSiteSearchEngineRESTClient(ctx, opts...) + if err != nil { + return nil, fmt.Errorf("building discoveryengine siteSearchEngine client: %w", err) + } + + return gcpClient, err +} + +func (m *dataStoreTargetSiteModel) AdapterForObject(ctx context.Context, reader client.Reader, u *unstructured.Unstructured) (directbase.Adapter, error) { + obj := &krm.DiscoveryEngineDataStoreTargetSite{} + if err := runtime.DefaultUnstructuredConverter.FromUnstructured(u.Object, &obj); err != nil { + return nil, fmt.Errorf("error converting to %T: %w", obj, err) + } + + dataStoreLink, link, err := krm.NewTargetSiteLinkFromObject(ctx, reader, obj) + if err != nil { + return nil, err + } + + mapCtx := &direct.MapContext{} + desired := DiscoveryEngineDataStoreTargetSiteSpec_ToProto(mapCtx, &obj.Spec) + if mapCtx.Err() != nil { + return nil, mapCtx.Err() + } + + gcpClient, err := m.client(ctx, dataStoreLink.ProjectID) + if err != nil { + return nil, err + } + + return &dataStoreTargetSiteAdapter{ + gcpClient: gcpClient, + projectMapper: m.config.ProjectMapper, + parent: dataStoreLink, + link: link, + desired: desired, + }, nil +} + +func (m *dataStoreTargetSiteModel) AdapterForURL(ctx context.Context, url string) (directbase.Adapter, error) { + log := klog.FromContext(ctx) + if strings.HasPrefix(url, "//discoveryengine.googleapis.com/") { + id, err := krm.ParseTargetSiteExternal(url) + if err != nil { + log.V(2).Error(err, "url did not match DiscoveryEngineDataStoreTargetSite format", "url", url) + } else { + gcpClient, err := m.client(ctx, id.ProjectID) + if err != nil { + return nil, err + } + return &dataStoreTargetSiteAdapter{ + gcpClient: gcpClient, + projectMapper: m.config.ProjectMapper, + parent: id.DiscoveryEngineDataStoreID, + link: id, + }, nil + } + } + return nil, nil +} + +type dataStoreTargetSiteAdapter struct { + gcpClient *gcp.SiteSearchEngineClient + projectMapper *projects.ProjectMapper + parent *krm.DiscoveryEngineDataStoreID + link *krm.TargetSiteLink + desired *pb.TargetSite + actual *pb.TargetSite +} + +var _ directbase.Adapter = &dataStoreTargetSiteAdapter{} + +func (a *dataStoreTargetSiteAdapter) Find(ctx context.Context) (bool, error) { + if a.link == nil { + // Server-generated ID and no ID set + return false, nil + } + fqn := a.link.String() + + log := klog.FromContext(ctx) + log.V(2).Info("getting discoveryengine targetSite", "name", fqn) + + req := &pb.GetTargetSiteRequest{Name: fqn} + actual, err := a.gcpClient.GetTargetSite(ctx, req) + if err != nil { + if direct.IsNotFound(err) { + return false, nil + } + return false, fmt.Errorf("getting discoveryengine targetSite %q from gcp: %w", fqn, err) + } + + a.actual = actual + return true, nil +} + +func (a *dataStoreTargetSiteAdapter) Create(ctx context.Context, createOp *directbase.CreateOperation) error { + // fqn := a.link.String() + parentFQN := a.parent.String() + "/siteSearchEngine" + + log := klog.FromContext(ctx) + log.V(2).Info("creating discoveryengine targetSite", "parent", parentFQN) + + desired := direct.ProtoClone(a.desired) + + req := &pb.CreateTargetSiteRequest{ + Parent: parentFQN, + TargetSite: desired, + } + op, err := a.gcpClient.CreateTargetSite(ctx, req) + if err != nil { + return fmt.Errorf("creating discoveryengine targetSite in %q: %w", parentFQN, err) + } + created, err := op.Wait(ctx) + if err != nil { + return fmt.Errorf("waiting for creation of discoveryengine targetSite in %q: %w", parentFQN, err) + } + fqn := created.Name + + log.V(2).Info("successfully created discoveryengine targetSite in gcp", "name", fqn) + + status := &krm.DiscoveryEngineDataStoreTargetSiteStatus{} + mapCtx := &direct.MapContext{} + status.ObservedState = DiscoveryEngineDataStoreTargetSiteObservedState_FromProto(mapCtx, created) + if mapCtx.Err() != nil { + return mapCtx.Err() + } + + link, err := krm.ParseTargetSiteExternal(created.Name) + if err != nil { + return fmt.Errorf("unexpected name %q for created targetSite: %w", created.Name, err) + } + if s, err := a.projectMapper.ReplaceProjectNumberWithID(ctx, link.ProjectID); err != nil { + return err + } else { + link.ProjectID = s + } + + status.ExternalRef = direct.PtrTo(link.String()) + + return createOp.UpdateStatus(ctx, status, nil) +} + +func (a *dataStoreTargetSiteAdapter) Update(ctx context.Context, updateOp *directbase.UpdateOperation) error { + fqn := a.link.String() + + log := klog.FromContext(ctx) + log.V(2).Info("updating discoveryengine targetSite", "name", fqn) + + desired := direct.ProtoClone(a.desired) + desired.Name = fqn + + updateMask := &fieldmaskpb.FieldMask{} + if !reflect.DeepEqual(a.desired.ProvidedUriPattern, a.actual.ProvidedUriPattern) { + updateMask.Paths = append(updateMask.Paths, "provided_uri_pattern") + } + if !reflect.DeepEqual(a.desired.Type, a.actual.Type) { + updateMask.Paths = append(updateMask.Paths, "type") + } + if !reflect.DeepEqual(a.desired.ExactMatch, a.actual.ExactMatch) { + updateMask.Paths = append(updateMask.Paths, "exact_match") + } + + if len(updateMask.Paths) == 0 { + log.V(2).Info("no field needs update", "name", fqn) + return nil + } + + req := &pb.UpdateTargetSiteRequest{ + TargetSite: desired, + } + op, err := a.gcpClient.UpdateTargetSite(ctx, req) + if err != nil { + return fmt.Errorf("updating discoveryengine targetSite %q: %w", fqn, err) + } + if !op.Done() { + if _, err := op.Wait(ctx); err != nil { + return fmt.Errorf("waiting for update of discoveryengine targetSite %q: %w", fqn, err) + } + } + + updated, err := a.gcpClient.GetTargetSite(ctx, &pb.GetTargetSiteRequest{Name: fqn}) + if err != nil { + return fmt.Errorf("getting updated discoveryengine targetSite %q: %w", fqn, err) + } + log.V(2).Info("successfully updated discoveryengine targetSite", "name", fqn) + + status := &krm.DiscoveryEngineDataStoreTargetSiteStatus{} + mapCtx := &direct.MapContext{} + status.ObservedState = DiscoveryEngineDataStoreTargetSiteObservedState_FromProto(mapCtx, updated) + if mapCtx.Err() != nil { + return mapCtx.Err() + } + return updateOp.UpdateStatus(ctx, status, nil) +} + +func (a *dataStoreTargetSiteAdapter) Export(ctx context.Context) (*unstructured.Unstructured, error) { + log := klog.FromContext(ctx) + + if a.actual == nil { + return nil, fmt.Errorf("Find() not called") + } + + obj := &krm.DiscoveryEngineDataStoreTargetSite{} + mapCtx := &direct.MapContext{} + obj.Spec = direct.ValueOf(DiscoveryEngineDataStoreTargetSiteSpec_FromProto(mapCtx, a.actual)) + if mapCtx.Err() != nil { + return nil, mapCtx.Err() + } + + link, err := krm.ParseTargetSiteExternal(a.actual.Name) + if err != nil { + return nil, fmt.Errorf("unexpected name %q for targetSite: %w", a.actual.Name, err) + } + obj.Spec.DataStoreRef = &krm.DiscoveryEngineDataStoreRef{ + External: link.DiscoveryEngineDataStoreID.String(), + } + + uObj, err := runtime.DefaultUnstructuredConverter.ToUnstructured(obj) + if err != nil { + return nil, err + } + + u := &unstructured.Unstructured{Object: uObj} + u.SetName(link.TargetSite) + u.SetGroupVersionKind(krm.DiscoveryEngineDataStoreTargetSiteGVK) + + log.Info("exported object", "obj", u, "gvk", u.GroupVersionKind()) + return u, nil +} + +// Delete implements the Adapter interface. +func (a *dataStoreTargetSiteAdapter) Delete(ctx context.Context, deleteOp *directbase.DeleteOperation) (bool, error) { + fqn := a.link.String() + + log := klog.FromContext(ctx) + log.V(2).Info("deleting discoveryengine datastoretargetsite", "name", fqn) + + req := &pb.DeleteTargetSiteRequest{Name: fqn} + op, err := a.gcpClient.DeleteTargetSite(ctx, req) + if err != nil { + if direct.IsNotFound(err) { + return false, nil + } + return false, fmt.Errorf("deleting discoveryengine targetSite %q: %w", fqn, err) + } + log.V(2).Info("successfully deleted discoveryengine targetSite", "name", fqn) + + if !op.Done() { + err = op.Wait(ctx) + if err != nil { + return false, fmt.Errorf("waiting for deletion of discoveryengine targetSite %q: %w", fqn, err) + } + } + return true, nil +} From 561ba16f5ab0b61faf7f656525c2e9efb581da50 Mon Sep 17 00:00:00 2001 From: justinsb Date: Wed, 18 Dec 2024 22:08:21 -0500 Subject: [PATCH 09/10] chore: create shared project number/id mapper --- apis/common/projects/mapper.go | 58 +++++++++++++++++++ apis/refs/v1beta1/computerefs.go | 23 ++------ pkg/config/controllerconfig.go | 23 ++++++++ .../cloudbuild/workerpool_controller.go | 28 ++------- pkg/controller/kccmanager/kccmanager.go | 4 ++ 5 files changed, 95 insertions(+), 41 deletions(-) create mode 100644 apis/common/projects/mapper.go diff --git a/apis/common/projects/mapper.go b/apis/common/projects/mapper.go new file mode 100644 index 0000000000..bec6538b7a --- /dev/null +++ b/apis/common/projects/mapper.go @@ -0,0 +1,58 @@ +package projects + +import ( + "context" + "fmt" + "strconv" + "strings" + + resourcemanager "cloud.google.com/go/resourcemanager/apiv3" + "cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb" +) + +type ProjectMapper struct { + client *resourcemanager.ProjectsClient +} + +func NewProjectMapper(client *resourcemanager.ProjectsClient) *ProjectMapper { + return &ProjectMapper{ + client: client, + } +} + +func (m *ProjectMapper) ReplaceProjectNumberWithID(ctx context.Context, projectID string) (string, error) { + if _, err := strconv.ParseInt(projectID, 10, 64); err != nil { + // Not a project number, no need to map + return projectID, nil + } + + req := &resourcemanagerpb.GetProjectRequest{ + Name: "projects/" + projectID, + } + project, err := m.client.GetProject(ctx, req) + if err != nil { + return "", fmt.Errorf("error getting project %q: %w", req.Name, err) + } + return project.ProjectId, nil +} + +func (m *ProjectMapper) LookupProjectNumber(ctx context.Context, projectID string) (int64, error) { + // Check if the project number is already a valid integer + // If not, we need to look it up + projectNumber, err := strconv.ParseInt(projectID, 10, 64) + if err != nil { + req := &resourcemanagerpb.GetProjectRequest{ + Name: "projects/" + projectID, + } + project, err := m.client.GetProject(ctx, req) + if err != nil { + return 0, fmt.Errorf("error getting project %q: %w", req.Name, err) + } + n, err := strconv.ParseInt(strings.TrimPrefix(project.Name, "projects/"), 10, 64) + if err != nil { + return 0, fmt.Errorf("error parsing project number for %q: %w", project.Name, err) + } + projectNumber = n + } + return projectNumber, nil +} diff --git a/apis/refs/v1beta1/computerefs.go b/apis/refs/v1beta1/computerefs.go index 707d95397d..86fdcbcc6a 100644 --- a/apis/refs/v1beta1/computerefs.go +++ b/apis/refs/v1beta1/computerefs.go @@ -20,8 +20,7 @@ import ( "strconv" "strings" - resourcemanager "cloud.google.com/go/resourcemanager/apiv3" - resourcemanagerpb "cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb" + "github.com/GoogleCloudPlatform/k8s-config-connector/apis/common/projects" "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/k8s" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -74,7 +73,7 @@ func ParseComputeNetworkID(external string) (*ComputeNetworkID, error) { } // ConvertToProjectNumber converts the external reference to use a project number. -func (ref *ComputeNetworkRef) ConvertToProjectNumber(ctx context.Context, projectsClient *resourcemanager.ProjectsClient) error { +func (ref *ComputeNetworkRef) ConvertToProjectNumber(ctx context.Context, projectMapper *projects.ProjectMapper) error { if ref == nil { return nil } @@ -84,24 +83,12 @@ func (ref *ComputeNetworkRef) ConvertToProjectNumber(ctx context.Context, projec return err } - // Check if the project number is already a valid integer - // If not, we need to look it up - projectNumber, err := strconv.ParseInt(id.Project, 10, 64) + projectNumber, err := projectMapper.LookupProjectNumber(ctx, id.Project) if err != nil { - req := &resourcemanagerpb.GetProjectRequest{ - Name: "projects/" + id.Project, - } - project, err := projectsClient.GetProject(ctx, req) - if err != nil { - return fmt.Errorf("error getting project %q: %w", req.Name, err) - } - n, err := strconv.ParseInt(strings.TrimPrefix(project.Name, "projects/"), 10, 64) - if err != nil { - return fmt.Errorf("error parsing project number for %q: %w", project.Name, err) - } - projectNumber = n + return fmt.Errorf("error looking up project number for project %q: %w", id.Project, err) } id.Project = strconv.FormatInt(projectNumber, 10) + ref.External = id.String() return nil } diff --git a/pkg/config/controllerconfig.go b/pkg/config/controllerconfig.go index c0e3ad7a7d..fefb4eca7d 100644 --- a/pkg/config/controllerconfig.go +++ b/pkg/config/controllerconfig.go @@ -15,8 +15,12 @@ package config import ( + "context" + "fmt" "net/http" + cloudresourcemanager "cloud.google.com/go/resourcemanager/apiv3" + "github.com/GoogleCloudPlatform/k8s-config-connector/apis/common/projects" "golang.org/x/oauth2" "google.golang.org/api/option" ) @@ -40,6 +44,25 @@ type ControllerConfig struct { // GCPTokenSource mints OAuth2 tokens to be passed with GCP API calls, // allowing use of a non-default OAuth2 identity GCPTokenSource oauth2.TokenSource + + // ProjectMapper maps between project ids and numbers + ProjectMapper *projects.ProjectMapper +} + +func (c *ControllerConfig) Init(ctx context.Context) error { + if c.ProjectMapper == nil { + opts, err := c.RESTClientOptions() + if err != nil { + return err + } + + projectsClient, err := cloudresourcemanager.NewProjectsRESTClient(ctx, opts...) + if err != nil { + return fmt.Errorf("building cloudresourcemanager client: %w", err) + } + c.ProjectMapper = projects.NewProjectMapper(projectsClient) + } + return nil } func (c *ControllerConfig) RESTClientOptions() ([]option.ClientOption, error) { diff --git a/pkg/controller/direct/cloudbuild/workerpool_controller.go b/pkg/controller/direct/cloudbuild/workerpool_controller.go index 037a611fd2..e073c016af 100644 --- a/pkg/controller/direct/cloudbuild/workerpool_controller.go +++ b/pkg/controller/direct/cloudbuild/workerpool_controller.go @@ -23,10 +23,10 @@ import ( gcp "cloud.google.com/go/cloudbuild/apiv1/v2" cloudbuildpb "cloud.google.com/go/cloudbuild/apiv1/v2/cloudbuildpb" - cloudresourcemanager "cloud.google.com/go/resourcemanager/apiv3" "google.golang.org/protobuf/types/known/fieldmaskpb" krm "github.com/GoogleCloudPlatform/k8s-config-connector/apis/cloudbuild/v1beta1" + "github.com/GoogleCloudPlatform/k8s-config-connector/apis/common/projects" refs "github.com/GoogleCloudPlatform/k8s-config-connector/apis/refs/v1beta1" "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/config" "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct" @@ -69,19 +69,6 @@ func (m *model) client(ctx context.Context) (*gcp.Client, error) { return gcpClient, err } -func (m *model) projectsClient(ctx context.Context) (*cloudresourcemanager.ProjectsClient, error) { - opts, err := m.config.RESTClientOptions() - if err != nil { - return nil, err - } - - crmClient, err := cloudresourcemanager.NewProjectsRESTClient(ctx, opts...) - if err != nil { - return nil, fmt.Errorf("building cloudresourcemanager client: %w", err) - } - return crmClient, err -} - func (m *model) AdapterForObject(ctx context.Context, reader client.Reader, u *unstructured.Unstructured) (directbase.Adapter, error) { obj := &krm.CloudBuildWorkerPool{} if err := runtime.DefaultUnstructuredConverter.FromUnstructured(u.Object, &obj); err != nil { @@ -134,12 +121,6 @@ func (m *model) AdapterForObject(ctx context.Context, reader client.Reader, u *u } } - // Get Project GCP client - projectClient, err := m.projectsClient(ctx) - if err != nil { - return nil, err - } - // Get CloudBuild GCP client gcpClient, err := m.client(ctx) if err != nil { @@ -148,7 +129,7 @@ func (m *model) AdapterForObject(ctx context.Context, reader client.Reader, u *u return &Adapter{ id: id, - projectClient: projectClient, + projectMapper: m.config.ProjectMapper, gcpClient: gcpClient, reader: reader, desired: obj, @@ -170,6 +151,7 @@ func (m *model) AdapterForURL(ctx context.Context, url string) (directbase.Adapt } return &Adapter{ + projectMapper: m.config.ProjectMapper, id: &CloudBuildWorkerPoolIdentity{ project: tokens[1], location: tokens[3], @@ -184,7 +166,7 @@ func (m *model) AdapterForURL(ctx context.Context, url string) (directbase.Adapt type Adapter struct { id *CloudBuildWorkerPoolIdentity - projectClient *cloudresourcemanager.ProjectsClient + projectMapper *projects.ProjectMapper gcpClient *gcp.Client reader client.Reader desired *krm.CloudBuildWorkerPool @@ -370,7 +352,7 @@ func (a *Adapter) resolveDependencies(ctx context.Context, reader client.Reader, return err } - if err := networkSpec.PeeredNetworkRef.ConvertToProjectNumber(ctx, a.projectClient); err != nil { + if err := networkSpec.PeeredNetworkRef.ConvertToProjectNumber(ctx, a.projectMapper); err != nil { return err } } diff --git a/pkg/controller/kccmanager/kccmanager.go b/pkg/controller/kccmanager/kccmanager.go index 0a23b9bea6..908428ba4e 100644 --- a/pkg/controller/kccmanager/kccmanager.go +++ b/pkg/controller/kccmanager/kccmanager.go @@ -144,6 +144,10 @@ func New(ctx context.Context, restConfig *rest.Config, cfg Config) (manager.Mana UserAgent: gcp.KCCUserAgent, } + if err := controllerConfig.Init(ctx); err != nil { + return nil, err + } + // Initialize direct controllers if err := registry.Init(ctx, controllerConfig); err != nil { return nil, err From abb91741a317b740f2bb7849688319a3db8c85ca Mon Sep 17 00:00:00 2001 From: justinsb Date: Wed, 18 Dec 2024 22:08:55 -0500 Subject: [PATCH 10/10] DiscoveryEngineDataStoreTargetSite: mockgcp support --- config/tests/samples/create/harness.go | 1 + mockgcp/Makefile | 2 + .../v1/site_search_engine_service.pb.gw.go | 2615 +++++++++++++++++ mockgcp/mockdiscoveryengine/service.go | 2 + mockgcp/mockdiscoveryengine/targetsite.go | 193 ++ .../_http.log | 23 +- 6 files changed, 2824 insertions(+), 12 deletions(-) create mode 100644 mockgcp/generated/google/cloud/discoveryengine/v1/site_search_engine_service.pb.gw.go create mode 100644 mockgcp/mockdiscoveryengine/targetsite.go diff --git a/config/tests/samples/create/harness.go b/config/tests/samples/create/harness.go index 9a999ec696..73e256142b 100644 --- a/config/tests/samples/create/harness.go +++ b/config/tests/samples/create/harness.go @@ -793,6 +793,7 @@ func MaybeSkip(t *testing.T, name string, resources []*unstructured.Unstructured case schema.GroupKind{Group: "dataform.cnrm.cloud.google.com", Kind: "DataformRepository"}: case schema.GroupKind{Group: "discoveryengine.cnrm.cloud.google.com", Kind: "DiscoveryEngineDataStore"}: + case schema.GroupKind{Group: "discoveryengine.cnrm.cloud.google.com", Kind: "DiscoveryEngineDataStoreTargetSite"}: case schema.GroupKind{Group: "iam.cnrm.cloud.google.com", Kind: "IAMPartialPolicy"}: case schema.GroupKind{Group: "iam.cnrm.cloud.google.com", Kind: "IAMPolicy"}: diff --git a/mockgcp/Makefile b/mockgcp/Makefile index abb73090d6..b09180cacc 100644 --- a/mockgcp/Makefile +++ b/mockgcp/Makefile @@ -131,6 +131,8 @@ generate-grpc-for-google-protos: --grpc-gateway_opt standalone=true \ ./third_party/googleapis/google/cloud/discoveryengine/v1/data_store_service.proto \ ./third_party/googleapis/google/cloud/discoveryengine/v1/engine_service.proto \ + ./third_party/googleapis/google/cloud/discoveryengine/v1/site_search_engine.proto \ + ./third_party/googleapis/google/cloud/discoveryengine/v1/site_search_engine_service.proto \ ./third_party/googleapis/google/bigtable/admin/v2/*.proto .PHONY: generate-protos-from-openapi diff --git a/mockgcp/generated/google/cloud/discoveryengine/v1/site_search_engine_service.pb.gw.go b/mockgcp/generated/google/cloud/discoveryengine/v1/site_search_engine_service.pb.gw.go new file mode 100644 index 0000000000..02173acdb0 --- /dev/null +++ b/mockgcp/generated/google/cloud/discoveryengine/v1/site_search_engine_service.pb.gw.go @@ -0,0 +1,2615 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: google/cloud/discoveryengine/v1/site_search_engine_service.proto + +/* +Package discoveryenginepb is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package discoveryenginepb + +import ( + "context" + "io" + "net/http" + + extDiscoveryenginepb "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb" + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = metadata.Join + +func request_SiteSearchEngineService_GetSiteSearchEngine_0(ctx context.Context, marshaler runtime.Marshaler, client extDiscoveryenginepb.SiteSearchEngineServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.GetSiteSearchEngineRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + msg, err := client.GetSiteSearchEngine(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SiteSearchEngineService_GetSiteSearchEngine_0(ctx context.Context, marshaler runtime.Marshaler, server extDiscoveryenginepb.SiteSearchEngineServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.GetSiteSearchEngineRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + msg, err := server.GetSiteSearchEngine(ctx, &protoReq) + return msg, metadata, err + +} + +func request_SiteSearchEngineService_GetSiteSearchEngine_1(ctx context.Context, marshaler runtime.Marshaler, client extDiscoveryenginepb.SiteSearchEngineServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.GetSiteSearchEngineRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + msg, err := client.GetSiteSearchEngine(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SiteSearchEngineService_GetSiteSearchEngine_1(ctx context.Context, marshaler runtime.Marshaler, server extDiscoveryenginepb.SiteSearchEngineServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.GetSiteSearchEngineRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + msg, err := server.GetSiteSearchEngine(ctx, &protoReq) + return msg, metadata, err + +} + +func request_SiteSearchEngineService_CreateTargetSite_0(ctx context.Context, marshaler runtime.Marshaler, client extDiscoveryenginepb.SiteSearchEngineServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.CreateTargetSiteRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.TargetSite); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["parent"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") + } + + protoReq.Parent, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) + } + + msg, err := client.CreateTargetSite(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SiteSearchEngineService_CreateTargetSite_0(ctx context.Context, marshaler runtime.Marshaler, server extDiscoveryenginepb.SiteSearchEngineServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.CreateTargetSiteRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.TargetSite); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["parent"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") + } + + protoReq.Parent, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) + } + + msg, err := server.CreateTargetSite(ctx, &protoReq) + return msg, metadata, err + +} + +func request_SiteSearchEngineService_CreateTargetSite_1(ctx context.Context, marshaler runtime.Marshaler, client extDiscoveryenginepb.SiteSearchEngineServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.CreateTargetSiteRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.TargetSite); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["parent"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") + } + + protoReq.Parent, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) + } + + msg, err := client.CreateTargetSite(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SiteSearchEngineService_CreateTargetSite_1(ctx context.Context, marshaler runtime.Marshaler, server extDiscoveryenginepb.SiteSearchEngineServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.CreateTargetSiteRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.TargetSite); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["parent"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") + } + + protoReq.Parent, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) + } + + msg, err := server.CreateTargetSite(ctx, &protoReq) + return msg, metadata, err + +} + +func request_SiteSearchEngineService_BatchCreateTargetSites_0(ctx context.Context, marshaler runtime.Marshaler, client extDiscoveryenginepb.SiteSearchEngineServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.BatchCreateTargetSitesRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["parent"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") + } + + protoReq.Parent, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) + } + + msg, err := client.BatchCreateTargetSites(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SiteSearchEngineService_BatchCreateTargetSites_0(ctx context.Context, marshaler runtime.Marshaler, server extDiscoveryenginepb.SiteSearchEngineServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.BatchCreateTargetSitesRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["parent"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") + } + + protoReq.Parent, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) + } + + msg, err := server.BatchCreateTargetSites(ctx, &protoReq) + return msg, metadata, err + +} + +func request_SiteSearchEngineService_BatchCreateTargetSites_1(ctx context.Context, marshaler runtime.Marshaler, client extDiscoveryenginepb.SiteSearchEngineServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.BatchCreateTargetSitesRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["parent"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") + } + + protoReq.Parent, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) + } + + msg, err := client.BatchCreateTargetSites(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SiteSearchEngineService_BatchCreateTargetSites_1(ctx context.Context, marshaler runtime.Marshaler, server extDiscoveryenginepb.SiteSearchEngineServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.BatchCreateTargetSitesRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["parent"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") + } + + protoReq.Parent, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) + } + + msg, err := server.BatchCreateTargetSites(ctx, &protoReq) + return msg, metadata, err + +} + +func request_SiteSearchEngineService_GetTargetSite_0(ctx context.Context, marshaler runtime.Marshaler, client extDiscoveryenginepb.SiteSearchEngineServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.GetTargetSiteRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + msg, err := client.GetTargetSite(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SiteSearchEngineService_GetTargetSite_0(ctx context.Context, marshaler runtime.Marshaler, server extDiscoveryenginepb.SiteSearchEngineServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.GetTargetSiteRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + msg, err := server.GetTargetSite(ctx, &protoReq) + return msg, metadata, err + +} + +func request_SiteSearchEngineService_GetTargetSite_1(ctx context.Context, marshaler runtime.Marshaler, client extDiscoveryenginepb.SiteSearchEngineServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.GetTargetSiteRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + msg, err := client.GetTargetSite(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SiteSearchEngineService_GetTargetSite_1(ctx context.Context, marshaler runtime.Marshaler, server extDiscoveryenginepb.SiteSearchEngineServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.GetTargetSiteRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + msg, err := server.GetTargetSite(ctx, &protoReq) + return msg, metadata, err + +} + +func request_SiteSearchEngineService_UpdateTargetSite_0(ctx context.Context, marshaler runtime.Marshaler, client extDiscoveryenginepb.SiteSearchEngineServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.UpdateTargetSiteRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.TargetSite); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["target_site.name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "target_site.name") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "target_site.name", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "target_site.name", err) + } + + msg, err := client.UpdateTargetSite(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SiteSearchEngineService_UpdateTargetSite_0(ctx context.Context, marshaler runtime.Marshaler, server extDiscoveryenginepb.SiteSearchEngineServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.UpdateTargetSiteRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.TargetSite); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["target_site.name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "target_site.name") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "target_site.name", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "target_site.name", err) + } + + msg, err := server.UpdateTargetSite(ctx, &protoReq) + return msg, metadata, err + +} + +func request_SiteSearchEngineService_UpdateTargetSite_1(ctx context.Context, marshaler runtime.Marshaler, client extDiscoveryenginepb.SiteSearchEngineServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.UpdateTargetSiteRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.TargetSite); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["target_site.name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "target_site.name") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "target_site.name", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "target_site.name", err) + } + + msg, err := client.UpdateTargetSite(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SiteSearchEngineService_UpdateTargetSite_1(ctx context.Context, marshaler runtime.Marshaler, server extDiscoveryenginepb.SiteSearchEngineServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.UpdateTargetSiteRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.TargetSite); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["target_site.name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "target_site.name") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "target_site.name", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "target_site.name", err) + } + + msg, err := server.UpdateTargetSite(ctx, &protoReq) + return msg, metadata, err + +} + +func request_SiteSearchEngineService_DeleteTargetSite_0(ctx context.Context, marshaler runtime.Marshaler, client extDiscoveryenginepb.SiteSearchEngineServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.DeleteTargetSiteRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + msg, err := client.DeleteTargetSite(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SiteSearchEngineService_DeleteTargetSite_0(ctx context.Context, marshaler runtime.Marshaler, server extDiscoveryenginepb.SiteSearchEngineServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.DeleteTargetSiteRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + msg, err := server.DeleteTargetSite(ctx, &protoReq) + return msg, metadata, err + +} + +func request_SiteSearchEngineService_DeleteTargetSite_1(ctx context.Context, marshaler runtime.Marshaler, client extDiscoveryenginepb.SiteSearchEngineServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.DeleteTargetSiteRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + msg, err := client.DeleteTargetSite(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SiteSearchEngineService_DeleteTargetSite_1(ctx context.Context, marshaler runtime.Marshaler, server extDiscoveryenginepb.SiteSearchEngineServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.DeleteTargetSiteRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + msg, err := server.DeleteTargetSite(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_SiteSearchEngineService_ListTargetSites_0 = &utilities.DoubleArray{Encoding: map[string]int{"parent": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_SiteSearchEngineService_ListTargetSites_0(ctx context.Context, marshaler runtime.Marshaler, client extDiscoveryenginepb.SiteSearchEngineServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.ListTargetSitesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["parent"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") + } + + protoReq.Parent, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SiteSearchEngineService_ListTargetSites_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ListTargetSites(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SiteSearchEngineService_ListTargetSites_0(ctx context.Context, marshaler runtime.Marshaler, server extDiscoveryenginepb.SiteSearchEngineServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.ListTargetSitesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["parent"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") + } + + protoReq.Parent, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SiteSearchEngineService_ListTargetSites_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ListTargetSites(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_SiteSearchEngineService_ListTargetSites_1 = &utilities.DoubleArray{Encoding: map[string]int{"parent": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_SiteSearchEngineService_ListTargetSites_1(ctx context.Context, marshaler runtime.Marshaler, client extDiscoveryenginepb.SiteSearchEngineServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.ListTargetSitesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["parent"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") + } + + protoReq.Parent, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SiteSearchEngineService_ListTargetSites_1); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ListTargetSites(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SiteSearchEngineService_ListTargetSites_1(ctx context.Context, marshaler runtime.Marshaler, server extDiscoveryenginepb.SiteSearchEngineServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.ListTargetSitesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["parent"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") + } + + protoReq.Parent, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SiteSearchEngineService_ListTargetSites_1); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ListTargetSites(ctx, &protoReq) + return msg, metadata, err + +} + +func request_SiteSearchEngineService_EnableAdvancedSiteSearch_0(ctx context.Context, marshaler runtime.Marshaler, client extDiscoveryenginepb.SiteSearchEngineServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.EnableAdvancedSiteSearchRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["site_search_engine"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "site_search_engine") + } + + protoReq.SiteSearchEngine, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "site_search_engine", err) + } + + msg, err := client.EnableAdvancedSiteSearch(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SiteSearchEngineService_EnableAdvancedSiteSearch_0(ctx context.Context, marshaler runtime.Marshaler, server extDiscoveryenginepb.SiteSearchEngineServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.EnableAdvancedSiteSearchRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["site_search_engine"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "site_search_engine") + } + + protoReq.SiteSearchEngine, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "site_search_engine", err) + } + + msg, err := server.EnableAdvancedSiteSearch(ctx, &protoReq) + return msg, metadata, err + +} + +func request_SiteSearchEngineService_EnableAdvancedSiteSearch_1(ctx context.Context, marshaler runtime.Marshaler, client extDiscoveryenginepb.SiteSearchEngineServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.EnableAdvancedSiteSearchRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["site_search_engine"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "site_search_engine") + } + + protoReq.SiteSearchEngine, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "site_search_engine", err) + } + + msg, err := client.EnableAdvancedSiteSearch(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SiteSearchEngineService_EnableAdvancedSiteSearch_1(ctx context.Context, marshaler runtime.Marshaler, server extDiscoveryenginepb.SiteSearchEngineServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.EnableAdvancedSiteSearchRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["site_search_engine"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "site_search_engine") + } + + protoReq.SiteSearchEngine, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "site_search_engine", err) + } + + msg, err := server.EnableAdvancedSiteSearch(ctx, &protoReq) + return msg, metadata, err + +} + +func request_SiteSearchEngineService_DisableAdvancedSiteSearch_0(ctx context.Context, marshaler runtime.Marshaler, client extDiscoveryenginepb.SiteSearchEngineServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.DisableAdvancedSiteSearchRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["site_search_engine"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "site_search_engine") + } + + protoReq.SiteSearchEngine, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "site_search_engine", err) + } + + msg, err := client.DisableAdvancedSiteSearch(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SiteSearchEngineService_DisableAdvancedSiteSearch_0(ctx context.Context, marshaler runtime.Marshaler, server extDiscoveryenginepb.SiteSearchEngineServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.DisableAdvancedSiteSearchRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["site_search_engine"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "site_search_engine") + } + + protoReq.SiteSearchEngine, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "site_search_engine", err) + } + + msg, err := server.DisableAdvancedSiteSearch(ctx, &protoReq) + return msg, metadata, err + +} + +func request_SiteSearchEngineService_DisableAdvancedSiteSearch_1(ctx context.Context, marshaler runtime.Marshaler, client extDiscoveryenginepb.SiteSearchEngineServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.DisableAdvancedSiteSearchRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["site_search_engine"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "site_search_engine") + } + + protoReq.SiteSearchEngine, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "site_search_engine", err) + } + + msg, err := client.DisableAdvancedSiteSearch(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SiteSearchEngineService_DisableAdvancedSiteSearch_1(ctx context.Context, marshaler runtime.Marshaler, server extDiscoveryenginepb.SiteSearchEngineServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.DisableAdvancedSiteSearchRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["site_search_engine"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "site_search_engine") + } + + protoReq.SiteSearchEngine, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "site_search_engine", err) + } + + msg, err := server.DisableAdvancedSiteSearch(ctx, &protoReq) + return msg, metadata, err + +} + +func request_SiteSearchEngineService_RecrawlUris_0(ctx context.Context, marshaler runtime.Marshaler, client extDiscoveryenginepb.SiteSearchEngineServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.RecrawlUrisRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["site_search_engine"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "site_search_engine") + } + + protoReq.SiteSearchEngine, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "site_search_engine", err) + } + + msg, err := client.RecrawlUris(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SiteSearchEngineService_RecrawlUris_0(ctx context.Context, marshaler runtime.Marshaler, server extDiscoveryenginepb.SiteSearchEngineServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.RecrawlUrisRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["site_search_engine"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "site_search_engine") + } + + protoReq.SiteSearchEngine, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "site_search_engine", err) + } + + msg, err := server.RecrawlUris(ctx, &protoReq) + return msg, metadata, err + +} + +func request_SiteSearchEngineService_RecrawlUris_1(ctx context.Context, marshaler runtime.Marshaler, client extDiscoveryenginepb.SiteSearchEngineServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.RecrawlUrisRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["site_search_engine"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "site_search_engine") + } + + protoReq.SiteSearchEngine, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "site_search_engine", err) + } + + msg, err := client.RecrawlUris(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SiteSearchEngineService_RecrawlUris_1(ctx context.Context, marshaler runtime.Marshaler, server extDiscoveryenginepb.SiteSearchEngineServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.RecrawlUrisRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["site_search_engine"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "site_search_engine") + } + + protoReq.SiteSearchEngine, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "site_search_engine", err) + } + + msg, err := server.RecrawlUris(ctx, &protoReq) + return msg, metadata, err + +} + +func request_SiteSearchEngineService_BatchVerifyTargetSites_0(ctx context.Context, marshaler runtime.Marshaler, client extDiscoveryenginepb.SiteSearchEngineServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.BatchVerifyTargetSitesRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["parent"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") + } + + protoReq.Parent, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) + } + + msg, err := client.BatchVerifyTargetSites(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SiteSearchEngineService_BatchVerifyTargetSites_0(ctx context.Context, marshaler runtime.Marshaler, server extDiscoveryenginepb.SiteSearchEngineServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.BatchVerifyTargetSitesRequest + var metadata runtime.ServerMetadata + + newReader, berr := utilities.IOReaderFactory(req.Body) + if berr != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr) + } + if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["parent"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") + } + + protoReq.Parent, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) + } + + msg, err := server.BatchVerifyTargetSites(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_SiteSearchEngineService_FetchDomainVerificationStatus_0 = &utilities.DoubleArray{Encoding: map[string]int{"site_search_engine": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_SiteSearchEngineService_FetchDomainVerificationStatus_0(ctx context.Context, marshaler runtime.Marshaler, client extDiscoveryenginepb.SiteSearchEngineServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.FetchDomainVerificationStatusRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["site_search_engine"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "site_search_engine") + } + + protoReq.SiteSearchEngine, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "site_search_engine", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SiteSearchEngineService_FetchDomainVerificationStatus_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.FetchDomainVerificationStatus(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_SiteSearchEngineService_FetchDomainVerificationStatus_0(ctx context.Context, marshaler runtime.Marshaler, server extDiscoveryenginepb.SiteSearchEngineServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq extDiscoveryenginepb.FetchDomainVerificationStatusRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["site_search_engine"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "site_search_engine") + } + + protoReq.SiteSearchEngine, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "site_search_engine", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_SiteSearchEngineService_FetchDomainVerificationStatus_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.FetchDomainVerificationStatus(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterSiteSearchEngineServiceHandlerServer registers the http handlers for service SiteSearchEngineService to "mux". +// UnaryRPC :call SiteSearchEngineServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterSiteSearchEngineServiceHandlerFromEndpoint instead. +func RegisterSiteSearchEngineServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server extDiscoveryenginepb.SiteSearchEngineServiceServer) error { + + mux.Handle("GET", pattern_SiteSearchEngineService_GetSiteSearchEngine_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/GetSiteSearchEngine", runtime.WithHTTPPathPattern("/v1/{name=projects/*/locations/*/dataStores/*/siteSearchEngine}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SiteSearchEngineService_GetSiteSearchEngine_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_GetSiteSearchEngine_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_SiteSearchEngineService_GetSiteSearchEngine_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/GetSiteSearchEngine", runtime.WithHTTPPathPattern("/v1/{name=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SiteSearchEngineService_GetSiteSearchEngine_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_GetSiteSearchEngine_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SiteSearchEngineService_CreateTargetSite_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/CreateTargetSite", runtime.WithHTTPPathPattern("/v1/{parent=projects/*/locations/*/dataStores/*/siteSearchEngine}/targetSites")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SiteSearchEngineService_CreateTargetSite_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_CreateTargetSite_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SiteSearchEngineService_CreateTargetSite_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/CreateTargetSite", runtime.WithHTTPPathPattern("/v1/{parent=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine}/targetSites")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SiteSearchEngineService_CreateTargetSite_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_CreateTargetSite_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SiteSearchEngineService_BatchCreateTargetSites_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/BatchCreateTargetSites", runtime.WithHTTPPathPattern("/v1/{parent=projects/*/locations/*/dataStores/*/siteSearchEngine}/targetSites:batchCreate")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SiteSearchEngineService_BatchCreateTargetSites_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_BatchCreateTargetSites_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SiteSearchEngineService_BatchCreateTargetSites_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/BatchCreateTargetSites", runtime.WithHTTPPathPattern("/v1/{parent=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine}/targetSites:batchCreate")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SiteSearchEngineService_BatchCreateTargetSites_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_BatchCreateTargetSites_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_SiteSearchEngineService_GetTargetSite_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/GetTargetSite", runtime.WithHTTPPathPattern("/v1/{name=projects/*/locations/*/dataStores/*/siteSearchEngine/targetSites/*}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SiteSearchEngineService_GetTargetSite_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_GetTargetSite_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_SiteSearchEngineService_GetTargetSite_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/GetTargetSite", runtime.WithHTTPPathPattern("/v1/{name=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine/targetSites/*}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SiteSearchEngineService_GetTargetSite_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_GetTargetSite_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PATCH", pattern_SiteSearchEngineService_UpdateTargetSite_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/UpdateTargetSite", runtime.WithHTTPPathPattern("/v1/{target_site.name=projects/*/locations/*/dataStores/*/siteSearchEngine/targetSites/*}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SiteSearchEngineService_UpdateTargetSite_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_UpdateTargetSite_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PATCH", pattern_SiteSearchEngineService_UpdateTargetSite_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/UpdateTargetSite", runtime.WithHTTPPathPattern("/v1/{target_site.name=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine/targetSites/*}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SiteSearchEngineService_UpdateTargetSite_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_UpdateTargetSite_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_SiteSearchEngineService_DeleteTargetSite_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/DeleteTargetSite", runtime.WithHTTPPathPattern("/v1/{name=projects/*/locations/*/dataStores/*/siteSearchEngine/targetSites/*}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SiteSearchEngineService_DeleteTargetSite_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_DeleteTargetSite_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_SiteSearchEngineService_DeleteTargetSite_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/DeleteTargetSite", runtime.WithHTTPPathPattern("/v1/{name=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine/targetSites/*}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SiteSearchEngineService_DeleteTargetSite_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_DeleteTargetSite_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_SiteSearchEngineService_ListTargetSites_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/ListTargetSites", runtime.WithHTTPPathPattern("/v1/{parent=projects/*/locations/*/dataStores/*/siteSearchEngine}/targetSites")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SiteSearchEngineService_ListTargetSites_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_ListTargetSites_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_SiteSearchEngineService_ListTargetSites_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/ListTargetSites", runtime.WithHTTPPathPattern("/v1/{parent=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine}/targetSites")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SiteSearchEngineService_ListTargetSites_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_ListTargetSites_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SiteSearchEngineService_EnableAdvancedSiteSearch_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/EnableAdvancedSiteSearch", runtime.WithHTTPPathPattern("/v1/{site_search_engine=projects/*/locations/*/dataStores/*/siteSearchEngine}:enableAdvancedSiteSearch")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SiteSearchEngineService_EnableAdvancedSiteSearch_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_EnableAdvancedSiteSearch_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SiteSearchEngineService_EnableAdvancedSiteSearch_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/EnableAdvancedSiteSearch", runtime.WithHTTPPathPattern("/v1/{site_search_engine=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine}:enableAdvancedSiteSearch")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SiteSearchEngineService_EnableAdvancedSiteSearch_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_EnableAdvancedSiteSearch_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SiteSearchEngineService_DisableAdvancedSiteSearch_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/DisableAdvancedSiteSearch", runtime.WithHTTPPathPattern("/v1/{site_search_engine=projects/*/locations/*/dataStores/*/siteSearchEngine}:disableAdvancedSiteSearch")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SiteSearchEngineService_DisableAdvancedSiteSearch_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_DisableAdvancedSiteSearch_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SiteSearchEngineService_DisableAdvancedSiteSearch_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/DisableAdvancedSiteSearch", runtime.WithHTTPPathPattern("/v1/{site_search_engine=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine}:disableAdvancedSiteSearch")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SiteSearchEngineService_DisableAdvancedSiteSearch_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_DisableAdvancedSiteSearch_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SiteSearchEngineService_RecrawlUris_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/RecrawlUris", runtime.WithHTTPPathPattern("/v1/{site_search_engine=projects/*/locations/*/dataStores/*/siteSearchEngine}:recrawlUris")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SiteSearchEngineService_RecrawlUris_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_RecrawlUris_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SiteSearchEngineService_RecrawlUris_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/RecrawlUris", runtime.WithHTTPPathPattern("/v1/{site_search_engine=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine}:recrawlUris")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SiteSearchEngineService_RecrawlUris_1(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_RecrawlUris_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SiteSearchEngineService_BatchVerifyTargetSites_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/BatchVerifyTargetSites", runtime.WithHTTPPathPattern("/v1/{parent=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine}:batchVerifyTargetSites")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SiteSearchEngineService_BatchVerifyTargetSites_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_BatchVerifyTargetSites_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_SiteSearchEngineService_FetchDomainVerificationStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/FetchDomainVerificationStatus", runtime.WithHTTPPathPattern("/v1/{site_search_engine=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine}:fetchDomainVerificationStatus")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_SiteSearchEngineService_FetchDomainVerificationStatus_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_FetchDomainVerificationStatus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterSiteSearchEngineServiceHandlerFromEndpoint is same as RegisterSiteSearchEngineServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterSiteSearchEngineServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterSiteSearchEngineServiceHandler(ctx, mux, conn) +} + +// RegisterSiteSearchEngineServiceHandler registers the http handlers for service SiteSearchEngineService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterSiteSearchEngineServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterSiteSearchEngineServiceHandlerClient(ctx, mux, extDiscoveryenginepb.NewSiteSearchEngineServiceClient(conn)) +} + +// RegisterSiteSearchEngineServiceHandlerClient registers the http handlers for service SiteSearchEngineService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "extDiscoveryenginepb.SiteSearchEngineServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "extDiscoveryenginepb.SiteSearchEngineServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "extDiscoveryenginepb.SiteSearchEngineServiceClient" to call the correct interceptors. +func RegisterSiteSearchEngineServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client extDiscoveryenginepb.SiteSearchEngineServiceClient) error { + + mux.Handle("GET", pattern_SiteSearchEngineService_GetSiteSearchEngine_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/GetSiteSearchEngine", runtime.WithHTTPPathPattern("/v1/{name=projects/*/locations/*/dataStores/*/siteSearchEngine}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SiteSearchEngineService_GetSiteSearchEngine_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_GetSiteSearchEngine_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_SiteSearchEngineService_GetSiteSearchEngine_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/GetSiteSearchEngine", runtime.WithHTTPPathPattern("/v1/{name=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SiteSearchEngineService_GetSiteSearchEngine_1(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_GetSiteSearchEngine_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SiteSearchEngineService_CreateTargetSite_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/CreateTargetSite", runtime.WithHTTPPathPattern("/v1/{parent=projects/*/locations/*/dataStores/*/siteSearchEngine}/targetSites")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SiteSearchEngineService_CreateTargetSite_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_CreateTargetSite_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SiteSearchEngineService_CreateTargetSite_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/CreateTargetSite", runtime.WithHTTPPathPattern("/v1/{parent=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine}/targetSites")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SiteSearchEngineService_CreateTargetSite_1(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_CreateTargetSite_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SiteSearchEngineService_BatchCreateTargetSites_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/BatchCreateTargetSites", runtime.WithHTTPPathPattern("/v1/{parent=projects/*/locations/*/dataStores/*/siteSearchEngine}/targetSites:batchCreate")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SiteSearchEngineService_BatchCreateTargetSites_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_BatchCreateTargetSites_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SiteSearchEngineService_BatchCreateTargetSites_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/BatchCreateTargetSites", runtime.WithHTTPPathPattern("/v1/{parent=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine}/targetSites:batchCreate")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SiteSearchEngineService_BatchCreateTargetSites_1(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_BatchCreateTargetSites_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_SiteSearchEngineService_GetTargetSite_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/GetTargetSite", runtime.WithHTTPPathPattern("/v1/{name=projects/*/locations/*/dataStores/*/siteSearchEngine/targetSites/*}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SiteSearchEngineService_GetTargetSite_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_GetTargetSite_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_SiteSearchEngineService_GetTargetSite_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/GetTargetSite", runtime.WithHTTPPathPattern("/v1/{name=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine/targetSites/*}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SiteSearchEngineService_GetTargetSite_1(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_GetTargetSite_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PATCH", pattern_SiteSearchEngineService_UpdateTargetSite_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/UpdateTargetSite", runtime.WithHTTPPathPattern("/v1/{target_site.name=projects/*/locations/*/dataStores/*/siteSearchEngine/targetSites/*}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SiteSearchEngineService_UpdateTargetSite_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_UpdateTargetSite_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("PATCH", pattern_SiteSearchEngineService_UpdateTargetSite_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/UpdateTargetSite", runtime.WithHTTPPathPattern("/v1/{target_site.name=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine/targetSites/*}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SiteSearchEngineService_UpdateTargetSite_1(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_UpdateTargetSite_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_SiteSearchEngineService_DeleteTargetSite_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/DeleteTargetSite", runtime.WithHTTPPathPattern("/v1/{name=projects/*/locations/*/dataStores/*/siteSearchEngine/targetSites/*}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SiteSearchEngineService_DeleteTargetSite_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_DeleteTargetSite_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("DELETE", pattern_SiteSearchEngineService_DeleteTargetSite_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/DeleteTargetSite", runtime.WithHTTPPathPattern("/v1/{name=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine/targetSites/*}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SiteSearchEngineService_DeleteTargetSite_1(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_DeleteTargetSite_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_SiteSearchEngineService_ListTargetSites_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/ListTargetSites", runtime.WithHTTPPathPattern("/v1/{parent=projects/*/locations/*/dataStores/*/siteSearchEngine}/targetSites")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SiteSearchEngineService_ListTargetSites_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_ListTargetSites_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_SiteSearchEngineService_ListTargetSites_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/ListTargetSites", runtime.WithHTTPPathPattern("/v1/{parent=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine}/targetSites")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SiteSearchEngineService_ListTargetSites_1(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_ListTargetSites_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SiteSearchEngineService_EnableAdvancedSiteSearch_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/EnableAdvancedSiteSearch", runtime.WithHTTPPathPattern("/v1/{site_search_engine=projects/*/locations/*/dataStores/*/siteSearchEngine}:enableAdvancedSiteSearch")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SiteSearchEngineService_EnableAdvancedSiteSearch_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_EnableAdvancedSiteSearch_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SiteSearchEngineService_EnableAdvancedSiteSearch_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/EnableAdvancedSiteSearch", runtime.WithHTTPPathPattern("/v1/{site_search_engine=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine}:enableAdvancedSiteSearch")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SiteSearchEngineService_EnableAdvancedSiteSearch_1(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_EnableAdvancedSiteSearch_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SiteSearchEngineService_DisableAdvancedSiteSearch_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/DisableAdvancedSiteSearch", runtime.WithHTTPPathPattern("/v1/{site_search_engine=projects/*/locations/*/dataStores/*/siteSearchEngine}:disableAdvancedSiteSearch")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SiteSearchEngineService_DisableAdvancedSiteSearch_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_DisableAdvancedSiteSearch_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SiteSearchEngineService_DisableAdvancedSiteSearch_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/DisableAdvancedSiteSearch", runtime.WithHTTPPathPattern("/v1/{site_search_engine=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine}:disableAdvancedSiteSearch")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SiteSearchEngineService_DisableAdvancedSiteSearch_1(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_DisableAdvancedSiteSearch_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SiteSearchEngineService_RecrawlUris_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/RecrawlUris", runtime.WithHTTPPathPattern("/v1/{site_search_engine=projects/*/locations/*/dataStores/*/siteSearchEngine}:recrawlUris")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SiteSearchEngineService_RecrawlUris_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_RecrawlUris_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SiteSearchEngineService_RecrawlUris_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/RecrawlUris", runtime.WithHTTPPathPattern("/v1/{site_search_engine=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine}:recrawlUris")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SiteSearchEngineService_RecrawlUris_1(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_RecrawlUris_1(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("POST", pattern_SiteSearchEngineService_BatchVerifyTargetSites_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/BatchVerifyTargetSites", runtime.WithHTTPPathPattern("/v1/{parent=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine}:batchVerifyTargetSites")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SiteSearchEngineService_BatchVerifyTargetSites_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_BatchVerifyTargetSites_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_SiteSearchEngineService_FetchDomainVerificationStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/google.cloud.discoveryengine.v1.SiteSearchEngineService/FetchDomainVerificationStatus", runtime.WithHTTPPathPattern("/v1/{site_search_engine=projects/*/locations/*/collections/*/dataStores/*/siteSearchEngine}:fetchDomainVerificationStatus")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_SiteSearchEngineService_FetchDomainVerificationStatus_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + + forward_SiteSearchEngineService_FetchDomainVerificationStatus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_SiteSearchEngineService_GetSiteSearchEngine_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 2, 4, 4, 7, 5, 5}, []string{"v1", "projects", "locations", "dataStores", "siteSearchEngine", "name"}, "")) + + pattern_SiteSearchEngineService_GetSiteSearchEngine_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 2, 4, 1, 0, 2, 5, 4, 9, 5, 6}, []string{"v1", "projects", "locations", "collections", "dataStores", "siteSearchEngine", "name"}, "")) + + pattern_SiteSearchEngineService_CreateTargetSite_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 2, 4, 4, 7, 5, 5, 2, 6}, []string{"v1", "projects", "locations", "dataStores", "siteSearchEngine", "parent", "targetSites"}, "")) + + pattern_SiteSearchEngineService_CreateTargetSite_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 2, 4, 1, 0, 2, 5, 4, 9, 5, 6, 2, 7}, []string{"v1", "projects", "locations", "collections", "dataStores", "siteSearchEngine", "parent", "targetSites"}, "")) + + pattern_SiteSearchEngineService_BatchCreateTargetSites_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 2, 4, 4, 7, 5, 5, 2, 6}, []string{"v1", "projects", "locations", "dataStores", "siteSearchEngine", "parent", "targetSites"}, "batchCreate")) + + pattern_SiteSearchEngineService_BatchCreateTargetSites_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 2, 4, 1, 0, 2, 5, 4, 9, 5, 6, 2, 7}, []string{"v1", "projects", "locations", "collections", "dataStores", "siteSearchEngine", "parent", "targetSites"}, "batchCreate")) + + pattern_SiteSearchEngineService_GetTargetSite_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 2, 4, 2, 5, 1, 0, 4, 9, 5, 6}, []string{"v1", "projects", "locations", "dataStores", "siteSearchEngine", "targetSites", "name"}, "")) + + pattern_SiteSearchEngineService_GetTargetSite_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 2, 4, 1, 0, 2, 5, 2, 6, 1, 0, 4, 11, 5, 7}, []string{"v1", "projects", "locations", "collections", "dataStores", "siteSearchEngine", "targetSites", "name"}, "")) + + pattern_SiteSearchEngineService_UpdateTargetSite_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 2, 4, 2, 5, 1, 0, 4, 9, 5, 6}, []string{"v1", "projects", "locations", "dataStores", "siteSearchEngine", "targetSites", "target_site.name"}, "")) + + pattern_SiteSearchEngineService_UpdateTargetSite_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 2, 4, 1, 0, 2, 5, 2, 6, 1, 0, 4, 11, 5, 7}, []string{"v1", "projects", "locations", "collections", "dataStores", "siteSearchEngine", "targetSites", "target_site.name"}, "")) + + pattern_SiteSearchEngineService_DeleteTargetSite_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 2, 4, 2, 5, 1, 0, 4, 9, 5, 6}, []string{"v1", "projects", "locations", "dataStores", "siteSearchEngine", "targetSites", "name"}, "")) + + pattern_SiteSearchEngineService_DeleteTargetSite_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 2, 4, 1, 0, 2, 5, 2, 6, 1, 0, 4, 11, 5, 7}, []string{"v1", "projects", "locations", "collections", "dataStores", "siteSearchEngine", "targetSites", "name"}, "")) + + pattern_SiteSearchEngineService_ListTargetSites_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 2, 4, 4, 7, 5, 5, 2, 6}, []string{"v1", "projects", "locations", "dataStores", "siteSearchEngine", "parent", "targetSites"}, "")) + + pattern_SiteSearchEngineService_ListTargetSites_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 2, 4, 1, 0, 2, 5, 4, 9, 5, 6, 2, 7}, []string{"v1", "projects", "locations", "collections", "dataStores", "siteSearchEngine", "parent", "targetSites"}, "")) + + pattern_SiteSearchEngineService_EnableAdvancedSiteSearch_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 2, 4, 4, 7, 5, 5}, []string{"v1", "projects", "locations", "dataStores", "siteSearchEngine", "site_search_engine"}, "enableAdvancedSiteSearch")) + + pattern_SiteSearchEngineService_EnableAdvancedSiteSearch_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 2, 4, 1, 0, 2, 5, 4, 9, 5, 6}, []string{"v1", "projects", "locations", "collections", "dataStores", "siteSearchEngine", "site_search_engine"}, "enableAdvancedSiteSearch")) + + pattern_SiteSearchEngineService_DisableAdvancedSiteSearch_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 2, 4, 4, 7, 5, 5}, []string{"v1", "projects", "locations", "dataStores", "siteSearchEngine", "site_search_engine"}, "disableAdvancedSiteSearch")) + + pattern_SiteSearchEngineService_DisableAdvancedSiteSearch_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 2, 4, 1, 0, 2, 5, 4, 9, 5, 6}, []string{"v1", "projects", "locations", "collections", "dataStores", "siteSearchEngine", "site_search_engine"}, "disableAdvancedSiteSearch")) + + pattern_SiteSearchEngineService_RecrawlUris_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 2, 4, 4, 7, 5, 5}, []string{"v1", "projects", "locations", "dataStores", "siteSearchEngine", "site_search_engine"}, "recrawlUris")) + + pattern_SiteSearchEngineService_RecrawlUris_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 2, 4, 1, 0, 2, 5, 4, 9, 5, 6}, []string{"v1", "projects", "locations", "collections", "dataStores", "siteSearchEngine", "site_search_engine"}, "recrawlUris")) + + pattern_SiteSearchEngineService_BatchVerifyTargetSites_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 2, 4, 1, 0, 2, 5, 4, 9, 5, 6}, []string{"v1", "projects", "locations", "collections", "dataStores", "siteSearchEngine", "parent"}, "batchVerifyTargetSites")) + + pattern_SiteSearchEngineService_FetchDomainVerificationStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 3, 1, 0, 2, 4, 1, 0, 2, 5, 4, 9, 5, 6}, []string{"v1", "projects", "locations", "collections", "dataStores", "siteSearchEngine", "site_search_engine"}, "fetchDomainVerificationStatus")) +) + +var ( + forward_SiteSearchEngineService_GetSiteSearchEngine_0 = runtime.ForwardResponseMessage + + forward_SiteSearchEngineService_GetSiteSearchEngine_1 = runtime.ForwardResponseMessage + + forward_SiteSearchEngineService_CreateTargetSite_0 = runtime.ForwardResponseMessage + + forward_SiteSearchEngineService_CreateTargetSite_1 = runtime.ForwardResponseMessage + + forward_SiteSearchEngineService_BatchCreateTargetSites_0 = runtime.ForwardResponseMessage + + forward_SiteSearchEngineService_BatchCreateTargetSites_1 = runtime.ForwardResponseMessage + + forward_SiteSearchEngineService_GetTargetSite_0 = runtime.ForwardResponseMessage + + forward_SiteSearchEngineService_GetTargetSite_1 = runtime.ForwardResponseMessage + + forward_SiteSearchEngineService_UpdateTargetSite_0 = runtime.ForwardResponseMessage + + forward_SiteSearchEngineService_UpdateTargetSite_1 = runtime.ForwardResponseMessage + + forward_SiteSearchEngineService_DeleteTargetSite_0 = runtime.ForwardResponseMessage + + forward_SiteSearchEngineService_DeleteTargetSite_1 = runtime.ForwardResponseMessage + + forward_SiteSearchEngineService_ListTargetSites_0 = runtime.ForwardResponseMessage + + forward_SiteSearchEngineService_ListTargetSites_1 = runtime.ForwardResponseMessage + + forward_SiteSearchEngineService_EnableAdvancedSiteSearch_0 = runtime.ForwardResponseMessage + + forward_SiteSearchEngineService_EnableAdvancedSiteSearch_1 = runtime.ForwardResponseMessage + + forward_SiteSearchEngineService_DisableAdvancedSiteSearch_0 = runtime.ForwardResponseMessage + + forward_SiteSearchEngineService_DisableAdvancedSiteSearch_1 = runtime.ForwardResponseMessage + + forward_SiteSearchEngineService_RecrawlUris_0 = runtime.ForwardResponseMessage + + forward_SiteSearchEngineService_RecrawlUris_1 = runtime.ForwardResponseMessage + + forward_SiteSearchEngineService_BatchVerifyTargetSites_0 = runtime.ForwardResponseMessage + + forward_SiteSearchEngineService_FetchDomainVerificationStatus_0 = runtime.ForwardResponseMessage +) diff --git a/mockgcp/mockdiscoveryengine/service.go b/mockgcp/mockdiscoveryengine/service.go index 3c6a5b0e54..cf51ac3862 100644 --- a/mockgcp/mockdiscoveryengine/service.go +++ b/mockgcp/mockdiscoveryengine/service.go @@ -52,11 +52,13 @@ func (s *MockService) ExpectedHosts() []string { func (s *MockService) Register(grpcServer *grpc.Server) { pb.RegisterDataStoreServiceServer(grpcServer, &dataStoreService{MockService: s}) + pb.RegisterSiteSearchEngineServiceServer(grpcServer, &siteSearchEngineService{MockService: s}) } func (s *MockService) NewHTTPMux(ctx context.Context, conn *grpc.ClientConn) (http.Handler, error) { mux, err := httpmux.NewServeMux(ctx, conn, httpmux.Options{}, pbhttp.RegisterDataStoreServiceHandler, + pbhttp.RegisterSiteSearchEngineServiceHandler, // s.operations.RegisterOperationsPath("/v1beta1/{prefix=**}/operations/{name}") ) if err != nil { diff --git a/mockgcp/mockdiscoveryengine/targetsite.go b/mockgcp/mockdiscoveryengine/targetsite.go new file mode 100644 index 0000000000..aa7ad560c3 --- /dev/null +++ b/mockgcp/mockdiscoveryengine/targetsite.go @@ -0,0 +1,193 @@ +// Copyright 2024 Google LLC +// +// 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. + +// +tool:mockgcp-support +// krm.apiVersion: discoveryengine.cnrm.cloud.google.com/v1alpha1 +// krm.kind: DiscoveryEngineDataStoreTargetSite +// proto.service: google.cloud.discoveryengine.v1.SiteSearchEngineService +// proto.resource: TargetSite + +package mockdiscoveryengine + +import ( + "context" + "fmt" + "strings" + "time" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/timestamppb" + + pb "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" + + "github.com/GoogleCloudPlatform/k8s-config-connector/mockgcp/common/projects" +) + +type siteSearchEngineService struct { + *MockService + pb.UnimplementedSiteSearchEngineServiceServer +} + +func (s *siteSearchEngineService) CreateTargetSite(ctx context.Context, req *pb.CreateTargetSiteRequest) (*longrunningpb.Operation, error) { + // targetSiteID is system-generated + targetSiteID := fmt.Sprintf("%x", time.Now().UnixNano()) + + reqName := fmt.Sprintf("%s/targetSites/%s", req.GetParent(), targetSiteID) + name, err := s.parseTargetSiteName(reqName) + if err != nil { + return nil, err + } + + now := time.Now() + + fqn := name.String() + obj := proto.Clone(req.GetTargetSite()).(*pb.TargetSite) + obj.Name = fqn + obj.UpdateTime = timestamppb.New(now) + + if err := s.populateTargetSiteDefaults(ctx, obj); err != nil { + return nil, err + } + + if err := s.storage.Create(ctx, fqn, obj); err != nil { + return nil, err + } + + // Not all fields are returned in LRO result + lroRet := proto.Clone(obj).(*pb.TargetSite) + lroRet.ExactMatch = false + + op, err := s.operations.DoneLRO(ctx, "", nil, lroRet) + if op != nil { + // Name is not returned in LRO + op.Name = "" + } + return op, err +} + +func (s *siteSearchEngineService) UpdateTargetSite(ctx context.Context, req *pb.UpdateTargetSiteRequest) (*longrunningpb.Operation, error) { + name, err := s.parseTargetSiteName(req.TargetSite.Name) + if err != nil { + return nil, err + } + fqn := name.String() + obj := &pb.TargetSite{} + + if err := s.storage.Get(ctx, fqn, obj); err != nil { + if status.Code(err) == codes.NotFound { + return nil, status.Errorf(codes.NotFound, "targetSite %q not found", name) + } + return nil, err + } + + now := time.Now() + updated := proto.Clone(req.GetTargetSite()).(*pb.TargetSite) + updated.UpdateTime = timestamppb.New(now) + + if err := s.populateTargetSiteDefaults(ctx, updated); err != nil { + return nil, err + } + + if err := s.storage.Update(ctx, fqn, updated); err != nil { + return nil, err + } + + return &longrunningpb.Operation{Done: true}, nil +} + +func (s *siteSearchEngineService) populateTargetSiteDefaults(ctx context.Context, obj *pb.TargetSite) error { + obj.GeneratedUriPattern = obj.ProvidedUriPattern + + rootDomainUri := strings.SplitN(obj.GeneratedUriPattern, "/", 2)[0] + if strings.HasSuffix(rootDomainUri, ".google.com") { + rootDomainUri = "google.com" + } + obj.RootDomainUri = rootDomainUri + + return nil +} + +func (s *siteSearchEngineService) DeleteTargetSite(ctx context.Context, req *pb.DeleteTargetSiteRequest) (*longrunningpb.Operation, error) { + name, err := s.parseTargetSiteName(req.Name) + if err != nil { + return nil, err + } + + fqn := name.String() + + deleted := &pb.TargetSite{} + if err := s.storage.Delete(ctx, fqn, deleted); err != nil { + return nil, err + } + + return &longrunningpb.Operation{Done: true}, nil +} + +func (s *siteSearchEngineService) GetTargetSite(ctx context.Context, req *pb.GetTargetSiteRequest) (*pb.TargetSite, error) { + name, err := s.parseTargetSiteName(req.Name) + if err != nil { + return nil, err + } + + fqn := name.String() + obj := &pb.TargetSite{} + if err := s.storage.Get(ctx, fqn, obj); err != nil { + if status.Code(err) == codes.NotFound { + return nil, status.Errorf(codes.NotFound, "targetSite %v not found.", name) + } + return nil, err + } + + // Not all fields are returned in LRO result + retObj := proto.Clone(obj).(*pb.TargetSite) + retObj.ExactMatch = false + retObj.ProvidedUriPattern = "" + + return retObj, nil +} + +type targetSiteName struct { + Project *projects.ProjectData + Location string + Collection string + DataStore string + TargetSite string +} + +func (n *targetSiteName) String() string { + return fmt.Sprintf("projects/%d/locations/%s/collections/%s/dataStores/%s/siteSearchEngine/targetSites/%s", n.Project.Number, n.Location, n.Collection, n.DataStore, n.TargetSite) +} + +func (s *MockService) parseTargetSiteName(name string) (*targetSiteName, error) { + tokens := strings.Split(name, "/") + if len(tokens) == 11 && tokens[0] == "projects" && tokens[2] == "locations" && tokens[4] == "collections" && tokens[6] == "dataStores" && tokens[8] == "siteSearchEngine" && tokens[9] == "targetSites" { + project, err := s.Projects.GetProjectByID(tokens[1]) + if err != nil { + return nil, err + } + + return &targetSiteName{ + Project: project, + Location: tokens[3], + Collection: tokens[5], + DataStore: tokens[7], + TargetSite: tokens[10], + }, nil + } + + return nil, status.Errorf(codes.InvalidArgument, "invalid name %q", name) +} diff --git a/pkg/test/resourcefixture/testdata/basic/discoveryengine/v1alpha1/discoveryenginedatastoretargetsite/discoveryenginedatastoretargetsiteminimal/_http.log b/pkg/test/resourcefixture/testdata/basic/discoveryengine/v1alpha1/discoveryenginedatastoretargetsite/discoveryenginedatastoretargetsiteminimal/_http.log index f85431c810..50a8d38917 100644 --- a/pkg/test/resourcefixture/testdata/basic/discoveryengine/v1alpha1/discoveryenginedatastoretargetsite/discoveryenginedatastoretargetsiteminimal/_http.log +++ b/pkg/test/resourcefixture/testdata/basic/discoveryengine/v1alpha1/discoveryenginedatastoretargetsite/discoveryenginedatastoretargetsiteminimal/_http.log @@ -5,6 +5,7 @@ X-Goog-User-Project: ${projectId} x-goog-request-params: name=projects%2F${projectId}%2Flocations%2Fglobal%2Fcollections%2Fdefault_collection%2FdataStores%2F${dataStoreID} 404 Not Found +Cache-Control: private Content-Type: application/json; charset=UTF-8 Server: ESF Vary: Origin @@ -38,6 +39,7 @@ x-goog-request-params: parent=projects%2F${projectId}%2Flocations%2Fglobal%2Fcol } 200 OK +Cache-Control: private Content-Type: application/json; charset=UTF-8 Server: ESF Vary: Origin @@ -56,8 +58,7 @@ X-Xss-Protection: 0 "defaultSchemaId": "default_schema", "displayName": "KCC Test DisplayName", "industryVertical": 1, - "name": "projects/${projectNumber}/locations/global/collections/default_collection/dataStores/datastore-${uniqueId}", - "servingConfigDataStore": {} + "name": "projects/${projectNumber}/locations/global/collections/default_collection/dataStores/datastore-${uniqueId}" } } @@ -76,6 +77,7 @@ x-goog-request-params: parent=projects%2F${projectId}%2Flocations%2Fglobal%2Fcol } 200 OK +Cache-Control: private Content-Type: application/json; charset=UTF-8 Server: ESF Vary: Origin @@ -106,6 +108,7 @@ User-Agent: kcc/controller-manager x-goog-request-params: name=projects%2F${projectNumber} 200 OK +Cache-Control: private Content-Type: application/json; charset=UTF-8 Server: ESF Vary: Origin @@ -117,17 +120,10 @@ X-Xss-Protection: 0 { "createTime": "2024-04-01T12:34:56.123456Z", - "displayName": "${projectId}", "etag": "abcdef0123A=", - "labels": { - "cnrm-test": "true", - "managed-by-cnrm": "true" - }, "name": "projects/${projectNumber}", - "parent": "folders/${folderID}", "projectId": "${projectId}", - "state": 1, - "updateTime": "2024-04-01T12:34:56.123456Z" + "state": 1 } --- @@ -139,6 +135,7 @@ X-Goog-User-Project: ${projectId} x-goog-request-params: name=projects%2F${projectId}%2Flocations%2Fglobal%2Fcollections%2Fdefault_collection%2FdataStores%2F${dataStoreID}%2FsiteSearchEngine%2FtargetSites%2F${targetSiteID} 200 OK +Cache-Control: private Content-Type: application/json; charset=UTF-8 Server: ESF Vary: Origin @@ -165,6 +162,7 @@ X-Goog-User-Project: ${projectId} x-goog-request-params: name=projects%2F${projectId}%2Flocations%2Fglobal%2Fcollections%2Fdefault_collection%2FdataStores%2F${dataStoreID}%2FsiteSearchEngine%2FtargetSites%2F${targetSiteID} 200 OK +Cache-Control: private Content-Type: application/json; charset=UTF-8 Server: ESF Vary: Origin @@ -187,6 +185,7 @@ X-Goog-User-Project: ${projectId} x-goog-request-params: name=projects%2F${projectId}%2Flocations%2Fglobal%2Fcollections%2Fdefault_collection%2FdataStores%2F${dataStoreID} 200 OK +Cache-Control: private Content-Type: application/json; charset=UTF-8 Server: ESF Vary: Origin @@ -202,8 +201,7 @@ X-Xss-Protection: 0 "defaultSchemaId": "default_schema", "displayName": "KCC Test DisplayName", "industryVertical": 1, - "name": "projects/${projectNumber}/locations/global/collections/default_collection/dataStores/datastore-${uniqueId}", - "servingConfigDataStore": {} + "name": "projects/${projectNumber}/locations/global/collections/default_collection/dataStores/datastore-${uniqueId}" } --- @@ -215,6 +213,7 @@ X-Goog-User-Project: ${projectId} x-goog-request-params: name=projects%2F${projectId}%2Flocations%2Fglobal%2Fcollections%2Fdefault_collection%2FdataStores%2F${dataStoreID} 200 OK +Cache-Control: private Content-Type: application/json; charset=UTF-8 Server: ESF Vary: Origin