text:
<#
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the MIT License. See License.txt in the project root for license information.
#>

<#
.SYNOPSIS
    Shut down an infrastructure role instance.

.DESCRIPTION
    Shut down an infrastructure role instance.

.PARAMETER Name
    Name of an infrastructure role instance.

.PARAMETER Location
    Location of the resource.

.PARAMETER ResourceGroupName
    Resource group in which the resource provider has been registered.

.PARAMETER ResourceId
    Infrastructure role instance resource ID.

.PARAMETER AsJob
    Run asynchronous as a job and return the job object.

.PARAMETER Force
    Don't ask for confirmation

.EXAMPLE

    PS C:\> Suspend-AzsInfrastructureRoleInstance -Name "AzS-ACS01"

    Shut down an infrastructure role instance. On failure an exception is thrown.

#>
function Suspend-AzsInfrastructureRoleInstance {
    [CmdletBinding(DefaultParameterSetName = 'Shutdown', SupportsShouldProcess = $true)]
    param(
        [Parameter(Mandatory = $true, ParameterSetName = 'Shutdown')]
        [ValidateNotNullOrEmpty()]
        [System.String]
        $Name,

        [Parameter(Mandatory = $false, ParameterSetName = 'Shutdown')]
        [System.String]
        $Location,

        [Parameter(Mandatory = $false, ParameterSetName = 'Shutdown')]
        [ValidateLength(1, 90)]
        [System.String]
        $ResourceGroupName,

        [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'ResourceId')]
        [Alias('id')]
        [ValidateNotNullOrEmpty()]
        [System.String]
        $ResourceId,

        [Parameter(Mandatory = $false)]
        [switch]
        $AsJob,

        [Parameter(Mandatory = $false)]
        [switch]
        $Force
    )

    Begin {
        Initialize-PSSwaggerDependencies -Azure
        $tracerObject = $null
        if (('continue' -eq $DebugPreference) -or ('inquire' -eq $DebugPreference)) {
            $oldDebugPreference = $global:DebugPreference
            $global:DebugPreference = "continue"
            $tracerObject = New-PSSwaggerClientTracing
            Register-PSSwaggerClientTracing -TracerObject $tracerObject
        }
    }

    Process {

        if ('ResourceId' -eq $PsCmdlet.ParameterSetName) {
            $GetArmResourceIdParameterValue_params = @{
                IdTemplate = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fabric.Admin/fabricLocations/{location}/infraRoleInstances/{infraRoleInstance}'
            }

            $GetArmResourceIdParameterValue_params['Id'] = $ResourceId
            $ArmResourceIdParameterValues = Get-ArmResourceIdParameterValue @GetArmResourceIdParameterValue_params

            $ResourceGroupName = $ArmResourceIdParameterValues['resourceGroupName']
            $Location = $ArmResourceIdParameterValues['location']
            $Name = $ArmResourceIdParameterValues['infraRoleInstance']
        } else {
            $Name = Get-ResourceNameSuffix -ResourceName $Name
        }

        if ($PSCmdlet.ShouldProcess("$Name" , "Disable infrastructure role instance")) {
            if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Disable infrastructure role instance?", "Performing operation disable infrastructure role instance for $Name")) {

                $NewServiceClient_params = @{
                    FullClientTypeName = 'Microsoft.AzureStack.Management.Fabric.Admin.FabricAdminClient'
                }

                $GlobalParameterHashtable = @{}
                $NewServiceClient_params['GlobalParameterHashtable'] = $GlobalParameterHashtable

                $GlobalParameterHashtable['SubscriptionId'] = $null
                if ($PSBoundParameters.ContainsKey('SubscriptionId')) {
                    $GlobalParameterHashtable['SubscriptionId'] = $PSBoundParameters['SubscriptionId']
                }

                $FabricAdminClient = New-ServiceClient @NewServiceClient_params

                if ([System.String]::IsNullOrEmpty($Location)) {
                    $Location = (Get-AzureRMLocation).Location
                }
                if ([System.String]::IsNullOrEmpty($ResourceGroupName)) {
                    $ResourceGroupName = "System.$Location"
                }

                if ('Shutdown' -eq $PsCmdlet.ParameterSetName -or 'ResourceId' -eq $PsCmdlet.ParameterSetName) {
                    Write-Verbose -Message 'Performing operation ShutdownWithHttpMessagesAsync on $FabricAdminClient.'
                    $TaskResult = $FabricAdminClient.InfraRoleInstances.ShutdownWithHttpMessagesAsync($ResourceGroupName, $Location, $Name)
                } else {
                    Write-Verbose -Message 'Failed to map parameter set to operation method.'
                    throw 'Module failed to find operation to execute.'
                }

                Write-Verbose -Message "Waiting for the operation to complete."

                $PSSwaggerJobScriptBlock = {
                    [CmdletBinding()]
                    param(
                        [Parameter(Mandatory = $true)]
                        [System.Threading.Tasks.Task]
                        $TaskResult,

                        [Parameter(Mandatory = $true)]
                        [System.String]
                        $TaskHelperFilePath
                    )
                    if ($TaskResult) {
                        . $TaskHelperFilePath
                        $GetTaskResult_params = @{
                            TaskResult = $TaskResult
                        }

                        Get-TaskResult @GetTaskResult_params

                    }
                }

                $PSCommonParameters = Get-PSCommonParameter -CallerPSBoundParameters $PSBoundParameters
                $TaskHelperFilePath = Join-Path -Path $ExecutionContext.SessionState.Module.ModuleBase -ChildPath 'Get-TaskResult.ps1'
                if (-not $AsJob.IsPresent) {
                    Invoke-Command -ScriptBlock $PSSwaggerJobScriptBlock `
                        -ArgumentList $TaskResult, $TaskHelperFilePath `
                        @PSCommonParameters
                } else {
                    $ScriptBlockParameters = New-Object -TypeName 'System.Collections.Generic.Dictionary[string,object]'
                    $ScriptBlockParameters['TaskResult'] = $TaskResult
                    $ScriptBlockParameters['AsJob'] = $true
                    $ScriptBlockParameters['TaskHelperFilePath'] = $TaskHelperFilePath
                    $PSCommonParameters.GetEnumerator() | ForEach-Object { $ScriptBlockParameters[$_.Name] = $_.Value }

                    Start-PSSwaggerJobHelper -ScriptBlock $PSSwaggerJobScriptBlock `
                        -CallerPSBoundParameters $ScriptBlockParameters `
                        -CallerPSCmdlet $PSCmdlet `
                        @PSCommonParameters
                }
            }
        }
    }

    End {
        if ($tracerObject) {
            $global:DebugPreference = $oldDebugPreference
            Unregister-PSSwaggerClientTracing -TracerObject $tracerObject
        }
    }
}


text:
<?php

/**
 * Defines the interface for all persistent object definition managers.
 *
 * Definition managers are used to fetch the definition of a specific
 * persistent object. The definition is returned in form of a
 * ezcPersistentObjectDefinition structure.
 *
 * @version //autogen//
 * @package PersistentObject
 */
abstract class ezcPersistentDefinitionManager
{
    /**
     * Returns the definition of the persistent object with the class $class.
     *
     * @throws ezcPersistentDefinitionNotFoundException if no such definition can be found.
     * @param string $class
     * @return ezcPersistentObjectDefinition
     */
    public abstract function fetchDefinition( $class );

    // public function storeDefinition( ezcPersistentObjectDefinition $def );

    /**
     * Returns the definition $def with the reverse relations field correctly set up.
     *
     * This method will go through all of the properties in the definition and set up
     * the columns field in the definition.
     *
     * @param ezcPersistentObjectDefinition $def The target persistent object definition.
     * @return ezcPersistentObjectDefinition
     */
    protected static function setupReversePropertyDefinition( ezcPersistentObjectDefinition $def )
    {
        foreach ( $def->properties as $field )
        {
            $def->columns[$field->resultColumnName] = $field;
        }
        if ( isset( $def->idProperty ) && $def->idProperty->columnName !== null )
        {
            $def->columns[$def->idProperty->resultColumnName] = $def->idProperty;
        }
        return $def;
    }
}
?>

redpajama_set_name: RedPajamaGithub


text:
``attrs`` by Example
====================

Basics
------

The simplest possible usage is:

.. doctest::

   >>> from attrs import define, field
   >>> @define
   ... class Empty:
   ...     pass
   >>> Empty()
   Empty()
   >>> Empty() == Empty()
   True
   >>> Empty() is Empty()
   False

So in other words: ``attrs`` is useful even without actual attributes!

But you'll usually want some data on your classes, so let's add some:

.. doctest::

   >>> @define
   ... class Coordinates:
   ...     x: int
   ...     y: int

By default, all features are added, so you immediately have a fully functional data class with a nice ``repr`` string and comparison methods.

.. doctest::

   >>> c1 = Coordinates(1, 2)
   >>> c1
   Coordinates(x=1, y=2)
   >>> c2 = Coordinates(x=2, y=1)
   >>> c2
   Coordinates(x=2, y=1)
   >>> c1 == c2
   False

As shown, the generated ``__init__`` method allows for both positional and keyword arguments.

For private attributes, ``attrs`` will strip the leading underscores for keyword arguments:

.. doctest::

   >>> @define
   ... class C:
   ...     _x: int
   >>> C(x=1)
   C(_x=1)

If you want to initialize your private attributes yourself, you can do that too:

.. doctest::

   >>> @define
   ... class C:
   ...     _x: int = field(init=False, default=42)
   >>> C()
   C(_x=42)
   >>> C(23)
   Traceback (most recent call last):
      ...
   TypeError: __init__() takes exactly 1 argument (2 given)

An additional way of defining attributes is supported too.
This is useful in times when you want to enhance classes that are not yours (nice ``__repr__`` for Django models anyone?):

.. doctest::

   >>> class SomethingFromSomeoneElse:
   ...     def __init__(self, x):
   ...         self.x = x
   >>> SomethingFromSomeoneElse = define(
   ...     these={
   ...         "x": field()
   ...     }, init=False)(SomethingFromSomeoneElse)
   >>> SomethingFromSomeoneElse(1)
   SomethingFromSomeoneElse(x=1)

`Subclassing is bad for you <https://www.youtube.com/watch?v=3MNVP9-hglc>`_, but ``attrs`` will still do what you'd hope for:

.. doctest::

   >>> @define(slots=False)
   ... class A:
   ...     a: int
   ...     def get_a(self):
   ...         return self.a
   >>> @define(slots=False)
   ... class B:
   ...     b: int
   >>> @define(slots=False)
   ... class C(B, A):
   ...     c: int
   >>> i = C(1, 2, 3)
   >>> i
   C(a=1, b=2, c=3)
   >>> i == C(1, 2, 3)
   True
   >>> i.get_a()
   1

:term:`Slotted classes <slotted classes>`, which are the default for the new APIs, don't play well with multiple inheritance so we don't use them in the example.

The order of the attributes is defined by the `MRO <https://www.python.org/download/releases/2.3/mro/>`_.

Keyword-only Attributes
~~~~~~~~~~~~~~~~~~~~~~~

You can also add `keyword-only <https://docs.python.org/3/glossary.html#keyword-only-parameter>`_ attributes:

.. doctest::

    >>> @define
    ... class A:
    ...     a: int = field(kw_only=True)
    >>> A()
    Traceback (most recent call last):
      ...
    TypeError: A() missing 1 required keyword-only argument: 'a'
    >>> A(a=1)
    A(a=1)

``kw_only`` may also be specified at via ``define``, and will apply to all attributes:

.. doctest::

    >>> @define(kw_only=True)
    ... class A:
    ...     a: int
    ...     b: int
    >>> A(1, 2)
    Traceback (most recent call last):
      ...
    TypeError: __init__() takes 1 positional argument but 3 were given
    >>> A(a=1, b=2)
    A(a=1, b=2)

If you create an attribute with ``init=False``, the ``kw_only`` argument is ignored.

Keyword-only attributes allow subclasses to add attributes without default values, even if the base class defines attributes with default values:

.. doctest::

    >>> @define
    ... class A:
    ...     a: int = 0
    >>> @define
    ... class B(A):
    ...     b: int = field(kw_only=True)
    >>> B(b=1)
    B(a=0, b=1)
    >>> B()
    Traceback (most recent call last):
      ...
    TypeError: B() missing 1 required keyword-only argument: 'b'

If you don't set ``kw_only=True``, then there is no valid attribute ordering, and you'll get an error:

.. doctest::

    >>> @define
    ... class A:
    ...     a: int = 0
    >>> @define
    ... class B(A):
    ...     b: int
    Traceback (most recent call last):
      ...
    ValueError: No mandatory attributes allowed after an attribute with a default value or factory.  Attribute in question: Attribute(name='b', default=NOTHING, validator=None, repr=True, cmp=True, hash=None, init=True, converter=None, metadata=mappingproxy({}), type=int, kw_only=False)

.. _asdict:

Converting to Collections Types
-------------------------------

When you have a class with data, it often is very convenient to transform that class into a `dict` (for example if you want to serialize it to JSON):

.. doctest::

   >>> from attrs import asdict

   >>> asdict(Coordinates(x=1, y=2))
   {'x': 1, 'y': 2}

Some fields cannot or should not be transformed.
For that, `attrs.asdict` offers a callback that decides whether an attribute should be included:

.. doctest::

   >>> @define
   ... class User:
   ...     email: str
   ...     password: str

   >>> @define
   ... class UserList:
   ...     users: list[User]

   >>> asdict(UserList([User("jane@doe.invalid", "s33kred"),
   ...                  User("joe@doe.invalid", "p4ssw0rd")]),
   ...        filter=lambda attr, value: attr.name != "password")
   {'users': [{'email': 'jane@doe.invalid'}, {'email': 'joe@doe.invalid'}]}

For the common case where you want to `include <attr.filters.include>` or `exclude <attr.filters.exclude>` certain types or attributes, ``attrs`` ships with a few helpers:

.. doctest::

   >>> from attrs import asdict, filters, fields

   >>> @define
   ... class User:
   ...     login: str
   ...     password: str
   ...     id: int

   >>> asdict(
   ...     User("jane", "s33kred", 42),
   ...     filter=filters.exclude(fields(User).password, int))
   {'login': 'jane'}

   >>> @define
   ... class C:
   ...     x: str
   ...     y: str
   ...     z: int

   >>> asdict(C("foo", "2", 3),
   ...        filter=filters.include(int, fields(C).x))
   {'x': 'foo', 'z': 3}

Other times, all you want is a tuple and ``attrs`` won't let you down:

.. doctest::

   >>> import sqlite3
   >>> from attrs import astuple

   >>> @define
   ... class Foo:
   ...    a: int
   ...    b: int

   >>> foo = Foo(2, 3)
   >>> with sqlite3.connect(":memory:") as conn:
   ...    c = conn.cursor()
   ...    c.execute("CREATE TABLE foo (x INTEGER PRIMARY KEY ASC, y)") #doctest: +ELLIPSIS
   ...    c.execute("INSERT INTO foo VALUES (?, ?)", astuple(foo)) #doctest: +ELLIPSIS
   ...    foo2 = Foo(*c.execute("SELECT x, y FROM foo").fetchone())
   <sqlite3.Cursor object at ...>
   <sqlite3.Cursor object at ...>
   >>> foo == foo2
   True

For more advanced transformations and conversions, we recommend you look at a companion library (such as `cattrs <https://github.com/python-attrs/cattrs>`_).

Defaults
--------

Sometimes you want to have default values for your initializer.
And sometimes you even want mutable objects as default values (ever accidentally used ``def f(arg=[])``?).
``attrs`` has you covered in both cases:

.. doctest::

   >>> import collections

   >>> @define
   ... class Connection:
   ...     socket: int
   ...     @classmethod
   ...     def connect(cls, db_string):
   ...        # ... connect somehow to db_string ...
   ...        return cls(socket=42)

   >>> @define
   ... class ConnectionPool:
   ...     db_string: str
   ...     pool: collections.deque = Factory(collections.deque)
   ...     debug: bool = False
   ...     def get_connection(self):
   ...         try:
   ...             return self.pool.pop()
   ...         except IndexError:
   ...             if self.debug:
   ...                 print("New connection!")
   ...             return Connection.connect(self.db_string)
   ...     def free_connection(self, conn):
   ...         if self.debug:
   ...             print("Connection returned!")
   ...         self.pool.appendleft(conn)
   ...
   >>> cp = ConnectionPool("postgres://localhost")
   >>> cp
   ConnectionPool(db_string='postgres://localhost', pool=deque([]), debug=False)
   >>> conn = cp.get_connection()
   >>> conn
   Connection(socket=42)
   >>> cp.free_connection(conn)
   >>> cp
   ConnectionPool(db_string='postgres://localhost', pool=deque([Connection(socket=42)]), debug=False)

More information on why class methods for constructing objects are awesome can be found in this insightful `blog post <https://web.archive.org/web/20210130220433/http://as.ynchrono.us/2014/12/asynchronous-object-initialization.html>`_.

Default factories can also be set using the ``factory`` argument to ``field``, and using a decorator.
The method receives the partially initialized instance which enables you to base a default value on other attributes:

.. doctest::

   >>> @define
   ... class C:
   ...     x: int = 1
   ...     y: int = field()
   ...     @y.default
   ...     def _any_name_except_a_name_of_an_attribute(self):
   ...         return self.x + 1
   ...     z: list = field(factory=list)
   >>> C()
   C(x=1, y=2, z=[])

Please keep in mind that the decorator approach *only* works if the attribute in question has a ``field`` assigned to it.
As a result, annotating an attribute with a type is *not* enough if you use ``@default``.

.. _examples_validators:

Validators
----------

Although your initializers should do as little as possible (ideally: just initialize your instance according to the arguments!), it can come in handy to do some kind of validation on the arguments.

``attrs`` offers two ways to define validators for each attribute and it's up to you to choose which one suits your style and project better.

You can use a decorator:

.. doctest::

   >>> @define
   ... class C:
   ...     x: int = field()
   ...     @x.validator
   ...     def check(self, attribute, value):
   ...         if value > 42:
   ...             raise ValueError("x must be smaller or equal to 42")
   >>> C(42)
   C(x=42)
   >>> C(43)
   Traceback (most recent call last):
      ...
   ValueError: x must be smaller or equal to 42

...or a callable...

.. doctest::

   >>> from attrs import validators

   >>> def x_smaller_than_y(instance, attribute, value):
   ...     if value >= instance.y:
   ...         raise ValueError("'x' has to be smaller than 'y'!")
   >>> @define
   ... class C:
   ...     x: int = field(validator=[validators.instance_of(int),
   ...                               x_smaller_than_y])
   ...     y: int
   >>> C(x=3, y=4)
   C(x=3, y=4)
   >>> C(x=4, y=3)
   Traceback (most recent call last):
      ...
   ValueError: 'x' has to be smaller than 'y'!

...or both at once:

.. doctest::

   >>> @define
   ... class C:
   ...     x: int = field(validator=validators.instance_of(int))
   ...     @x.validator
   ...     def fits_byte(self, attribute, value):
   ...         if not 0 <= value < 256:
   ...             raise ValueError("value out of bounds")
   >>> C(128)
   C(x=128)
   >>> C("128")
   Traceback (most recent call last):
      ...
   TypeError: ("'x' must be <class 'int'> (got '128' that is a <class 'str'>).", Attribute(name='x', default=NOTHING, validator=[<instance_of validator for type <class 'int'>>, <function fits_byte at 0x10fd7a0d0>], repr=True, cmp=True, hash=True, init=True, metadata=mappingproxy({}), type=int, converter=None, kw_only=False), <class 'int'>, '128')
   >>> C(256)
   Traceback (most recent call last):
      ...
   ValueError: value out of bounds

Please note that the decorator approach only works if -- and only if! -- the attribute in question has a ``field`` assigned.
Therefore if you use ``@validator``, it is *not* enough to annotate said attribute with a type.

``attrs`` ships with a bunch of validators, make sure to `check them out <api_validators>` before writing your own:

.. doctest::

   >>> @define
   ... class C:
   ...     x: int = field(validator=validators.instance_of(int))
   >>> C(42)
   C(x=42)
   >>> C("42")
   Traceback (most recent call last):
      ...
   TypeError: ("'x' must be <type 'int'> (got '42' that is a <type 'str'>).", Attribute(name='x', default=NOTHING, factory=NOTHING, validator=<instance_of validator for type <type 'int'>>, type=None, kw_only=False), <type 'int'>, '42')

Please note that if you use `attr.s` (and not `attrs.define`) to define your class, validators only run on initialization by default.
This behavior can be changed using the ``on_setattr`` argument.

Check out `validators` for more details.

Conversion
----------

Attributes can have a ``converter`` function specified, which will be called with the attribute's passed-in value to get a new value to use.
This can be useful for doing type-conversions on values that you don't want to force your callers to do.

.. doctest::

    >>> @define
    ... class C:
    ...     x: int = field(converter=int)
    >>> o = C("1")
    >>> o.x
    1

Please note that converters only run on initialization.

Check out `converters` for more details.

.. _metadata:

Metadata
--------

All ``attrs`` attributes may include arbitrary metadata in the form of a read-only dictionary.

.. doctest::

    >>> from attrs import fields

    >>> @define
    ... class C:
    ...    x = field(metadata={'my_metadata': 1})
    >>> fields(C).x.metadata
    mappingproxy({'my_metadata': 1})
    >>> fields(C).x.metadata['my_metadata']
    1

Metadata is not used by ``attrs``, and is meant to enable rich functionality in third-party libraries.
The metadata dictionary follows the normal dictionary rules: keys need to be hashable, and both keys and values are recommended to be immutable.

If you're the author of a third-party library with ``attrs`` integration, please see `Extending Metadata <extending_metadata>`.

Types
-----

``attrs`` also allows you to associate a type with an attribute using either the *type* argument to `attr.ib` or using :pep:`526`-annotations:

.. doctest::

   >>> from attrs import fields

   >>> @define
   ... class C:
   ...     x: int
   >>> fields(C).x.type
   <class 'int'>

   >>> import attr
   >>> @attr.s
   ... class C:
   ...     x = attr.ib(type=int)
   >>> fields(C).x.type
   <class 'int'>

If you don't mind annotating *all* attributes, you can even drop the `attrs.field` and assign default values instead:

.. doctest::

   >>> import typing
   >>> from attrs import fields

   >>> @define
   ... class AutoC:
   ...     cls_var: typing.ClassVar[int] = 5  # this one is ignored
   ...     l: list[int] = Factory(list)
   ...     x: int = 1
   ...     foo: str = "every attrib needs a type if auto_attribs=True"
   ...     bar: typing.Any = None
   >>> fields(AutoC).l.type
   list[int]
   >>> fields(AutoC).x.type
   <class 'int'>
   >>> fields(AutoC).foo.type
   <class 'str'>
   >>> fields(AutoC).bar.type
   typing.Any
   >>> AutoC()
   AutoC(l=[], x=1, foo='every attrib needs a type if auto_attribs=True', bar=None)
   >>> AutoC.cls_var
   5

The generated ``__init__`` method will have an attribute called ``__annotations__`` that contains this type information.

If your annotations contain strings (e.g. forward references),
you can resolve these after all references have been defined by using :func:`attrs.resolve_types`.
This will replace the *type* attribute in the respective fields.

.. doctest::

    >>> from attrs import fields, resolve_types

    >>> @define
    ... class A:
    ...     a: 'list[A]'
    ...     b: 'B'
    ...
    >>> @define
    ... class B:
    ...     a: A
    ...
    >>> fields(A).a.type
    'list[A]'
    >>> fields(A).b.type
    'B'
    >>> resolve_types(A, globals(), locals())
    <class 'A'>
    >>> fields(A).a.type
    list[A]
    >>> fields(A).b.type
    <class 'B'>

.. note::

   If you find yourself using string type annotations to handle forward references, wrap the entire type annotation in quotes instead of only the type you need a forward reference to (so ``'list[A]'`` instead of ``list['A']``).
   This is a limitation of the Python typing system.

.. warning::

   ``attrs`` itself doesn't have any features that work on top of type metadata *yet*.
   However it's useful for writing your own validators or serialization frameworks.

Slots
-----

:term:`Slotted classes <slotted classes>` have several advantages on CPython.
Defining ``__slots__`` by hand is tedious, in ``attrs`` it's just a matter of using `attrs.define` or passing ``slots=True`` to `attr.s`:

.. doctest::

   >>> import attr

   >>> @attr.s(slots=True)
   ... class Coordinates:
   ...     x: int
   ...     y: int

Immutability
------------

Sometimes you have instances that shouldn't be changed after instantiation.
Immutability is especially popular in functional programming and is generally a very good thing.
If you'd like to enforce it, ``attrs`` will try to help:

.. doctest::
   >>> from attrs import frozen

   >>> @frozen
   ... class C:
   ...     x: int
   >>> i = C(1)
   >>> i.x = 2
   Traceback (most recent call last):
      ...
   attr.exceptions.FrozenInstanceError: can't set attribute
   >>> i.x
   1

Please note that true immutability is impossible in Python but it will `get <how-frozen>` you 99% there.
By themselves, immutable classes are useful for long-lived objects that should never change; like configurations for example.

In order to use them in regular program flow, you'll need a way to easily create new instances with changed attributes.
In Clojure that function is called `assoc <https://clojuredocs.org/clojure.core/assoc>`_ and ``attrs`` shamelessly imitates it: `attr.evolve`:

.. doctest::

   >>> from attrs import evolve, frozen

   >>> @frozen
   ... class C:
   ...     x: int
   ...     y: int
   >>> i1 = C(1, 2)
   >>> i1
   C(x=1, y=2)
   >>> i2 = evolve(i1, y=3)
   >>> i2
   C(x=1, y=3)
   >>> i1 == i2
   False

Other Goodies
-------------

Sometimes you may want to create a class programmatically.
``attrs`` won't let you down and gives you `attrs.make_class` :

.. doctest::

   >>> from attrs import fields, make_class
   >>> @define
   ... class C1:
   ...     x = field()
   ...     y = field()
   >>> C2 = make_class("C2", ["x", "y"])
   >>> fields(C1) == fields(C2)
   True

You can still have power over the attributes if you pass a dictionary of name: ``field`` mappings and can pass arguments to ``@attr.s``:

.. doctest::

   >>> from attrs import make_class

   >>> C = make_class("C", {"x": field(default=42),
   ...                      "y": field(default=Factory(list))},
   ...                repr=False)
   >>> i = C()
   >>> i  # no repr added!
   <__main__.C object at ...>
   >>> i.x
   42
   >>> i.y
   []

If you need to dynamically make a class with `attrs.make_class` and it needs to be a subclass of something else than ``object``, use the ``bases`` argument:

.. doctest::

   >>> from attrs import make_class

   >>> class D:
   ...    def __eq__(self, other):
   ...        return True  # arbitrary example
   >>> C = make_class("C", {}, bases=(D,), cmp=False)
   >>> isinstance(C(), D)
   True

Sometimes, you want to have your class's ``__init__`` method do more than just
the initialization, validation, etc. that gets done for you automatically when
using ``@define``.
To do this, just define a ``__attrs_post_init__`` method in your class.
It will get called at the end of the generated ``__init__`` method.

.. doctest::

   >>> @define
   ... class C:
   ...     x: int
   ...     y: int
   ...     z: int = field(init=False)
   ...
   ...     def __attrs_post_init__(self):
   ...         self.z = self.x + self.y
   >>> obj = C(x=1, y=2)
   >>> obj
   C(x=1, y=2, z=3)

You can exclude single attributes from certain methods:

.. doctest::

   >>> @define
   ... class C:
   ...     user: str
   ...     password: str = field(repr=False)
   >>> C("me", "s3kr3t")
   C(user='me')

Alternatively, to influence how the generated ``__repr__()`` method formats a specific attribute, specify a custom callable to be used instead of the ``repr()`` built-in function:

.. doctest::

   >>> @define
   ... class C:
   ...     user: str
   ...     password: str = field(repr=lambda value: '***')
   >>> C("me", "s3kr3t")
   C(user='me', password=***)


text:
namespace vg {

//------------------------------------------------------------------------------

void load_gbwtgraph(gbwtgraph::GBWTGraph& graph, const std::string& filename, bool show_progress) {
    if (show_progress) {
        std::cerr << "Loading GBWTGraph from " << filename << std::endl;
    }
    std::unique_ptr<gbwtgraph::GBWTGraph> loaded = vg::io::VPKG::load_one<gbwtgraph::GBWTGraph>(filename);
    if (loaded.get() == nullptr) {
        std::cerr << "error: [load_gbwtgraph()] cannot load GBWTGraph " << filename << std::endl;
        std::exit(EXIT_FAILURE);
    }
    graph = std::move(*loaded);
}

void load_gbz(gbwtgraph::GBZ& gbz, const std::string& filename, bool show_progress) {
    if (show_progress) {
        std::cerr << "Loading GBZ from " << filename << std::endl;
    }
    std::unique_ptr<gbwtgraph::GBZ> loaded = vg::io::VPKG::load_one<gbwtgraph::GBZ>(filename);
    if (loaded.get() == nullptr) {
        std::cerr << "error: [load_gbz()] cannot load GBZ " << filename << std::endl;
        std::exit(EXIT_FAILURE);
    }
    gbz = std::move(*loaded);
}

void load_gbz(gbwt::GBWT& index, gbwtgraph::GBWTGraph& graph, const std::string& filename, bool show_progress) {
    if (show_progress) {
        std::cerr << "Loading GBWT and GBWTGraph from " << filename << std::endl;
    }
    std::unique_ptr<gbwtgraph::GBZ> loaded = vg::io::VPKG::load_one<gbwtgraph::GBZ>(filename);
    if (loaded.get() == nullptr) {
        std::cerr << "error: [load_gbz()] cannot load GBZ " << filename << std::endl;
        std::exit(EXIT_FAILURE);
    }
    index = std::move(loaded->index);
    graph = std::move(loaded->graph);
    graph.set_gbwt(index); // We moved the GBWT out from the GBZ, so we have to update the pointer.
}

void load_gbz(gbwtgraph::GBZ& gbz, const std::string& gbwt_name, const std::string& graph_name, bool show_progress) {
    gbz = gbwtgraph::GBZ();
    load_gbwt(gbz.index, gbwt_name, show_progress);
    load_gbwtgraph(gbz.graph, graph_name, show_progress);
    gbz.graph.set_gbwt(gbz.index); // We know the GBWT index corresponding to the graph.
}

void load_minimizer(gbwtgraph::DefaultMinimizerIndex& index, const std::string& filename, bool show_progress) {
    if (show_progress) {
        std::cerr << "Loading MinimizerIndex from " << filename << std::endl;
    }
    std::unique_ptr<gbwtgraph::DefaultMinimizerIndex> loaded = vg::io::VPKG::load_one<gbwtgraph::DefaultMinimizerIndex>(filename);
    if (loaded.get() == nullptr) {
        std::cerr << "error: [load_minimizer()] cannot load MinimizerIndex " << filename << std::endl;
        std::exit(EXIT_FAILURE);
    }
    index = std::move(*loaded);
}

void save_gbwtgraph(const gbwtgraph::GBWTGraph& graph, const std::string& filename, bool show_progress) {
    if (show_progress) {
        std::cerr << "Saving GBWTGraph to " << filename << std::endl;
    }
    graph.serialize(filename);
}

void save_gbz(const gbwtgraph::GBZ& gbz, const std::string& filename, bool show_progress) {
    if (show_progress) {
        std::cerr << "Saving GBZ to " << filename << std::endl;
    }
    sdsl::simple_sds::serialize_to(gbz, filename);
}

void save_gbz(const gbwt::GBWT& index, gbwtgraph::GBWTGraph& graph, const std::string& filename, bool show_progress) {
    if (show_progress) {
        std::cerr << "Saving GBWT and GBWTGraph to " << filename << std::endl;
    }
    std::ofstream out(filename, std::ios_base::binary);
    if (!out) {
        std::cerr << "error: [save_gbz()] cannot open file " << filename << " for writing" << std::endl;
        std::exit(EXIT_FAILURE);
    }
    gbwtgraph::GBZ::simple_sds_serialize(index, graph, out);
    out.close();
}

void save_gbz(const gbwtgraph::GBZ& gbz, const std::string& gbwt_name, const std::string& graph_name, bool show_progress) {
    save_gbwt(gbz.index, gbwt_name, show_progress);
    save_gbwtgraph(gbz.graph, graph_name, show_progress);
}

void save_minimizer(const gbwtgraph::DefaultMinimizerIndex& index, const std::string& filename, bool show_progress) {
    if (show_progress) {
        std::cerr << "Saving MinimizerIndex to " << filename << std::endl;
    }
    std::ofstream out(filename, std::ios_base::binary);
    if (!out) {
        std::cerr << "error: [save_minimizer()] cannot open file " << filename << " for writing" << std::endl;
        std::exit(EXIT_FAILURE);
    }
    index.serialize(out);
    out.close();
}

//------------------------------------------------------------------------------

} // namespace vg


text:
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: google/cloud/dataproc/v1/clusters.proto

package com.google.cloud.dataproc.v1;

/**
 *
 *
 *

 * Specifies the cluster auto-delete schedule configuration.
 *

 *
 * Protobuf type {@code google.cloud.dataproc.v1.LifecycleConfig}
 */
public final class LifecycleConfig extends com.google.protobuf.GeneratedMessageV3
    implements
    // @@protoc_insertion_point(message_implements:google.cloud.dataproc.v1.LifecycleConfig)
    LifecycleConfigOrBuilder {
  private static final long serialVersionUID = 0L;
  // Use LifecycleConfig.newBuilder() to construct.
  private LifecycleConfig(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }

  private LifecycleConfig() {}

  @java.lang.Override
  @SuppressWarnings({"unused"})
  protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
    return new LifecycleConfig();
  }

  @java.lang.Override
  public final com.google.protobuf.UnknownFieldSet getUnknownFields() {
    return this.unknownFields;
  }

  public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
    return com.google.cloud.dataproc.v1.ClustersProto
        .internal_static_google_cloud_dataproc_v1_LifecycleConfig_descriptor;
  }

  @java.lang.Override
  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.google.cloud.dataproc.v1.ClustersProto
        .internal_static_google_cloud_dataproc_v1_LifecycleConfig_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.google.cloud.dataproc.v1.LifecycleConfig.class,
            com.google.cloud.dataproc.v1.LifecycleConfig.Builder.class);
  }

  private int ttlCase_ = 0;
  private java.lang.Object ttl_;

  public enum TtlCase
      implements
          com.google.protobuf.Internal.EnumLite,
          com.google.protobuf.AbstractMessage.InternalOneOfEnum {
    AUTO_DELETE_TIME(2),
    AUTO_DELETE_TTL(3),
    TTL_NOT_SET(0);
    private final int value;

    private TtlCase(int value) {
      this.value = value;
    }
    /**
     * @param value The number of the enum to look for.
     * @return The enum associated with the given number.
     * @deprecated Use {@link #forNumber(int)} instead.
     */
    @java.lang.Deprecated
    public static TtlCase valueOf(int value) {
      return forNumber(value);
    }

    public static TtlCase forNumber(int value) {
      switch (value) {
        case 2:
          return AUTO_DELETE_TIME;
        case 3:
          return AUTO_DELETE_TTL;
        case 0:
          return TTL_NOT_SET;
        default:
          return null;
      }
    }

    public int getNumber() {
      return this.value;
    }
  };

  public TtlCase getTtlCase() {
    return TtlCase.forNumber(ttlCase_);
  }

  public static final int IDLE_DELETE_TTL_FIELD_NUMBER = 1;
  private com.google.protobuf.Duration idleDeleteTtl_;
  /**
   *
   *
   *

   * Optional. The duration to keep the cluster alive while idling (when no jobs
   * are running). Passing this threshold will cause the cluster to be
   * deleted. Minimum value is 5 minutes; maximum value is 14 days (see JSON
   * representation of
   * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
   *

   *
   * .google.protobuf.Duration idle_delete_ttl = 1 [(.google.api.field_behavior) = OPTIONAL];
   *
   *
   * @return Whether the idleDeleteTtl field is set.
   */
  @java.lang.Override
  public boolean hasIdleDeleteTtl() {
    return idleDeleteTtl_ != null;
  }
  /**
   *
   *
   *

   * Optional. The duration to keep the cluster alive while idling (when no jobs
   * are running). Passing this threshold will cause the cluster to be
   * deleted. Minimum value is 5 minutes; maximum value is 14 days (see JSON
   * representation of
   * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
   *

   *
   * .google.protobuf.Duration idle_delete_ttl = 1 [(.google.api.field_behavior) = OPTIONAL];
   *
   *
   * @return The idleDeleteTtl.
   */
  @java.lang.Override
  public com.google.protobuf.Duration getIdleDeleteTtl() {
    return idleDeleteTtl_ == null
        ? com.google.protobuf.Duration.getDefaultInstance()
        : idleDeleteTtl_;
  }
  /**
   *
   *
   *

   * Optional. The duration to keep the cluster alive while idling (when no jobs
   * are running). Passing this threshold will cause the cluster to be
   * deleted. Minimum value is 5 minutes; maximum value is 14 days (see JSON
   * representation of
   * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
   *

   *
   * .google.protobuf.Duration idle_delete_ttl = 1 [(.google.api.field_behavior) = OPTIONAL];
   *
   */
  @java.lang.Override
  public com.google.protobuf.DurationOrBuilder getIdleDeleteTtlOrBuilder() {
    return getIdleDeleteTtl();
  }

  public static final int AUTO_DELETE_TIME_FIELD_NUMBER = 2;
  /**
   *
   *
   *

   * Optional. The time when cluster will be auto-deleted (see JSON representation of
   * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
   *

   *
   *
   * .google.protobuf.Timestamp auto_delete_time = 2 [(.google.api.field_behavior) = OPTIONAL];
   *
   *
   * @return Whether the autoDeleteTime field is set.
   */
  @java.lang.Override
  public boolean hasAutoDeleteTime() {
    return ttlCase_ == 2;
  }
  /**
   *
   *
   *

   * Optional. The time when cluster will be auto-deleted (see JSON representation of
   * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
   *

   *
   *
   * .google.protobuf.Timestamp auto_delete_time = 2 [(.google.api.field_behavior) = OPTIONAL];
   *
   *
   * @return The autoDeleteTime.
   */
  @java.lang.Override
  public com.google.protobuf.Timestamp getAutoDeleteTime() {
    if (ttlCase_ == 2) {
      return (com.google.protobuf.Timestamp) ttl_;
    }
    return com.google.protobuf.Timestamp.getDefaultInstance();
  }
  /**
   *
   *
   *

   * Optional. The time when cluster will be auto-deleted (see JSON representation of
   * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
   *

   *
   *
   * .google.protobuf.Timestamp auto_delete_time = 2 [(.google.api.field_behavior) = OPTIONAL];
   *
   */
  @java.lang.Override
  public com.google.protobuf.TimestampOrBuilder getAutoDeleteTimeOrBuilder() {
    if (ttlCase_ == 2) {
      return (com.google.protobuf.Timestamp) ttl_;
    }
    return com.google.protobuf.Timestamp.getDefaultInstance();
  }

  public static final int AUTO_DELETE_TTL_FIELD_NUMBER = 3;
  /**
   *
   *
   *

   * Optional. The lifetime duration of cluster. The cluster will be
   * auto-deleted at the end of this period. Minimum value is 10 minutes;
   * maximum value is 14 days (see JSON representation of
   * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
   *

   *
   * .google.protobuf.Duration auto_delete_ttl = 3 [(.google.api.field_behavior) = OPTIONAL];
   *
   *
   * @return Whether the autoDeleteTtl field is set.
   */
  @java.lang.Override
  public boolean hasAutoDeleteTtl() {
    return ttlCase_ == 3;
  }
  /**
   *
   *
   *

   * Optional. The lifetime duration of cluster. The cluster will be
   * auto-deleted at the end of this period. Minimum value is 10 minutes;
   * maximum value is 14 days (see JSON representation of
   * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
   *

   *
   * .google.protobuf.Duration auto_delete_ttl = 3 [(.google.api.field_behavior) = OPTIONAL];
   *
   *
   * @return The autoDeleteTtl.
   */
  @java.lang.Override
  public com.google.protobuf.Duration getAutoDeleteTtl() {
    if (ttlCase_ == 3) {
      return (com.google.protobuf.Duration) ttl_;
    }
    return com.google.protobuf.Duration.getDefaultInstance();
  }
  /**
   *
   *
   *

   * Optional. The lifetime duration of cluster. The cluster will be
   * auto-deleted at the end of this period. Minimum value is 10 minutes;
   * maximum value is 14 days (see JSON representation of
   * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
   *

   *
   * .google.protobuf.Duration auto_delete_ttl = 3 [(.google.api.field_behavior) = OPTIONAL];
   *
   */
  @java.lang.Override
  public com.google.protobuf.DurationOrBuilder getAutoDeleteTtlOrBuilder() {
    if (ttlCase_ == 3) {
      return (com.google.protobuf.Duration) ttl_;
    }
    return com.google.protobuf.Duration.getDefaultInstance();
  }

  public static final int IDLE_START_TIME_FIELD_NUMBER = 4;
  private com.google.protobuf.Timestamp idleStartTime_;
  /**
   *
   *
   *

   * Output only. The time when cluster became idle (most recent job finished)
   * and became eligible for deletion due to idleness (see JSON representation
   * of
   * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
   *

   *
   *
   * .google.protobuf.Timestamp idle_start_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY];
   *
   *
   * @return Whether the idleStartTime field is set.
   */
  @java.lang.Override
  public boolean hasIdleStartTime() {
    return idleStartTime_ != null;
  }
  /**
   *
   *
   *

   * Output only. The time when cluster became idle (most recent job finished)
   * and became eligible for deletion due to idleness (see JSON representation
   * of
   * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
   *

   *
   *
   * .google.protobuf.Timestamp idle_start_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY];
   *
   *
   * @return The idleStartTime.
   */
  @java.lang.Override
  public com.google.protobuf.Timestamp getIdleStartTime() {
    return idleStartTime_ == null
        ? com.google.protobuf.Timestamp.getDefaultInstance()
        : idleStartTime_;
  }
  /**
   *
   *
   *

   * Output only. The time when cluster became idle (most recent job finished)
   * and became eligible for deletion due to idleness (see JSON representation
   * of
   * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
   *

   *
   *
   * .google.protobuf.Timestamp idle_start_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY];
   *
   */
  @java.lang.Override
  public com.google.protobuf.TimestampOrBuilder getIdleStartTimeOrBuilder() {
    return getIdleStartTime();
  }

  private byte memoizedIsInitialized = -1;

  @java.lang.Override
  public final boolean isInitialized() {
    byte isInitialized = memoizedIsInitialized;
    if (isInitialized == 1) return true;
    if (isInitialized == 0) return false;

    memoizedIsInitialized = 1;
    return true;
  }

  @java.lang.Override
  public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException {
    if (idleDeleteTtl_ != null) {
      output.writeMessage(1, getIdleDeleteTtl());
    }
    if (ttlCase_ == 2) {
      output.writeMessage(2, (com.google.protobuf.Timestamp) ttl_);
    }
    if (ttlCase_ == 3) {
      output.writeMessage(3, (com.google.protobuf.Duration) ttl_);
    }
    if (idleStartTime_ != null) {
      output.writeMessage(4, getIdleStartTime());
    }
    getUnknownFields().writeTo(output);
  }

  @java.lang.Override
  public int getSerializedSize() {
    int size = memoizedSize;
    if (size != -1) return size;

    size = 0;
    if (idleDeleteTtl_ != null) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getIdleDeleteTtl());
    }
    if (ttlCase_ == 2) {
      size +=
          com.google.protobuf.CodedOutputStream.computeMessageSize(
              2, (com.google.protobuf.Timestamp) ttl_);
    }
    if (ttlCase_ == 3) {
      size +=
          com.google.protobuf.CodedOutputStream.computeMessageSize(
              3, (com.google.protobuf.Duration) ttl_);
    }
    if (idleStartTime_ != null) {
      size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getIdleStartTime());
    }
    size += getUnknownFields().getSerializedSize();
    memoizedSize = size;
    return size;
  }

  @java.lang.Override
  public boolean equals(final java.lang.Object obj) {
    if (obj == this) {
      return true;
    }
    if (!(obj instanceof com.google.cloud.dataproc.v1.LifecycleConfig)) {
      return super.equals(obj);
    }
    com.google.cloud.dataproc.v1.LifecycleConfig other =
        (com.google.cloud.dataproc.v1.LifecycleConfig) obj;

    if (hasIdleDeleteTtl() != other.hasIdleDeleteTtl()) return false;
    if (hasIdleDeleteTtl()) {
      if (!getIdleDeleteTtl().equals(other.getIdleDeleteTtl())) return false;
    }
    if (hasIdleStartTime() != other.hasIdleStartTime()) return false;
    if (hasIdleStartTime()) {
      if (!getIdleStartTime().equals(other.getIdleStartTime())) return false;
    }
    if (!getTtlCase().equals(other.getTtlCase())) return false;
    switch (ttlCase_) {
      case 2:
        if (!getAutoDeleteTime().equals(other.getAutoDeleteTime())) return false;
        break;
      case 3:
        if (!getAutoDeleteTtl().equals(other.getAutoDeleteTtl())) return false;
        break;
      case 0:
      default:
    }
    if (!getUnknownFields().equals(other.getUnknownFields())) return false;
    return true;
  }

  @java.lang.Override
  public int hashCode() {
    if (memoizedHashCode != 0) {
      return memoizedHashCode;
    }
    int hash = 41;
    hash = (19 * hash) + getDescriptor().hashCode();
    if (hasIdleDeleteTtl()) {
      hash = (37 * hash) + IDLE_DELETE_TTL_FIELD_NUMBER;
      hash = (53 * hash) + getIdleDeleteTtl().hashCode();
    }
    if (hasIdleStartTime()) {
      hash = (37 * hash) + IDLE_START_TIME_FIELD_NUMBER;
      hash = (53 * hash) + getIdleStartTime().hashCode();
    }
    switch (ttlCase_) {
      case 2:
        hash = (37 * hash) + AUTO_DELETE_TIME_FIELD_NUMBER;
        hash = (53 * hash) + getAutoDeleteTime().hashCode();
        break;
      case 3:
        hash = (37 * hash) + AUTO_DELETE_TTL_FIELD_NUMBER;
        hash = (53 * hash) + getAutoDeleteTtl().hashCode();
        break;
      case 0:
      default:
    }
    hash = (29 * hash) + getUnknownFields().hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static com.google.cloud.dataproc.v1.LifecycleConfig parseFrom(java.nio.ByteBuffer data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.dataproc.v1.LifecycleConfig parseFrom(
      java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.cloud.dataproc.v1.LifecycleConfig parseFrom(
      com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.dataproc.v1.LifecycleConfig parseFrom(
      com.google.protobuf.ByteString data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.cloud.dataproc.v1.LifecycleConfig parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.dataproc.v1.LifecycleConfig parseFrom(
      byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.cloud.dataproc.v1.LifecycleConfig parseFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
  }

  public static com.google.cloud.dataproc.v1.LifecycleConfig parseFrom(
      java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(
        PARSER, input, extensionRegistry);
  }

  public static com.google.cloud.dataproc.v1.LifecycleConfig parseDelimitedFrom(
      java.io.InputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
  }

  public static com.google.cloud.dataproc.v1.LifecycleConfig parseDelimitedFrom(
      java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(
        PARSER, input, extensionRegistry);
  }

  public static com.google.cloud.dataproc.v1.LifecycleConfig parseFrom(
      com.google.protobuf.CodedInputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
  }

  public static com.google.cloud.dataproc.v1.LifecycleConfig parseFrom(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(
        PARSER, input, extensionRegistry);
  }

  @java.lang.Override
  public Builder newBuilderForType() {
    return newBuilder();
  }

  public static Builder newBuilder() {
    return DEFAULT_INSTANCE.toBuilder();
  }

  public static Builder newBuilder(com.google.cloud.dataproc.v1.LifecycleConfig prototype) {
    return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
  }

  @java.lang.Override
  public Builder toBuilder() {
    return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this);
  }

  @java.lang.Override
  protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
    Builder builder = new Builder(parent);
    return builder;
  }
  /**
   *
   *
   *

   * Specifies the cluster auto-delete schedule configuration.
   *

   *
   * Protobuf type {@code google.cloud.dataproc.v1.LifecycleConfig}
   */
  public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
      implements
      // @@protoc_insertion_point(builder_implements:google.cloud.dataproc.v1.LifecycleConfig)
      com.google.cloud.dataproc.v1.LifecycleConfigOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
      return com.google.cloud.dataproc.v1.ClustersProto
          .internal_static_google_cloud_dataproc_v1_LifecycleConfig_descriptor;
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.cloud.dataproc.v1.ClustersProto
          .internal_static_google_cloud_dataproc_v1_LifecycleConfig_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.cloud.dataproc.v1.LifecycleConfig.class,
              com.google.cloud.dataproc.v1.LifecycleConfig.Builder.class);
    }

    // Construct using com.google.cloud.dataproc.v1.LifecycleConfig.newBuilder()
    private Builder() {}

    private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
      super(parent);
    }

    @java.lang.Override
    public Builder clear() {
      super.clear();
      if (idleDeleteTtlBuilder_ == null) {
        idleDeleteTtl_ = null;
      } else {
        idleDeleteTtl_ = null;
        idleDeleteTtlBuilder_ = null;
      }
      if (autoDeleteTimeBuilder_ != null) {
        autoDeleteTimeBuilder_.clear();
      }
      if (autoDeleteTtlBuilder_ != null) {
        autoDeleteTtlBuilder_.clear();
      }
      if (idleStartTimeBuilder_ == null) {
        idleStartTime_ = null;
      } else {
        idleStartTime_ = null;
        idleStartTimeBuilder_ = null;
      }
      ttlCase_ = 0;
      ttl_ = null;
      return this;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
      return com.google.cloud.dataproc.v1.ClustersProto
          .internal_static_google_cloud_dataproc_v1_LifecycleConfig_descriptor;
    }

    @java.lang.Override
    public com.google.cloud.dataproc.v1.LifecycleConfig getDefaultInstanceForType() {
      return com.google.cloud.dataproc.v1.LifecycleConfig.getDefaultInstance();
    }

    @java.lang.Override
    public com.google.cloud.dataproc.v1.LifecycleConfig build() {
      com.google.cloud.dataproc.v1.LifecycleConfig result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    @java.lang.Override
    public com.google.cloud.dataproc.v1.LifecycleConfig buildPartial() {
      com.google.cloud.dataproc.v1.LifecycleConfig result =
          new com.google.cloud.dataproc.v1.LifecycleConfig(this);
      if (idleDeleteTtlBuilder_ == null) {
        result.idleDeleteTtl_ = idleDeleteTtl_;
      } else {
        result.idleDeleteTtl_ = idleDeleteTtlBuilder_.build();
      }
      if (ttlCase_ == 2) {
        if (autoDeleteTimeBuilder_ == null) {
          result.ttl_ = ttl_;
        } else {
          result.ttl_ = autoDeleteTimeBuilder_.build();
        }
      }
      if (ttlCase_ == 3) {
        if (autoDeleteTtlBuilder_ == null) {
          result.ttl_ = ttl_;
        } else {
          result.ttl_ = autoDeleteTtlBuilder_.build();
        }
      }
      if (idleStartTimeBuilder_ == null) {
        result.idleStartTime_ = idleStartTime_;
      } else {
        result.idleStartTime_ = idleStartTimeBuilder_.build();
      }
      result.ttlCase_ = ttlCase_;
      onBuilt();
      return result;
    }

    @java.lang.Override
    public Builder clone() {
      return super.clone();
    }

    @java.lang.Override
    public Builder setField(
        com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) {
      return super.setField(field, value);
    }

    @java.lang.Override
    public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) {
      return super.clearField(field);
    }

    @java.lang.Override
    public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) {
      return super.clearOneof(oneof);
    }

    @java.lang.Override
    public Builder setRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) {
      return super.setRepeatedField(field, index, value);
    }

    @java.lang.Override
    public Builder addRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) {
      return super.addRepeatedField(field, value);
    }

    @java.lang.Override
    public Builder mergeFrom(com.google.protobuf.Message other) {
      if (other instanceof com.google.cloud.dataproc.v1.LifecycleConfig) {
        return mergeFrom((com.google.cloud.dataproc.v1.LifecycleConfig) other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(com.google.cloud.dataproc.v1.LifecycleConfig other) {
      if (other == com.google.cloud.dataproc.v1.LifecycleConfig.getDefaultInstance()) return this;
      if (other.hasIdleDeleteTtl()) {
        mergeIdleDeleteTtl(other.getIdleDeleteTtl());
      }
      if (other.hasIdleStartTime()) {
        mergeIdleStartTime(other.getIdleStartTime());
      }
      switch (other.getTtlCase()) {
        case AUTO_DELETE_TIME:
          {
            mergeAutoDeleteTime(other.getAutoDeleteTime());
            break;
          }
        case AUTO_DELETE_TTL:
          {
            mergeAutoDeleteTtl(other.getAutoDeleteTtl());
            break;
          }
        case TTL_NOT_SET:
          {
            break;
          }
      }
      this.mergeUnknownFields(other.getUnknownFields());
      onChanged();
      return this;
    }

    @java.lang.Override
    public final boolean isInitialized() {
      return true;
    }

    @java.lang.Override
    public Builder mergeFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      if (extensionRegistry == null) {
        throw new java.lang.NullPointerException();
      }
      try {
        boolean done = false;
        while (!done) {
          int tag = input.readTag();
          switch (tag) {
            case 0:
              done = true;
              break;
            case 10:
              {
                input.readMessage(getIdleDeleteTtlFieldBuilder().getBuilder(), extensionRegistry);

                break;
              } // case 10
            case 18:
              {
                input.readMessage(getAutoDeleteTimeFieldBuilder().getBuilder(), extensionRegistry);
                ttlCase_ = 2;
                break;
              } // case 18
            case 26:
              {
                input.readMessage(getAutoDeleteTtlFieldBuilder().getBuilder(), extensionRegistry);
                ttlCase_ = 3;
                break;
              } // case 26
            case 34:
              {
                input.readMessage(getIdleStartTimeFieldBuilder().getBuilder(), extensionRegistry);

                break;
              } // case 34
            default:
              {
                if (!super.parseUnknownField(input, extensionRegistry, tag)) {
                  done = true; // was an endgroup tag
                }
                break;
              } // default:
          } // switch (tag)
        } // while (!done)
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        throw e.unwrapIOException();
      } finally {
        onChanged();
      } // finally
      return this;
    }

    private int ttlCase_ = 0;
    private java.lang.Object ttl_;

    public TtlCase getTtlCase() {
      return TtlCase.forNumber(ttlCase_);
    }

    public Builder clearTtl() {
      ttlCase_ = 0;
      ttl_ = null;
      onChanged();
      return this;
    }

    private com.google.protobuf.Duration idleDeleteTtl_;
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.protobuf.Duration,
            com.google.protobuf.Duration.Builder,
            com.google.protobuf.DurationOrBuilder>
        idleDeleteTtlBuilder_;
    /**
     *
     *
     *

     * Optional. The duration to keep the cluster alive while idling (when no jobs
     * are running). Passing this threshold will cause the cluster to be
     * deleted. Minimum value is 5 minutes; maximum value is 14 days (see JSON
     * representation of
     * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Duration idle_delete_ttl = 1 [(.google.api.field_behavior) = OPTIONAL];
     *
     *
     * @return Whether the idleDeleteTtl field is set.
     */
    public boolean hasIdleDeleteTtl() {
      return idleDeleteTtlBuilder_ != null || idleDeleteTtl_ != null;
    }
    /**
     *
     *
     *

     * Optional. The duration to keep the cluster alive while idling (when no jobs
     * are running). Passing this threshold will cause the cluster to be
     * deleted. Minimum value is 5 minutes; maximum value is 14 days (see JSON
     * representation of
     * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Duration idle_delete_ttl = 1 [(.google.api.field_behavior) = OPTIONAL];
     *
     *
     * @return The idleDeleteTtl.
     */
    public com.google.protobuf.Duration getIdleDeleteTtl() {
      if (idleDeleteTtlBuilder_ == null) {
        return idleDeleteTtl_ == null
            ? com.google.protobuf.Duration.getDefaultInstance()
            : idleDeleteTtl_;
      } else {
        return idleDeleteTtlBuilder_.getMessage();
      }
    }
    /**
     *
     *
     *

     * Optional. The duration to keep the cluster alive while idling (when no jobs
     * are running). Passing this threshold will cause the cluster to be
     * deleted. Minimum value is 5 minutes; maximum value is 14 days (see JSON
     * representation of
     * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Duration idle_delete_ttl = 1 [(.google.api.field_behavior) = OPTIONAL];
     *
     */
    public Builder setIdleDeleteTtl(com.google.protobuf.Duration value) {
      if (idleDeleteTtlBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        idleDeleteTtl_ = value;
        onChanged();
      } else {
        idleDeleteTtlBuilder_.setMessage(value);
      }

      return this;
    }
    /**
     *
     *
     *

     * Optional. The duration to keep the cluster alive while idling (when no jobs
     * are running). Passing this threshold will cause the cluster to be
     * deleted. Minimum value is 5 minutes; maximum value is 14 days (see JSON
     * representation of
     * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Duration idle_delete_ttl = 1 [(.google.api.field_behavior) = OPTIONAL];
     *
     */
    public Builder setIdleDeleteTtl(com.google.protobuf.Duration.Builder builderForValue) {
      if (idleDeleteTtlBuilder_ == null) {
        idleDeleteTtl_ = builderForValue.build();
        onChanged();
      } else {
        idleDeleteTtlBuilder_.setMessage(builderForValue.build());
      }

      return this;
    }
    /**
     *
     *
     *

     * Optional. The duration to keep the cluster alive while idling (when no jobs
     * are running). Passing this threshold will cause the cluster to be
     * deleted. Minimum value is 5 minutes; maximum value is 14 days (see JSON
     * representation of
     * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Duration idle_delete_ttl = 1 [(.google.api.field_behavior) = OPTIONAL];
     *
     */
    public Builder mergeIdleDeleteTtl(com.google.protobuf.Duration value) {
      if (idleDeleteTtlBuilder_ == null) {
        if (idleDeleteTtl_ != null) {
          idleDeleteTtl_ =
              com.google.protobuf.Duration.newBuilder(idleDeleteTtl_)
                  .mergeFrom(value)
                  .buildPartial();
        } else {
          idleDeleteTtl_ = value;
        }
        onChanged();
      } else {
        idleDeleteTtlBuilder_.mergeFrom(value);
      }

      return this;
    }
    /**
     *
     *
     *

     * Optional. The duration to keep the cluster alive while idling (when no jobs
     * are running). Passing this threshold will cause the cluster to be
     * deleted. Minimum value is 5 minutes; maximum value is 14 days (see JSON
     * representation of
     * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Duration idle_delete_ttl = 1 [(.google.api.field_behavior) = OPTIONAL];
     *
     */
    public Builder clearIdleDeleteTtl() {
      if (idleDeleteTtlBuilder_ == null) {
        idleDeleteTtl_ = null;
        onChanged();
      } else {
        idleDeleteTtl_ = null;
        idleDeleteTtlBuilder_ = null;
      }

      return this;
    }
    /**
     *
     *
     *

     * Optional. The duration to keep the cluster alive while idling (when no jobs
     * are running). Passing this threshold will cause the cluster to be
     * deleted. Minimum value is 5 minutes; maximum value is 14 days (see JSON
     * representation of
     * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Duration idle_delete_ttl = 1 [(.google.api.field_behavior) = OPTIONAL];
     *
     */
    public com.google.protobuf.Duration.Builder getIdleDeleteTtlBuilder() {

      onChanged();
      return getIdleDeleteTtlFieldBuilder().getBuilder();
    }
    /**
     *
     *
     *

     * Optional. The duration to keep the cluster alive while idling (when no jobs
     * are running). Passing this threshold will cause the cluster to be
     * deleted. Minimum value is 5 minutes; maximum value is 14 days (see JSON
     * representation of
     * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Duration idle_delete_ttl = 1 [(.google.api.field_behavior) = OPTIONAL];
     *
     */
    public com.google.protobuf.DurationOrBuilder getIdleDeleteTtlOrBuilder() {
      if (idleDeleteTtlBuilder_ != null) {
        return idleDeleteTtlBuilder_.getMessageOrBuilder();
      } else {
        return idleDeleteTtl_ == null
            ? com.google.protobuf.Duration.getDefaultInstance()
            : idleDeleteTtl_;
      }
    }
    /**
     *
     *
     *

     * Optional. The duration to keep the cluster alive while idling (when no jobs
     * are running). Passing this threshold will cause the cluster to be
     * deleted. Minimum value is 5 minutes; maximum value is 14 days (see JSON
     * representation of
     * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Duration idle_delete_ttl = 1 [(.google.api.field_behavior) = OPTIONAL];
     *
     */
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.protobuf.Duration,
            com.google.protobuf.Duration.Builder,
            com.google.protobuf.DurationOrBuilder>
        getIdleDeleteTtlFieldBuilder() {
      if (idleDeleteTtlBuilder_ == null) {
        idleDeleteTtlBuilder_ =
            new com.google.protobuf.SingleFieldBuilderV3<
                com.google.protobuf.Duration,
                com.google.protobuf.Duration.Builder,
                com.google.protobuf.DurationOrBuilder>(
                getIdleDeleteTtl(), getParentForChildren(), isClean());
        idleDeleteTtl_ = null;
      }
      return idleDeleteTtlBuilder_;
    }

    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.protobuf.Timestamp,
            com.google.protobuf.Timestamp.Builder,
            com.google.protobuf.TimestampOrBuilder>
        autoDeleteTimeBuilder_;
    /**
     *
     *
     *

     * Optional. The time when cluster will be auto-deleted (see JSON representation of
     * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Timestamp auto_delete_time = 2 [(.google.api.field_behavior) = OPTIONAL];
     *
     *
     * @return Whether the autoDeleteTime field is set.
     */
    @java.lang.Override
    public boolean hasAutoDeleteTime() {
      return ttlCase_ == 2;
    }
    /**
     *
     *
     *

     * Optional. The time when cluster will be auto-deleted (see JSON representation of
     * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Timestamp auto_delete_time = 2 [(.google.api.field_behavior) = OPTIONAL];
     *
     *
     * @return The autoDeleteTime.
     */
    @java.lang.Override
    public com.google.protobuf.Timestamp getAutoDeleteTime() {
      if (autoDeleteTimeBuilder_ == null) {
        if (ttlCase_ == 2) {
          return (com.google.protobuf.Timestamp) ttl_;
        }
        return com.google.protobuf.Timestamp.getDefaultInstance();
      } else {
        if (ttlCase_ == 2) {
          return autoDeleteTimeBuilder_.getMessage();
        }
        return com.google.protobuf.Timestamp.getDefaultInstance();
      }
    }
    /**
     *
     *
     *

     * Optional. The time when cluster will be auto-deleted (see JSON representation of
     * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Timestamp auto_delete_time = 2 [(.google.api.field_behavior) = OPTIONAL];
     *
     */
    public Builder setAutoDeleteTime(com.google.protobuf.Timestamp value) {
      if (autoDeleteTimeBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ttl_ = value;
        onChanged();
      } else {
        autoDeleteTimeBuilder_.setMessage(value);
      }
      ttlCase_ = 2;
      return this;
    }
    /**
     *
     *
     *

     * Optional. The time when cluster will be auto-deleted (see JSON representation of
     * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Timestamp auto_delete_time = 2 [(.google.api.field_behavior) = OPTIONAL];
     *
     */
    public Builder setAutoDeleteTime(com.google.protobuf.Timestamp.Builder builderForValue) {
      if (autoDeleteTimeBuilder_ == null) {
        ttl_ = builderForValue.build();
        onChanged();
      } else {
        autoDeleteTimeBuilder_.setMessage(builderForValue.build());
      }
      ttlCase_ = 2;
      return this;
    }
    /**
     *
     *
     *

     * Optional. The time when cluster will be auto-deleted (see JSON representation of
     * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Timestamp auto_delete_time = 2 [(.google.api.field_behavior) = OPTIONAL];
     *
     */
    public Builder mergeAutoDeleteTime(com.google.protobuf.Timestamp value) {
      if (autoDeleteTimeBuilder_ == null) {
        if (ttlCase_ == 2 && ttl_ != com.google.protobuf.Timestamp.getDefaultInstance()) {
          ttl_ =
              com.google.protobuf.Timestamp.newBuilder((com.google.protobuf.Timestamp) ttl_)
                  .mergeFrom(value)
                  .buildPartial();
        } else {
          ttl_ = value;
        }
        onChanged();
      } else {
        if (ttlCase_ == 2) {
          autoDeleteTimeBuilder_.mergeFrom(value);
        } else {
          autoDeleteTimeBuilder_.setMessage(value);
        }
      }
      ttlCase_ = 2;
      return this;
    }
    /**
     *
     *
     *

     * Optional. The time when cluster will be auto-deleted (see JSON representation of
     * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Timestamp auto_delete_time = 2 [(.google.api.field_behavior) = OPTIONAL];
     *
     */
    public Builder clearAutoDeleteTime() {
      if (autoDeleteTimeBuilder_ == null) {
        if (ttlCase_ == 2) {
          ttlCase_ = 0;
          ttl_ = null;
          onChanged();
        }
      } else {
        if (ttlCase_ == 2) {
          ttlCase_ = 0;
          ttl_ = null;
        }
        autoDeleteTimeBuilder_.clear();
      }
      return this;
    }
    /**
     *
     *
     *

     * Optional. The time when cluster will be auto-deleted (see JSON representation of
     * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Timestamp auto_delete_time = 2 [(.google.api.field_behavior) = OPTIONAL];
     *
     */
    public com.google.protobuf.Timestamp.Builder getAutoDeleteTimeBuilder() {
      return getAutoDeleteTimeFieldBuilder().getBuilder();
    }
    /**
     *
     *
     *

     * Optional. The time when cluster will be auto-deleted (see JSON representation of
     * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Timestamp auto_delete_time = 2 [(.google.api.field_behavior) = OPTIONAL];
     *
     */
    @java.lang.Override
    public com.google.protobuf.TimestampOrBuilder getAutoDeleteTimeOrBuilder() {
      if ((ttlCase_ == 2) && (autoDeleteTimeBuilder_ != null)) {
        return autoDeleteTimeBuilder_.getMessageOrBuilder();
      } else {
        if (ttlCase_ == 2) {
          return (com.google.protobuf.Timestamp) ttl_;
        }
        return com.google.protobuf.Timestamp.getDefaultInstance();
      }
    }
    /**
     *
     *
     *

     * Optional. The time when cluster will be auto-deleted (see JSON representation of
     * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Timestamp auto_delete_time = 2 [(.google.api.field_behavior) = OPTIONAL];
     *
     */
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.protobuf.Timestamp,
            com.google.protobuf.Timestamp.Builder,
            com.google.protobuf.TimestampOrBuilder>
        getAutoDeleteTimeFieldBuilder() {
      if (autoDeleteTimeBuilder_ == null) {
        if (!(ttlCase_ == 2)) {
          ttl_ = com.google.protobuf.Timestamp.getDefaultInstance();
        }
        autoDeleteTimeBuilder_ =
            new com.google.protobuf.SingleFieldBuilderV3<
                com.google.protobuf.Timestamp,
                com.google.protobuf.Timestamp.Builder,
                com.google.protobuf.TimestampOrBuilder>(
                (com.google.protobuf.Timestamp) ttl_, getParentForChildren(), isClean());
        ttl_ = null;
      }
      ttlCase_ = 2;
      onChanged();
      ;
      return autoDeleteTimeBuilder_;
    }

    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.protobuf.Duration,
            com.google.protobuf.Duration.Builder,
            com.google.protobuf.DurationOrBuilder>
        autoDeleteTtlBuilder_;
    /**
     *
     *
     *

     * Optional. The lifetime duration of cluster. The cluster will be
     * auto-deleted at the end of this period. Minimum value is 10 minutes;
     * maximum value is 14 days (see JSON representation of
     * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Duration auto_delete_ttl = 3 [(.google.api.field_behavior) = OPTIONAL];
     *
     *
     * @return Whether the autoDeleteTtl field is set.
     */
    @java.lang.Override
    public boolean hasAutoDeleteTtl() {
      return ttlCase_ == 3;
    }
    /**
     *
     *
     *

     * Optional. The lifetime duration of cluster. The cluster will be
     * auto-deleted at the end of this period. Minimum value is 10 minutes;
     * maximum value is 14 days (see JSON representation of
     * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Duration auto_delete_ttl = 3 [(.google.api.field_behavior) = OPTIONAL];
     *
     *
     * @return The autoDeleteTtl.
     */
    @java.lang.Override
    public com.google.protobuf.Duration getAutoDeleteTtl() {
      if (autoDeleteTtlBuilder_ == null) {
        if (ttlCase_ == 3) {
          return (com.google.protobuf.Duration) ttl_;
        }
        return com.google.protobuf.Duration.getDefaultInstance();
      } else {
        if (ttlCase_ == 3) {
          return autoDeleteTtlBuilder_.getMessage();
        }
        return com.google.protobuf.Duration.getDefaultInstance();
      }
    }
    /**
     *
     *
     *

     * Optional. The lifetime duration of cluster. The cluster will be
     * auto-deleted at the end of this period. Minimum value is 10 minutes;
     * maximum value is 14 days (see JSON representation of
     * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Duration auto_delete_ttl = 3 [(.google.api.field_behavior) = OPTIONAL];
     *
     */
    public Builder setAutoDeleteTtl(com.google.protobuf.Duration value) {
      if (autoDeleteTtlBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ttl_ = value;
        onChanged();
      } else {
        autoDeleteTtlBuilder_.setMessage(value);
      }
      ttlCase_ = 3;
      return this;
    }
    /**
     *
     *
     *

     * Optional. The lifetime duration of cluster. The cluster will be
     * auto-deleted at the end of this period. Minimum value is 10 minutes;
     * maximum value is 14 days (see JSON representation of
     * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Duration auto_delete_ttl = 3 [(.google.api.field_behavior) = OPTIONAL];
     *
     */
    public Builder setAutoDeleteTtl(com.google.protobuf.Duration.Builder builderForValue) {
      if (autoDeleteTtlBuilder_ == null) {
        ttl_ = builderForValue.build();
        onChanged();
      } else {
        autoDeleteTtlBuilder_.setMessage(builderForValue.build());
      }
      ttlCase_ = 3;
      return this;
    }
    /**
     *
     *
     *

     * Optional. The lifetime duration of cluster. The cluster will be
     * auto-deleted at the end of this period. Minimum value is 10 minutes;
     * maximum value is 14 days (see JSON representation of
     * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Duration auto_delete_ttl = 3 [(.google.api.field_behavior) = OPTIONAL];
     *
     */
    public Builder mergeAutoDeleteTtl(com.google.protobuf.Duration value) {
      if (autoDeleteTtlBuilder_ == null) {
        if (ttlCase_ == 3 && ttl_ != com.google.protobuf.Duration.getDefaultInstance()) {
          ttl_ =
              com.google.protobuf.Duration.newBuilder((com.google.protobuf.Duration) ttl_)
                  .mergeFrom(value)
                  .buildPartial();
        } else {
          ttl_ = value;
        }
        onChanged();
      } else {
        if (ttlCase_ == 3) {
          autoDeleteTtlBuilder_.mergeFrom(value);
        } else {
          autoDeleteTtlBuilder_.setMessage(value);
        }
      }
      ttlCase_ = 3;
      return this;
    }
    /**
     *
     *
     *

     * Optional. The lifetime duration of cluster. The cluster will be
     * auto-deleted at the end of this period. Minimum value is 10 minutes;
     * maximum value is 14 days (see JSON representation of
     * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Duration auto_delete_ttl = 3 [(.google.api.field_behavior) = OPTIONAL];
     *
     */
    public Builder clearAutoDeleteTtl() {
      if (autoDeleteTtlBuilder_ == null) {
        if (ttlCase_ == 3) {
          ttlCase_ = 0;
          ttl_ = null;
          onChanged();
        }
      } else {
        if (ttlCase_ == 3) {
          ttlCase_ = 0;
          ttl_ = null;
        }
        autoDeleteTtlBuilder_.clear();
      }
      return this;
    }
    /**
     *
     *
     *

     * Optional. The lifetime duration of cluster. The cluster will be
     * auto-deleted at the end of this period. Minimum value is 10 minutes;
     * maximum value is 14 days (see JSON representation of
     * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Duration auto_delete_ttl = 3 [(.google.api.field_behavior) = OPTIONAL];
     *
     */
    public com.google.protobuf.Duration.Builder getAutoDeleteTtlBuilder() {
      return getAutoDeleteTtlFieldBuilder().getBuilder();
    }
    /**
     *
     *
     *

     * Optional. The lifetime duration of cluster. The cluster will be
     * auto-deleted at the end of this period. Minimum value is 10 minutes;
     * maximum value is 14 days (see JSON representation of
     * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Duration auto_delete_ttl = 3 [(.google.api.field_behavior) = OPTIONAL];
     *
     */
    @java.lang.Override
    public com.google.protobuf.DurationOrBuilder getAutoDeleteTtlOrBuilder() {
      if ((ttlCase_ == 3) && (autoDeleteTtlBuilder_ != null)) {
        return autoDeleteTtlBuilder_.getMessageOrBuilder();
      } else {
        if (ttlCase_ == 3) {
          return (com.google.protobuf.Duration) ttl_;
        }
        return com.google.protobuf.Duration.getDefaultInstance();
      }
    }
    /**
     *
     *
     *

     * Optional. The lifetime duration of cluster. The cluster will be
     * auto-deleted at the end of this period. Minimum value is 10 minutes;
     * maximum value is 14 days (see JSON representation of
     * [Duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Duration auto_delete_ttl = 3 [(.google.api.field_behavior) = OPTIONAL];
     *
     */
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.protobuf.Duration,
            com.google.protobuf.Duration.Builder,
            com.google.protobuf.DurationOrBuilder>
        getAutoDeleteTtlFieldBuilder() {
      if (autoDeleteTtlBuilder_ == null) {
        if (!(ttlCase_ == 3)) {
          ttl_ = com.google.protobuf.Duration.getDefaultInstance();
        }
        autoDeleteTtlBuilder_ =
            new com.google.protobuf.SingleFieldBuilderV3<
                com.google.protobuf.Duration,
                com.google.protobuf.Duration.Builder,
                com.google.protobuf.DurationOrBuilder>(
                (com.google.protobuf.Duration) ttl_, getParentForChildren(), isClean());
        ttl_ = null;
      }
      ttlCase_ = 3;
      onChanged();
      ;
      return autoDeleteTtlBuilder_;
    }

    private com.google.protobuf.Timestamp idleStartTime_;
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.protobuf.Timestamp,
            com.google.protobuf.Timestamp.Builder,
            com.google.protobuf.TimestampOrBuilder>
        idleStartTimeBuilder_;
    /**
     *
     *
     *

     * Output only. The time when cluster became idle (most recent job finished)
     * and became eligible for deletion due to idleness (see JSON representation
     * of
     * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Timestamp idle_start_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY];
     *
     *
     * @return Whether the idleStartTime field is set.
     */
    public boolean hasIdleStartTime() {
      return idleStartTimeBuilder_ != null || idleStartTime_ != null;
    }
    /**
     *
     *
     *

     * Output only. The time when cluster became idle (most recent job finished)
     * and became eligible for deletion due to idleness (see JSON representation
     * of
     * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Timestamp idle_start_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY];
     *
     *
     * @return The idleStartTime.
     */
    public com.google.protobuf.Timestamp getIdleStartTime() {
      if (idleStartTimeBuilder_ == null) {
        return idleStartTime_ == null
            ? com.google.protobuf.Timestamp.getDefaultInstance()
            : idleStartTime_;
      } else {
        return idleStartTimeBuilder_.getMessage();
      }
    }
    /**
     *
     *
     *

     * Output only. The time when cluster became idle (most recent job finished)
     * and became eligible for deletion due to idleness (see JSON representation
     * of
     * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Timestamp idle_start_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY];
     *
     */
    public Builder setIdleStartTime(com.google.protobuf.Timestamp value) {
      if (idleStartTimeBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        idleStartTime_ = value;
        onChanged();
      } else {
        idleStartTimeBuilder_.setMessage(value);
      }

      return this;
    }
    /**
     *
     *
     *

     * Output only. The time when cluster became idle (most recent job finished)
     * and became eligible for deletion due to idleness (see JSON representation
     * of
     * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Timestamp idle_start_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY];
     *
     */
    public Builder setIdleStartTime(com.google.protobuf.Timestamp.Builder builderForValue) {
      if (idleStartTimeBuilder_ == null) {
        idleStartTime_ = builderForValue.build();
        onChanged();
      } else {
        idleStartTimeBuilder_.setMessage(builderForValue.build());
      }

      return this;
    }
    /**
     *
     *
     *

     * Output only. The time when cluster became idle (most recent job finished)
     * and became eligible for deletion due to idleness (see JSON representation
     * of
     * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Timestamp idle_start_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY];
     *
     */
    public Builder mergeIdleStartTime(com.google.protobuf.Timestamp value) {
      if (idleStartTimeBuilder_ == null) {
        if (idleStartTime_ != null) {
          idleStartTime_ =
              com.google.protobuf.Timestamp.newBuilder(idleStartTime_)
                  .mergeFrom(value)
                  .buildPartial();
        } else {
          idleStartTime_ = value;
        }
        onChanged();
      } else {
        idleStartTimeBuilder_.mergeFrom(value);
      }

      return this;
    }
    /**
     *
     *
     *

     * Output only. The time when cluster became idle (most recent job finished)
     * and became eligible for deletion due to idleness (see JSON representation
     * of
     * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Timestamp idle_start_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY];
     *
     */
    public Builder clearIdleStartTime() {
      if (idleStartTimeBuilder_ == null) {
        idleStartTime_ = null;
        onChanged();
      } else {
        idleStartTime_ = null;
        idleStartTimeBuilder_ = null;
      }

      return this;
    }
    /**
     *
     *
     *

     * Output only. The time when cluster became idle (most recent job finished)
     * and became eligible for deletion due to idleness (see JSON representation
     * of
     * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Timestamp idle_start_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY];
     *
     */
    public com.google.protobuf.Timestamp.Builder getIdleStartTimeBuilder() {

      onChanged();
      return getIdleStartTimeFieldBuilder().getBuilder();
    }
    /**
     *
     *
     *

     * Output only. The time when cluster became idle (most recent job finished)
     * and became eligible for deletion due to idleness (see JSON representation
     * of
     * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Timestamp idle_start_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY];
     *
     */
    public com.google.protobuf.TimestampOrBuilder getIdleStartTimeOrBuilder() {
      if (idleStartTimeBuilder_ != null) {
        return idleStartTimeBuilder_.getMessageOrBuilder();
      } else {
        return idleStartTime_ == null
            ? com.google.protobuf.Timestamp.getDefaultInstance()
            : idleStartTime_;
      }
    }
    /**
     *
     *
     *

     * Output only. The time when cluster became idle (most recent job finished)
     * and became eligible for deletion due to idleness (see JSON representation
     * of
     * [Timestamp](https://developers.google.com/protocol-buffers/docs/proto3#json)).
     *

     *
     *
     * .google.protobuf.Timestamp idle_start_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY];
     *
     */
    private com.google.protobuf.SingleFieldBuilderV3<
            com.google.protobuf.Timestamp,
            com.google.protobuf.Timestamp.Builder,
            com.google.protobuf.TimestampOrBuilder>
        getIdleStartTimeFieldBuilder() {
      if (idleStartTimeBuilder_ == null) {
        idleStartTimeBuilder_ =
            new com.google.protobuf.SingleFieldBuilderV3<
                com.google.protobuf.Timestamp,
                com.google.protobuf.Timestamp.Builder,
                com.google.protobuf.TimestampOrBuilder>(
                getIdleStartTime(), getParentForChildren(), isClean());
        idleStartTime_ = null;
      }
      return idleStartTimeBuilder_;
    }

    @java.lang.Override
    public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.setUnknownFields(unknownFields);
    }

    @java.lang.Override
    public final Builder mergeUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.mergeUnknownFields(unknownFields);
    }

    // @@protoc_insertion_point(builder_scope:google.cloud.dataproc.v1.LifecycleConfig)
  }

  // @@protoc_insertion_point(class_scope:google.cloud.dataproc.v1.LifecycleConfig)
  private static final com.google.cloud.dataproc.v1.LifecycleConfig DEFAULT_INSTANCE;

  static {
    DEFAULT_INSTANCE = new com.google.cloud.dataproc.v1.LifecycleConfig();
  }

  public static com.google.cloud.dataproc.v1.LifecycleConfig getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

  private static final com.google.protobuf.Parser<LifecycleConfig> PARSER =
      new com.google.protobuf.AbstractParser<LifecycleConfig>() {
        @java.lang.Override
        public LifecycleConfig parsePartialFrom(
            com.google.protobuf.CodedInputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws com.google.protobuf.InvalidProtocolBufferException {
          Builder builder = newBuilder();
          try {
            builder.mergeFrom(input, extensionRegistry);
          } catch (com.google.protobuf.InvalidProtocolBufferException e) {
            throw e.setUnfinishedMessage(builder.buildPartial());
          } catch (com.google.protobuf.UninitializedMessageException e) {
            throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial());
          } catch (java.io.IOException e) {
            throw new com.google.protobuf.InvalidProtocolBufferException(e)
                .setUnfinishedMessage(builder.buildPartial());
          }
          return builder.buildPartial();
        }
      };

  public static com.google.protobuf.Parser<LifecycleConfig> parser() {
    return PARSER;
  }

  @java.lang.Override
  public com.google.protobuf.Parser<LifecycleConfig> getParserForType() {
    return PARSER;
  }

  @java.lang.Override
  public com.google.cloud.dataproc.v1.LifecycleConfig getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }
}