class EIPLog(resource.Resource): resources_key = 'logs' base_path = '/antiddos/%(floating_ip_id)s/logs' service = anti_ddos_service.AntiDDosService() _query_mapping = resource.QueryParameters('limit', 'offset', 'sort_dir') # capabilities allow_list = True # Properties #: start time #: *Type: int* start_time = resource.Body('start_time', type=int) #: end time #: *Type: int* end_time = resource.Body('end_time', type=int) #: Anti-ddos status #: *Type: int* status = resource.Body('status', type=int) #: Trigger bps (bit/s) #: *Type: int* trigger_bps = resource.Body('trigger_bps', type=int) #: Trigger package per second #: *Type: int* trigger_pps = resource.Body('trigger_pps', type=int) #: Trigger http requests #: *Type: int* trigger_http_pps = resource.Body('trigger_http_pps', type=int)
def __init__(self, plugins=None): """User preference for each service. :param plugins: List of entry point namespaces to load. Create a new :class:`~openstack.profile.Profile` object with no preferences defined, but knowledge of the services. Services are identified by their service type, e.g.: 'identity', 'compute', etc. """ self._services = {} self._add_service(anti_ddos_service.AntiDDosService(version="v1")) self._add_service(block_store_service.BlockStoreService(version="v2")) self._add_service(compute_service.ComputeService(version="v2")) self._add_service(cts_service.CTSService(version="v1")) self._add_service(dms_service.DMSService(version="v1")) self._add_service(identity_service.IdentityService(version="v3")) self._add_service(image_service.ImageService(version="v2")) self._add_service(kms_service.KMSService(version="v1")) self._add_service(maas_service.MaaSService(version="v1")) self._add_service(network_service.NetworkService(version="v2.0")) self._add_service( orchestration_service.OrchestrationService(version="v1")) self._add_service(smn_service.SMNService(version="v2")) # QianBiao.NG HuaWei Services self._add_service(dns_service.DNSService(version="v2")) self._add_service(cloud_eye_service.CloudEyeService(version="v1")) ass = auto_scaling_service.AutoScalingService(version="v1") self._add_service(ass) vbs_v2 = volume_backup_service.VolumeBackupService(version="v2") self._add_service(vbs_v2) self._add_service(map_reduce_service.MapReduceService(version="v1")) self._add_service(evs_service.EvsServiceV2_1(version='v2.1')) self._add_service(evs_service.EvsService(version='v2')) self._add_service(ecs_service.EcsService(version='v1')) self._add_service(ecs_service.EcsServiceV1_1(version='v1.1')) self._add_service(vpc_service.VpcService(version='v2.0')) self._add_service(bms_service.BmsService(version='v1')) self._add_service(lb_service.LoadBalancerService(version='v1')) # not support below service # self._add_service(message_service.MessageService(version="v1")) # self._add_service(cluster_service.ClusterService(version="v1")) # self._add_service(database_service.DatabaseService(version="v1")) # self._add_service(alarm_service.AlarmService(version="v2")) # self._add_service(bare_metal_service.BareMetalService(version="v1")) # self._add_service(key_manager_service.KeyManagerService(version="v1")) # self._add_service( # object_store_service.ObjectStoreService(version="v1")) self._add_service(rds_service.RDSService(version="v1")) self._add_service(cdn_service.CDNService(version='v1')) # self._add_service(rds_os_service.RDSService(version="v1")) # self._add_service(telemetry_service.TelemetryService(version="v2")) # self._add_service(workflow_service.WorkflowService(version="v2")) if plugins: for plugin in plugins: self._load_plugin(plugin) self.service_keys = sorted(self._services.keys())
class EIPDaily(resource.Resource): resources_key = 'data' base_path = '/antiddos/%(floating_ip_id)s/daily' service = anti_ddos_service.AntiDDosService() # capabilities allow_list = True # Properties #: Data start time #: *Type: int* period_start = resource.Body('period_start', type=int) #: In (bit/s) #: *Type: int* bps_in = resource.Body('bps_in', type=int) #: Attack (bit/s) #: *Type: int* bps_attack = resource.Body('bps_attack', type=int) #: Total data (bit/s) #: *Type: int* total_bps = resource.Body('total_bps', type=int) #: Package in speed (/s) #: *Type: int* pps_in = resource.Body('pps_in', type=int) #: Package attack speed (/s) #: *Type: int* pps_attack = resource.Body('pps_attack', type=int) #: Total package speed (/s) #: *Type: int* total_pps = resource.Body('total_pps', type=int)
def test_service(self): sot = anti_ddos_service.AntiDDosService() self.assertEqual('anti-ddos', sot.service_type) self.assertEqual('public', sot.interface) self.assertIsNone(sot.region) self.assertIsNone(sot.service_name) self.assertEqual(1, len(sot.valid_versions)) self.assertEqual('v1', sot.valid_versions[0].module) self.assertEqual('v1', sot.valid_versions[0].path) self.assertTrue(sot.requires_project_id)
class Version(resource.Resource): resource_key = 'version' resources_key = 'versions' base_path = '/' service = anti_ddos_service.AntiDDosService( version=anti_ddos_service.AntiDDosService.UNVERSIONED) # capabilities allow_list = True # Properties links = resource.prop('links') status = resource.prop('status')
class EIPStatus(resource.Resource): base_path = '/antiddos/%(floating_ip_id)s/status' service = anti_ddos_service.AntiDDosService() # capabilities allow_get = True # Properties floating_ip_id = resource.URI('floating_ip_id') #: Status of Anti-DDos #: validate status are `normal`, `configging`, `notConfig`, #: `packetcleaning`, `packetdropping` status = resource.Body('status')
class AntiDDosMin(resource.Resource): service = anti_ddos_service.AntiDDosService() @classmethod def list(cls, session, paginated=False, **params): query_params = cls._query_mapping._transpose(params) uri = cls.base_path % params endpoint_override = cls.service.get_endpoint_override() resp = session.get(uri, endpoint_filter=cls.service, endpoint_override=endpoint_override, headers={"Accept": "application/json"}, params=query_params) resp = resp.json() return cls.existing(**resp)
class QueryConfigList(resource.Resource): base_path = '/antiddos/query_config_list' service = anti_ddos_service.AntiDDosService() # capabilities allow_get = True # Properties #: A list of traffic limited. #: *Type: list* traffic_limited_list = resource.Body('traffic_limited_list', type=list) #: Http limit list #: *Type: list* http_limited_list = resource.Body('http_limited_list', type=list) #: Connection limit list #: *Type: list* connection_limited_list = resource.Body('connection_limited_list', type=list) #: A list of extended ddos config of user #: *Type: list* extend_ddos_config = resource.Body('extend_ddos_config', type=list)
class AlertConfig(resource.Resource): base_path = '/warnalert/alertconfig/query' service = anti_ddos_service.AntiDDosService() # capabilities allow_create = False allow_list = False allow_get = True allow_delete = False allow_update = False # Properties #: warn alert config information #: *Type: dict* warn_config = resource.Body('warn_config', type=dict) #: unique topic id topic_urn = resource.Body('topic_urn') #: warn alert group name display_name = resource.Body('display_name') # This overrides the default behavior of resource get def get(self, session, requires_id=False): return super(AlertConfig, self).get(session, requires_id=requires_id)
class FloatingIP(resource.Resource): resources_key = 'ddosStatus' base_path = '/antiddos' service = anti_ddos_service.AntiDDosService() # capabilities allow_list = True allow_get = True allow_delete = True allow_update = True _query_mapping = resource.QueryParameters('status', 'limit', 'offset', 'ip') # Properties floating_ip_id = resource.Body('floating_ip_id', alternate_id=True) #: Whether enable L7 protect #: *Type: bool* enable_L7 = resource.Body('enable_L7', type=bool) #: Traffic segment id #: Valid values are from `1` to `9` #: *Type: int* traffic_pos_id = resource.Body('traffic_pos_id', type=int) #: Http request segment id #: Valid values are from `1` to `15` #: *Type: int* http_request_pos_id = resource.Body('http_request_pos_id', type=int) #: Cleaning access limit id #: Valid values are from `1` to `8` #: *Type: int* cleaning_access_pos_id = resource.Body('cleaning_access_pos_id', type=int) #: Application type id #: Valid values are from `0`, `1` #: *Type: int* app_type_id = resource.Body('app_type_id', type=int) #: Floating ipaddress floating_ip_address = resource.Body('floating_ip_address') #: Network type: EIP or ELB network_type = resource.Body('network_type') #: Status of the EIP status = resource.Body('status') #: Task id task_id = resource.Body('task_id') def create(self, session, prepend_key=True): endpoint_override = self.service.get_endpoint_override() request = self._prepare_request(requires_id=True, prepend_key=prepend_key) request.body.pop('floating_ip_id') response = session.post(request.uri, endpoint_filter=self.service, endpoint_override=endpoint_override, json=request.body, headers=request.headers) self._translate_response(response) return self def update(self, session, prepend_key=True, has_body=True): # floating update requires body to have `enable_L7, traffic_pos_id # http_request_pos_id, cleaning_access_pos_id, app_type_id` # but resource2.py won't put them into body is they are not # dirty # The id cannot be dirty for an update self._body._dirty.discard("id") # Only try to update if we actually have anything to update. if not any([self._body.dirty, self._header.dirty]): return self request = self._prepare_request(prepend_key=prepend_key) endpoint_override = self.service.get_endpoint_override() for r in ('enable_L7', 'traffic_pos_id', 'http_request_pos_id', 'cleaning_access_pos_id', 'app_type_id'): if r not in request.body: request.body[r] = getattr(self, r) response = session.put(request.uri, endpoint_filter=self.service, endpoint_override=endpoint_override, json=request.body, headers=request.headers) self._translate_response(response, has_body=has_body) return self