Beispiel #1
0

class SaveResultsAsCsvRequestParams(SaveResultsRequestParams):
    def __init__(self):
        super().__init__()
        self.include_headers: bool = None


class SaveResultsAsJsonRequestParams(SaveResultsRequestParams):
    def __init__(self):
        super().__init__()


class SaveResultsAsExcelRequestParams(SaveResultsRequestParams):
    def __init__(self):
        super().__init__()
        self.include_headers: bool = None


SAVE_AS_CSV_REQUEST = IncomingMessageConfiguration(
    'query/saveCsv', SaveResultsAsCsvRequestParams)

SAVE_AS_JSON_REQUEST = IncomingMessageConfiguration(
    'query/saveJson', SaveResultsAsJsonRequestParams)

SAVE_AS_EXCEL_REQUEST = IncomingMessageConfiguration(
    'query/saveExcel', SaveResultsAsExcelRequestParams)

SERIALIZATION_OPTIONS = FeatureMetadataProvider(True, 'serializationService',
                                                [])
Beispiel #2
0
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from pgsqltoolsservice.hosting import IncomingMessageConfiguration
from pgsqltoolsservice.serialization import Serializable


class CloseSessionParameters(Serializable):
    def __init__(self):
        self.session_id: str = None
        self.owner_uri: str = None
        self.type: int = None
        self.options: dict = None
        self.server_name: str = None
        self.database_name: str = None
        self.user_name: str = None


CLOSE_SESSION_REQUEST = IncomingMessageConfiguration(
    'objectexplorer/closesession', CloseSessionParameters)
Beispiel #3
0
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from pgsqltoolsservice.hosting import IncomingMessageConfiguration
from pgsqltoolsservice.edit_data.contracts import RowOperationRequest


class RevertRowRequest(RowOperationRequest):
    def __init__(self):
        RowOperationRequest.__init__(self)


class RevertRowResponse:
    def __init__(self):
        pass


REVERT_ROW_REQUEST = IncomingMessageConfiguration('edit/revertRow',
                                                  RevertRowRequest)
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from pgsqltoolsservice.hosting import IncomingMessageConfiguration
from pgsqltoolsservice.connection.contracts.common import ConnectionDetails, ConnectionType  # noqa
from pgsqltoolsservice.serialization import Serializable


class ChangeDatabaseRequestParams(Serializable):
    @classmethod
    def get_child_serializable_types(cls):
        return {'connection': ConnectionDetails}

    def __init__(self, owner_uri=None, new_database=None):
        self.owner_uri: str = owner_uri
        self.new_database: str = new_database


CHANGE_DATABASE_REQUEST = IncomingMessageConfiguration(
    'connection/changedatabase', ChangeDatabaseRequestParams)
Beispiel #5
0
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from pgsqltoolsservice.hosting import IncomingMessageConfiguration
import pgsqltoolsservice.utils as utils


class ListTasksParameters:
    """Parameters for the tasks/listtasks request"""
    @classmethod
    def from_dict(cls, dictionary: dict):
        return utils.serialization.convert_from_dict(cls, dictionary)

    def __init__(self):
        self.list_active_tasks_only: bool = None


LIST_TASKS_REQUEST = IncomingMessageConfiguration('tasks/listtasks',
                                                  ListTasksParameters)
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from pgsqltoolsservice.hosting import IncomingMessageConfiguration
from pgsqltoolsservice.serialization import Serializable


class ExpandParameters(Serializable):
    def __init__(self):
        self.session_id: str = None
        self.node_path: str = None


EXPAND_REQUEST = IncomingMessageConfiguration('objectexplorer/expand',
                                              ExpandParameters)
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from pgsqltoolsservice.hosting import IncomingMessageConfiguration
from pgsqltoolsservice.edit_data.contracts import RowOperationRequest, EditCellResponse, EditCell


class RevertCellRequest(RowOperationRequest):
    def __init__(self):
        RowOperationRequest.__init__(self)
        self.column_id: int = None


class RevertCellResponse(EditCellResponse):
    def __init__(self, edit_cell: EditCell, is_row_dirty: bool):
        EditCellResponse.__init__(self, edit_cell, is_row_dirty)


