Exemple #1
0
def update_pool(
        client,
        pool_id,
        json_file=None,
        start_task_command_line=None,  # pylint:disable=too-many-arguments
        certificate_references=None,
        application_package_references=None,
        metadata=None,
        start_task_run_elevated=None,
        start_task_environment_settings=None,
        start_task_wait_for_success=None,
        start_task_max_task_retry_count=None):
    def action():
        client.update_properties(pool_id=pool_id,
                                 pool_update_properties_parameter=param)
        return client.get(pool_id)

    if json_file:
        with open(json_file) as f:
            json_obj = json.load(f)
            param = None
            try:
                param = client._deserialize('PoolUpdatePropertiesParameter',
                                            json_obj)  # pylint: disable=protected-access
            except DeserializationError:
                pass
            if not param:
                raise ValueError(
                    "JSON file '{}' is not in correct format.".format(
                        json_file))

            if param.certificate_references is None:
                param.certificate_references = []
            if param.metadata is None:
                param.metadata = []
            if param.application_package_references is None:
                param.application_package_references = []
    else:
        if certificate_references is None:
            certificate_references = []
        if metadata is None:
            metadata = []
        if application_package_references is None:
            application_package_references = []
        param = PoolUpdatePropertiesParameter(certificate_references,
                                              application_package_references,
                                              metadata)

        if start_task_command_line:
            param.start_task = StartTask(
                start_task_command_line,
                environment_settings=start_task_environment_settings,
                run_elevated=start_task_run_elevated,
                wait_for_success=start_task_wait_for_success,
                max_task_retry_count=start_task_max_task_retry_count)
    return _handle_batch_exception(action)
Exemple #2
0
def update_pool(
    client,
    pool_id,
    json_file=None,
    start_task_command_line=None,  # pylint:disable=too-many-arguments
    certificate_references=None,
    application_package_references=None,
    metadata=None,
    start_task_run_elevated=None,
    start_task_environment_settings=None,
    start_task_wait_for_success=None,
    start_task_max_task_retry_count=None,
):
    def action():
        client.update_properties(pool_id=pool_id, pool_update_properties_parameter=param)
        return client.get(pool_id)

    if json_file:
        with open(json_file) as f:
            json_obj = json.load(f)
            param = None
            try:
                param = client._deserialize(
                    "PoolUpdatePropertiesParameter", json_obj
                )  # pylint: disable=protected-access
            except DeserializationError:
                pass
            if not param:
                raise ValueError("JSON file '{}' is not in correct format.".format(json_file))

            if param.certificate_references is None:
                param.certificate_references = []
            if param.metadata is None:
                param.metadata = []
            if param.application_package_references is None:
                param.application_package_references = []
    else:
        if certificate_references is None:
            certificate_references = []
        if metadata is None:
            metadata = []
        if application_package_references is None:
            application_package_references = []
        param = PoolUpdatePropertiesParameter(certificate_references, application_package_references, metadata)

        if start_task_command_line:
            param.start_task = StartTask(
                start_task_command_line,
                environment_settings=start_task_environment_settings,
                run_elevated=start_task_run_elevated,
                wait_for_success=start_task_wait_for_success,
                max_task_retry_count=start_task_max_task_retry_count,
            )
    return _handle_batch_exception(action)
Exemple #3
0
def update_pool(client,
                pool_id,
                json_file=None,
                start_task_command_line=None,
                certificate_references=None,
                application_package_references=None,
                metadata=None,
                start_task_environment_settings=None,
                start_task_wait_for_success=None,
                start_task_max_task_retry_count=None):
    if json_file:
        with open(json_file) as f:
            json_obj = json.load(f)
            param = None
            try:
                param = PoolUpdatePropertiesParameter.from_dict(json_obj)
            except DeserializationError:
                pass
            if not param:
                raise ValueError(
                    "JSON file '{}' is not in correct format.".format(
                        json_file))

            if param.certificate_references is None:
                param.certificate_references = []
            if param.metadata is None:
                param.metadata = []
            if param.application_package_references is None:
                param.application_package_references = []
    else:
        if certificate_references is None:
            certificate_references = []
        if metadata is None:
            metadata = []
        if application_package_references is None:
            application_package_references = []
        param = PoolUpdatePropertiesParameter(certificate_references,
                                              application_package_references,
                                              metadata)

        if start_task_command_line:
            param.start_task = StartTask(
                start_task_command_line,
                environment_settings=start_task_environment_settings,
                wait_for_success=start_task_wait_for_success,
                max_task_retry_count=start_task_max_task_retry_count)
    client.update_properties(pool_id=pool_id,
                             pool_update_properties_parameter=param)
    return client.get(pool_id)
Exemple #4
0
def update_pool(client,
                pool_id, json_file=None, start_task_command_line=None, certificate_references=None,
                application_package_references=None, metadata=None,
                start_task_environment_settings=None, start_task_wait_for_success=None,
                start_task_max_task_retry_count=None):
    if json_file:
        json_obj = get_file_json(json_file)
        param = None
        try:
            param = PoolUpdatePropertiesParameter.from_dict(json_obj)
        except DeserializationError:
            pass
        if not param:
            raise ValueError("JSON file '{}' is not in correct format.".format(json_file))

        if param.certificate_references is None:
            param.certificate_references = []
        if param.metadata is None:
            param.metadata = []
        if param.application_package_references is None:
            param.application_package_references = []
    else:
        if certificate_references is None:
            certificate_references = []
        if metadata is None:
            metadata = []
        if application_package_references is None:
            application_package_references = []
        param = PoolUpdatePropertiesParameter(
            certificate_references=certificate_references,
            application_package_references=application_package_references,
            metadata=metadata)

        if start_task_command_line:
            param.start_task = StartTask(command_line=start_task_command_line,
                                         environment_settings=start_task_environment_settings,
                                         wait_for_success=start_task_wait_for_success,
                                         max_task_retry_count=start_task_max_task_retry_count)
    client.update_properties(pool_id=pool_id, pool_update_properties_parameter=param)
    return client.get(pool_id)