Пример #1
0
 def MessageEntriesToJson(cls, cors_message):
   """Translates an apitools message to CORS JSON."""
   json_text = ''
   # Because CORS is a MessageField, serialize/deserialize as JSON list.
   json_text += '['
   printed_one = False
   for cors_entry in cors_message:
     if printed_one:
       json_text += ','
     else:
       printed_one = True
     json_text += encoding.MessageToJson(cors_entry)
   json_text += ']\n'
   return json_text
Пример #2
0
  def _GetWeb(self):
    """Gets website configuration for a bucket."""
    bucket_url, bucket_metadata = self.GetSingleBucketUrlFromArg(
        self.args[0], bucket_fields=['website'])

    if bucket_url.scheme == 's3':
      sys.stdout.write(self.gsutil_api.XmlPassThroughGetWebsite(
          bucket_url, provider=bucket_url.scheme))
    else:
      if bucket_metadata.website and (bucket_metadata.website.mainPageSuffix or
                                      bucket_metadata.website.notFoundPage):
        sys.stdout.write(str(encoding.MessageToJson(
            bucket_metadata.website)) + '\n')
      else:
        sys.stdout.write('%s has no website configuration.\n' % bucket_url)

    return 0
Пример #3
0
    def _Get(self):
        """Gets logging configuration for a bucket."""
        bucket_url, bucket_metadata = self.GetSingleBucketUrlFromArg(
            self.args[0], bucket_fields=['logging'])

        if bucket_url.scheme == 's3':
            sys.stdout.write(
                self.gsutil_api.XmlPassThroughGetLogging(
                    bucket_url, provider=bucket_url.scheme))
        else:
            if (bucket_metadata.logging and bucket_metadata.logging.logBucket
                    and bucket_metadata.logging.logObjectPrefix):
                sys.stdout.write(
                    str(encoding.MessageToJson(bucket_metadata.logging)) +
                    '\n')
            else:
                sys.stdout.write('%s has no logging configuration.\n' %
                                 bucket_url)
        return 0
Пример #4
0
 def SerializeMessage(self, message):
     return encoding.MessageToJson(message,
                                   include_fields=self.__include_fields)
Пример #5
0
 def JsonLifecycleFromMessage(cls, lifecycle_message):
   """Translates an apitools message to lifecycle JSON."""
   return str(encoding.MessageToJson(lifecycle_message)) + '\n'