| OLD | NEW |
| (Empty) |
| 1 # Copyright 2011 Google Inc. All Rights Reserved. | |
| 2 # | |
| 3 # Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 # you may not use this file except in compliance with the License. | |
| 5 # You may obtain a copy of the License at | |
| 6 # | |
| 7 # http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 # | |
| 9 # Unless required by applicable law or agreed to in writing, software | |
| 10 # distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 # See the License for the specific language governing permissions and | |
| 13 # limitations under the License. | |
| 14 | |
| 15 from gslib.command import Command | |
| 16 from gslib.command import COMMAND_NAME | |
| 17 from gslib.command import COMMAND_NAME_ALIASES | |
| 18 from gslib.command import CONFIG_REQUIRED | |
| 19 from gslib.command import FILE_URIS_OK | |
| 20 from gslib.command import MAX_ARGS | |
| 21 from gslib.command import MIN_ARGS | |
| 22 from gslib.command import PROVIDER_URIS_OK | |
| 23 from gslib.command import SUPPORTED_SUB_ARGS | |
| 24 from gslib.command import URIS_START_ARG | |
| 25 from gslib.exception import CommandException | |
| 26 from gslib.help_provider import HELP_NAME | |
| 27 from gslib.help_provider import HELP_NAME_ALIASES | |
| 28 from gslib.help_provider import HELP_ONE_LINE_SUMMARY | |
| 29 from gslib.help_provider import HELP_TEXT | |
| 30 from gslib.help_provider import HelpType | |
| 31 from gslib.help_provider import HELP_TYPE | |
| 32 from gslib.util import NO_MAX | |
| 33 | |
| 34 _detailed_help_text = (""" | |
| 35 <B>SYNOPSIS</B> | |
| 36 gsutil disablelogging uri... | |
| 37 | |
| 38 | |
| 39 <B>DESCRIPTION</B> | |
| 40 This command will disable access logging of the buckets named by the | |
| 41 specified uris. All URIs must name buckets (e.g., gs://bucket). | |
| 42 | |
| 43 No logging data is removed from the log buckets when you disable logging, | |
| 44 but Google Cloud Storage will stop delivering new logs once you have | |
| 45 run this command. | |
| 46 """) | |
| 47 | |
| 48 | |
| 49 class DisableLoggingCommand(Command): | |
| 50 """Implementation of disablelogging command.""" | |
| 51 | |
| 52 # Command specification (processed by parent class). | |
| 53 command_spec = { | |
| 54 # Name of command. | |
| 55 COMMAND_NAME : 'disablelogging', | |
| 56 # List of command name aliases. | |
| 57 COMMAND_NAME_ALIASES : [], | |
| 58 # Min number of args required by this command. | |
| 59 MIN_ARGS : 1, | |
| 60 # Max number of args required by this command, or NO_MAX. | |
| 61 MAX_ARGS : NO_MAX, | |
| 62 # Getopt-style string specifying acceptable sub args. | |
| 63 SUPPORTED_SUB_ARGS : '', | |
| 64 # True if file URIs acceptable for this command. | |
| 65 FILE_URIS_OK : False, | |
| 66 # True if provider-only URIs acceptable for this command. | |
| 67 PROVIDER_URIS_OK : False, | |
| 68 # Index in args of first URI arg. | |
| 69 URIS_START_ARG : 0, | |
| 70 # True if must configure gsutil before running command. | |
| 71 CONFIG_REQUIRED : True, | |
| 72 } | |
| 73 help_spec = { | |
| 74 # Name of command or auxiliary help info for which this help applies. | |
| 75 HELP_NAME : 'disablelogging', | |
| 76 # List of help name aliases. | |
| 77 HELP_NAME_ALIASES : [], | |
| 78 # Type of help: | |
| 79 HELP_TYPE : HelpType.COMMAND_HELP, | |
| 80 # One line summary of this help. | |
| 81 HELP_ONE_LINE_SUMMARY : 'Disable logging on buckets', | |
| 82 # The full help text. | |
| 83 HELP_TEXT : _detailed_help_text, | |
| 84 } | |
| 85 | |
| 86 # Command entry point. | |
| 87 def RunCommand(self): | |
| 88 did_some_work = False | |
| 89 for uri_str in self.args: | |
| 90 for uri in self.WildcardIterator(uri_str).IterUris(): | |
| 91 if uri.names_object(): | |
| 92 raise CommandException('disablelogging cannot be applied to objects') | |
| 93 did_some_work = True | |
| 94 print 'Disabling logging on %s...' % uri | |
| 95 self.proj_id_handler.FillInProjectHeaderIfNeeded('disablelogging', | |
| 96 uri, self.headers) | |
| 97 uri.disable_logging(False, self.headers) | |
| 98 if not did_some_work: | |
| 99 raise CommandException('No URIs matched') | |
| 100 | |
| 101 return 0 | |
| OLD | NEW |