class EnterpriseProjectResourceMigrate(resource2.Resource): """Define a EnterpriseProject class. get detail and update EP""" base_path = '/enterprise-projects/%(enterprise_project_id)s/resources-migrate' service = eps_service.EpsService() # Allow operation for this resource. # capabilities allow_create = True allow_list = False allow_get = False allow_update = False allow_delete = False enterprise_project_id = resource2.URI("enterprise_project_id") project_id = resource2.Body("project_id") cloud_resource_type = resource2.Body("resource_type") resource_id = resource2.Body("resource_id") def create(self, session, prepend_key=True): """Create a remote resource based on this instance. :param session: The session to use for making this request. :type session: :class:`~openstack.session.Session` :param prepend_key: A boolean indicating whether the resource_key should be prepended in a resource creation request. Default to True. :return: This :class:`Resource` instance. :raises: :exc:`~openstack.exceptions.MethodNotSupported` if :data:`Resource.allow_create` is not set to ``True``. """ if not self.allow_create: raise exceptions.MethodNotSupported(self, "create") endpoint_override = self.service.get_endpoint_override() service = self.get_service_filter(self, session) if self.put_create: request = self._prepare_request(requires_id=True, prepend_key=prepend_key) response = session.put(request.uri, endpoint_filter=self.service, endpoint_override=endpoint_override, json=request.body, headers=request.headers, microversion=service.microversion) else: request = self._prepare_request(requires_id=False, prepend_key=prepend_key) response = session.post(request.uri, endpoint_filter=self.service, endpoint_override=endpoint_override, json=request.body, headers=request.headers, microversion=service.microversion) self._translate_response(response, False) return self
class EnterpriseProjectDetail(resource2.Resource): """Define a EnterpriseProject class. get detail and update EP""" base_path = '/enterprise-projects/%(enterprise_project_id)s' service = eps_service.EpsService() # Allow operation for this resource. # capabilities allow_create = False allow_list = False allow_get = True allow_update = False allow_delete = False enterprise_project_id = resource2.URI("enterprise_project_id") enterprise_project = resource2.Body("enterprise_project") id = resource2.Body("id") name = resource2.Body("name") description = resource2.Body("description") status = resource2.Body("status", type=int) created_at = resource2.Body("created_at") updated_at = resource2.Body("updated_at") def get(self, session, requires_id=True): """Get a remote resource based on this instance. :param session: The session to use for making this request. :type session: :class:`~openstack.session.Session` :param boolean requires_id: A boolean indicating whether resource ID should be part of the requested URI. :return: This :class:`Resource` instance. :raises: :exc:`~openstack.exceptions.MethodNotSupported` if :data:`Resource.allow_get` is not set to ``True``. """ if not self.allow_get: raise exceptions.MethodNotSupported(self, "get") request = self._prepare_request(requires_id=False) endpoint_override = self.service.get_endpoint_override() service = self.get_service_filter(self, session) response = session.get(request.uri, endpoint_filter=self.service, microversion=service.microversion, endpoint_override=endpoint_override) self._translate_response(response) return self
class EnterpriseProjectResourceFilter(resource2.Resource): """Define a EnterpriseProject class. get detail and update EP""" base_path = '/enterprise-projects/%(enterprise_project_id)s/resources/filter' service = eps_service.EpsService() # Allow operation for this resource. # capabilities allow_create = True allow_list = False allow_get = False allow_update = False allow_delete = False enterprise_project_id = resource2.URI("enterprise_project_id") projects = resource2.Body("projects") resource_types = resource2.Body("resource_types") resources = resource2.Body("resources") errors = resource2.Body("errors") total_count = resource2.Body("total_count")
class EnterpriseProject(resource2.Resource): """Define a EnterpriseProject class. list and create EP""" base_path = '/enterprise-projects' service = eps_service.EpsService() # Allow operation for this resource. # capabilities allow_create = True allow_list = True allow_get = False allow_update = False allow_delete = False # Mapping of accepted query parameter names. _query_mapping = resource2.QueryParameters('name', 'status', 'id') enterprise_projects = resource2.Body("enterprise_projects", type=list) total_count = resource2.Body("total_count", type=int) @classmethod def list(cls, session, paginated=False, **params): if not cls.allow_list: raise exceptions.MethodNotSupported(cls, "list") query_params = cls._query_mapping._transpose(params) uri = cls.get_list_uri(params) service = cls.get_service_filter(cls, session) endpoint_override = cls.service.get_endpoint_override() resp = session.get(uri, endpoint_filter=cls.service, microversion=service.microversion, endpoint_override=endpoint_override, headers={"Accept": "application/json"}, params=query_params) response_json = resp.json() value = cls.existing(**response_json) return value
class EnterpriseProjectUpdate(resource2.Resource): """Define a EnterpriseProject class. get detail and update EP""" base_path = '/enterprise-projects/%(enterprise_project_id)s' service = eps_service.EpsService() # Allow operation for this resource. # capabilities allow_create = False allow_list = False allow_get = True allow_update = True allow_delete = False enterprise_project_id = resource2.URI("enterprise_project_id") enterprise_project = resource2.Body("enterprise_project") name = resource2.Body("name") description = resource2.Body("description") def update(self, session, prepend_key=True, has_body=False): """Update the remote resource based on this instance. :param session: The session to use for making this request. :type session: :class:`~openstack.session.Session` :param prepend_key: A boolean indicating whether the resource_key should be prepended in a resource update request. Default to True. :return: This :class:`Resource` instance. :raises: :exc:`~openstack.exceptions.MethodNotSupported` if :data:`Resource.allow_update` is not set to ``True``. """ # The id cannot be dirty for an update self._body._dirty.discard("id") id_mapping_name = self._body_mapping()["id"] self._body._dirty.discard(id_mapping_name) # Only try to update if we actually have anything to update. if not any([self._body.dirty, self._header.dirty]): return self if not self.allow_update: raise exceptions.MethodNotSupported(self, "update") request = self._prepare_request(requires_id=False, prepend_key=prepend_key) service = self.get_service_filter(self, session) endpoint_override = self.service.get_endpoint_override() if self.patch_update: response = session.patch(request.uri, endpoint_filter=self.service, microversion=service.microversion, endpoint_override=endpoint_override, json=request.body, headers=request.headers) else: response = session.put(request.uri, endpoint_filter=self.service, microversion=service.microversion, endpoint_override=endpoint_override, json=request.body, headers=request.headers) self._translate_response(response, has_body=True) return self
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._services_module = {} 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(vpc_service.VpcServiceV1(version='v1')) self._add_service(bms_service.BmsService(version='v1')) self._add_service(deh_service.DehService(version='v1.0')) self._add_service(csbs_service.CsbsService(version='v1')) self._add_service(ims_service.ImsService(version='v2')) self._add_service(nat_service.NatService(version='v2.0')) self._add_service(lb_service.LoadBalancerService(version='v1')) self._add_service(bss_service.BssService(version='v1')) self._add_service(bss_intl_service.BssIntlService(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(rds_service.RDSServiceV3(version="v3")) self._add_service(cdn_service.CDNService(version='v1')) self._add_service(iam_service.IamService(version='v3.0')) # 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")) self._add_service(fgs_service.FGSService(version='v2')) self._add_service(tms_service.TmsService(version='v1')) self._add_service(eps_service.EpsService(version='v1')) if plugins: for plugin in plugins: self._load_plugin(plugin) self.service_keys = sorted(self._services.keys())