# Path: spanner_orm/api.py
# class SpannerRetryableApi(abc.ABC):
# class SpannerReadApi(SpannerRetryableApi):
# class SpannerWriteApi(SpannerRetryableApi):
# class SpannerConnection:
# class SpannerApi(SpannerReadApi, SpannerWriteApi):
#   def _ensure_session(self, api_method, *args, **kwargs):
#   def _connection(self) -> spanner_database.Database:
#   def run_read_only(self, method: Callable[..., CallableReturn], *args: Any,
#                     **kwargs: Any) -> CallableReturn:
#   def _run_read_only(self, method, *args, **kwargs):
#   def _connection(self) -> spanner_database.Database:
#   def run_write(self, method: Callable[..., CallableReturn], *args: Any,
#                 **kwargs: Any) -> CallableReturn:
#   def __init__(
#       self,
#       instance: str,
#       database: str,
#       project: Optional[str] = None,
#       credentials: Optional[auth_credentials.Credentials] = None,
#       pool: Optional[spanner_pool.AbstractSessionPool] = None,
#       create_ddl: Optional[Iterable[str]] = None,
#       *,
#       client_options: Union[api_client_options.ClientOptions, Dict[Any, Any],
#                             None] = None,
#   ):
#   def connect(self):
#   def __init__(self, connection: SpannerConnection):
#   def spanner_connection(self) -> SpannerConnection:
#   def _connection(self):
# def connect(
#     instance: str,
#     database: str,
#     project: Optional[str] = None,
#     credentials: Optional[auth_credentials.Credentials] = None,
#     pool: Optional[spanner_pool.AbstractSessionPool] = None) -> SpannerApi:
# def from_connection(connection: SpannerConnection) -> SpannerApi:
# def hangup() -> None:
# def spanner_api() -> SpannerApi:
# 
# Path: spanner_orm/admin/migration_executor.py
# class MigrationExecutor:
#   def __init__(self,
#                connection: api.SpannerConnection,
#                basedir: Optional[str] = None):
#   def migrated(self, migration_id: str) -> bool:
#   def migrations(self) -> List[migration.Migration]:
#   def migrate(self, target_migration: Optional[str] = None) -> None:
#   def rollback(self, target_migration: str) -> None:
#   def _connect(self) -> None:
#   def _hangup(self) -> None:
#   def _filter_migrations(
#       self, migrations: Iterable[migration.Migration], migrated: bool,
#       last_migration: Optional[str]) -> List[migration.Migration]:
#   def _migration_status(self) -> Dict[str, bool]:
#   def _update_status(self, migration_id: str, new_status: bool) -> None:
#   def _validate_migrations(self) -> None:
# 
# Path: spanner_orm/admin/migration_manager.py
# class MigrationManager:
#   DEFAULT_DIRECTORY = 'migrations'
#   def __init__(self, basedir: Optional[str] = None):
#   def generate(self, migration_name: str) -> str:
#   def migrations(self) -> List[migration.Migration]:
#   def _migration_from_file(self, filename: str) -> migration.Migration:
#   def _all_migrations(self) -> List[migration.Migration]:
#   def _order_migrations(
#       self,
#       migrations: Iterable[migration.Migration]) -> List[migration.Migration]:


import argparse
from typing import Any
from spanner_orm import api
from spanner_orm.admin import migration_executor
from spanner_orm.admin import migration_manager
#
# 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
#
#     https://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.
"""Entry point for spanner_orm scripts."""




def generate(args: Any) -> None:
  manager = migration_manager.MigrationManager(args.directory)
  manager.generate(args.name)


def migrate(args: Any) -> None:
  connection = api.SpannerConnection(args.instance, args.database)
  executor = migration_executor.MigrationExecutor(connection, args.directory)
  executor.migrate(args.name)


def rollback(args: Any) -> None:
  connection = api.SpannerConnection(args.instance, args.database)

