Esempio n. 1
0
             _UPDATE_SYNOPSIS.lstrip('\n') + '\n\n')

_DESCRIPTION = """
  The hmac command is used to interact with service account `HMAC keys
  <https://cloud.google.com/storage/docs/authentication/hmackeys>`_.

  The hmac command has five sub-commands:
""" + '\n'.join([
    _CREATE_DESCRIPTION,
    _DELETE_DESCRIPTION,
    _GET_DESCRIPTION,
    _LIST_DESCRIPTION,
    _UPDATE_DESCRIPTION,
])

_DETAILED_HELP_TEXT = CreateHelpText(_SYNOPSIS, _DESCRIPTION)

_VALID_UPDATE_STATES = ['INACTIVE', 'ACTIVE']
_TIME_FORMAT = '%a, %d %b %Y %H:%M:%S GMT'

_create_help_text = CreateHelpText(_CREATE_SYNOPSIS, _CREATE_DESCRIPTION)
_delete_help_text = CreateHelpText(_DELETE_SYNOPSIS, _DELETE_DESCRIPTION)
_get_help_text = CreateHelpText(_GET_SYNOPSIS, _GET_DESCRIPTION)
_list_help_text = CreateHelpText(_LIST_SYNOPSIS, _LIST_DESCRIPTION)
_update_help_text = CreateHelpText(_UPDATE_SYNOPSIS, _UPDATE_DESCRIPTION)


def _AccessIdException(command_name, subcommand, synopsis):
    return CommandException(
        '%s %s requires an Access ID to be specified as the last argument.\n%s'
        % (command_name, subcommand, synopsis))
Esempio n. 2
0
  CSV files that you can download and view. Access logs provide information
  for all of the requests made on a specified bucket in the last 24 hours,
  while the storage logs provide information about the storage consumption of
  that bucket for the last 24 hour period. The logs and storage data files
  are automatically created as new objects in a bucket that you specify, in
  24 hour intervals.

  The logging command has two sub-commands:
""" + _SET_DESCRIPTION + _GET_DESCRIPTION + """

<B>ACCESS LOG AND STORAGE DATA FIELDS</B>
  For a complete list of access log fields and storage data fields, see:
  https://developers.google.com/storage/docs/accesslogs#reviewing
"""

_detailed_help_text = CreateHelpText(_SYNOPSIS, _DESCRIPTION)

_get_help_text = CreateHelpText(_GET_SYNOPSIS, _GET_DESCRIPTION)
_set_help_text = CreateHelpText(_SET_SYNOPSIS, _SET_DESCRIPTION)


class LoggingCommand(Command):
    """Implementation of gsutil logging command."""

    # Command specification (processed by parent class).
    command_spec = {
        # Name of command.
        COMMAND_NAME: 'logging',
        # List of command name aliases.
        COMMAND_NAME_ALIASES:
        ['disablelogging', 'enablelogging', 'getlogging'],
Esempio n. 3
0
"""

_DESCRIPTION = """
  The kms command is used to configure Google Cloud Storage and Cloud KMS
  resources to support encryption of Cloud Storage objects with
  `Cloud KMS keys
  <https://cloud.google.com/storage/docs/encryption/customer-managed-keys>`_.

  The kms command has three sub-commands that deal with configuring Cloud
  Storage's integration with Cloud KMS: ``authorize``, ``encryption``,
  and ``serviceaccount``.
""" + (_AUTHORIZE_DESCRIPTION + _ENCRYPTION_DESCRIPTION +
       _SERVICEACCOUNT_DESCRIPTION)

_DETAILED_HELP_TEXT = CreateHelpText(_SYNOPSIS, _DESCRIPTION)

_authorize_help_text = CreateHelpText(_AUTHORIZE_SYNOPSIS,
                                      _AUTHORIZE_DESCRIPTION)
_encryption_help_text = CreateHelpText(_ENCRYPTION_SYNOPSIS,
                                       _ENCRYPTION_DESCRIPTION)
_serviceaccount_help_text = CreateHelpText(_SERVICEACCOUNT_SYNOPSIS,
                                           _SERVICEACCOUNT_DESCRIPTION)