REVERT_CELL_REQUEST = IncomingMessageConfiguration('edit/revertCell',
                                                   RevertCellRequest)
    SELECT = 0
    CREATE = 1
    # INSERT = 2    # TODO: Reenable INSERT script operation when it is supported. (https://github.com/Microsoft/carbon/issues/1751)
    UPDATE = 3
    DELETE = 4


class ScriptAsParameters(Serializable):
    @classmethod
    def get_child_serializable_types(cls):
        return {'metadata': ObjectMetadata, 'operation': ScriptOperation}

    def __init__(self):
        self.owner_uri: str = None
        self.operation: ScriptOperation = None
        self.scripting_objects: List[ObjectMetadata] = None

    @classmethod
    def ignore_extra_attributes(cls):
        return True


class ScriptAsResponse(Serializable):

    def __init__(self, owner_uri: str, script: str):
        self.owner_uri: str = owner_uri
        self.script: str = script


SCRIPTAS_REQUEST = IncomingMessageConfiguration('scripting/script', ScriptAsParameters)
Beispiel #9
0
from typing import Any, Dict  # noqa

from pgsqltoolsservice.hosting import IncomingMessageConfiguration
from pgsqltoolsservice.serialization import Serializable


class GetDatabaseInfoParameters(Serializable):
    """Contract for the parameters to admin/getdatabaseinfo requests"""

    def __init__(self):
        self.options: dict = None
        self.owner_uri: str = None


class DatabaseInfo:
    """Contract for database information"""
    OWNER = 'owner'

    def __init__(self, options: Dict[str, Any]) -> None:
        self.options: Dict[str, Any] = options


class GetDatabaseInfoResponse:
    """Contract for the response to admin/getdatabaseinfo requests"""

    def __init__(self, database_info: DatabaseInfo) -> None:
        self.database_info: DatabaseInfo = database_info


GET_DATABASE_INFO_REQUEST = IncomingMessageConfiguration('admin/getdatabaseinfo', GetDatabaseInfoParameters)
Beispiel #10
0
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from typing import List

from pgsqltoolsservice.hosting import IncomingMessageConfiguration
from pgsqltoolsservice.serialization import Serializable
from pgsqltoolsservice.edit_data.contracts import EditRow


class EditSubsetParams(Serializable):
    def __init__(self):
        self.owner_uri: str = None
        self.row_start_index: int = None
        self.row_count: int = None


class EditSubsetResponse:
    def __init__(self, row_count: int, edit_rows: List[EditRow]):
        self.row_count = row_count
        self.subset = edit_rows


EDIT_SUBSET_REQUEST = IncomingMessageConfiguration('edit/subset',
                                                   EditSubsetParams)
Beispiel #11
0
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from pgsqltoolsservice.hosting import IncomingMessageConfiguration
from pgsqltoolsservice.edit_data.contracts import RowOperationRequest, EditCellResponse


class UpdateCellRequest(RowOperationRequest):
    def __init__(self):
        RowOperationRequest.__init__(self)
        self.column_id = None
        self.new_value = None


class UpdateCellResponse(EditCellResponse):
    def __init__(self):
        EditCellResponse.__init__(self)


UPDATE_CELL_REQUEST = IncomingMessageConfiguration('edit/updateCell',
                                                   UpdateCellRequest)
class FeatureMetadataProvider:
    """Defines a set of options that will be sent to the client"""
    def __init__(self, enabled: bool, feature_name: str,
                 options_metadata: List[ServiceOption]):
        self.enabled = enabled
        self.feature_name = feature_name
        self.options_metadata = options_metadata


class DMPServerCapabilities:
    """Defines the DMP server capabilities"""
    def __init__(self, protocol_version: str, provider_name: str,
                 provider_display_name: str,
                 connection_options: ConnectionProviderOptions,
                 features: List[FeatureMetadataProvider]):
        self.protocol_version: str = protocol_version
        self.provider_name: str = provider_name
        self.provider_display_name: str = provider_display_name
        self.connection_provider: ConnectionProviderOptions = connection_options
        self.features: List[FeatureMetadataProvider] = features


class CapabilitiesResult(object):
    """Defines the capabilities result contract"""
    def __init__(self, capabilities: DMPServerCapabilities):
        self.capabilities: DMPServerCapabilities = capabilities


