Exemplo n.º 1
0
 def register_sas_arguments(self):
     from azure.cli.command_modules.storage._validators import ipv4_range_type, get_datetime_type
     self.argument(
         'ip',
         type=ipv4_range_type,
         help=
         'Specifies the IP address or range of IP addresses from which to accept requests. Supports '
         'only IPv4 style addresses.')
     self.argument(
         'expiry',
         type=get_datetime_type(True),
         help=
         'Specifies the UTC datetime (Y-m-d\'T\'H:M\'Z\') at which the SAS becomes invalid. Do not '
         'use if a stored access policy is referenced with --id that specifies this value.'
     )
     self.argument(
         'start',
         type=get_datetime_type(True),
         help=
         'Specifies the UTC datetime (Y-m-d\'T\'H:M\'Z\') at which the SAS becomes valid. Do not use '
         'if a stored access policy is referenced with --id that specifies this value. Defaults to '
         'the time of the request.')
     self.argument(
         'protocol',
         options_list=('--https-only', ),
         action='store_const',
         const='https',
         help=
         'Only permit requests made with the HTTPS protocol. If omitted, requests from both the HTTP '
         'and HTTPS protocol are permitted.')
Exemplo n.º 2
0
    def test_datetime_type(self):
        input = "2017-01-01T12:30Z"
        actual = get_datetime_type(False)(input)
        expected = datetime(2017, 1, 1, 12, 30, 0)
        self.assertEqual(actual, expected)

        input = "2017-01-01 12:30"
        with self.assertRaises(ValueError):
            actual = get_datetime_type(False)(input)
Exemplo n.º 3
0
    def test_datetime_string_type(self):
        input = "2017-01-01T12:30Z"
        actual = get_datetime_type(True)(input)
        expected = "2017-01-01T12:30Z"
        self.assertEqual(actual, expected)

        input = "2017-01-01 12:30"
        with self.assertRaises(ValueError):
            actual = get_datetime_type(True)(input)
Exemplo n.º 4
0
    def test_datetime_string_type(self):
        input = "2017-01-01T12:30Z"
        actual = get_datetime_type(True)(input)
        expected = "2017-01-01T12:30Z"
        self.assertEqual(actual, expected)

        input = "2017-01-01 12:30"
        with self.assertRaises(ValueError):
            get_datetime_type(True)(input)
    def test_datetime_type(self):
        input = "2017-01-01T12:30Z"
        actual = get_datetime_type(False)(input)
        expected = datetime(2017, 1, 1, 12, 30, 0)
        self.assertEqual(actual, expected)

        input = "2017-01-01 12:30"
        with self.assertRaises(ValueError):
            actual = get_datetime_type(False)(input)
Exemplo n.º 6
0
 def register_sas_arguments(self):
     from azure.cli.command_modules.storage._validators import ipv4_range_type, get_datetime_type
     self.argument('ip', type=ipv4_range_type,
                   help='Specifies the IP address or range of IP addresses from which to accept requests. Supports '
                        'only IPv4 style addresses.')
     self.argument('expiry', type=get_datetime_type(True),
                   help='Specifies the UTC datetime (Y-m-d\'T\'H:M\'Z\') at which the SAS becomes invalid. Do not '
                        'use if a stored access policy is referenced with --id that specifies this value.')
     self.argument('start', type=get_datetime_type(True),
                   help='Specifies the UTC datetime (Y-m-d\'T\'H:M\'Z\') at which the SAS becomes valid. Do not use '
                        'if a stored access policy is referenced with --id that specifies this value. Defaults to '
                        'the time of the request.')
     self.argument('protocol', options_list=('--https-only',), action='store_const', const='https',
                   help='Only permit requests made with the HTTPS protocol. If omitted, requests from both the HTTP '
                        'and HTTPS protocol are permitted.')
Exemplo n.º 7
0
 def register_precondition_options(self, prefix=''):
     from ._validators import (get_datetime_type)
     self.extra('{}if_modified_since'.format(prefix), arg_group='Precondition',
                help="Commence only if modified since supplied UTC datetime (Y-m-d'T'H:M'Z').",
                type=get_datetime_type(False))
     self.extra('{}if_unmodified_since'.format(prefix), arg_group='Precondition',
                help="Commence only if unmodified since supplied UTC datetime (Y-m-d'T'H:M'Z').",
                type=get_datetime_type(False))
     self.extra('{}if_match'.format(prefix), arg_group='Precondition',
                help="An ETag value, or the wildcard character (*). Specify this header to perform the "
                "operation only if the resource's ETag matches the value specified.")
     self.extra('{}if_none_match'.format(prefix), arg_group='Precondition',
                help="An ETag value, or the wildcard character (*). Specify this header to perform "
                "the operation only if the resource's ETag does not match the value specified. Specify the wildcard "
                "character (*) to perform the operation only if the resource does not exist, and fail the operation "
                "if it does exist.")
     self.extra('{}if_tags_match_condition'.format(prefix), arg_group='Precondition',
                options_list=['--{}tags-condition'.format(prefix.replace('_', '-'))],
                help='Specify a SQL where clause on blob tags to operate only on blobs with a matching value.')