class KmsCommand(Command):
  """Implements of gsutil kms command."""

  command_spec = Command.CreateCommandSpec(
      'kms',
      usage_synopsis=_SYNOPSIS,
Esempio n. 4
0
  {watch_error}

You attempted to watch a bucket with an application URL of:

  {watch_url}

which is not authorized for your project. Please ensure that you are using
Service Account authentication and that the Service Account's project is
authorized for the application URL. Notification endpoint URLs must also be
whitelisted in your Cloud Console project. To do that, the domain must also be
verified using Google Webmaster Tools. For instructions, please see
`Notification Authorization
<https://cloud.google.com/storage/docs/object-change-notification#_Authorization>`_.
"""

_DETAILED_HELP_TEXT = CreateHelpText(_SYNOPSIS, _DESCRIPTION)

# yapf: disable
_create_help_text = (
    CreateHelpText(_CREATE_SYNOPSIS, _CREATE_DESCRIPTION))
_list_help_text = (
    CreateHelpText(_LIST_SYNOPSIS, _LIST_DESCRIPTION))
_delete_help_text = (
    CreateHelpText(_DELETE_SYNOPSIS, _DELETE_DESCRIPTION))
_watchbucket_help_text = (
    CreateHelpText(_WATCHBUCKET_SYNOPSIS, _WATCHBUCKET_DESCRIPTION))
_stopchannel_help_text = (
    CreateHelpText(_STOPCHANNEL_SYNOPSIS, _STOPCHANNEL_DESCRIPTION))
# yapf: enable

PAYLOAD_FORMAT_MAP = {
Esempio n. 5
0
     http://www.example.com/index.html, and a GET request for
     http://www.example.com/photos would retrieve
     http://www.example.com/photos/index.html.

  3. There is just one 404.html page: For example, a GET request for
     http://www.example.com/photos/missing would retrieve
     http://www.example.com/404.html, not
     http://www.example.com/photos/404.html.

  4. For additional details see
     https://cloud.google.com/storage/docs/website-configuration.

  The web command has two sub-commands:
""" + _SET_DESCRIPTION + _GET_DESCRIPTION

_DETAILED_HELP_TEXT = CreateHelpText(_SYNOPSIS, _DESCRIPTION)

_get_help_text = CreateHelpText(_GET_SYNOPSIS, _GET_DESCRIPTION)
_set_help_text = CreateHelpText(_SET_SYNOPSIS, _SET_DESCRIPTION)


class WebCommand(Command):
    """Implementation of gsutil web command."""

    # Command specification. See base class for documentation.
    command_spec = Command.CreateCommandSpec(
        'web',
        command_name_aliases=['setwebcfg', 'getwebcfg'],
        usage_synopsis=_SYNOPSIS,
        min_args=2,
        max_args=NO_MAX,
Esempio n. 6
0
  {watch_error}

You attempted to watch a bucket with an application URL of:

  {watch_url}

which is not authorized for your project. Please ensure that you are using
Service Account authentication and that the Service Account's project is
authorized for the application URL. Notification endpoint URLs must also be
whitelisted in your Cloud Console project. To do that, the domain must also be
verified using Google Webmaster Tools. For instructions, please see:

  https://cloud.google.com/storage/docs/object-change-notification#_Authorization
"""

_DETAILED_HELP_TEXT = CreateHelpText(_SYNOPSIS, _DESCRIPTION)

_create_help_text = (CreateHelpText(_CREATE_SYNOPSIS, _CREATE_DESCRIPTION))
_list_help_text = (CreateHelpText(_LIST_SYNOPSIS, _LIST_DESCRIPTION))
_delete_help_text = (CreateHelpText(_DELETE_SYNOPSIS, _DELETE_DESCRIPTION))
_watchbucket_help_text = (CreateHelpText(_WATCHBUCKET_SYNOPSIS,
                                         _WATCHBUCKET_DESCRIPTION))
_stopchannel_help_text = (CreateHelpText(_STOPCHANNEL_SYNOPSIS,
                                         _STOPCHANNEL_DESCRIPTION))

PAYLOAD_FORMAT_MAP = {'none': 'NONE', 'json': 'JSON_API_V1'}


class NotificationCommand(Command):
    """Implementation of gsutil notification command."""
Esempio n. 7
0
  If you want to set or release a temporary hold on a large number of objects, then
  you might want to use the top-level '-m' option to perform a parallel update.
  For example, the following command sets a temporary hold on objects ending
  with .jpg in parallel, in the root folder:

    gsutil -m retention temp set gs://bucket/*.jpg
"""

_SYNOPSIS = (_SET_SYNOPSIS + _CLEAR_SYNOPSIS + _GET_SYNOPSIS + _LOCK_SYNOPSIS +
             _EVENT_DEFAULT_SYNOPSIS + _EVENT_SYNOPSIS + _TEMP_SYNOPSIS)

_DESCRIPTION = (_SET_DESCRIPTION + _CLEAR_DESCRIPTION + _GET_DESCRIPTION +
                _LOCK_DESCRIPTION + _EVENT_DEFAULT_DESCRIPTION +
                _EVENT_DESCRIPTION + _TEMP_DESCRIPTION)

_DETAILED_HELP_TEXT = CreateHelpText(_SYNOPSIS, _DESCRIPTION)

_set_help_text = CreateHelpText(_SET_SYNOPSIS, _SET_DESCRIPTION)
_clear_help_text = CreateHelpText(_CLEAR_SYNOPSIS, _CLEAR_DESCRIPTION)
_get_help_text = CreateHelpText(_GET_SYNOPSIS, _GET_DESCRIPTION)
_lock_help_text = CreateHelpText(_LOCK_SYNOPSIS, _LOCK_DESCRIPTION)
_event_default_help_text = CreateHelpText(_EVENT_DEFAULT_SYNOPSIS,
                                          _EVENT_DEFAULT_DESCRIPTION)
_event_help_text = CreateHelpText(_EVENT_SYNOPSIS, _EVENT_DESCRIPTION)
_temp_help_text = CreateHelpText(_TEMP_SYNOPSIS, _TEMP_DESCRIPTION)


class RetentionCommand(Command):
  """Implementation of gsutil retention command."""

  # Command specification. See base class for documentation.
Esempio n. 8
0
  {watch_error}

You attempted to watch a bucket with an application URL of:

  {watch_url}

which is not authorized for your project. Please ensure that you are using
Service Account authentication and that the Service Account's project is
authorized for the application URL. Notification endpoint URLs must also be
whitelisted in your Cloud Console project. To do that, the domain must also be
verified using Google Webmain Tools. For instructions, please see:

  https://cloud.google.com/storage/docs/object-change-notification#_Authorization
"""

_DETAILED_HELP_TEXT = CreateHelpText(_SYNOPSIS, _DESCRIPTION)

_watchbucket_help_text = (CreateHelpText(_WATCHBUCKET_SYNOPSIS,
                                         _WATCHBUCKET_DESCRIPTION))
_stopchannel_help_text = (CreateHelpText(_STOPCHANNEL_SYNOPSIS,
                                         _STOPCHANNEL_DESCRIPTION))


class NotificationCommand(Command):
    """Implementation of gsutil notification command."""

    # Command specification. See base class for documentation.
    command_spec = Command.CreateCommandSpec(
        'notification',
        command_name_aliases=[
            'notify', 'notifyconfig', 'notifications', 'notif'
Esempio n. 9
0
    -R, -r      Performs "iam ch" recursively to all objects under the
                specified bucket.

    -f          Default gsutil error handling is fail-fast. This flag
                changes the request to fail-silent mode. This is implicitly
                set when invoking the gsutil -m option.
"""

_SYNOPSIS = (_ALPHA_DISCLAIMER + '\n' + _SET_SYNOPSIS.lstrip('\n') +
             _GET_SYNOPSIS.lstrip('\n') + _CH_SYNOPSIS.lstrip('\n') + '\n\n')

_DESCRIPTION = ("""
  The iam command has three sub-commands:
""" + '\n'.join([_GET_DESCRIPTION, _SET_DESCRIPTION, _CH_DESCRIPTION]))

_DETAILED_HELP_TEXT = CreateHelpText(_SYNOPSIS, _DESCRIPTION)

_get_help_text = CreateHelpText(_ALPHA_DISCLAIMER + _GET_SYNOPSIS,
                                _GET_DESCRIPTION)
_set_help_text = CreateHelpText(_ALPHA_DISCLAIMER + _SET_SYNOPSIS,
                                _SET_DESCRIPTION)
_ch_help_text = CreateHelpText(_ALPHA_DISCLAIMER + _CH_SYNOPSIS,
                               _CH_DESCRIPTION)


def _PatchIamWrapper(cls, iter_result, thread_state):
    (serialized_bindings_tuples, expansion_result) = iter_result
    return cls.PatchIamHelper(
        expansion_result.expanded_storage_url,
        # Deserialize the JSON object passed from Command.Apply.
        [DeserializeBindingsTuple(t) for t in serialized_bindings_tuples],
Esempio n. 10
0
NOTIFICATION_AUTHORIZATION_FAILED_MESSAGE = """
Watch bucket attempt failed:
  {watch_error}

You attempted to watch a bucket with an application URL of:

  {watch_uri}

which is not authorized for your project. Notification endpoint URLs must be
whitelisted in your Cloud Console project. To do that, the domain must also be
verified using Google Webmaster Tools. For instructions, please see:

  https://developers.google.com/storage/docs/object-change-notification#_Authorization
"""

_detailed_help_text = CreateHelpText(_SYNOPSIS, _DESCRIPTION)

_watchbucket_help_text = (CreateHelpText(_WATCHBUCKET_SYNOPSIS,
                                         _WATCHBUCKET_DESCRIPTION))
_stopchannel_help_text = (CreateHelpText(_STOPCHANNEL_SYNOPSIS,
                                         _STOPCHANNEL_DESCRIPTION))

DISCOVERY_SERVICE_URL = boto.config.get_value('GSUtil',
                                              'discovery_service_url', None)
JSON_API_VERSION = boto.config.get_value('GSUtil', 'json_api_version',
                                         'v1beta2')


class NotificationCommand(Command):
    """Implementation of gsutil notification command."""