コード例 #1
0
class BackupRun(_messages.Message):
    """A database instance backup run resource.

  Fields:
    backupConfiguration: Backup Configuration identifier.
    dueTime: The due time of this run in UTC timezone in RFC 3339 format, for
      example 2012-11-15T16:19:00.094Z.
    endTime: The time the backup operation completed in UTC timezone in RFC
      3339 format, for example 2012-11-15T16:19:00.094Z.
    enqueuedTime: The time the run was enqueued in UTC timezone in RFC 3339
      format, for example 2012-11-15T16:19:00.094Z.
    error: Information about why the backup operation failed. This is only
      present if the run has the FAILED status.
    instance: Name of the database instance.
    kind: This is always sql#backupRun.
    startTime: The time the backup operation actually started in UTC timezone
      in RFC 3339 format, for example 2012-11-15T16:19:00.094Z.
    status: The status of this run.
  """

    backupConfiguration = _messages.StringField(1)
    dueTime = _message_types.DateTimeField(2)
    endTime = _message_types.DateTimeField(3)
    enqueuedTime = _message_types.DateTimeField(4)
    error = _messages.MessageField('OperationError', 5)
    instance = _messages.StringField(6)
    kind = _messages.StringField(7, default=u'sql#backupRun')
    startTime = _message_types.DateTimeField(8)
    status = _messages.StringField(9)
コード例 #2
0
class MyMessage(messages.Message):
    """Test message containing various types."""

    class Color(messages.Enum):

        RED = 1
        GREEN = 2
        BLUE = 3

    class Nested(messages.Message):

        nested_value = messages.StringField(1)

    a_string = messages.StringField(2)
    an_integer = messages.IntegerField(3)
    a_float = messages.FloatField(4)
    a_boolean = messages.BooleanField(5)
    an_enum = messages.EnumField(Color, 6)
    a_nested = messages.MessageField(Nested, 7)
    a_repeated = messages.IntegerField(8, repeated=True)
    a_repeated_float = messages.FloatField(9, repeated=True)
    a_datetime = message_types.DateTimeField(10)
    a_repeated_datetime = message_types.DateTimeField(11, repeated=True)
    a_custom = CustomField(12)
    a_repeated_custom = CustomField(13, repeated=True)
コード例 #3
0
 def testValueToMessageWithTimeZone(self):
     time_zone = util.TimeZoneOffset(60 * 10)
     field = message_types.DateTimeField(1)
     message = field.value_to_message(
         datetime.datetime(2033, 2, 4, 11, 22, 10, tzinfo=time_zone))
     self.assertEqual(
         message_types.DateTimeMessage(milliseconds=1991128930000,
                                       time_zone_offset=600), message)
コード例 #4
0
 def testValueFromMessageWithTimeZone(self):
     message = message_types.DateTimeMessage(milliseconds=1991128000000,
                                             time_zone_offset=300)
     field = message_types.DateTimeField(1)
     timestamp = field.value_from_message(message)
     time_zone = util.TimeZoneOffset(60 * 5)
     self.assertEqual(
         datetime.datetime(2033, 2, 4, 11, 6, 40, tzinfo=time_zone),
         timestamp)
コード例 #5
0
class InstanceOperation(_messages.Message):
    """An Operations resource contains information about database instance
  operations such as create, delete, and restart. Operations resources are
  created in response to operations that were initiated; you never create them
  directly.

  Fields:
    endTime: The time this operation finished in UTC timezone in RFC 3339
      format, for example 2012-11-15T16:19:00.094Z.
    enqueuedTime: The time this operation was enqueued in UTC timezone in RFC
      3339 format, for example 2012-11-15T16:19:00.094Z.
    error: The error(s) encountered by this operation. Only set if the
      operation results in an error.
    exportContext: The context for export operation, if applicable.
    importContext: The context for import operation, if applicable.
    instance: Name of the database instance.
    kind: This is always sql#instanceOperation.
    operation: An identifier that uniquely identifies the operation. You can
      use this identifier to retrieve the Operations resource that has
      information about the operation.
    operationType: The type of the operation. Valid values are CREATE, DELETE,
      UPDATE, RESTART, IMPORT, EXPORT, BACKUP_VOLUME, RESTORE_VOLUME.
    startTime: The time this operation actually started in UTC timezone in RFC
      3339 format, for example 2012-11-15T16:19:00.094Z.
    state: The state of an operation. Valid values are PENDING, RUNNING, DONE,
      UNKNOWN.
    userEmailAddress: The email address of the user who initiated this
      operation.
  """

    endTime = _message_types.DateTimeField(1)
    enqueuedTime = _message_types.DateTimeField(2)
    error = _messages.MessageField('OperationError', 3, repeated=True)
    exportContext = _messages.MessageField('ExportContext', 4)
    importContext = _messages.MessageField('ImportContext', 5)
    instance = _messages.StringField(6)
    kind = _messages.StringField(7, default=u'sql#instanceOperation')
    operation = _messages.StringField(8)
    operationType = _messages.StringField(9)
    startTime = _message_types.DateTimeField(10)
    state = _messages.StringField(11)
    userEmailAddress = _messages.StringField(12)
