def set_service_properties(self, account):

        # Create an page blob service object
        blockblob_service = account.create_block_blob_service()

        print('1. Get Blob service properties')
        props = blockblob_service.get_blob_service_properties()

        retention = RetentionPolicy(enabled=True, days=5)
        logging = Logging(delete=True,
                          read=False,
                          write=True,
                          retention_policy=retention)
        hour_metrics = Metrics(enabled=True,
                               include_apis=True,
                               retention_policy=retention)
        minute_metrics = Metrics(enabled=False)

        try:
            print('2. Ovewrite Blob service properties')
            blockblob_service.set_blob_service_properties(
                logging=logging,
                hour_metrics=hour_metrics,
                minute_metrics=minute_metrics,
                target_version='2015-04-05')
        finally:
            print(
                '3. Revert Blob service properties back to the original ones')
            blockblob_service.set_blob_service_properties(
                logging=props.logging,
                hour_metrics=props.hour_metrics,
                minute_metrics=props.minute_metrics,
                target_version='2015-04-05')

        print('4. Set Blob service properties completed')
    def set_service_properties(self, queue_service):

        try:
            print('1. Get Queue service properties')
            props = queue_service.get_queue_service_properties()

            retention = RetentionPolicy(enabled=True, days=5)
            logging = Logging(delete=True,
                              read=False,
                              write=True,
                              retention_policy=retention)
            hour_metrics = Metrics(enabled=True,
                                   include_apis=True,
                                   retention_policy=retention)
            minute_metrics = Metrics(enabled=False)

            print('2. Ovewrite Queue service properties')
            queue_service.set_queue_service_properties(
                logging=logging,
                hour_metrics=hour_metrics,
                minute_metrics=minute_metrics)
        finally:
            print(
                '3. Revert Queue service properties back to the original ones')
            queue_service.set_queue_service_properties(
                logging=props.logging,
                hour_metrics=props.hour_metrics,
                minute_metrics=props.minute_metrics)

        print('4. Set Queue service properties completed')
コード例 #3
0
 def set_logging(self, read, write, delete, retention, account_name=None, account_key=None,
                 connection_string=None, sas_token=None, timeout=None):
     self.init_client(account_name, account_key, connection_string, sas_token)
     retention_policy = RetentionPolicy(
         enabled=retention != 0,
         days=retention
     )
     logging = Logging(delete, read, write, retention_policy)
     return self.set_service_properties()(logging=logging, timeout=timeout)
コード例 #4
0
 def set_metrics(self, retention, hour, minute, api=None, account_name=None, account_key=None,
                 connection_string=None, sas_token=None, timeout=None):
     self.init_client(account_name, account_key, connection_string, sas_token)
     retention_policy = RetentionPolicy(
         enabled=retention != 0,
         days=retention
     )
     hour_metrics = Metrics(hour, api, retention_policy) if hour is not None else None
     minute_metrics = Metrics(minute, api, retention_policy) if minute is not None else None
     return self.set_service_properties()(
         hour_metrics=hour_metrics, minute_metrics=minute_metrics, timeout=timeout)