Skip to content

create_service_environment

create_service_environment(
    *,
    config_overrides: Optional[BatchClientConfig] = None,
    service_environment_name: Optional[String] = None,
    service_environment_type: Optional[ServiceEnvironmentType] = None,
    state: Optional[ServiceEnvironmentState] = None,
    capacity_limits: Optional[CapacityLimits] = None,
    tags: Optional[TagrisTagsMap] = None,
) -> CreateServiceEnvironmentResponse

Creates a service environment for running service jobs. Service environments define capacity limits for specific service types such as SageMaker Training jobs.

Parameters:

  • service_environment_name (Optional[String], default: None ) –

    The name for the service environment. It can be up to 128 characters long and can contain letters, numbers, hyphens (-), and underscores (_).

  • service_environment_type (Optional[ServiceEnvironmentType], default: None ) –

    The type of service environment. For SageMaker Training jobs, specify SAGEMAKER_TRAINING.

  • state (Optional[ServiceEnvironmentState], default: None ) –

    The state of the service environment. Valid values are ENABLED and DISABLED. The default value is ENABLED.

  • capacity_limits (Optional[CapacityLimits], default: None ) –

    The capacity limits for the service environment. The number of instances a job consumes is the total number of instances requested in the submit training job request resource configuration.

  • tags (Optional[TagrisTagsMap], default: None ) –

    The tags that you apply to the service environment to help you categorize and organize your resources. Each tag consists of a key and an optional value. For more information, see Tagging your Batch resources.

Raises:

  • ClientException –

    These errors are usually caused by a client action. One example cause is using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Another cause is specifying an identifier that's not valid.

  • ServerException –

    These errors are usually caused by a server issue.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_batch/_services/batch.py
def create_service_environment(
    self,
    *,
    config_overrides: Optional[BatchClientConfig] = None,
    service_environment_name: Optional["capo_batch.types.string.String"] = None,
    service_environment_type: Optional[
        "capo_batch.types.service_environment_type.ServiceEnvironmentType"
    ] = None,
    state: Optional[
        "capo_batch.types.service_environment_state.ServiceEnvironmentState"
    ] = None,
    capacity_limits: Optional[
        "capo_batch.types.capacity_limits.CapacityLimits"
    ] = None,
    tags: Optional["capo_batch.types.tagris_tags_map.TagrisTagsMap"] = None,
) -> "capo_batch.types.create_service_environment_response.CreateServiceEnvironmentResponse":
    """<p>Creates a service environment for running service jobs. Service environments define capacity limits for specific service types such as SageMaker Training jobs.</p>

    Args:
        service_environment_name: <p>The name for the service environment. It can be up to 128 characters long and can contain letters, numbers, hyphens (-), and underscores (_).</p>
        service_environment_type: <p>The type of service environment. For SageMaker Training jobs, specify <code>SAGEMAKER_TRAINING</code>.</p>
        state: <p>The state of the service environment. Valid values are <code>ENABLED</code> and <code>DISABLED</code>. The default value is <code>ENABLED</code>.</p>
        capacity_limits: <p>The capacity limits for the service environment. The number of instances a job consumes is the total number of instances requested in the submit training job request resource configuration.</p>
        tags: <p>The tags that you apply to the service environment to help you categorize and organize your resources. Each tag consists of a key and an optional value. For more information, see <a href="https://docs.aws.amazon.com/batch/latest/userguide/using-tags.html">Tagging your Batch resources</a>.</p>

    Raises:
        capo_batch.errors.client_exception.ClientException: <p>These errors are usually caused by a client action. One example cause is using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Another cause is specifying an identifier that's not valid.</p>
        capo_batch.errors.server_exception.ServerException: <p>These errors are usually caused by a server issue.</p>
        capo_batch.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_batch.types.create_service_environment_request.CreateServiceEnvironmentRequest]",
    ) -> OperationResponse[
        "capo_batch.types.create_service_environment_response.CreateServiceEnvironmentResponse"
    ]:
        import capo_batch._operations.aws_batch_v20160810.create_service_environment

        output, http_response = (
            capo_batch._operations.aws_batch_v20160810.create_service_environment.create_service_environment(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateServiceEnvironment")
    )
    input_: capo_batch.types.create_service_environment_request.CreateServiceEnvironmentRequest = {}
    if service_environment_name is not None:
        input_["service_environment_name"] = service_environment_name
    if service_environment_type is not None:
        input_["service_environment_type"] = service_environment_type
    if state is not None:
        input_["state"] = state
    if capacity_limits is not None:
        input_["capacity_limits"] = capacity_limits
    if tags is not None:
        input_["tags"] = tags

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output