# coding=utf-8
# *** WARNING: this file was generated by pulumi-language-python. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***

import builtins as _builtins
import warnings
import sys
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union, overload
if sys.version_info >= (3, 11):
    from typing import NotRequired, TypedDict, TypeAlias
else:
    from typing_extensions import NotRequired, TypedDict, TypeAlias
from . import _utilities
from . import outputs
from ._inputs import *

__all__ = ['ServiceArgs', 'Service']

@pulumi.input_type
class ServiceArgs:
    def __init__(__self__, *,
                 task_spec: pulumi.Input['ServiceTaskSpecArgs'],
                 auth: Optional[pulumi.Input['ServiceAuthArgs']] = None,
                 converge_config: Optional[pulumi.Input['ServiceConvergeConfigArgs']] = None,
                 endpoint_spec: Optional[pulumi.Input['ServiceEndpointSpecArgs']] = None,
                 labels: Optional[pulumi.Input[Sequence[pulumi.Input['ServiceLabelArgs']]]] = None,
                 mode: Optional[pulumi.Input['ServiceModeArgs']] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None,
                 rollback_config: Optional[pulumi.Input['ServiceRollbackConfigArgs']] = None,
                 update_config: Optional[pulumi.Input['ServiceUpdateConfigArgs']] = None):
        """
        The set of arguments for constructing a Service resource.

        :param pulumi.Input['ServiceTaskSpecArgs'] task_spec: User modifiable task configuration
        :param pulumi.Input['ServiceAuthArgs'] auth: Configuration for the authentication for pulling the images of the service
        :param pulumi.Input['ServiceConvergeConfigArgs'] converge_config: A configuration to ensure that a service converges aka reaches the desired that of all task up and running
        :param pulumi.Input['ServiceEndpointSpecArgs'] endpoint_spec: Properties that can be configured to access and load balance a service
        :param pulumi.Input[Sequence[pulumi.Input['ServiceLabelArgs']]] labels: User-defined key/value metadata
        :param pulumi.Input['ServiceModeArgs'] mode: Scheduling mode for the service
        :param pulumi.Input[_builtins.str] name: Name of the service
        :param pulumi.Input['ServiceRollbackConfigArgs'] rollback_config: Specification for the rollback strategy of the service
        :param pulumi.Input['ServiceUpdateConfigArgs'] update_config: Specification for the update strategy of the service
        """
        pulumi.set(__self__, "task_spec", task_spec)
        if auth is not None:
            pulumi.set(__self__, "auth", auth)
        if converge_config is not None:
            pulumi.set(__self__, "converge_config", converge_config)
        if endpoint_spec is not None:
            pulumi.set(__self__, "endpoint_spec", endpoint_spec)
        if labels is not None:
            pulumi.set(__self__, "labels", labels)
        if mode is not None:
            pulumi.set(__self__, "mode", mode)
        if name is not None:
            pulumi.set(__self__, "name", name)
        if rollback_config is not None:
            pulumi.set(__self__, "rollback_config", rollback_config)
        if update_config is not None:
            pulumi.set(__self__, "update_config", update_config)

    @_builtins.property
    @pulumi.getter(name="taskSpec")
    def task_spec(self) -> pulumi.Input['ServiceTaskSpecArgs']:
        """
        User modifiable task configuration
        """
        return pulumi.get(self, "task_spec")

    @task_spec.setter
    def task_spec(self, value: pulumi.Input['ServiceTaskSpecArgs']):
        pulumi.set(self, "task_spec", value)

    @_builtins.property
    @pulumi.getter
    def auth(self) -> Optional[pulumi.Input['ServiceAuthArgs']]:
        """
        Configuration for the authentication for pulling the images of the service
        """
        return pulumi.get(self, "auth")

    @auth.setter
    def auth(self, value: Optional[pulumi.Input['ServiceAuthArgs']]):
        pulumi.set(self, "auth", value)

    @_builtins.property
    @pulumi.getter(name="convergeConfig")
    def converge_config(self) -> Optional[pulumi.Input['ServiceConvergeConfigArgs']]:
        """
        A configuration to ensure that a service converges aka reaches the desired that of all task up and running
        """
        return pulumi.get(self, "converge_config")

    @converge_config.setter
    def converge_config(self, value: Optional[pulumi.Input['ServiceConvergeConfigArgs']]):
        pulumi.set(self, "converge_config", value)

    @_builtins.property
    @pulumi.getter(name="endpointSpec")
    def endpoint_spec(self) -> Optional[pulumi.Input['ServiceEndpointSpecArgs']]:
        """
        Properties that can be configured to access and load balance a service
        """
        return pulumi.get(self, "endpoint_spec")

    @endpoint_spec.setter
    def endpoint_spec(self, value: Optional[pulumi.Input['ServiceEndpointSpecArgs']]):
        pulumi.set(self, "endpoint_spec", value)

    @_builtins.property
    @pulumi.getter
    def labels(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['ServiceLabelArgs']]]]:
        """
        User-defined key/value metadata
        """
        return pulumi.get(self, "labels")

    @labels.setter
    def labels(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['ServiceLabelArgs']]]]):
        pulumi.set(self, "labels", value)

    @_builtins.property
    @pulumi.getter
    def mode(self) -> Optional[pulumi.Input['ServiceModeArgs']]:
        """
        Scheduling mode for the service
        """
        return pulumi.get(self, "mode")

    @mode.setter
    def mode(self, value: Optional[pulumi.Input['ServiceModeArgs']]):
        pulumi.set(self, "mode", value)

    @_builtins.property
    @pulumi.getter
    def name(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        Name of the service
        """
        return pulumi.get(self, "name")

    @name.setter
    def name(self, value: Optional[pulumi.Input[_builtins.str]]):
        pulumi.set(self, "name", value)

    @_builtins.property
    @pulumi.getter(name="rollbackConfig")
    def rollback_config(self) -> Optional[pulumi.Input['ServiceRollbackConfigArgs']]:
        """
        Specification for the rollback strategy of the service
        """
        return pulumi.get(self, "rollback_config")

    @rollback_config.setter
    def rollback_config(self, value: Optional[pulumi.Input['ServiceRollbackConfigArgs']]):
        pulumi.set(self, "rollback_config", value)

    @_builtins.property
    @pulumi.getter(name="updateConfig")
    def update_config(self) -> Optional[pulumi.Input['ServiceUpdateConfigArgs']]:
        """
        Specification for the update strategy of the service
        """
        return pulumi.get(self, "update_config")

    @update_config.setter
    def update_config(self, value: Optional[pulumi.Input['ServiceUpdateConfigArgs']]):
        pulumi.set(self, "update_config", value)


@pulumi.input_type
class _ServiceState:
    def __init__(__self__, *,
                 auth: Optional[pulumi.Input['ServiceAuthArgs']] = None,
                 converge_config: Optional[pulumi.Input['ServiceConvergeConfigArgs']] = None,
                 endpoint_spec: Optional[pulumi.Input['ServiceEndpointSpecArgs']] = None,
                 labels: Optional[pulumi.Input[Sequence[pulumi.Input['ServiceLabelArgs']]]] = None,
                 mode: Optional[pulumi.Input['ServiceModeArgs']] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None,
                 rollback_config: Optional[pulumi.Input['ServiceRollbackConfigArgs']] = None,
                 task_spec: Optional[pulumi.Input['ServiceTaskSpecArgs']] = None,
                 update_config: Optional[pulumi.Input['ServiceUpdateConfigArgs']] = None):
        """
        Input properties used for looking up and filtering Service resources.

        :param pulumi.Input['ServiceAuthArgs'] auth: Configuration for the authentication for pulling the images of the service
        :param pulumi.Input['ServiceConvergeConfigArgs'] converge_config: A configuration to ensure that a service converges aka reaches the desired that of all task up and running
        :param pulumi.Input['ServiceEndpointSpecArgs'] endpoint_spec: Properties that can be configured to access and load balance a service
        :param pulumi.Input[Sequence[pulumi.Input['ServiceLabelArgs']]] labels: User-defined key/value metadata
        :param pulumi.Input['ServiceModeArgs'] mode: Scheduling mode for the service
        :param pulumi.Input[_builtins.str] name: Name of the service
        :param pulumi.Input['ServiceRollbackConfigArgs'] rollback_config: Specification for the rollback strategy of the service
        :param pulumi.Input['ServiceTaskSpecArgs'] task_spec: User modifiable task configuration
        :param pulumi.Input['ServiceUpdateConfigArgs'] update_config: Specification for the update strategy of the service
        """
        if auth is not None:
            pulumi.set(__self__, "auth", auth)
        if converge_config is not None:
            pulumi.set(__self__, "converge_config", converge_config)
        if endpoint_spec is not None:
            pulumi.set(__self__, "endpoint_spec", endpoint_spec)
        if labels is not None:
            pulumi.set(__self__, "labels", labels)
        if mode is not None:
            pulumi.set(__self__, "mode", mode)
        if name is not None:
            pulumi.set(__self__, "name", name)
        if rollback_config is not None:
            pulumi.set(__self__, "rollback_config", rollback_config)
        if task_spec is not None:
            pulumi.set(__self__, "task_spec", task_spec)
        if update_config is not None:
            pulumi.set(__self__, "update_config", update_config)

    @_builtins.property
    @pulumi.getter
    def auth(self) -> Optional[pulumi.Input['ServiceAuthArgs']]:
        """
        Configuration for the authentication for pulling the images of the service
        """
        return pulumi.get(self, "auth")

    @auth.setter
    def auth(self, value: Optional[pulumi.Input['ServiceAuthArgs']]):
        pulumi.set(self, "auth", value)

    @_builtins.property
    @pulumi.getter(name="convergeConfig")
    def converge_config(self) -> Optional[pulumi.Input['ServiceConvergeConfigArgs']]:
        """
        A configuration to ensure that a service converges aka reaches the desired that of all task up and running
        """
        return pulumi.get(self, "converge_config")

    @converge_config.setter
    def converge_config(self, value: Optional[pulumi.Input['ServiceConvergeConfigArgs']]):
        pulumi.set(self, "converge_config", value)

    @_builtins.property
    @pulumi.getter(name="endpointSpec")
    def endpoint_spec(self) -> Optional[pulumi.Input['ServiceEndpointSpecArgs']]:
        """
        Properties that can be configured to access and load balance a service
        """
        return pulumi.get(self, "endpoint_spec")

    @endpoint_spec.setter
    def endpoint_spec(self, value: Optional[pulumi.Input['ServiceEndpointSpecArgs']]):
        pulumi.set(self, "endpoint_spec", value)

    @_builtins.property
    @pulumi.getter
    def labels(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['ServiceLabelArgs']]]]:
        """
        User-defined key/value metadata
        """
        return pulumi.get(self, "labels")

    @labels.setter
    def labels(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['ServiceLabelArgs']]]]):
        pulumi.set(self, "labels", value)

    @_builtins.property
    @pulumi.getter
    def mode(self) -> Optional[pulumi.Input['ServiceModeArgs']]:
        """
        Scheduling mode for the service
        """
        return pulumi.get(self, "mode")

    @mode.setter
    def mode(self, value: Optional[pulumi.Input['ServiceModeArgs']]):
        pulumi.set(self, "mode", value)

    @_builtins.property
    @pulumi.getter
    def name(self) -> Optional[pulumi.Input[_builtins.str]]:
        """
        Name of the service
        """
        return pulumi.get(self, "name")

    @name.setter
    def name(self, value: Optional[pulumi.Input[_builtins.str]]):
        pulumi.set(self, "name", value)

    @_builtins.property
    @pulumi.getter(name="rollbackConfig")
    def rollback_config(self) -> Optional[pulumi.Input['ServiceRollbackConfigArgs']]:
        """
        Specification for the rollback strategy of the service
        """
        return pulumi.get(self, "rollback_config")

    @rollback_config.setter
    def rollback_config(self, value: Optional[pulumi.Input['ServiceRollbackConfigArgs']]):
        pulumi.set(self, "rollback_config", value)

    @_builtins.property
    @pulumi.getter(name="taskSpec")
    def task_spec(self) -> Optional[pulumi.Input['ServiceTaskSpecArgs']]:
        """
        User modifiable task configuration
        """
        return pulumi.get(self, "task_spec")

    @task_spec.setter
    def task_spec(self, value: Optional[pulumi.Input['ServiceTaskSpecArgs']]):
        pulumi.set(self, "task_spec", value)

    @_builtins.property
    @pulumi.getter(name="updateConfig")
    def update_config(self) -> Optional[pulumi.Input['ServiceUpdateConfigArgs']]:
        """
        Specification for the update strategy of the service
        """
        return pulumi.get(self, "update_config")

    @update_config.setter
    def update_config(self, value: Optional[pulumi.Input['ServiceUpdateConfigArgs']]):
        pulumi.set(self, "update_config", value)


@pulumi.type_token("docker:index/service:Service")
class Service(pulumi.CustomResource):
    @overload
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 auth: Optional[pulumi.Input[Union['ServiceAuthArgs', 'ServiceAuthArgsDict']]] = None,
                 converge_config: Optional[pulumi.Input[Union['ServiceConvergeConfigArgs', 'ServiceConvergeConfigArgsDict']]] = None,
                 endpoint_spec: Optional[pulumi.Input[Union['ServiceEndpointSpecArgs', 'ServiceEndpointSpecArgsDict']]] = None,
                 labels: Optional[pulumi.Input[Sequence[pulumi.Input[Union['ServiceLabelArgs', 'ServiceLabelArgsDict']]]]] = None,
                 mode: Optional[pulumi.Input[Union['ServiceModeArgs', 'ServiceModeArgsDict']]] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None,
                 rollback_config: Optional[pulumi.Input[Union['ServiceRollbackConfigArgs', 'ServiceRollbackConfigArgsDict']]] = None,
                 task_spec: Optional[pulumi.Input[Union['ServiceTaskSpecArgs', 'ServiceTaskSpecArgsDict']]] = None,
                 update_config: Optional[pulumi.Input[Union['ServiceUpdateConfigArgs', 'ServiceUpdateConfigArgsDict']]] = None,
                 __props__=None):
        """
        <!-- Bug: Type and Name are switched -->
        This resource manages the lifecycle of a Docker service. By default, the creation, update and delete of services are detached.
         With the Converge Config the behavior of the `docker cli` is imitated to guarantee tha for example, all tasks of a service are running or successfully updated or to inform `terraform` that a service could no be updated and was successfully rolled back.

        ## Example Usage

        ### Basic

        The following configuration starts a Docker Service with

        - the given image,
        - 1 replica
        - exposes the port `8080` in `vip` mode to the host machine
        - moreover, uses the `container` runtime

        ```python
        import pulumi
        import pulumi_docker as docker

        foo = docker.Service("foo",
            name="foo-service",
            task_spec={
                "container_spec": {
                    "image": "repo.mycompany.com:8080/foo-service:v1",
                },
            },
            endpoint_spec={
                "ports": [{
                    "target_port": 8080,
                }],
            })
        ```

        The following command is the equivalent:

        ### Basic with Datasource

        Alternatively, if the image is already present on the Docker Host and not managed
        by `terraform`, you can also use the `RemoteImage` datasource:

        ```python
        import pulumi
        import pulumi_docker as docker

        foo = docker.get_remote_image(name="repo.mycompany.com:8080/foo-service:v1")
        foo_service = docker.Service("foo",
            name="foo-service",
            task_spec={
                "container_spec": {
                    "image": foo.repo_digest,
                },
            },
            endpoint_spec={
                "ports": [{
                    "target_port": 8080,
                }],
            })
        ```

        ### Advanced

        The following configuration shows the full capabilities of a Docker Service,
        with a `volume`, `config`, `secret` and `network`

        ```python
        import pulumi
        import pulumi_docker as docker

        test_volume = docker.Volume("test_volume", name="tftest-volume")
        test_volume2 = docker.Volume("test_volume_2", name="tftest-volume2")
        service_config = docker.ServiceConfig("service_config",
            name="tftest-full-myconfig",
            data="ewogICJwcmVmaXgiOiAiMTIzIgp9")
        service_secret = docker.Secret("service_secret",
            name="tftest-mysecret",
            data="ewogICJrZXkiOiAiUVdFUlRZIgp9")
        test_network = docker.Network("test_network",
            name="tftest-network",
            driver="overlay")
        foo = docker.Service("foo",
            name="tftest-service-basic",
            task_spec={
                "container_spec": {
                    "configs": [
                        {
                            "config_id": service_config.id,
                            "config_name": service_config.name,
                            "file_name": "/configs.json",
                        },
                        {},
                    ],
                    "secrets": [
                        {
                            "secret_id": service_secret.id,
                            "secret_name": service_secret.name,
                            "file_name": "/secrets.json",
                            "file_uid": "0",
                            "file_gid": "0",
                            "file_mode": 777,
                        },
                        {},
                    ],
                    "image": "repo.mycompany.com:8080/foo-service:v1",
                    "labels": [{
                        "label": "foo.bar",
                        "value": "baz",
                    }],
                    "commands": ["ls"],
                    "args": ["-las"],
                    "hostname": "my-fancy-service",
                    "env": {
                        "MYFOO": "BAR",
                    },
                    "dir": "/root",
                    "user": "root",
                    "groups": [
                        "docker",
                        "foogroup",
                    ],
                    "privileges": {
                        "se_linux_context": {
                            "disable": True,
                            "user": "user-label",
                            "role": "role-label",
                            "type": "type-label",
                            "level": "level-label",
                        },
                    },
                    "read_only": True,
                    "mounts": [
                        {
                            "target": "/mount/test",
                            "source": test_volume.name,
                            "type": "bind",
                            "read_only": True,
                            "bind_options": {
                                "propagation": "rprivate",
                            },
                        },
                        {
                            "target": "/mount/test2",
                            "source": test_volume2.name,
                            "type": "volume",
                            "read_only": True,
                            "volume_options": {
                                "no_copy": True,
                                "labels": [{
                                    "label": "foo",
                                    "value": "bar",
                                }],
                                "driver_name": "random-driver",
                                "driver_options": {
                                    "op1": "val1",
                                },
                            },
                        },
                    ],
                    "stop_signal": "SIGTERM",
                    "stop_grace_period": "10s",
                    "healthcheck": {
                        "tests": [
                            "CMD",
                            "curl",
                            "-f",
                            "http://localhost:8080/health",
                        ],
                        "interval": "5s",
                        "timeout": "2s",
                        "retries": 4,
                    },
                    "hosts": [{
                        "host": "testhost",
                        "ip": "10.0.1.0",
                    }],
                    "dns_config": {
                        "nameservers": ["8.8.8.8"],
                        "searches": ["example.org"],
                        "options": ["timeout:3"],
                    },
                },
                "resources": {
                    "limits": {
                        "nano_cpus": 1000000,
                        "memory_bytes": 536870912,
                    },
                    "reservation": {
                        "nano_cpus": 1000000,
                        "memory_bytes": 536870912,
                        "generic_resources": {
                            "named_resources_specs": ["GPU=UUID1"],
                            "discrete_resources_specs": ["SSD=3"],
                        },
                    },
                },
                "restart_policy": {
                    "condition": "on-failure",
                    "delay": "3s",
                    "maxAttempts": 4,
                    "window": "10s",
                }[0],
                "placement": {
                    "constraints": ["node.role==manager"],
                    "prefs": ["spread=node.role.manager"],
                    "max_replicas": 1,
                },
                "force_update": 0,
                "runtime": "container",
                "networks": [test_network.id],
                "log_driver": {
                    "name": "json-file",
                    "options": {
                        "max-size": "10m",
                        "max-file": "3",
                    },
                },
            },
            mode={
                "replicated": {
                    "replicas": 2,
                },
            },
            update_config={
                "parallelism": 2,
                "delay": "10s",
                "failure_action": "pause",
                "monitor": "5s",
                "max_failure_ratio": "0.1",
                "order": "start-first",
            },
            rollback_config={
                "parallelism": 2,
                "delay": "5ms",
                "failure_action": "pause",
                "monitor": "10h",
                "max_failure_ratio": "0.9",
                "order": "stop-first",
            },
            endpoint_spec={
                "ports": [
                    {
                        "name": "random",
                        "protocol": "tcp",
                        "target_port": 8080,
                        "published_port": 8080,
                        "publish_mode": "ingress",
                    },
                    {},
                ],
                "mode": "vip",
            })
        ```

        ## Import

        !/bin/bash

        ```sh
        $ pulumi import docker:index/service:Service foo id
        ```

        ### Example

        Assuming you created a `service` as follows

        ```sh
        #!/bin/bash
        docker service create --name foo -p 8080:80 nginx
        # prints th ID
        4pcphbxkfn2rffhbhe6czytgi
        ```

        you provide the definition for the resource as follows

        ```python
        import pulumi
        import pulumi_docker as docker

        foo = docker.Service("foo",
            name="foo",
            task_spec={
                "container_spec": {
                    "image": "nginx",
                },
            },
            endpoint_spec={
                "ports": [{
                    "target_port": 80,
                    "published_port": 8080,
                }],
            })
        ```

        then the import command is as follows

        !/bin/bash

        ```sh
        $ pulumi import docker:index/service:Service foo 4pcphbxkfn2rffhbhe6czytgi
        ```


        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[Union['ServiceAuthArgs', 'ServiceAuthArgsDict']] auth: Configuration for the authentication for pulling the images of the service
        :param pulumi.Input[Union['ServiceConvergeConfigArgs', 'ServiceConvergeConfigArgsDict']] converge_config: A configuration to ensure that a service converges aka reaches the desired that of all task up and running
        :param pulumi.Input[Union['ServiceEndpointSpecArgs', 'ServiceEndpointSpecArgsDict']] endpoint_spec: Properties that can be configured to access and load balance a service
        :param pulumi.Input[Sequence[pulumi.Input[Union['ServiceLabelArgs', 'ServiceLabelArgsDict']]]] labels: User-defined key/value metadata
        :param pulumi.Input[Union['ServiceModeArgs', 'ServiceModeArgsDict']] mode: Scheduling mode for the service
        :param pulumi.Input[_builtins.str] name: Name of the service
        :param pulumi.Input[Union['ServiceRollbackConfigArgs', 'ServiceRollbackConfigArgsDict']] rollback_config: Specification for the rollback strategy of the service
        :param pulumi.Input[Union['ServiceTaskSpecArgs', 'ServiceTaskSpecArgsDict']] task_spec: User modifiable task configuration
        :param pulumi.Input[Union['ServiceUpdateConfigArgs', 'ServiceUpdateConfigArgsDict']] update_config: Specification for the update strategy of the service
        """
        ...
    @overload
    def __init__(__self__,
                 resource_name: str,
                 args: ServiceArgs,
                 opts: Optional[pulumi.ResourceOptions] = None):
        """
        <!-- Bug: Type and Name are switched -->
        This resource manages the lifecycle of a Docker service. By default, the creation, update and delete of services are detached.
         With the Converge Config the behavior of the `docker cli` is imitated to guarantee tha for example, all tasks of a service are running or successfully updated or to inform `terraform` that a service could no be updated and was successfully rolled back.

        ## Example Usage

        ### Basic

        The following configuration starts a Docker Service with

        - the given image,
        - 1 replica
        - exposes the port `8080` in `vip` mode to the host machine
        - moreover, uses the `container` runtime

        ```python
        import pulumi
        import pulumi_docker as docker

        foo = docker.Service("foo",
            name="foo-service",
            task_spec={
                "container_spec": {
                    "image": "repo.mycompany.com:8080/foo-service:v1",
                },
            },
            endpoint_spec={
                "ports": [{
                    "target_port": 8080,
                }],
            })
        ```

        The following command is the equivalent:

        ### Basic with Datasource

        Alternatively, if the image is already present on the Docker Host and not managed
        by `terraform`, you can also use the `RemoteImage` datasource:

        ```python
        import pulumi
        import pulumi_docker as docker

        foo = docker.get_remote_image(name="repo.mycompany.com:8080/foo-service:v1")
        foo_service = docker.Service("foo",
            name="foo-service",
            task_spec={
                "container_spec": {
                    "image": foo.repo_digest,
                },
            },
            endpoint_spec={
                "ports": [{
                    "target_port": 8080,
                }],
            })
        ```

        ### Advanced

        The following configuration shows the full capabilities of a Docker Service,
        with a `volume`, `config`, `secret` and `network`

        ```python
        import pulumi
        import pulumi_docker as docker

        test_volume = docker.Volume("test_volume", name="tftest-volume")
        test_volume2 = docker.Volume("test_volume_2", name="tftest-volume2")
        service_config = docker.ServiceConfig("service_config",
            name="tftest-full-myconfig",
            data="ewogICJwcmVmaXgiOiAiMTIzIgp9")
        service_secret = docker.Secret("service_secret",
            name="tftest-mysecret",
            data="ewogICJrZXkiOiAiUVdFUlRZIgp9")
        test_network = docker.Network("test_network",
            name="tftest-network",
            driver="overlay")
        foo = docker.Service("foo",
            name="tftest-service-basic",
            task_spec={
                "container_spec": {
                    "configs": [
                        {
                            "config_id": service_config.id,
                            "config_name": service_config.name,
                            "file_name": "/configs.json",
                        },
                        {},
                    ],
                    "secrets": [
                        {
                            "secret_id": service_secret.id,
                            "secret_name": service_secret.name,
                            "file_name": "/secrets.json",
                            "file_uid": "0",
                            "file_gid": "0",
                            "file_mode": 777,
                        },
                        {},
                    ],
                    "image": "repo.mycompany.com:8080/foo-service:v1",
                    "labels": [{
                        "label": "foo.bar",
                        "value": "baz",
                    }],
                    "commands": ["ls"],
                    "args": ["-las"],
                    "hostname": "my-fancy-service",
                    "env": {
                        "MYFOO": "BAR",
                    },
                    "dir": "/root",
                    "user": "root",
                    "groups": [
                        "docker",
                        "foogroup",
                    ],
                    "privileges": {
                        "se_linux_context": {
                            "disable": True,
                            "user": "user-label",
                            "role": "role-label",
                            "type": "type-label",
                            "level": "level-label",
                        },
                    },
                    "read_only": True,
                    "mounts": [
                        {
                            "target": "/mount/test",
                            "source": test_volume.name,
                            "type": "bind",
                            "read_only": True,
                            "bind_options": {
                                "propagation": "rprivate",
                            },
                        },
                        {
                            "target": "/mount/test2",
                            "source": test_volume2.name,
                            "type": "volume",
                            "read_only": True,
                            "volume_options": {
                                "no_copy": True,
                                "labels": [{
                                    "label": "foo",
                                    "value": "bar",
                                }],
                                "driver_name": "random-driver",
                                "driver_options": {
                                    "op1": "val1",
                                },
                            },
                        },
                    ],
                    "stop_signal": "SIGTERM",
                    "stop_grace_period": "10s",
                    "healthcheck": {
                        "tests": [
                            "CMD",
                            "curl",
                            "-f",
                            "http://localhost:8080/health",
                        ],
                        "interval": "5s",
                        "timeout": "2s",
                        "retries": 4,
                    },
                    "hosts": [{
                        "host": "testhost",
                        "ip": "10.0.1.0",
                    }],
                    "dns_config": {
                        "nameservers": ["8.8.8.8"],
                        "searches": ["example.org"],
                        "options": ["timeout:3"],
                    },
                },
                "resources": {
                    "limits": {
                        "nano_cpus": 1000000,
                        "memory_bytes": 536870912,
                    },
                    "reservation": {
                        "nano_cpus": 1000000,
                        "memory_bytes": 536870912,
                        "generic_resources": {
                            "named_resources_specs": ["GPU=UUID1"],
                            "discrete_resources_specs": ["SSD=3"],
                        },
                    },
                },
                "restart_policy": {
                    "condition": "on-failure",
                    "delay": "3s",
                    "maxAttempts": 4,
                    "window": "10s",
                }[0],
                "placement": {
                    "constraints": ["node.role==manager"],
                    "prefs": ["spread=node.role.manager"],
                    "max_replicas": 1,
                },
                "force_update": 0,
                "runtime": "container",
                "networks": [test_network.id],
                "log_driver": {
                    "name": "json-file",
                    "options": {
                        "max-size": "10m",
                        "max-file": "3",
                    },
                },
            },
            mode={
                "replicated": {
                    "replicas": 2,
                },
            },
            update_config={
                "parallelism": 2,
                "delay": "10s",
                "failure_action": "pause",
                "monitor": "5s",
                "max_failure_ratio": "0.1",
                "order": "start-first",
            },
            rollback_config={
                "parallelism": 2,
                "delay": "5ms",
                "failure_action": "pause",
                "monitor": "10h",
                "max_failure_ratio": "0.9",
                "order": "stop-first",
            },
            endpoint_spec={
                "ports": [
                    {
                        "name": "random",
                        "protocol": "tcp",
                        "target_port": 8080,
                        "published_port": 8080,
                        "publish_mode": "ingress",
                    },
                    {},
                ],
                "mode": "vip",
            })
        ```

        ## Import

        !/bin/bash

        ```sh
        $ pulumi import docker:index/service:Service foo id
        ```

        ### Example

        Assuming you created a `service` as follows

        ```sh
        #!/bin/bash
        docker service create --name foo -p 8080:80 nginx
        # prints th ID
        4pcphbxkfn2rffhbhe6czytgi
        ```

        you provide the definition for the resource as follows

        ```python
        import pulumi
        import pulumi_docker as docker

        foo = docker.Service("foo",
            name="foo",
            task_spec={
                "container_spec": {
                    "image": "nginx",
                },
            },
            endpoint_spec={
                "ports": [{
                    "target_port": 80,
                    "published_port": 8080,
                }],
            })
        ```

        then the import command is as follows

        !/bin/bash

        ```sh
        $ pulumi import docker:index/service:Service foo 4pcphbxkfn2rffhbhe6czytgi
        ```


        :param str resource_name: The name of the resource.
        :param ServiceArgs args: The arguments to use to populate this resource's properties.
        :param pulumi.ResourceOptions opts: Options for the resource.
        """
        ...
    def __init__(__self__, resource_name: str, *args, **kwargs):
        resource_args, opts = _utilities.get_resource_args_opts(ServiceArgs, pulumi.ResourceOptions, *args, **kwargs)
        if resource_args is not None:
            __self__._internal_init(resource_name, opts, **resource_args.__dict__)
        else:
            __self__._internal_init(resource_name, *args, **kwargs)

    def _internal_init(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 auth: Optional[pulumi.Input[Union['ServiceAuthArgs', 'ServiceAuthArgsDict']]] = None,
                 converge_config: Optional[pulumi.Input[Union['ServiceConvergeConfigArgs', 'ServiceConvergeConfigArgsDict']]] = None,
                 endpoint_spec: Optional[pulumi.Input[Union['ServiceEndpointSpecArgs', 'ServiceEndpointSpecArgsDict']]] = None,
                 labels: Optional[pulumi.Input[Sequence[pulumi.Input[Union['ServiceLabelArgs', 'ServiceLabelArgsDict']]]]] = None,
                 mode: Optional[pulumi.Input[Union['ServiceModeArgs', 'ServiceModeArgsDict']]] = None,
                 name: Optional[pulumi.Input[_builtins.str]] = None,
                 rollback_config: Optional[pulumi.Input[Union['ServiceRollbackConfigArgs', 'ServiceRollbackConfigArgsDict']]] = None,
                 task_spec: Optional[pulumi.Input[Union['ServiceTaskSpecArgs', 'ServiceTaskSpecArgsDict']]] = None,
                 update_config: Optional[pulumi.Input[Union['ServiceUpdateConfigArgs', 'ServiceUpdateConfigArgsDict']]] = None,
                 __props__=None):
        opts = pulumi.ResourceOptions.merge(_utilities.get_resource_opts_defaults(), opts)
        if not isinstance(opts, pulumi.ResourceOptions):
            raise TypeError('Expected resource options to be a ResourceOptions instance')
        if opts.id is None:
            if __props__ is not None:
                raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
            __props__ = ServiceArgs.__new__(ServiceArgs)

            __props__.__dict__["auth"] = auth
            __props__.__dict__["converge_config"] = converge_config
            __props__.__dict__["endpoint_spec"] = endpoint_spec
            __props__.__dict__["labels"] = labels
            __props__.__dict__["mode"] = mode
            __props__.__dict__["name"] = name
            __props__.__dict__["rollback_config"] = rollback_config
            if task_spec is None and not opts.urn:
                raise TypeError("Missing required property 'task_spec'")
            __props__.__dict__["task_spec"] = task_spec
            __props__.__dict__["update_config"] = update_config
        super(Service, __self__).__init__(
            'docker:index/service:Service',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            auth: Optional[pulumi.Input[Union['ServiceAuthArgs', 'ServiceAuthArgsDict']]] = None,
            converge_config: Optional[pulumi.Input[Union['ServiceConvergeConfigArgs', 'ServiceConvergeConfigArgsDict']]] = None,
            endpoint_spec: Optional[pulumi.Input[Union['ServiceEndpointSpecArgs', 'ServiceEndpointSpecArgsDict']]] = None,
            labels: Optional[pulumi.Input[Sequence[pulumi.Input[Union['ServiceLabelArgs', 'ServiceLabelArgsDict']]]]] = None,
            mode: Optional[pulumi.Input[Union['ServiceModeArgs', 'ServiceModeArgsDict']]] = None,
            name: Optional[pulumi.Input[_builtins.str]] = None,
            rollback_config: Optional[pulumi.Input[Union['ServiceRollbackConfigArgs', 'ServiceRollbackConfigArgsDict']]] = None,
            task_spec: Optional[pulumi.Input[Union['ServiceTaskSpecArgs', 'ServiceTaskSpecArgsDict']]] = None,
            update_config: Optional[pulumi.Input[Union['ServiceUpdateConfigArgs', 'ServiceUpdateConfigArgsDict']]] = None) -> 'Service':
        """
        Get an existing Service resource's state with the given name, id, and optional extra
        properties used to qualify the lookup.

        :param str resource_name: The unique name of the resulting resource.
        :param pulumi.Input[str] id: The unique provider ID of the resource to lookup.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[Union['ServiceAuthArgs', 'ServiceAuthArgsDict']] auth: Configuration for the authentication for pulling the images of the service
        :param pulumi.Input[Union['ServiceConvergeConfigArgs', 'ServiceConvergeConfigArgsDict']] converge_config: A configuration to ensure that a service converges aka reaches the desired that of all task up and running
        :param pulumi.Input[Union['ServiceEndpointSpecArgs', 'ServiceEndpointSpecArgsDict']] endpoint_spec: Properties that can be configured to access and load balance a service
        :param pulumi.Input[Sequence[pulumi.Input[Union['ServiceLabelArgs', 'ServiceLabelArgsDict']]]] labels: User-defined key/value metadata
        :param pulumi.Input[Union['ServiceModeArgs', 'ServiceModeArgsDict']] mode: Scheduling mode for the service
        :param pulumi.Input[_builtins.str] name: Name of the service
        :param pulumi.Input[Union['ServiceRollbackConfigArgs', 'ServiceRollbackConfigArgsDict']] rollback_config: Specification for the rollback strategy of the service
        :param pulumi.Input[Union['ServiceTaskSpecArgs', 'ServiceTaskSpecArgsDict']] task_spec: User modifiable task configuration
        :param pulumi.Input[Union['ServiceUpdateConfigArgs', 'ServiceUpdateConfigArgsDict']] update_config: Specification for the update strategy of the service
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = _ServiceState.__new__(_ServiceState)

        __props__.__dict__["auth"] = auth
        __props__.__dict__["converge_config"] = converge_config
        __props__.__dict__["endpoint_spec"] = endpoint_spec
        __props__.__dict__["labels"] = labels
        __props__.__dict__["mode"] = mode
        __props__.__dict__["name"] = name
        __props__.__dict__["rollback_config"] = rollback_config
        __props__.__dict__["task_spec"] = task_spec
        __props__.__dict__["update_config"] = update_config
        return Service(resource_name, opts=opts, __props__=__props__)

    @_builtins.property
    @pulumi.getter
    def auth(self) -> pulumi.Output[Optional['outputs.ServiceAuth']]:
        """
        Configuration for the authentication for pulling the images of the service
        """
        return pulumi.get(self, "auth")

    @_builtins.property
    @pulumi.getter(name="convergeConfig")
    def converge_config(self) -> pulumi.Output[Optional['outputs.ServiceConvergeConfig']]:
        """
        A configuration to ensure that a service converges aka reaches the desired that of all task up and running
        """
        return pulumi.get(self, "converge_config")

    @_builtins.property
    @pulumi.getter(name="endpointSpec")
    def endpoint_spec(self) -> pulumi.Output['outputs.ServiceEndpointSpec']:
        """
        Properties that can be configured to access and load balance a service
        """
        return pulumi.get(self, "endpoint_spec")

    @_builtins.property
    @pulumi.getter
    def labels(self) -> pulumi.Output[Sequence['outputs.ServiceLabel']]:
        """
        User-defined key/value metadata
        """
        return pulumi.get(self, "labels")

    @_builtins.property
    @pulumi.getter
    def mode(self) -> pulumi.Output['outputs.ServiceMode']:
        """
        Scheduling mode for the service
        """
        return pulumi.get(self, "mode")

    @_builtins.property
    @pulumi.getter
    def name(self) -> pulumi.Output[_builtins.str]:
        """
        Name of the service
        """
        return pulumi.get(self, "name")

    @_builtins.property
    @pulumi.getter(name="rollbackConfig")
    def rollback_config(self) -> pulumi.Output[Optional['outputs.ServiceRollbackConfig']]:
        """
        Specification for the rollback strategy of the service
        """
        return pulumi.get(self, "rollback_config")

    @_builtins.property
    @pulumi.getter(name="taskSpec")
    def task_spec(self) -> pulumi.Output['outputs.ServiceTaskSpec']:
        """
        User modifiable task configuration
        """
        return pulumi.get(self, "task_spec")

    @_builtins.property
    @pulumi.getter(name="updateConfig")
    def update_config(self) -> pulumi.Output[Optional['outputs.ServiceUpdateConfig']]:
        """
        Specification for the update strategy of the service
        """
        return pulumi.get(self, "update_config")