CAPABILITIES_REQUEST = IncomingMessageConfiguration('capabilities/list',
                                                    CapabilitiesRequestParams)
        self.enable_quick_info = True


class Configuration(Serializable):
    """
    Configuration of the tools service
    """
    @classmethod
    def get_child_serializable_types(cls):
        return {'sql': SQLConfiguration, 'pgsql': PGSQLConfiguration}

    def __init__(self):
        self.sql = SQLConfiguration()
        self.pgsql = PGSQLConfiguration()


class DidChangeConfigurationParams(Serializable):
    """
    Parameters received when configuration has been changed
    """
    @classmethod
    def get_child_serializable_types(cls):
        return {'settings': Configuration}

    def __init__(self):
        self.settings: Configuration = None


DID_CHANGE_CONFIG_NOTIFICATION = IncomingMessageConfiguration(
    'workspace/didChangeConfiguration', DidChangeConfigurationParams)
Beispiel #14
0
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from pgsqltoolsservice.hosting import IncomingMessageConfiguration
from pgsqltoolsservice.object_explorer.contracts.expand_request import ExpandParameters

REFRESH_REQUEST = IncomingMessageConfiguration('objectexplorer/refresh',
                                               ExpandParameters)
Beispiel #15
0
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from pgsqltoolsservice.connection.contracts.common import ConnectionType
from pgsqltoolsservice.hosting import IncomingMessageConfiguration
from pgsqltoolsservice.serialization import Serializable


class BuildConnectionInfoParams(Serializable):
    """Parameters for Serializing Connection String request"""
    def __init__(self,
                 owner_uri: str = None,
                 connection_type: ConnectionType = ConnectionType.DEFAULT):
        self.owner_uri: str = owner_uri
        self.type: ConnectionType = connection_type


BUILD_CONNECTION_INFO_REQUEST = IncomingMessageConfiguration(
    'connection/buildconnectioninfo', BuildConnectionInfoParams)
            'options': FormattingOptions
        }

    def __init__(self):
        self.text_document: TextDocumentIdentifier = None
        self.options: FormattingOptions = None


class DocumentRangeFormattingParams(DocumentFormattingParams):
    """
    Parameters used in a formatting request to process a specific text range
    """
    @classmethod
    def get_child_serializable_types(cls):
        return {
            'range': Range,
            'text_document': TextDocumentIdentifier,
            'options': FormattingOptions
        }

    def __init__(self):
        DocumentFormattingParams.__init__(self)
        self.range: Range = None


DOCUMENT_FORMATTING_REQUEST = IncomingMessageConfiguration(
    'textDocument/formatting', DocumentFormattingParams)

DOCUMENT_RANGE_FORMATTING_REQUEST = IncomingMessageConfiguration(
    'textDocument/rangeFormatting', DocumentRangeFormattingParams)
Beispiel #17
0
    File = 17
    Reference = 18


class CompletionItem(Serializable):
    """
    Completion items are presented in an IntelliSense user interface, representing valid
    items to complete an in-process typing
    """
    @classmethod
    def get_child_serializable_types(cls):
        return {'kind': CompletionItemKind, 'text_edit': TextEdit}

    def __init__(self):
        self.label: str = None
        self.kind: CompletionItemKind = None
        self.detail: str = None
        self.documentation: str = None
        self.sort_text: str = None
        self.filter_text: str = None
        self.insert_text: str = None
        self.text_edit: TextEdit = None
        self.data: any = None


COMPLETION_REQUEST = IncomingMessageConfiguration('textDocument/completion',
                                                  TextDocumentPosition)

COMPLETION_RESOLVE_REQUEST = IncomingMessageConfiguration(
    'completionItem/resolve', CompletionItem)
from pgsqltoolsservice.serialization import Serializable
from pgsqltoolsservice.hosting import IncomingMessageConfiguration


class QueryExecutionPlanRequest(Serializable):
    def __init__(self):
        self.owner_uri: str = None
        self.batch_index: int = None
        self.result_set_index: int = None


class QueryExecutionResponse:
    def __init__(self):
        self.execution_plan = None


QUERY_EXECUTION_PLAN_REQUEST = IncomingMessageConfiguration(
    'query/executionPlan', QueryExecutionPlanRequest)
