diff --git a/cli/dcoscli/analytics.py b/cli/dcoscli/analytics.py index 9285fe0..020e4a2 100644 --- a/cli/dcoscli/analytics.py +++ b/cli/dcoscli/analytics.py @@ -6,7 +6,7 @@ import uuid import dcoscli import requests import rollbar -from dcos.api import util +from dcos import util from dcoscli.constants import (ROLLBAR_SERVER_POST_KEY, SEGMENT_IO_CLI_ERROR_EVENT, SEGMENT_IO_CLI_EVENT, SEGMENT_IO_WRITE_KEY_DEV, diff --git a/cli/dcoscli/config/main.py b/cli/dcoscli/config/main.py index 419d211..05298a8 100644 --- a/cli/dcoscli/config/main.py +++ b/cli/dcoscli/config/main.py @@ -31,8 +31,8 @@ import docopt import pkg_resources import six import toml -from dcos.api import (cmds, config, constants, emitting, errors, http, - jsonitem, options, subcommand, util) +from dcos import (cmds, config, constants, emitting, errors, http, jsonitem, + options, subcommand, util) from dcoscli.analytics import segment_identify emitter = emitting.FlatEmitter() @@ -92,7 +92,7 @@ def compare_validations(toml_config_pre, toml_config_post): def _cmds(): """ :returns: all the supported commands - :rtype: list of dcos.api.cmds.Command + :rtype: list of dcos.cmds.Command """ return [ @@ -360,9 +360,9 @@ def _generate_choice_msg(name, value): :param name: name of the property :type name: str :param value: dictionary for the value - :type value: dcos.api.config.Toml + :type value: dcos.config.Toml :returns: an error message for top level properties - :rtype: dcos.api.errors.Error + :rtype: dcos.errors.Error """ message = ("Property {!r} doesn't fully specify a value - " @@ -401,7 +401,7 @@ def _get_config_schema(command): :param command: the subcommand name :type command: str :returns: the subcommand's configuration schema - :rtype: (dict, dcos.api.errors.Error) + :rtype: (dict, dcos.errors.Error) """ # core.* config variables are special. They're valid, but don't @@ -448,7 +448,7 @@ def _parse_array_item(name, value): :param value: the value to parse :type value: str :returns: the parsed value as an array with one element - :rtype: (list of any, dcos.api.errors.Error) where any is string, int, + :rtype: (list of any, dcos.errors.Error) where any is string, int, float, bool, array or dict """ diff --git a/cli/dcoscli/help/main.py b/cli/dcoscli/help/main.py index 9f7a1fc..c7e7bb9 100644 --- a/cli/dcoscli/help/main.py +++ b/cli/dcoscli/help/main.py @@ -12,7 +12,7 @@ Options: import dcoscli import docopt import futures -from dcos.api import cmds, emitting, options, subcommand, util +from dcos import cmds, emitting, options, subcommand, util emitter = emitting.FlatEmitter() logger = util.get_logger(__name__) @@ -40,7 +40,7 @@ def main(): def _cmds(): """ :returns: All of the supported commands - :rtype: list of dcos.api.cmds.Command + :rtype: list of dcos.cmds.Command """ return [ diff --git a/cli/dcoscli/main.py b/cli/dcoscli/main.py index 965ad43..979b477 100644 --- a/cli/dcoscli/main.py +++ b/cli/dcoscli/main.py @@ -37,7 +37,7 @@ from subprocess import PIPE, Popen import dcoscli import docopt -from dcos.api import auth, constants, emitting, errors, http, subcommand, util +from dcos import auth, constants, emitting, errors, http, subcommand, util from dcoscli import analytics emitter = emitting.FlatEmitter() diff --git a/cli/dcoscli/marathon/main.py b/cli/dcoscli/marathon/main.py index f2dea51..6aa27ef 100644 --- a/cli/dcoscli/marathon/main.py +++ b/cli/dcoscli/marathon/main.py @@ -60,7 +60,7 @@ import time import dcoscli import docopt import pkg_resources -from dcos.api import cmds, emitting, errors, jsonitem, marathon, options, util +from dcos import cmds, emitting, errors, jsonitem, marathon, options, util logger = util.get_logger(__name__) emitter = emitting.FlatEmitter() @@ -88,7 +88,7 @@ def main(): def _cmds(): """ :returns: all the supported commands - :rtype: dcos.api.cmds.Command + :rtype: dcos.cmds.Command """ return [ @@ -752,7 +752,7 @@ def _update_from_stdin(app_id, force): def _calculate_version(client, app_id, version): """ :param client: Marathon client - :type client: dcos.api.marathon.Client + :type client: dcos.marathon.Client :param app_id: The ID of the application :type app_id: str :param version: Relative or absolute version or None diff --git a/cli/dcoscli/package/main.py b/cli/dcoscli/package/main.py index df9a14c..c50b7dd 100644 --- a/cli/dcoscli/package/main.py +++ b/cli/dcoscli/package/main.py @@ -50,8 +50,8 @@ import json import dcoscli import docopt import pkg_resources -from dcos.api import (cmds, emitting, errors, marathon, options, package, - subcommand, util) +from dcos import (cmds, emitting, errors, marathon, options, package, + subcommand, util) logger = util.get_logger(__name__) @@ -80,7 +80,7 @@ def main(): def _cmds(): """ :returns: All of the supported commands - :rtype: dcos.api.cmds.Command + :rtype: dcos.cmds.Command """ return [ diff --git a/cli/tests/integrations/cli/test_analytics.py b/cli/tests/integrations/cli/test_analytics.py index d2ec35c..0e94d61 100644 --- a/cli/tests/integrations/cli/test_analytics.py +++ b/cli/tests/integrations/cli/test_analytics.py @@ -4,7 +4,7 @@ from functools import wraps import dcoscli.analytics import requests import rollbar -from dcos.api import constants, util +from dcos import constants, util from dcoscli.analytics import _base_properties from dcoscli.config.main import main as config_main from dcoscli.constants import (ROLLBAR_SERVER_POST_KEY, diff --git a/cli/tests/integrations/cli/test_auth.py b/cli/tests/integrations/cli/test_auth.py index 771dcab..c57969e 100644 --- a/cli/tests/integrations/cli/test_auth.py +++ b/cli/tests/integrations/cli/test_auth.py @@ -1,7 +1,7 @@ import os import webbrowser -from dcos.api import auth, constants, util +from dcos import auth, constants, util from dcoscli.main import main from mock import Mock, patch @@ -15,7 +15,7 @@ def test_no_browser_auth(): def test_when_authenticated(): - with patch('dcos.api.auth.force_auth'): + with patch('dcos.auth.force_auth'): _mock_dcos_run([util.which('dcos')], True) assert auth.force_auth.call_count == 0 diff --git a/cli/tests/integrations/cli/test_config.py b/cli/tests/integrations/cli/test_config.py index a4bc2b4..94c22ba 100644 --- a/cli/tests/integrations/cli/test_config.py +++ b/cli/tests/integrations/cli/test_config.py @@ -3,7 +3,7 @@ import os import dcoscli.constants as cli_constants import six -from dcos.api import constants +from dcos import constants import pytest from common import assert_command, exec_command diff --git a/cli/tests/integrations/cli/test_dcos.py b/cli/tests/integrations/cli/test_dcos.py index db25795..eb6b4f3 100644 --- a/cli/tests/integrations/cli/test_dcos.py +++ b/cli/tests/integrations/cli/test_dcos.py @@ -1,6 +1,6 @@ import os -from dcos.api import constants +from dcos import constants from common import assert_command, exec_command diff --git a/cli/tests/integrations/cli/test_package.py b/cli/tests/integrations/cli/test_package.py index 05d40e4..e70df0a 100644 --- a/cli/tests/integrations/cli/test_package.py +++ b/cli/tests/integrations/cli/test_package.py @@ -2,7 +2,7 @@ import json import os import six -from dcos.api import subcommand +from dcos import subcommand from common import assert_command, exec_command diff --git a/dcos/api/__init__.py b/dcos/api/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/dcos/api/auth.py b/dcos/auth.py similarity index 97% rename from dcos/api/auth.py rename to dcos/auth.py index f74dfac..5c87aba 100644 --- a/dcos/api/auth.py +++ b/dcos/auth.py @@ -4,7 +4,7 @@ import uuid import pkg_resources import toml -from dcos.api import config, constants, emitting, errors, http, jsonitem, util +from dcos import config, constants, emitting, errors, http, jsonitem, util from six import iteritems, moves from oauth2client import client @@ -23,7 +23,7 @@ def _authorize(): """Create OAuth flow and authorize user :return: Tuple of credentials dict end Error - :rtype: (dict, dcos.api.errors.Error) + :rtype: (dict, dcos.errors.Error) """ try: flow = client.OAuth2WebServerFlow( diff --git a/dcos/api/cmds.py b/dcos/cmds.py similarity index 98% rename from dcos/api/cmds.py rename to dcos/cmds.py index 2977de0..ee5f93c 100644 --- a/dcos/api/cmds.py +++ b/dcos/cmds.py @@ -1,6 +1,6 @@ import collections -from dcos.api import errors +from dcos import errors Command = collections.namedtuple( 'Command', diff --git a/dcos/api/config.py b/dcos/config.py similarity index 100% rename from dcos/api/config.py rename to dcos/config.py diff --git a/dcos/api/constants.py b/dcos/constants.py similarity index 100% rename from dcos/api/constants.py rename to dcos/constants.py diff --git a/dcos/api/emitting.py b/dcos/emitting.py similarity index 96% rename from dcos/api/emitting.py rename to dcos/emitting.py index e6c78d1..394b2cb 100644 --- a/dcos/api/emitting.py +++ b/dcos/emitting.py @@ -11,7 +11,7 @@ import sys import pager import pygments import six -from dcos.api import constants, errors, util +from dcos import constants, errors, util from pygments.formatters import Terminal256Formatter from pygments.lexers import JsonLexer @@ -67,7 +67,7 @@ def print_handler(event): """Default handler for printing event to stdout. :param event: event to emit to stdout - :type event: str, dict, list, or dcos.api.errors.Error + :type event: str, dict, list, or dcos.errors.Error """ pager_command = os.environ.get(constants.DCOS_PAGER_COMMAND_ENV) @@ -98,7 +98,7 @@ def _process_json(event, pager_command): """Conditionally highlights the supplied JSON value. :param event: event to emit to stdout - :type event: str, dict, list, or dcos.api.errors.Error + :type event: str, dict, list, or dcos.errors.Error :returns: String representation of the supplied JSON value, possibly syntax-highlighted. :rtype: str diff --git a/dcos/api/errors.py b/dcos/errors.py similarity index 100% rename from dcos/api/errors.py rename to dcos/errors.py diff --git a/dcos/api/http.py b/dcos/http.py similarity index 98% rename from dcos/api/http.py rename to dcos/http.py index 7ef0b82..7b7bbd4 100644 --- a/dcos/api/http.py +++ b/dcos/http.py @@ -1,6 +1,6 @@ import requests -from dcos.api import util -from dcos.api.errors import DefaultError, Error +from dcos import util +from dcos.errors import DefaultError, Error logger = util.get_logger(__name__) diff --git a/dcos/api/jsonitem.py b/dcos/jsonitem.py similarity index 99% rename from dcos/api/jsonitem.py rename to dcos/jsonitem.py index 1aec07d..01f9570 100644 --- a/dcos/api/jsonitem.py +++ b/dcos/jsonitem.py @@ -1,7 +1,7 @@ import collections import json -from dcos.api import errors +from dcos import errors def parse_json_item(json_item, schema): diff --git a/dcos/api/marathon.py b/dcos/marathon.py similarity index 98% rename from dcos/api/marathon.py rename to dcos/marathon.py index 26e878b..6958009 100644 --- a/dcos/api/marathon.py +++ b/dcos/marathon.py @@ -1,7 +1,7 @@ import json -from dcos.api import http, util -from dcos.api.errors import DefaultError, Error +from dcos import http, util +from dcos.errors import DefaultError, Error try: from urllib import quote @@ -17,7 +17,7 @@ def create_client(config=None): :param config: configuration dictionary :type config: config.Toml :returns: Marathon client - :rtype: dcos.api.marathon.Client + :rtype: dcos.marathon.Client """ if config is None: config = util.get_config() @@ -435,7 +435,7 @@ class Client(object): :param app_id: the id of the application to restart :type app_id: str :returns: a list of tasks - :rtype: (list of dict, dcos.api.errors.Error) + :rtype: (list of dict, dcos.errors.Error) """ url = self._create_url('v2/tasks') @@ -461,7 +461,7 @@ class Client(object): :param task_id: the id of the task :type task_id: str :returns: a tasks - :rtype: (dict, dcos.api.errors.Error) + :rtype: (dict, dcos.errors.Error) """ url = self._create_url('v2/tasks') diff --git a/dcos/api/options.py b/dcos/options.py similarity index 100% rename from dcos/api/options.py rename to dcos/options.py diff --git a/dcos/api/package.py b/dcos/package.py similarity index 99% rename from dcos/api/package.py rename to dcos/package.py index 47794fc..a21c043 100644 --- a/dcos/api/package.py +++ b/dcos/package.py @@ -14,7 +14,7 @@ import git import portalocker import pystache import six -from dcos.api import constants, emitting, errors, marathon, subcommand, util +from dcos import constants, emitting, errors, marathon, subcommand, util from six.moves import urllib @@ -452,7 +452,7 @@ def search(query, cfg): :param query: The search term :type query: str :param cfg: Configuration dictionary - :type cfg: dcos.api.config.Toml + :type cfg: dcos.config.Toml :rtype: (list of IndexEntries, Error) """ @@ -567,7 +567,7 @@ def resolve_package(package_name, config): :param package_name: The name of the package to resolve :type package_name: str :param config: Configuration dictionary - :type config: dcos.api.config.Toml + :type config: dcos.config.Toml :returns: The named package, if found :rtype: (Package, Error) """ @@ -588,7 +588,7 @@ def registries(config): """Returns configured cached package registries. :param config: Configuration dictionary - :type config: dcos.api.config.Toml + :type config: dcos.config.Toml :returns: The list of registries, in resolution order :rtype: ([Registry], Error) """ @@ -605,7 +605,7 @@ def list_sources(config): """List configured package sources. :param config: Configuration dictionary - :type config: dcos.api.config.Toml + :type config: dcos.config.Toml :returns: The list of sources, in resolution order :rtype: (list of Source, Error) """ @@ -677,7 +677,7 @@ def update_sources(config, validate=False): """Overwrites the local package cache with the latest source data. :param config: Configuration dictionary - :type config: dcos.api.config.Toml + :type config: dcos.config.Toml :returns: Error, if any. :rtype: list of Error """ @@ -783,7 +783,7 @@ class Source: """Returns the file system path to this source's local cache. :param config: Configuration dictionary - :type config: dcos.api.config.Toml + :type config: dcos.config.Toml :returns: Path to this source's local cache on disk :rtype: str or None """ @@ -1145,7 +1145,7 @@ class Package(): :param user_options: package parameters :type user_options: dict :returns: a dictionary with the user supplied options - :rtype: (dict, dcos.api.errors.Error) + :rtype: (dict, dcos.errors.Error) """ if user_options is None: diff --git a/dcos/api/subcommand.py b/dcos/subcommand.py similarity index 98% rename from dcos/api/subcommand.py rename to dcos/subcommand.py index dd54a9b..eebf6ea 100644 --- a/dcos/api/subcommand.py +++ b/dcos/subcommand.py @@ -5,7 +5,7 @@ import os import shutil import subprocess -from dcos.api import constants, errors, util +from dcos import constants, errors, util logger = util.get_logger(__name__) @@ -18,7 +18,7 @@ def command_executables(subcommand, dcos_path): :param dcos_path: path to the dcos cli directory :type dcos_path: str :returns: the dcos program path - :rtype: (str, dcos.api.errors.Error) + :rtype: (str, dcos.errors.Error) """ executables = [ @@ -235,7 +235,7 @@ def _install_env(pkg, version, options): :param options: package parameters :type options: dict :returns: an error if the subcommand failed; None otherwise - :rtype: dcos.api.errors.Error + :rtype: dcos.errors.Error """ pkg_dir = package_dir(pkg.name()) @@ -268,7 +268,7 @@ def install(pkg, version, options): :param options: package parameters :type options: dict :returns: an error if the subcommand failed; None otherwise - :rtype: dcos.api.errors.Error + :rtype: dcos.errors.Error """ pkg_dir = package_dir(pkg.name()) @@ -338,7 +338,7 @@ def install_with_pip( :param requirements: the list of pip requirements :type requirements: list of str :returns: an Error if it failed to install the package; None otherwise - :rtype: dcos.api.errors.Error + :rtype: dcos.errors.Error """ bin_directory = os.path.join(util.dcos_path(), BIN_DIRECTORY) @@ -408,7 +408,7 @@ def _generic_error(package_name): :param package: package name :type: str :returns: generic error when installing package - :rtype: dcos.api.errors.Error + :rtype: dcos.errors.Error """ return errors.DefaultError( diff --git a/dcos/api/util.py b/dcos/util.py similarity index 98% rename from dcos/api/util.py rename to dcos/util.py index 0706f81..019f97c 100644 --- a/dcos/api/util.py +++ b/dcos/util.py @@ -11,7 +11,7 @@ import tempfile import jsonschema import pystache import six -from dcos.api import config, constants, errors +from dcos import config, constants, errors @contextlib.contextmanager @@ -141,7 +141,7 @@ def configure_logger_from_environ(): :returns: An Error if we were unable to configure logging from the environment; None otherwise - :rtype: dcos.api.errors.DefaultError + :rtype: dcos.errors.DefaultError """ return configure_logger(os.environ.get(constants.DCOS_LOG_LEVEL_ENV)) @@ -153,7 +153,7 @@ def configure_logger(log_level): :param log_level: Log level for configuring logging :type log_level: str :returns: An Error if we were unable to configure logging; None otherwise - :rtype: dcos.api.errors.DefaultError + :rtype: dcos.errors.DefaultError """ if log_level is None: logging.disable(logging.CRITICAL) diff --git a/pydoc/modules.rst b/pydoc/modules.rst index 6b366b8..457ac53 100644 --- a/pydoc/modules.rst +++ b/pydoc/modules.rst @@ -1,86 +1,112 @@ API Documentation ================= -The :mod:`dcos.api.cmds` Module ---------------------------------- +The :mod:`dcos.auth` Module +--------------------------- -.. automodule:: dcos.api.cmds +.. automodule:: dcos.auth :members: :undoc-members: :show-inheritance: :inherited-members: -The :mod:`dcos.api.config` Module ---------------------------------- +The :mod:`dcos.cmds` Module +--------------------------- -.. automodule:: dcos.api.config +.. automodule:: dcos.cmds :members: :undoc-members: :show-inheritance: :inherited-members: -The :mod:`dcos.api.constants` Module ------------------------------------- +The :mod:`dcos.config` Module +----------------------------- -.. automodule:: dcos.api.constants - :members: - :undoc-members: - :show-inheritance: - -The :mod:`dcos.api.emitting` Module ------------------------------------- - -.. automodule:: dcos.api.emitting - :members: - :undoc-members: - :show-inheritance: - -The :mod:`dcos.api.errors` Module ------------------------------------- - -.. automodule:: dcos.api.errors - :members: - :undoc-members: - :show-inheritance: - -The :mod:`dcos.api.jsonitem` Module ------------------------------------- - -.. automodule:: dcos.api.jsonitem - :members: - :undoc-members: - :show-inheritance: - -The :mod:`dcos.api.marathon` Module ------------------------------------- - -.. automodule:: dcos.api.marathon +.. automodule:: dcos.config :members: :undoc-members: :show-inheritance: :inherited-members: -The :mod:`dcos.api.options` Module ------------------------------------- +The :mod:`dcos.constants` Module +-------------------------------- -.. automodule:: dcos.api.options +.. automodule:: dcos.constants :members: :undoc-members: :show-inheritance: -The :mod:`dcos.api.package` Module ------------------------------------- +The :mod:`dcos.emitting` Module +------------------------------- -.. automodule:: dcos.api.package +.. automodule:: dcos.emitting + :members: + :undoc-members: + :show-inheritance: + +The :mod:`dcos.errors` Module +----------------------------- + +.. automodule:: dcos.errors + :members: + :undoc-members: + :show-inheritance: + +The :mod:`dcos.http` Module +----------------------------- + +.. automodule:: dcos.http + :members: + :undoc-members: + :show-inheritance: + +The :mod:`dcos.jsonitem` Module +------------------------------- + +.. automodule:: dcos.jsonitem + :members: + :undoc-members: + :show-inheritance: + +The :mod:`dcos.marathon` Module +------------------------------- + +.. automodule:: dcos.marathon :members: :undoc-members: :show-inheritance: :inherited-members: -The :mod:`dcos.api.util` Module ------------------------------------- +The :mod:`dcos.options` Module +------------------------------ -.. automodule:: dcos.api.util +.. automodule:: dcos.options + :members: + :undoc-members: + :show-inheritance: + +The :mod:`dcos.package` Module +------------------------------ + +.. automodule:: dcos.package + :members: + :undoc-members: + :show-inheritance: + :inherited-members: + +The :mod:`dcos.subcommand` Module +------------------------------ + +.. automodule:: dcos.subcommand + :members: + :undoc-members: + :show-inheritance: + :inherited-members: + +The :mod:`dcos.util` Module +--------------------------- + +.. automodule:: dcos.util :members: :undoc-members: :show-inheritance: diff --git a/tests/test_cmds.py b/tests/test_cmds.py index d5c2626..ce7a0c5 100644 --- a/tests/test_cmds.py +++ b/tests/test_cmds.py @@ -1,4 +1,4 @@ -from dcos.api import cmds, errors +from dcos import cmds, errors import pytest diff --git a/tests/test_config.py b/tests/test_config.py index 9b70f60..f4c9c6e 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1,4 +1,4 @@ -from dcos.api import config +from dcos import config import pytest diff --git a/tests/test_jsonitem.py b/tests/test_jsonitem.py index 43655d6..3f22e2a 100644 --- a/tests/test_jsonitem.py +++ b/tests/test_jsonitem.py @@ -1,4 +1,4 @@ -from dcos.api import errors, jsonitem +from dcos import errors, jsonitem import pytest diff --git a/tests/test_options.py b/tests/test_options.py index d406fd8..a3ad7b3 100644 --- a/tests/test_options.py +++ b/tests/test_options.py @@ -1,4 +1,4 @@ -from dcos.api import options +from dcos import options def test_extend_usage_docopt(): diff --git a/tests/test_package.py b/tests/test_package.py index a642d83..cd53de9 100644 --- a/tests/test_package.py +++ b/tests/test_package.py @@ -1,6 +1,6 @@ import collections -from dcos.api import package +from dcos import package import pytest diff --git a/tests/test_subcommand.py b/tests/test_subcommand.py index 17ebb8e..0eec173 100644 --- a/tests/test_subcommand.py +++ b/tests/test_subcommand.py @@ -1,4 +1,4 @@ -from dcos.api import subcommand +from dcos import subcommand def test_noun(): diff --git a/tests/test_util.py b/tests/test_util.py index 2733ac0..4c0eb6b 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -1,4 +1,4 @@ -from dcos.api import util +from dcos import util def test_render_mustache_json():