コード例 #1
0
    def _assert_properties_default(self, prop):
        self.assertIsNotNone(prop)

        self._assert_logging_equal(prop.logging, Logging())
        self._assert_metrics_equal(prop.hour_metrics, Metrics())
        self._assert_metrics_equal(prop.minute_metrics, Metrics())
        self._assert_cors_equal(prop.cors, list())
コード例 #2
0
    def test_queue_service_properties(self, resource_group, location,
                                      storage_account, storage_account_key):
        # Instantiate the QueueServiceClient from a connection string
        from azure.storage.queue import QueueServiceClient
        queue_service = QueueServiceClient.from_connection_string(
            self.connection_string(storage_account, storage_account_key))

        # [START set_queue_service_properties]
        # Create service properties
        from azure.storage.queue import Logging, Metrics, CorsRule, RetentionPolicy

        # Create logging settings
        logging = Logging(read=True,
                          write=True,
                          delete=True,
                          retention_policy=RetentionPolicy(enabled=True,
                                                           days=5))

        # Create metrics for requests statistics
        hour_metrics = Metrics(enabled=True,
                               include_apis=True,
                               retention_policy=RetentionPolicy(enabled=True,
                                                                days=5))
        minute_metrics = Metrics(enabled=True,
                                 include_apis=True,
                                 retention_policy=RetentionPolicy(enabled=True,
                                                                  days=5))

        # Create CORS rules
        cors_rule1 = CorsRule(['www.xyz.com'], ['GET'])
        allowed_origins = ['www.xyz.com', "www.ab.com", "www.bc.com"]
        allowed_methods = ['GET', 'PUT']
        max_age_in_seconds = 500
        exposed_headers = [
            "x-ms-meta-data*", "x-ms-meta-source*", "x-ms-meta-abc",
            "x-ms-meta-bcd"
        ]
        allowed_headers = [
            "x-ms-meta-data*", "x-ms-meta-target*", "x-ms-meta-xyz",
            "x-ms-meta-foo"
        ]
        cors_rule2 = CorsRule(allowed_origins,
                              allowed_methods,
                              max_age_in_seconds=max_age_in_seconds,
                              exposed_headers=exposed_headers,
                              allowed_headers=allowed_headers)

        cors = [cors_rule1, cors_rule2]

        # Set the service properties
        queue_service.set_service_properties(logging, hour_metrics,
                                             minute_metrics, cors)
        # [END set_queue_service_properties]

        # [START get_queue_service_properties]
        properties = queue_service.get_service_properties()
コード例 #3
0
    def test_set_logging(self):
        # Arrange
        logging = Logging(read=True, write=True, delete=True, retention_policy=RetentionPolicy(enabled=True, days=5))

        # Act
        self.qsc.set_service_properties(logging=logging)

        # Assert
        received_props = self.qsc.get_service_properties()
        self._assert_logging_equal(received_props.logging, logging)
コード例 #4
0
    def test_set_logging(self, resource_group, location, storage_account, storage_account_key):
        # Arrange
        qsc = QueueServiceClient(self._account_url(storage_account.name), storage_account_key)
        logging = Logging(read=True, write=True, delete=True, retention_policy=RetentionPolicy(enabled=True, days=5))

        # Act
        qsc.set_service_properties(logging=logging)

        # Assert
        received_props = qsc.get_service_properties()
        self._assert_logging_equal(received_props.logging, logging)
コード例 #5
0
    def test_queue_service_properties(self):
        # Arrange

        # Act
        resp = self.qsc.set_service_properties(
            logging=Logging(),
            hour_metrics=Metrics(),
            minute_metrics=Metrics(),
            cors=list())

        # Assert
        self.assertIsNone(resp)
        self._assert_properties_default(self.qsc.get_service_properties())
コード例 #6
0
    def test_queue_service_properties(self, resource_group, location, storage_account, storage_account_key):
        # Arrange
        qsc = QueueServiceClient(self._account_url(storage_account.name), storage_account_key)
        # Act
        resp = qsc.set_service_properties(
            logging=Logging(),
            hour_metrics=Metrics(),
            minute_metrics=Metrics(),
            cors=list())

        # Assert
        self.assertIsNone(resp)
        self._assert_properties_default(qsc.get_service_properties())