Beispiel #19
0
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from pgsqltoolsservice.hosting import IncomingMessageConfiguration
from pgsqltoolsservice.serialization.serializable import convert_from_dict


class CancelTaskParameters:
    """Parameters for the tasks/canceltask request"""
    @classmethod
    def from_dict(cls, dictionary: dict):
        return convert_from_dict(cls, dictionary)

    def __init__(self):
        self.task_id: str = None


CANCEL_TASK_REQUEST = IncomingMessageConfiguration('tasks/canceltask',
                                                   CancelTaskParameters)
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from pgsqltoolsservice.hosting import IncomingMessageConfiguration
from pgsqltoolsservice.serialization import Serializable


class DisconnectRequestParams(Serializable):
    def __init__(self):
        self.owner_uri = None
        self.type = None


DISCONNECT_REQUEST = IncomingMessageConfiguration('connection/disconnect',
                                                  DisconnectRequestParams)
Beispiel #21
0
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
"""This module holds contracts for the language flavor change notification"""

from pgsqltoolsservice.hosting import IncomingMessageConfiguration
from pgsqltoolsservice.serialization import Serializable


class LanguageFlavorChangeParams(Serializable):
    """
    Parameters for the Language Flavor Change notification
    """
    @classmethod
    def from_data(cls, uri: str, language: str, flavor: str):
        obj = cls()
        obj.uri = uri
        obj.language = language
        obj.flavor = flavor
        return obj

    def __init__(self):
        self.uri: str = None
        self.language: str = None
        self.flavor: str = None


LANGUAGE_FLAVOR_CHANGE_NOTIFICATION = IncomingMessageConfiguration(
    'connection/languageflavorchanged', LanguageFlavorChangeParams)
Beispiel #22
0
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from pgsqltoolsservice.connection.contracts.common import ConnectionType
from pgsqltoolsservice.hosting import IncomingMessageConfiguration
from pgsqltoolsservice.serialization import Serializable


class CancelConnectParams(Serializable):
    """Parameters for the cancel connect request"""

    def __init__(self, owner_uri: str = None, connection_type: ConnectionType = ConnectionType.DEFAULT):
        self.owner_uri: str = owner_uri
        self.type: ConnectionType = connection_type


CANCEL_CONNECT_REQUEST = IncomingMessageConfiguration('connection/cancelconnect', CancelConnectParams)
        return {'execution_plan_options': ExecutionPlanOptions}

    def __init__(self):
        self.owner_uri: str = None
        self.execution_plan_options: ExecutionPlanOptions = ExecutionPlanOptions()


class ExecuteStringParams(ExecuteRequestParamsBase):

    def __init__(self):
        super().__init__()
        self.query: str = None


EXECUTE_STRING_REQUEST = IncomingMessageConfiguration(
    'query/executeString',
    ExecuteStringParams
)

EXECUTE_DEPLOY_REQUEST = IncomingMessageConfiguration(
    'query/executeDeploy',
    ExecuteStringParams
)


class ExecuteDocumentSelectionParams(ExecuteRequestParamsBase):
    @classmethod
    def get_child_serializable_types(cls):
        return {'query_selection': SelectionData, 'execution_plan_options': ExecutionPlanOptions}

    def __init__(self):
        super().__init__()
Beispiel #24
0
                 completion_provider=None,
                 signature_help_provider=None,
                 definition_provider=None,
                 references_provider=None,
                 document_highlight_provider=None,
                 document_formatting_provider=None,
                 document_range_formatting_provider=None,
                 document_symbol_provider=None,
                 workspace_symbol_provider=None):
        self.text_document_sync: TextDocumentSyncKind = text_document_sync
        self.hover_provider: bool = hover_provider
        self.completion_provider: CompletionOptions = completion_provider
        self.signature_help_provider: SignatureHelpOptions = signature_help_provider
        self.definition_provider: bool = definition_provider
        self.references_provider: bool = references_provider
        self.document_highlight_provider: bool = document_highlight_provider
        self.document_formatting_provider: bool = document_formatting_provider
        self.document_range_formatting_provider: bool = document_range_formatting_provider
        self.document_symbol_provider: bool = document_symbol_provider
        self.workspace_symbol_provider: bool = workspace_symbol_provider


class InitializeResult:
    """Initialization result parameters"""
    def __init__(self, capabilities: ServerCapabilities):
        self.capabilities: ServerCapabilities = capabilities


