def update()

in src/sfctl/custom_service.py [0:0]


def update(client, service_id, stateless=False, stateful=False,  # pylint: disable=too-many-locals,too-many-arguments
           constraints=None, correlation=None, correlated_service=None,
           load_metrics=None, placement_policy_list=None,
           move_cost=None, instance_count=None, target_replica_set_size=None,
           min_replica_set_size=None, replica_restart_wait=None,
           quorum_loss_wait=None, stand_by_replica_keep=None, timeout=60,
           scaling_policies=None, service_placement_time=None,
           tags_required_to_place=None, tags_required_to_run=None):
    """
    Updates the specified service using the given update description.
    :param str service_id: The identity of the service. This is typically the
    full name of the service without the 'fabric:' URI scheme. Starting from
    version 6.0, hierarchical names are delimited with the "~" character. For
    example, if the service name is 'fabric:/myapp/app1/svc1', the service
    identity would be 'myapp~app1~svc1' in 6.0+ and 'myapp/app1/svc1' in
    previous versions.
    :param bool stateless: Indicates the target service is a stateless service.
    :param bool stateful: Indicates the target service is a stateful service.
    :param str constraints: The placement constraints as a string. Placement
    constraints are boolean expressions on node properties and allow for
    restricting a service to particular nodes based on the service
    requirements. For example, to place a service on nodes where NodeType is
    blue specify the following: "NodeColor == blue".
    :param str correlation: Correlate the service with an existing service
    using an alignment affinity. Possible values include: 'Invalid',
    'Affinity', 'AlignedAffinity', 'NonAlignedAffinity'.
    :param str correlated_service: Name of the target service to correlate
    with.
    :param str load_metrics: JSON encoded list of metrics
    used when load balancing across nodes.
    :param str placement_policy_list: JSON encoded list of placement policies
    for the service, and any associated domain names. Policies can be one or
    more of: `NonPartiallyPlaceService`, `PreferPrimaryDomain`,
    `RequireDomain`, `RequireDomainDistribution`.
    :param str move_cost: Specifies the move cost for the service. Possible
    values are: 'Zero', 'Low', 'Medium', 'High', 'VeryHigh'.
    :param int instance_count: The instance count. This applies to stateless
    services only.
    :param int target_replica_set_size: The target replica set size as a
    number. This applies to stateful services only.
    :param int min_replica_set_size: The minimum replica set size as a number.
    This applies to stateful services only.
    :param str replica_restart_wait: The duration, in seconds, between when a
    replica goes down and when a new replica is created. This applies to
    stateful services only.
    :param str quorum_loss_wait: The maximum duration, in seconds, for which a
    partition is allowed to be in a state of quorum loss. This applies to
    stateful services only.
    :param str stand_by_replica_keep: The maximum duration, in seconds,  for
    which StandBy replicas will be maintained before being removed. This
    applies to stateful services only.
    :param str scaling_policies: JSON encoded list of scaling policies for this service.
    :param list of str tags_required_to_place: JSON encoded list of tags to
    require to place the service, if using node tagging feature
    :param list of str tags_required_to_run: JSON encoded list of tags to
    require to run the service, if using node tagging feature
    :param int service_placement_time: The duration for which replicas can stay
    InBuild before reporting that build is stuck. This
    applies to stateful services only.
    """
    from azure.servicefabric.models import (StatefulServiceUpdateDescription,
                                            StatelessServiceUpdateDescription)

    validate_update_service_params(stateless, stateful,
                                   target_replica_set_size,
                                   min_replica_set_size, replica_restart_wait,
                                   quorum_loss_wait, stand_by_replica_keep,
                                   instance_count, service_placement_time)

    cor_desc = correlation_desc(correlated_service, correlation)
    metric_desc = parse_load_metrics(load_metrics)
    place_desc = parse_placement_policies(placement_policy_list)
    validate_move_cost(move_cost)
    scaling_policy_description = parse_scaling_policy(scaling_policies)
    tags_required_to_place_description = parse_service_tags(tags_required_to_place)
    tags_required_to_run_description = parse_service_tags(tags_required_to_run)

    flags = service_update_flags(target_replica_set_size, instance_count,
                                 replica_restart_wait, quorum_loss_wait,
                                 stand_by_replica_keep, min_replica_set_size,
                                 constraints, place_desc, cor_desc,
                                 metric_desc, move_cost, scaling_policy_description,
                                 service_placement_time)

    update_desc = None
    if stateful:
        update_desc = StatefulServiceUpdateDescription(
            flags=flags,
            placement_constraints=constraints,
            correlation_scheme=cor_desc,
            load_metrics=metric_desc,
            service_placement_policies=place_desc,
            default_move_cost=move_cost,
            scaling_policies=scaling_policy_description,
            target_replica_set_size=target_replica_set_size,
            min_replica_set_size=min_replica_set_size,
            replica_restart_wait_duration_seconds=replica_restart_wait,
            quorum_loss_wait_duration_seconds=quorum_loss_wait,
            stand_by_replica_keep_duration_seconds=stand_by_replica_keep,
            service_placement_time_limit_seconds=service_placement_time,
            tags_required_to_place=tags_required_to_place_description,
            tags_required_to_run=tags_required_to_run_description)

    if stateless:
        update_desc = StatelessServiceUpdateDescription(flags=flags,
                                                        placement_constraints=constraints,
                                                        correlation_scheme=cor_desc,
                                                        load_metrics=metric_desc,
                                                        service_placement_policies=place_desc,
                                                        default_move_cost=move_cost,
                                                        scaling_policies=scaling_policy_description,
                                                        instance_count=instance_count,
                                                        tags_required_to_place=tags_required_to_place_description,
                                                        tags_required_to_run=tags_required_to_run_description)

    client.update_service(service_id, update_desc, timeout)