我们从Python开源项目中,提取了以下13个代码示例,用于说明如何使用botocore.exceptions.UnknownServiceError()。
def get_available_regions(self, service_name, partition_name='aws', allow_non_regional=False): """Lists the region and endpoint names of a particular partition. :type service_name: string :param service_name: Name of a service to list endpoint for (e.g., s3). This parameter accepts a service name (e.g., "elb") or endpoint prefix (e.g., "elasticloadbalancing"). :type partition_name: string :param partition_name: Name of the partition to limit endpoints to. (e.g., aws for the public AWS endpoints, aws-cn for AWS China endpoints, aws-us-gov for AWS GovCloud (US) Endpoints, etc. :type allow_non_regional: bool :param allow_non_regional: Set to True to include endpoints that are not regional endpoints (e.g., s3-external-1, fips-us-gov-west-1, etc). :return: Returns a list of endpoint names (e.g., ["us-east-1"]). """ resolver = self.get_component('endpoint_resolver') results = [] try: service_data = self.get_service_data(service_name) endpoint_prefix = service_data['metadata'].get( 'endpointPrefix', service_name) results = resolver.get_available_endpoints( endpoint_prefix, partition_name, allow_non_regional) except UnknownServiceError: pass return results
def test_get_client_with_invalid_client_type(self, mock_get_credentials): service = "invalid_type" with pytest.raises(UnknownServiceError): self.connection_manager._get_client(service)
def load_service_model(self, service_name, type_name, api_version=None): """Load a botocore service model This is the main method for loading botocore models (e.g. a service model, pagination configs, waiter configs, etc.). :type service_name: str :param service_name: The name of the service (e.g ``ec2``, ``s3``). :type type_name: str :param type_name: The model type. Valid types include, but are not limited to: ``service-2``, ``paginators-1``, ``waiters-2``. :type api_version: str :param api_version: The API version to load. If this is not provided, then the latest API version will be used. :type load_extras: bool :param load_extras: Whether or not to load the tool extras which contain additional data to be added to the model. :raises: UnknownServiceError if there is no known service with the provided service_name. :raises: DataNotFoundError if no data could be found for the service_name/type_name/api_version. :return: The loaded data, as a python type (e.g. dict, list, etc). """ # Wrapper around the load_data. This will calculate the path # to call load_data with. known_services = self.list_available_services(type_name) if service_name not in known_services: raise UnknownServiceError( service_name=service_name, known_service_names=', '.join(sorted(known_services))) if api_version is None: api_version = self.determine_latest_version( service_name, type_name) full_path = os.path.join(service_name, api_version, type_name) model = self.load_data(full_path) # Load in all the extras extras_data = self._find_extras(service_name, type_name, api_version) self._extras_processor.process(model, extras_data) return model