#  Copyright 2016-2026. Couchbase, Inc.
#  All Rights Reserved.
#
#  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.

# flake8: noqa: E501
from __future__ import annotations

from typing import TYPE_CHECKING

from couchbase.logic.operation_types import (AnalyticsMgmtOperationType,
                                             BucketMgmtOperationType,
                                             BucketOperationType,
                                             ClusterMgmtOperationType,
                                             ClusterOperationType,
                                             CollectionMgmtOperationType,
                                             CollectionOperationType,
                                             EventingFunctionMgmtOperationType,
                                             KeyValueMultiOperationType,
                                             KeyValueOperationType,
                                             QueryIndexMgmtOperationType,
                                             SearchIndexMgmtOperationType,
                                             StreamingOperationType,
                                             UserMgmtOperationType,
                                             ViewIndexMgmtOperationType)
from couchbase.logic.pycbc_core.binding_map_types import PycbcConnectionOpMap

if TYPE_CHECKING:
    from couchbase.logic.pycbc_core import pycbc_connection


class BindingMap:

    def __init__(self, pycbc_conn: pycbc_connection) -> None:
        self._conn = pycbc_conn
        self._op_map: PycbcConnectionOpMap = {}
        self._load_op_map()

    @property
    def op_map(self) -> PycbcConnectionOpMap:
        return self._op_map

    def _load_op_map(self) -> None:
        """**INTERNAL**"""
        # cluster operations
        self._op_map.update(**{
            ClusterOperationType.Close.value: self._conn.pycbc_close,
            ClusterOperationType.Connect.value: self._conn.pycbc_connect,
            ClusterOperationType.Diagnostics.value: self._conn.pycbc_diagnostics,
            ClusterOperationType.GetClusterLabels.value: self._conn.pycbc_get_cluster_labels,
            ClusterOperationType.GetConnectionInfo.value: self._conn.pycbc_get_connection_info,
            ClusterOperationType.GetDefaultTimeouts.value: self._conn.pycbc_get_default_timeouts,
            ClusterOperationType.Ping.value: self._conn.pycbc_ping,
            ClusterOperationType.UpdateCredentials.value: self._conn.pycbc_update_credentials,
        })
        # bucket operations
        self._op_map.update(**{
            BucketOperationType.CloseBucket.value: self._conn.pycbc_close_bucket,
            BucketOperationType.OpenBucket.value: self._conn.pycbc_open_bucket,
            # ping is same as ClusterOperationType.Ping
        })

        # KV Range Scan operations
        self._op_map.update(**{
            CollectionOperationType.KeyValueRangeScan.value: self._conn.pycbc_kv_range_scan,
        })

