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.help_provider import HELP_NAME |
| 26 from gslib.help_provider import HELP_NAME_ALIASES |
| 27 from gslib.help_provider import HELP_ONE_LINE_SUMMARY |
| 28 from gslib.help_provider import HELP_TEXT |
| 29 from gslib.help_provider import HelpType |
| 30 from gslib.help_provider import HELP_TYPE |
| 31 |
| 32 _detailed_help_text = (""" |
| 33 <B>SYNOPSIS</B> |
| 34 gsutil getlogging uri |
| 35 |
| 36 |
| 37 <B>DESCRIPTION</B> |
| 38 If logging is enabled for the specified bucket uri, the server responds |
| 39 with a <Logging> XML element that looks something like this: |
| 40 |
| 41 <?xml version="1.0" ?> |
| 42 <Logging> |
| 43 <LogBucket> |
| 44 logs-bucket |
| 45 </LogBucket> |
| 46 <LogObjectPrefix> |
| 47 my-logs-enabled-bucket |
| 48 </LogObjectPrefix> |
| 49 </Logging> |
| 50 |
| 51 If logging is not enabled, an empty <Logging> element is returned. |
| 52 |
| 53 You can download log data from your log bucket using the gsutil cp command. |
| 54 |
| 55 |
| 56 <B>ACCESS LOG FIELDS</B> |
| 57 Field Type Description |
| 58 time_micros integer The time that the request was completed, in |
| 59 microseconds since the Unix epoch. |
| 60 c_ip string The IP address from which the request was made. |
| 61 The "c" prefix indicates that this is information |
| 62 about the client. |
| 63 c_ip_type integer The type of IP in the c_ip field: |
| 64 A value of 1 indicates an IPV4 address. |
| 65 A value of 2 indicates an IPV6 address. |
| 66 c_ip_region string Reserved for future use. |
| 67 cs_method string The HTTP method of this request. The "cs" prefix |
| 68 indicates that this information was sent from the |
| 69 client to the server. |
| 70 cs_uri string The URI of the request. |
| 71 sc_status integer The HTTP status code the server sent in response. |
| 72 The "sc" prefix indicates that this information |
| 73 was sent from the server to the client. |
| 74 cs_bytes integer The number of bytes sent in the request. |
| 75 sc_bytes integer The number of bytes sent in the response. |
| 76 time_taken_micros integer The time it took to serve the request in |
| 77 microseconds. |
| 78 cs_host string The host in the original request. |
| 79 cs_referrer string The HTTP referrer for the request. |
| 80 cs_user_agent string The User-Agent of the request. |
| 81 s_request_id string The request identifier. |
| 82 cs_operation string The Google Cloud Storage operation e.g. |
| 83 GET_Object. |
| 84 cs_bucket string The bucket specified in the request. If this is a |
| 85 list buckets request, this can be null. |
| 86 cs_object string The object specified in this request. This can be |
| 87 null. |
| 88 |
| 89 |
| 90 <B>STORAGE DATA FIELDS</B> |
| 91 Field Type Description |
| 92 bucket string The name of the bucket. |
| 93 storage_byte_hours integer Average size in bytes/per hour of that bucket. |
| 94 """) |
| 95 |
| 96 |
| 97 class GetLoggingCommand(Command): |
| 98 """Implementation of gsutil getlogging command.""" |
| 99 |
| 100 # Command specification (processed by parent class). |
| 101 command_spec = { |
| 102 # Name of command. |
| 103 COMMAND_NAME : 'getlogging', |
| 104 # List of command name aliases. |
| 105 COMMAND_NAME_ALIASES : [], |
| 106 # Min number of args required by this command. |
| 107 MIN_ARGS : 1, |
| 108 # Max number of args required by this command, or NO_MAX. |
| 109 MAX_ARGS : 1, |
| 110 # Getopt-style string specifying acceptable sub args. |
| 111 SUPPORTED_SUB_ARGS : '', |
| 112 # True if file URIs acceptable for this command. |
| 113 FILE_URIS_OK : False, |
| 114 # True if provider-only URIs acceptable for this command. |
| 115 PROVIDER_URIS_OK : False, |
| 116 # Index in args of first URI arg. |
| 117 URIS_START_ARG : 0, |
| 118 # True if must configure gsutil before running command. |
| 119 CONFIG_REQUIRED : True, |
| 120 } |
| 121 help_spec = { |
| 122 # Name of command or auxiliary help info for which this help applies. |
| 123 HELP_NAME : 'getlogging', |
| 124 # List of help name aliases. |
| 125 HELP_NAME_ALIASES : [], |
| 126 # Type of help: |
| 127 HELP_TYPE : HelpType.COMMAND_HELP, |
| 128 # One line summary of this help. |
| 129 HELP_ONE_LINE_SUMMARY : 'Get logging configuration for a bucket', |
| 130 # The full help text. |
| 131 HELP_TEXT : _detailed_help_text, |
| 132 } |
| 133 |
| 134 # Command entry point. |
| 135 def RunCommand(self): |
| 136 self.GetXmlSubresource('logging', self.args[0]) |
| 137 return 0 |
OLD | NEW |