# Path: spanner_orm/api.py
# class SpannerRetryableApi(abc.ABC):
# class SpannerReadApi(SpannerRetryableApi):
# class SpannerWriteApi(SpannerRetryableApi):
# class SpannerConnection:
# class SpannerApi(SpannerReadApi, SpannerWriteApi):
#   def _ensure_session(self, api_method, *args, **kwargs):
#   def _connection(self) -> spanner_database.Database:
#   def run_read_only(self, method: Callable[..., CallableReturn], *args: Any,
#                     **kwargs: Any) -> CallableReturn:
#   def _run_read_only(self, method, *args, **kwargs):
#   def _connection(self) -> spanner_database.Database:
#   def run_write(self, method: Callable[..., CallableReturn], *args: Any,
#                 **kwargs: Any) -> CallableReturn:
#   def __init__(
#       self,
#       instance: str,
#       database: str,
#       project: Optional[str] = None,
#       credentials: Optional[auth_credentials.Credentials] = None,
#       pool: Optional[spanner_pool.AbstractSessionPool] = None,
#       create_ddl: Optional[Iterable[str]] = None,
#       *,
#       client_options: Union[api_client_options.ClientOptions, Dict[Any, Any],
#                             None] = None,
#   ):
#   def connect(self):
#   def __init__(self, connection: SpannerConnection):
#   def spanner_connection(self) -> SpannerConnection:
#   def _connection(self):
# def connect(
#     instance: str,
#     database: str,
#     project: Optional[str] = None,
#     credentials: Optional[auth_credentials.Credentials] = None,
#     pool: Optional[spanner_pool.AbstractSessionPool] = None) -> SpannerApi:
# def from_connection(connection: SpannerConnection) -> SpannerApi:
# def hangup() -> None:
# def spanner_api() -> SpannerApi:
# 
# Path: spanner_orm/admin/migration_executor.py
# class MigrationExecutor:
#   def __init__(self,
#                connection: api.SpannerConnection,
#                basedir: Optional[str] = None):
#   def migrated(self, migration_id: str) -> bool:
#   def migrations(self) -> List[migration.Migration]:
#   def migrate(self, target_migration: Optional[str] = None) -> None:
#   def rollback(self, target_migration: str) -> None:
#   def _connect(self) -> None:
#   def _hangup(self) -> None:
#   def _filter_migrations(
#       self, migrations: Iterable[migration.Migration], migrated: bool,
#       last_migration: Optional[str]) -> List[migration.Migration]:
#   def _migration_status(self) -> Dict[str, bool]:
#   def _update_status(self, migration_id: str, new_status: bool) -> None:
#   def _validate_migrations(self) -> None:
# 
# Path: spanner_orm/admin/migration_manager.py
# class MigrationManager:
#   DEFAULT_DIRECTORY = 'migrations'
#   def __init__(self, basedir: Optional[str] = None):
#   def generate(self, migration_name: str) -> str:
#   def migrations(self) -> List[migration.Migration]:
#   def _migration_from_file(self, filename: str) -> migration.Migration:
#   def _all_migrations(self) -> List[migration.Migration]:
#   def _order_migrations(
#       self,
#       migrations: Iterable[migration.Migration]) -> List[migration.Migration]:


# Path: spanner_orm/admin/scripts.py
import argparse
from typing import Any
from spanner_orm import api
from spanner_orm.admin import migration_executor
from spanner_orm.admin import migration_manager

#
# 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
#
#     https://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.
"""Entry point for spanner_orm scripts."""




def generate(args: Any) -> None:
  manager = migration_manager.MigrationManager(args.directory)
  manager.generate(args.name)


def migrate(args: Any) -> None:
  connection = api.SpannerConnection(args.instance, args.database)
  executor = migration_executor.MigrationExecutor(connection, args.directory)
  executor.migrate(args.name)


def rollback(args: Any) -> None:
  connection = api.SpannerConnection(args.instance, args.database)

  executor = migration_executor.MigrationExecutor(connection, args.directory)