# ====================================================================================================
# AUTOGENERATED SECTION START - DO NOT EDIT MANUALLY
# Generated-On: 2026-02-21 16:18:41
# Content-Hash: 21d3f2aa18faa8b35563b2cfebec9026
# ====================================================================================================
        # key-value operations
        self._op_map.update({
            KeyValueOperationType.Append.value: self._conn.pycbc_append,
            KeyValueOperationType.AppendWithLegacyDurability.value: self._conn.pycbc_append_with_legacy_durability,
            KeyValueOperationType.Decrement.value: self._conn.pycbc_decrement,
            KeyValueOperationType.DecrementWithLegacyDurability.value: self._conn.pycbc_decrement_with_legacy_durability,
            KeyValueOperationType.Exists.value: self._conn.pycbc_exists,
            KeyValueOperationType.Get.value: self._conn.pycbc_get,
            KeyValueOperationType.GetAllReplicas.value: self._conn.pycbc_get_all_replicas,
            KeyValueOperationType.GetAndLock.value: self._conn.pycbc_get_and_lock,
            KeyValueOperationType.GetAndTouch.value: self._conn.pycbc_get_and_touch,
            KeyValueOperationType.GetAnyReplica.value: self._conn.pycbc_get_any_replica,
            KeyValueOperationType.GetProjected.value: self._conn.pycbc_get_projected,
            KeyValueOperationType.Increment.value: self._conn.pycbc_increment,
            KeyValueOperationType.IncrementWithLegacyDurability.value: self._conn.pycbc_increment_with_legacy_durability,
            KeyValueOperationType.Insert.value: self._conn.pycbc_insert,
            KeyValueOperationType.InsertWithLegacyDurability.value: self._conn.pycbc_insert_with_legacy_durability,
            KeyValueOperationType.LookupIn.value: self._conn.pycbc_lookup_in,
            KeyValueOperationType.LookupInAllReplicas.value: self._conn.pycbc_lookup_in_all_replicas,
            KeyValueOperationType.LookupInAnyReplica.value: self._conn.pycbc_lookup_in_any_replica,
            KeyValueOperationType.MutateIn.value: self._conn.pycbc_mutate_in,
            KeyValueOperationType.MutateInWithLegacyDurability.value: self._conn.pycbc_mutate_in_with_legacy_durability,
            KeyValueOperationType.Prepend.value: self._conn.pycbc_prepend,
            KeyValueOperationType.PrependWithLegacyDurability.value: self._conn.pycbc_prepend_with_legacy_durability,
            KeyValueOperationType.Remove.value: self._conn.pycbc_remove,
            KeyValueOperationType.RemoveWithLegacyDurability.value: self._conn.pycbc_remove_with_legacy_durability,
            KeyValueOperationType.Replace.value: self._conn.pycbc_replace,
            KeyValueOperationType.ReplaceWithLegacyDurability.value: self._conn.pycbc_replace_with_legacy_durability,
            KeyValueOperationType.Touch.value: self._conn.pycbc_touch,
            KeyValueOperationType.Unlock.value: self._conn.pycbc_unlock,
            KeyValueOperationType.Upsert.value: self._conn.pycbc_upsert,
            KeyValueOperationType.UpsertWithLegacyDurability.value: self._conn.pycbc_upsert_with_legacy_durability,

        })
        # key-value multi operations
        self._op_map.update({
            KeyValueMultiOperationType.AppendMulti.value: self._conn.pycbc_append_multi,
            KeyValueMultiOperationType.AppendWithLegacyDurabilityMulti.value: self._conn.pycbc_append_with_legacy_durability_multi,
            KeyValueMultiOperationType.DecrementMulti.value: self._conn.pycbc_decrement_multi,
            KeyValueMultiOperationType.DecrementWithLegacyDurabilityMulti.value: self._conn.pycbc_decrement_with_legacy_durability_multi,
            KeyValueMultiOperationType.ExistsMulti.value: self._conn.pycbc_exists_multi,
            KeyValueMultiOperationType.GetMulti.value: self._conn.pycbc_get_multi,
            KeyValueMultiOperationType.GetAllReplicasMulti.value: self._conn.pycbc_get_all_replicas_multi,
            KeyValueMultiOperationType.GetAndLockMulti.value: self._conn.pycbc_get_and_lock_multi,
            KeyValueMultiOperationType.GetAndTouchMulti.value: self._conn.pycbc_get_and_touch_multi,
            KeyValueMultiOperationType.GetAnyReplicaMulti.value: self._conn.pycbc_get_any_replica_multi,
            KeyValueMultiOperationType.IncrementMulti.value: self._conn.pycbc_increment_multi,
            KeyValueMultiOperationType.IncrementWithLegacyDurabilityMulti.value: self._conn.pycbc_increment_with_legacy_durability_multi,
            KeyValueMultiOperationType.InsertMulti.value: self._conn.pycbc_insert_multi,
            KeyValueMultiOperationType.InsertWithLegacyDurabilityMulti.value: self._conn.pycbc_insert_with_legacy_durability_multi,
            KeyValueMultiOperationType.PrependMulti.value: self._conn.pycbc_prepend_multi,
            KeyValueMultiOperationType.PrependWithLegacyDurabilityMulti.value: self._conn.pycbc_prepend_with_legacy_durability_multi,
            KeyValueMultiOperationType.RemoveMulti.value: self._conn.pycbc_remove_multi,
            KeyValueMultiOperationType.RemoveWithLegacyDurabilityMulti.value: self._conn.pycbc_remove_with_legacy_durability_multi,
            KeyValueMultiOperationType.ReplaceMulti.value: self._conn.pycbc_replace_multi,
            KeyValueMultiOperationType.ReplaceWithLegacyDurabilityMulti.value: self._conn.pycbc_replace_with_legacy_durability_multi,
            KeyValueMultiOperationType.TouchMulti.value: self._conn.pycbc_touch_multi,
            KeyValueMultiOperationType.UnlockMulti.value: self._conn.pycbc_unlock_multi,
            KeyValueMultiOperationType.UpsertMulti.value: self._conn.pycbc_upsert_multi,
            KeyValueMultiOperationType.UpsertWithLegacyDurabilityMulti.value: self._conn.pycbc_upsert_with_legacy_durability_multi,

        })
        # streaming operations
        self._op_map.update({
            StreamingOperationType.AnalyticsQuery.value: self._conn.pycbc_analytics_query,
            StreamingOperationType.Query.value: self._conn.pycbc_query,
            StreamingOperationType.SearchQuery.value: self._conn.pycbc_search_query,
            StreamingOperationType.ViewQuery.value: self._conn.pycbc_view_query,

        })

        # Analytics management operations
        self._op_map.update({
            AnalyticsMgmtOperationType.AnalyticsDatasetCreate.value: self._conn.pycbc_analytics_dataset_create,
            AnalyticsMgmtOperationType.AnalyticsDatasetDrop.value: self._conn.pycbc_analytics_dataset_drop,
            AnalyticsMgmtOperationType.AnalyticsDatasetGetAll.value: self._conn.pycbc_analytics_dataset_get_all,
            AnalyticsMgmtOperationType.AnalyticsDataverseCreate.value: self._conn.pycbc_analytics_dataverse_create,
            AnalyticsMgmtOperationType.AnalyticsDataverseDrop.value: self._conn.pycbc_analytics_dataverse_drop,
            AnalyticsMgmtOperationType.AnalyticsGetPendingMutations.value: self._conn.pycbc_analytics_get_pending_mutations,
            AnalyticsMgmtOperationType.AnalyticsIndexCreate.value: self._conn.pycbc_analytics_index_create,
            AnalyticsMgmtOperationType.AnalyticsIndexDrop.value: self._conn.pycbc_analytics_index_drop,
            AnalyticsMgmtOperationType.AnalyticsIndexGetAll.value: self._conn.pycbc_analytics_index_get_all,
            AnalyticsMgmtOperationType.AnalyticsLinkConnect.value: self._conn.pycbc_analytics_link_connect,
            AnalyticsMgmtOperationType.AnalyticsLinkCreateCouchbaseRemoteLink.value: self._conn.pycbc_analytics_link_create_couchbase_remote_link,
            AnalyticsMgmtOperationType.AnalyticsLinkCreateS3ExternalLink.value: self._conn.pycbc_analytics_link_create_s3_external_link,
            AnalyticsMgmtOperationType.AnalyticsLinkCreateAzureBlobExternalLink.value: self._conn.pycbc_analytics_link_create_azure_blob_external_link,
            AnalyticsMgmtOperationType.AnalyticsLinkDisconnect.value: self._conn.pycbc_analytics_link_disconnect,
            AnalyticsMgmtOperationType.AnalyticsLinkDrop.value: self._conn.pycbc_analytics_link_drop,
            AnalyticsMgmtOperationType.AnalyticsLinkGetAll.value: self._conn.pycbc_analytics_link_get_all,
            AnalyticsMgmtOperationType.AnalyticsLinkReplaceCouchbaseRemoteLink.value: self._conn.pycbc_analytics_link_replace_couchbase_remote_link,
            AnalyticsMgmtOperationType.AnalyticsLinkReplaceS3ExternalLink.value: self._conn.pycbc_analytics_link_replace_s3_external_link,
            AnalyticsMgmtOperationType.AnalyticsLinkReplaceAzureBlobExternalLink.value: self._conn.pycbc_analytics_link_replace_azure_blob_external_link,
        })

        # Bucket management operations
        self._op_map.update({
            BucketMgmtOperationType.BucketCreate.value: self._conn.pycbc_bucket_create,
            BucketMgmtOperationType.BucketDrop.value: self._conn.pycbc_bucket_drop,
            BucketMgmtOperationType.BucketFlush.value: self._conn.pycbc_bucket_flush,
            BucketMgmtOperationType.BucketGet.value: self._conn.pycbc_bucket_get,
            BucketMgmtOperationType.BucketGetAll.value: self._conn.pycbc_bucket_get_all,
            BucketMgmtOperationType.BucketUpdate.value: self._conn.pycbc_bucket_update,
            BucketMgmtOperationType.BucketDescribe.value: self._conn.pycbc_bucket_describe,
        })

        # Cluster management operations
        self._op_map.update({
            ClusterMgmtOperationType.ClusterDescribe.value: self._conn.pycbc_cluster_describe,
            ClusterMgmtOperationType.ClusterDeveloperPreviewEnable.value: self._conn.pycbc_cluster_developer_preview_enable,
        })

        # Collection management operations
        self._op_map.update({
            CollectionMgmtOperationType.CollectionCreate.value: self._conn.pycbc_collection_create,
            CollectionMgmtOperationType.CollectionsManifestGet.value: self._conn.pycbc_collections_manifest_get,
            CollectionMgmtOperationType.CollectionDrop.value: self._conn.pycbc_collection_drop,
            CollectionMgmtOperationType.CollectionUpdate.value: self._conn.pycbc_collection_update,
            CollectionMgmtOperationType.ScopeCreate.value: self._conn.pycbc_scope_create,
            CollectionMgmtOperationType.ScopeDrop.value: self._conn.pycbc_scope_drop,
            CollectionMgmtOperationType.ScopeGetAll.value: self._conn.pycbc_scope_get_all,
        })

        # EventingFunction management operations
        self._op_map.update({
            EventingFunctionMgmtOperationType.EventingDeployFunction.value: self._conn.pycbc_eventing_deploy_function,
            EventingFunctionMgmtOperationType.EventingDropFunction.value: self._conn.pycbc_eventing_drop_function,
            EventingFunctionMgmtOperationType.EventingGetAllFunctions.value: self._conn.pycbc_eventing_get_all_functions,
            EventingFunctionMgmtOperationType.EventingGetFunction.value: self._conn.pycbc_eventing_get_function,
            EventingFunctionMgmtOperationType.EventingGetStatus.value: self._conn.pycbc_eventing_get_status,
            EventingFunctionMgmtOperationType.EventingPauseFunction.value: self._conn.pycbc_eventing_pause_function,
            EventingFunctionMgmtOperationType.EventingResumeFunction.value: self._conn.pycbc_eventing_resume_function,
            EventingFunctionMgmtOperationType.EventingUndeployFunction.value: self._conn.pycbc_eventing_undeploy_function,
            EventingFunctionMgmtOperationType.EventingUpsertFunction.value: self._conn.pycbc_eventing_upsert_function,
        })

        # QueryIndex management operations
        self._op_map.update({
            QueryIndexMgmtOperationType.QueryIndexBuild.value: self._conn.pycbc_query_index_build,
            QueryIndexMgmtOperationType.QueryIndexBuildDeferred.value: self._conn.pycbc_query_index_build_deferred,
            QueryIndexMgmtOperationType.QueryIndexCreate.value: self._conn.pycbc_query_index_create,
            QueryIndexMgmtOperationType.QueryIndexDrop.value: self._conn.pycbc_query_index_drop,
            QueryIndexMgmtOperationType.QueryIndexGetAll.value: self._conn.pycbc_query_index_get_all,
            QueryIndexMgmtOperationType.QueryIndexGetAllDeferred.value: self._conn.pycbc_query_index_get_all_deferred,
        })

        # SearchIndex management operations
        self._op_map.update({
            SearchIndexMgmtOperationType.SearchGetStats.value: self._conn.pycbc_search_get_stats,
            SearchIndexMgmtOperationType.SearchIndexAnalyzeDocument.value: self._conn.pycbc_search_index_analyze_document,
            SearchIndexMgmtOperationType.SearchIndexControlIngest.value: self._conn.pycbc_search_index_control_ingest,
            SearchIndexMgmtOperationType.SearchIndexControlPlanFreeze.value: self._conn.pycbc_search_index_control_plan_freeze,
            SearchIndexMgmtOperationType.SearchIndexControlQuery.value: self._conn.pycbc_search_index_control_query,
            SearchIndexMgmtOperationType.SearchIndexDrop.value: self._conn.pycbc_search_index_drop,
            SearchIndexMgmtOperationType.SearchIndexGet.value: self._conn.pycbc_search_index_get,
            SearchIndexMgmtOperationType.SearchIndexGetAll.value: self._conn.pycbc_search_index_get_all,
            SearchIndexMgmtOperationType.SearchIndexGetDocumentsCount.value: self._conn.pycbc_search_index_get_documents_count,
            SearchIndexMgmtOperationType.SearchIndexGetStats.value: self._conn.pycbc_search_index_get_stats,
            SearchIndexMgmtOperationType.SearchIndexUpsert.value: self._conn.pycbc_search_index_upsert,
        })

        # User management operations
        self._op_map.update({
            UserMgmtOperationType.ChangePassword.value: self._conn.pycbc_change_password,
            UserMgmtOperationType.GroupDrop.value: self._conn.pycbc_group_drop,
            UserMgmtOperationType.GroupGet.value: self._conn.pycbc_group_get,
            UserMgmtOperationType.GroupGetAll.value: self._conn.pycbc_group_get_all,
            UserMgmtOperationType.GroupUpsert.value: self._conn.pycbc_group_upsert,
            UserMgmtOperationType.RoleGetAll.value: self._conn.pycbc_role_get_all,
            UserMgmtOperationType.UserDrop.value: self._conn.pycbc_user_drop,
            UserMgmtOperationType.UserGet.value: self._conn.pycbc_user_get,
            UserMgmtOperationType.UserGetAll.value: self._conn.pycbc_user_get_all,
            UserMgmtOperationType.UserUpsert.value: self._conn.pycbc_user_upsert,
        })

        # ViewIndex management operations
        self._op_map.update({
            ViewIndexMgmtOperationType.ViewIndexDrop.value: self._conn.pycbc_view_index_drop,
            ViewIndexMgmtOperationType.ViewIndexGet.value: self._conn.pycbc_view_index_get,
            ViewIndexMgmtOperationType.ViewIndexGetAll.value: self._conn.pycbc_view_index_get_all,
            ViewIndexMgmtOperationType.ViewIndexUpsert.value: self._conn.pycbc_view_index_upsert,
        })

# ====================================================================================================
# AUTOGENERATED SECTION END - DO NOT EDIT MANUALLY
# Generated-On: 2026-02-21 16:18:41
# Content-Hash: 21d3f2aa18faa8b35563b2cfebec9026
# ====================================================================================================