コード例 #6
0
class IpMapping(_messages.Message):
    """Database instance IP Mapping.

  Fields:
    ipAddress: The IP address assigned.
    timeToRetire: The due time for this IP to be retired in RFC 3339 format,
      for example 2012-11-15T16:19:00.094Z. This field is only available when
      the IP is scheduled to be retired.
  """

    ipAddress = _messages.StringField(1)
    timeToRetire = _message_types.DateTimeField(2)
コード例 #7
0
class SslCert(_messages.Message):
    """SslCerts Resource

  Fields:
    cert: PEM representation.
    certSerialNumber: Serial number, as extracted from the certificate.
    commonName: User supplied name. Constrained to [a-zA-Z.-_ ]+.
    createTime: Time when the certificate was created.
    expirationTime: Time when the certificate expires.
    instance: Name of the database instance.
    kind: This is always sql#sslCert.
    sha1Fingerprint: Sha1 Fingerprint.
  """

    cert = _messages.StringField(1)
    certSerialNumber = _messages.StringField(2)
    commonName = _messages.StringField(3)
    createTime = _message_types.DateTimeField(4)
    expirationTime = _message_types.DateTimeField(5)
    instance = _messages.StringField(6)
    kind = _messages.StringField(7, default=u'sql#sslCert')
    sha1Fingerprint = _messages.StringField(8)
コード例 #8
0
    def testDateTimeField(self):
        field = message_types.DateTimeField(20)
        field.name = 'a_timestamp'

        expected = descriptor.FieldDescriptor()
        expected.name = 'a_timestamp'
        expected.number = 20
        expected.label = descriptor.FieldDescriptor.Label.OPTIONAL
        expected.variant = messages.MessageField.DEFAULT_VARIANT
        expected.type_name = (
            'apitools.base.protorpclite.message_types.DateTimeMessage')

        described = descriptor.describe_field(field)
        described.check_initialized()
        self.assertEquals(expected, described)
コード例 #9
0
 def testValueToMessage(self):
     field = message_types.DateTimeField(1)
     message = field.value_to_message(
         datetime.datetime(2033, 2, 4, 11, 22, 10))
     self.assertEqual(
         message_types.DateTimeMessage(milliseconds=1991128930000), message)
コード例 #10
0
 def testValueFromMessageBadValue(self):
     field = message_types.DateTimeField(1)
     self.assertRaisesWithRegexpMatch(
         messages.DecodeError,
         'Expected type DateTimeMessage, got VoidMessage: <VoidMessage>',
         field.value_from_message, message_types.VoidMessage())
コード例 #11
0
 def testValueFromMessage(self):
     message = message_types.DateTimeMessage(milliseconds=1991128000000)
     field = message_types.DateTimeField(1)
     timestamp = field.value_from_message(message)
     self.assertEqual(datetime.datetime(2033, 2, 4, 11, 6, 40), timestamp)
コード例 #12
0
class MessageWithTime(messages.Message):
    timestamp = message_types.DateTimeField(1)
コード例 #13
0
 class AdditionalProperty(messages.Message):
     key = messages.StringField(1)
     value = message_types.DateTimeField(2)
コード例 #14
0
class TimeMessage(messages.Message):
    timefield = message_types.DateTimeField(3)
コード例 #15
0
ファイル: test_util.py プロジェクト: j3ffml/apitools
 class MyMessage(messages.Message):
     value = message_types.DateTimeField(1)
コード例 #16
0
def _DecodeDateTimeField(unused_field, value):
    result = protojson.ProtoJson().decode_field(message_types.DateTimeField(1),
                                                value)
    return encoding.CodecResult(value=result, complete=True)
コード例 #17
0
 def testValueToMessageBadValue(self):
     field = message_types.DateTimeField(1)
     self.assertRaisesWithRegexpMatch(
         messages.EncodeError, 'Expected type datetime, got int: 20',
         field.value_to_message, 20)
コード例 #18
0
    class NestedDatetime(messages.Message):

        nested_dt_value = message_types.DateTimeField(1)