INITIALIZE_REQUEST = IncomingMessageConfiguration('initialize',
                                                  InitializeRequestParams)
Beispiel #25
0
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------


from typing import List  # noqa

from pgsqltoolsservice.hosting import IncomingMessageConfiguration
from pgsqltoolsservice.edit_data.contracts import SessionOperationRequest


class CreateRowRequest(SessionOperationRequest):

    def __init__(self):
        SessionOperationRequest.__init__(self)


class CreateRowResponse:

    def __init__(self, new_row_id: int, default_values: List[str]):
        self.default_values = default_values
        self.new_row_id = new_row_id


CREATE_ROW_REQUEST = IncomingMessageConfiguration('edit/createRow', CreateRowRequest)
Beispiel #26
0
from pgsqltoolsservice.hosting import IncomingMessageConfiguration
from pgsqltoolsservice.serialization import Serializable


class SubsetParams(Serializable):

    def __init__(self):
        self.owner_uri = None
        self.batch_index: int = None
        self.result_set_index: int = None
        self.rows_start_index: int = None
        self.rows_count: int = None


SUBSET_REQUEST = IncomingMessageConfiguration('query/subset', SubsetParams)


class QueryCancelParams(Serializable):

    def __init__(self):
        self.owner_uri = None


CANCEL_REQUEST = IncomingMessageConfiguration('query/cancel', QueryCancelParams)


class QueryDisposeParams(Serializable):

    def __init__(self):
        self.owner_uri = None
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from pgsqltoolsservice.hosting import IncomingMessageConfiguration
from pgsqltoolsservice.workspace.contracts.common import TextDocumentItem
from pgsqltoolsservice.serialization import Serializable


class DidCloseTextDocumentParams(Serializable):
    """
    Parameters to receive with a textDocument/didClose notification
    Attributes:
        text_document:  The document that was closed
    """
    @classmethod
    def get_child_serializable_types(cls):
        return {'text_document': TextDocumentItem}

    def __init__(self):
        self.text_document: TextDocumentItem = None


DID_CLOSE_TEXT_DOCUMENT_NOTIFICATION = IncomingMessageConfiguration(
    'textDocument/didClose', DidCloseTextDocumentParams)
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from pgsqltoolsservice.hosting import IncomingMessageConfiguration
from pgsqltoolsservice.serialization import Serializable


class GetConnectionStringParams(Serializable):
    """Parameters for Getting Connection String request"""
    def __init__(self, owner_uri: str = None):
        self.owner_uri: str = owner_uri


GET_CONNECTION_STRING_REQUEST = IncomingMessageConfiguration(
    'connection/getconnectionstring', GetConnectionStringParams)
Beispiel #29
0
    Attributes:
        version:    Version of the changed text document
        uri:        The URI that uniquely identifies the path of the text document
    """
    def __init__(self):
        self.version: int = None
        self.uri: str = None


class DidChangeTextDocumentParams(Serializable):
    """
    Parameters for a testDocument/didChange notification
    Attributes:
        content_changes:    List of changes to the document's contents
        text_document:      The document that changed
    """
    @classmethod
    def get_child_serializable_types(cls):
        return {
            'content_changes': TextDocumentChangeEvent,
            'text_document': VersionedTextDocumentIdentifier
        }

    def __init__(self):
        self.content_changes: List[TextDocumentChangeEvent] = []
        self.text_document: VersionedTextDocumentIdentifier = None


DID_CHANGE_TEXT_DOCUMENT_NOTIFICATION = IncomingMessageConfiguration(
    'textDocument/didChange', DidChangeTextDocumentParams)
Beispiel #30
0
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

"""This module holds contracts for the definition service calls"""

from pgsqltoolsservice.hosting import IncomingMessageConfiguration
from pgsqltoolsservice.serialization import Serializable
from pgsqltoolsservice.workspace.contracts import TextDocumentPosition, Position, TextDocumentIdentifier


class TextDocumentPositionParams(Serializable):
    def __init__(self, text_document: TextDocumentIdentifier, position: Position):
        self.text_document = text_document
        self.position = position


DEFINITION_REQUEST = IncomingMessageConfiguration('textDocument/definition', TextDocumentPosition)