Beispiel #1
0
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from ossdbtoolsservice.hosting import IncomingMessageConfiguration
from ossdbtoolsservice.workspace.contracts.common import TextDocumentItem
from ossdbtoolsservice.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 typing import List

from ossdbtoolsservice.hosting import IncomingMessageConfiguration
from ossdbtoolsservice.serialization import Serializable
from ossdbtoolsservice.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 #3
0
            '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 #4
0
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

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


class DidOpenTextDocumentParams(Serializable):
    """
    Parameters for a textDocument/didOpen notification
    Attributes:
        text_document:  The document that was opened
    """
    @classmethod
    def get_child_serializable_types(cls):
        return {'text_document': TextDocumentItem}

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


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

from ossdbtoolsservice.connection.contracts.common import ConnectionType
from ossdbtoolsservice.hosting import IncomingMessageConfiguration
from ossdbtoolsservice.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)
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from ossdbtoolsservice.connection.contracts.common import ConnectionType
from ossdbtoolsservice.hosting import IncomingMessageConfiguration
from ossdbtoolsservice.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)
Beispiel #7
0
        self.table: str = None
        self.trigger: str = None
        self.no_privileges: bool = None
        self.single_transaction: bool = None
        self.disable_triggers: bool = None
        self.enable_row_security: bool = None
        self.if_exists: bool = None
        self.no_data_for_failed_tables: bool = None
        self.no_security_labels: bool = None
        self.no_tablespaces: bool = None
        self.section: str = None
        self.strict_names: bool = None
        self.role: str = None


RESTORE_REQUEST = IncomingMessageConfiguration('restore/restore', RestoreParams)

# These options are handled in the disaster recovery service's _perform_restore method. The path has special case handling, but most are handled automatically
# by using the option's name as the flag name, and the setting as the value. The RestoreOptions contract above has a field corresponding to each option.
# TODO: Localize the display names and descriptions
RESTORE_OPTIONS = FeatureMetadataProvider(
    True,
    'Restore',
    [
        ServiceOption(
            name='path',
            display_name='Backup path',
            description='The path to the backup file/directory to be used for restore',
            value_type=ServiceOption.VALUE_TYPE_STRING,
            is_required=True
        ),
Beispiel #8
0
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

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


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


class DisposeResponse:
    def __init__(self):
        pass


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

from ossdbtoolsservice.hosting import IncomingMessageConfiguration
from ossdbtoolsservice.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)
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

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


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


class EditCommitResponse:
    def __init__(self):
        pass


EDIT_COMMIT_REQUEST = IncomingMessageConfiguration('edit/commit',
                                                   EditCommitRequest)
# --------------------------------------------------------------------------------------------

from ossdbtoolsservice.hosting import IncomingMessageConfiguration
from ossdbtoolsservice.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 ossdbtoolsservice.hosting import IncomingMessageConfiguration
from ossdbtoolsservice.object_explorer.contracts.expand_request import ExpandParameters

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

from ossdbtoolsservice.hosting import IncomingMessageConfiguration
from ossdbtoolsservice.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)
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 ossdbtoolsservice.hosting import IncomingMessageConfiguration
from ossdbtoolsservice.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)
Beispiel #15
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)
    def get_child_serializable_types(cls):
        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__()
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------


from ossdbtoolsservice.hosting import IncomingMessageConfiguration
from ossdbtoolsservice.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)
# --------------------------------------------------------------------------------------------
# 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 ossdbtoolsservice.hosting import IncomingMessageConfiguration
from ossdbtoolsservice.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 #19
0
        self.section: str = None
        self.serializable_deferrable: bool = None
        self.snapshot: str = None
        self.strict_names: bool = None
        self.use_set_session_authorization: bool = None


class BackupType(enum.Enum):
    """Enum for the type of backups that are supported"""
    PG_DUMP = 'dump'
    DIRECTORY = 'directory'
    TAR = 'tar'
    PLAIN_TEXT = 'sql'


BACKUP_REQUEST = IncomingMessageConfiguration('backup/backup', BackupParams)


# These options are handled in the disaster recovery service's _perform_backup method. A few have special case handling, but most are handled automatically by
# using the option's name as the flag name, and the setting as the value. The BackupInfo contract above has a field corresponding to each option.
# TODO: Localize the display names and descriptions
BACKUP_OPTIONS = FeatureMetadataProvider(
    True,
    'backup',
    [
        ServiceOption(
            name='type',
            display_name='Backup type',
            description='The type of backup to perform',
            value_type=ServiceOption.VALUE_TYPE_CATEGORY,
            is_required=True,
Beispiel #20
0
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from ossdbtoolsservice.hosting import IncomingMessageConfiguration
from ossdbtoolsservice.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 #21
0
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from ossdbtoolsservice.hosting import IncomingMessageConfiguration
from ossdbtoolsservice.connection.contracts import ConnectionDetails
from ossdbtoolsservice.serialization import Serializable


class CreateSessionResponse(Serializable):
    def __init__(self, session_id):
        self.session_id: str = session_id


CREATE_SESSION_REQUEST = IncomingMessageConfiguration(
    'objectexplorer/createsession', ConnectionDetails)
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 ossdbtoolsservice.hosting import IncomingMessageConfiguration
import ossdbtoolsservice.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 ossdbtoolsservice.hosting import IncomingMessageConfiguration
from ossdbtoolsservice.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)
Beispiel #24
0
    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)
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from ossdbtoolsservice.hosting import IncomingMessageConfiguration
from ossdbtoolsservice.serialization import Serializable


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


DISCONNECT_REQUEST = IncomingMessageConfiguration('connection/disconnect',
                                                  DisconnectRequestParams)
Beispiel #26
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 connection/listdatabases method"""

from typing import List  # noqa

from ossdbtoolsservice.hosting import IncomingMessageConfiguration
from ossdbtoolsservice.serialization import Serializable


class ListDatabasesParams(Serializable):
    """Parameters for the connection/listdatabases request"""
    def __init__(self):
        self.owner_uri: str = None


class ListDatabasesResponse:
    """Response for the connection/listdatabases request"""
    def __init__(self, database_names):
        self.database_names: List[str] = database_names


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

from ossdbtoolsservice.hosting import IncomingMessageConfiguration
from ossdbtoolsservice.metadata.contracts.object_metadata import ObjectMetadata  # noqa
from typing import List  # noqa
from ossdbtoolsservice.serialization import Serializable


class MetadataListParameters(Serializable):

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


class MetadataListResponse:
    def __init__(self, metadata: List[ObjectMetadata]):
        self.metadata: List[ObjectMetadata] = metadata


METADATA_LIST_REQUEST = IncomingMessageConfiguration('metadata/list', MetadataListParameters)
from ossdbtoolsservice.serialization import Serializable
from ossdbtoolsservice.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)
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from ossdbtoolsservice.hosting import IncomingMessageConfiguration
from ossdbtoolsservice.connection.contracts.common import ConnectionDetails, ConnectionType  # noqa
from ossdbtoolsservice.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)
    """
    @classmethod
    def get_child_serializable_types(cls):
        return {'sql': SQLConfiguration, 'pgsql': PGSQLConfiguration, 'my_sql': MySQLConfiguration}

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

    def get_configuration(self, provider):
        return {'MySQL': self.my_sql, 'PGSQL': self.pgsql}[provider]


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
)