{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.OpsWorks.UpdateInstance
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates a specified instance.
--
-- __Required Permissions__: To use this action, an IAM user must have a
-- Manage permissions level for the stack, or an attached policy that
-- explicitly grants permissions. For more information on user permissions,
-- see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/opsworks-security-users.html Managing User Permissions>.
module Amazonka.OpsWorks.UpdateInstance
  ( -- * Creating a Request
    UpdateInstance (..),
    newUpdateInstance,

    -- * Request Lenses
    updateInstance_installUpdatesOnBoot,
    updateInstance_hostname,
    updateInstance_sshKeyName,
    updateInstance_agentVersion,
    updateInstance_instanceType,
    updateInstance_ebsOptimized,
    updateInstance_os,
    updateInstance_autoScalingType,
    updateInstance_layerIds,
    updateInstance_architecture,
    updateInstance_amiId,
    updateInstance_instanceId,

    -- * Destructuring the Response
    UpdateInstanceResponse (..),
    newUpdateInstanceResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.OpsWorks.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateInstance' smart constructor.
data UpdateInstance = UpdateInstance'
  { -- | Whether to install operating system and package updates when the
    -- instance boots. The default value is @true@. To control when updates are
    -- installed, set this value to @false@. You must then update your
    -- instances manually by using CreateDeployment to run the
    -- @update_dependencies@ stack command or by manually running @yum@ (Amazon
    -- Linux) or @apt-get@ (Ubuntu) on the instances.
    --
    -- We strongly recommend using the default value of @true@, to ensure that
    -- your instances have the latest security updates.
    UpdateInstance -> Maybe Bool
installUpdatesOnBoot :: Prelude.Maybe Prelude.Bool,
    -- | The instance host name.
    UpdateInstance -> Maybe Text
hostname :: Prelude.Maybe Prelude.Text,
    -- | The instance\'s Amazon EC2 key name.
    UpdateInstance -> Maybe Text
sshKeyName :: Prelude.Maybe Prelude.Text,
    -- | The default AWS OpsWorks Stacks agent version. You have the following
    -- options:
    --
    -- -   @INHERIT@ - Use the stack\'s default agent version setting.
    --
    -- -   /version_number/ - Use the specified agent version. This value
    --     overrides the stack\'s default setting. To update the agent version,
    --     you must edit the instance configuration and specify a new version.
    --     AWS OpsWorks Stacks then automatically installs that version on the
    --     instance.
    --
    -- The default setting is @INHERIT@. To specify an agent version, you must
    -- use the complete version number, not the abbreviated number shown on the
    -- console. For a list of available agent version numbers, call
    -- DescribeAgentVersions.
    --
    -- AgentVersion cannot be set to Chef 12.2.
    UpdateInstance -> Maybe Text
agentVersion :: Prelude.Maybe Prelude.Text,
    -- | The instance type, such as @t2.micro@. For a list of supported instance
    -- types, open the stack in the console, choose __Instances__, and choose
    -- __+ Instance__. The __Size__ list contains the currently supported
    -- types. For more information, see
    -- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html Instance Families and Types>.
    -- The parameter values that you use to specify the various types are in
    -- the __API Name__ column of the __Available Instance Types__ table.
    UpdateInstance -> Maybe Text
instanceType :: Prelude.Maybe Prelude.Text,
    -- | This property cannot be updated.
    UpdateInstance -> Maybe Bool
ebsOptimized :: Prelude.Maybe Prelude.Bool,
    -- | The instance\'s operating system, which must be set to one of the
    -- following. You cannot update an instance that is using a custom AMI.
    --
    -- -   A supported Linux operating system: An Amazon Linux version, such as
    --     @Amazon Linux 2018.03@, @Amazon Linux 2017.09@,
    --     @Amazon Linux 2017.03@, @Amazon Linux 2016.09@,
    --     @Amazon Linux 2016.03@, @Amazon Linux 2015.09@, or
    --     @Amazon Linux 2015.03@.
    --
    -- -   A supported Ubuntu operating system, such as @Ubuntu 16.04 LTS@,
    --     @Ubuntu 14.04 LTS@, or @Ubuntu 12.04 LTS@.
    --
    -- -   @CentOS Linux 7@
    --
    -- -   @Red Hat Enterprise Linux 7@
    --
    -- -   A supported Windows operating system, such as
    --     @Microsoft Windows Server 2012 R2 Base@,
    --     @Microsoft Windows Server 2012 R2 with SQL Server Express@,
    --     @Microsoft Windows Server 2012 R2 with SQL Server Standard@, or
    --     @Microsoft Windows Server 2012 R2 with SQL Server Web@.
    --
    -- For more information about supported operating systems, see
    -- <https://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-os.html AWS OpsWorks Stacks Operating Systems>.
    --
    -- The default option is the current Amazon Linux version. If you set this
    -- parameter to @Custom@, you must use the AmiId parameter to specify the
    -- custom AMI that you want to use. For more information about supported
    -- operating systems, see
    -- <https://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-os.html Operating Systems>.
    -- For more information about how to use custom AMIs with OpsWorks, see
    -- <https://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-custom-ami.html Using Custom AMIs>.
    --
    -- You can specify a different Linux operating system for the updated
    -- stack, but you cannot change from Linux to Windows or Windows to Linux.
    UpdateInstance -> Maybe Text
os :: Prelude.Maybe Prelude.Text,
    -- | For load-based or time-based instances, the type. Windows stacks can use
    -- only time-based instances.
    UpdateInstance -> Maybe AutoScalingType
autoScalingType :: Prelude.Maybe AutoScalingType,
    -- | The instance\'s layer IDs.
    UpdateInstance -> Maybe [Text]
layerIds :: Prelude.Maybe [Prelude.Text],
    -- | The instance architecture. Instance types do not necessarily support
    -- both architectures. For a list of the architectures that are supported
    -- by the different instance types, see
    -- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html Instance Families and Types>.
    UpdateInstance -> Maybe Architecture
architecture :: Prelude.Maybe Architecture,
    -- | The ID of the AMI that was used to create the instance. The value of
    -- this parameter must be the same AMI ID that the instance is already
    -- using. You cannot apply a new AMI to an instance by running
    -- UpdateInstance. UpdateInstance does not work on instances that are using
    -- custom AMIs.
    UpdateInstance -> Maybe Text
amiId :: Prelude.Maybe Prelude.Text,
    -- | The instance ID.
    UpdateInstance -> Text
instanceId :: Prelude.Text
  }
  deriving (UpdateInstance -> UpdateInstance -> Bool
(UpdateInstance -> UpdateInstance -> Bool)
-> (UpdateInstance -> UpdateInstance -> Bool) -> Eq UpdateInstance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateInstance -> UpdateInstance -> Bool
$c/= :: UpdateInstance -> UpdateInstance -> Bool
== :: UpdateInstance -> UpdateInstance -> Bool
$c== :: UpdateInstance -> UpdateInstance -> Bool
Prelude.Eq, ReadPrec [UpdateInstance]
ReadPrec UpdateInstance
Int -> ReadS UpdateInstance
ReadS [UpdateInstance]
(Int -> ReadS UpdateInstance)
-> ReadS [UpdateInstance]
-> ReadPrec UpdateInstance
-> ReadPrec [UpdateInstance]
-> Read UpdateInstance
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateInstance]
$creadListPrec :: ReadPrec [UpdateInstance]
readPrec :: ReadPrec UpdateInstance
$creadPrec :: ReadPrec UpdateInstance
readList :: ReadS [UpdateInstance]
$creadList :: ReadS [UpdateInstance]
readsPrec :: Int -> ReadS UpdateInstance
$creadsPrec :: Int -> ReadS UpdateInstance
Prelude.Read, Int -> UpdateInstance -> ShowS
[UpdateInstance] -> ShowS
UpdateInstance -> String
(Int -> UpdateInstance -> ShowS)
-> (UpdateInstance -> String)
-> ([UpdateInstance] -> ShowS)
-> Show UpdateInstance
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateInstance] -> ShowS
$cshowList :: [UpdateInstance] -> ShowS
show :: UpdateInstance -> String
$cshow :: UpdateInstance -> String
showsPrec :: Int -> UpdateInstance -> ShowS
$cshowsPrec :: Int -> UpdateInstance -> ShowS
Prelude.Show, (forall x. UpdateInstance -> Rep UpdateInstance x)
-> (forall x. Rep UpdateInstance x -> UpdateInstance)
-> Generic UpdateInstance
forall x. Rep UpdateInstance x -> UpdateInstance
forall x. UpdateInstance -> Rep UpdateInstance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateInstance x -> UpdateInstance
$cfrom :: forall x. UpdateInstance -> Rep UpdateInstance x
Prelude.Generic)

-- |
-- Create a value of 'UpdateInstance' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'installUpdatesOnBoot', 'updateInstance_installUpdatesOnBoot' - Whether to install operating system and package updates when the
-- instance boots. The default value is @true@. To control when updates are
-- installed, set this value to @false@. You must then update your
-- instances manually by using CreateDeployment to run the
-- @update_dependencies@ stack command or by manually running @yum@ (Amazon
-- Linux) or @apt-get@ (Ubuntu) on the instances.
--
-- We strongly recommend using the default value of @true@, to ensure that
-- your instances have the latest security updates.
--
-- 'hostname', 'updateInstance_hostname' - The instance host name.
--
-- 'sshKeyName', 'updateInstance_sshKeyName' - The instance\'s Amazon EC2 key name.
--
-- 'agentVersion', 'updateInstance_agentVersion' - The default AWS OpsWorks Stacks agent version. You have the following
-- options:
--
-- -   @INHERIT@ - Use the stack\'s default agent version setting.
--
-- -   /version_number/ - Use the specified agent version. This value
--     overrides the stack\'s default setting. To update the agent version,
--     you must edit the instance configuration and specify a new version.
--     AWS OpsWorks Stacks then automatically installs that version on the
--     instance.
--
-- The default setting is @INHERIT@. To specify an agent version, you must
-- use the complete version number, not the abbreviated number shown on the
-- console. For a list of available agent version numbers, call
-- DescribeAgentVersions.
--
-- AgentVersion cannot be set to Chef 12.2.
--
-- 'instanceType', 'updateInstance_instanceType' - The instance type, such as @t2.micro@. For a list of supported instance
-- types, open the stack in the console, choose __Instances__, and choose
-- __+ Instance__. The __Size__ list contains the currently supported
-- types. For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html Instance Families and Types>.
-- The parameter values that you use to specify the various types are in
-- the __API Name__ column of the __Available Instance Types__ table.
--
-- 'ebsOptimized', 'updateInstance_ebsOptimized' - This property cannot be updated.
--
-- 'os', 'updateInstance_os' - The instance\'s operating system, which must be set to one of the
-- following. You cannot update an instance that is using a custom AMI.
--
-- -   A supported Linux operating system: An Amazon Linux version, such as
--     @Amazon Linux 2018.03@, @Amazon Linux 2017.09@,
--     @Amazon Linux 2017.03@, @Amazon Linux 2016.09@,
--     @Amazon Linux 2016.03@, @Amazon Linux 2015.09@, or
--     @Amazon Linux 2015.03@.
--
-- -   A supported Ubuntu operating system, such as @Ubuntu 16.04 LTS@,
--     @Ubuntu 14.04 LTS@, or @Ubuntu 12.04 LTS@.
--
-- -   @CentOS Linux 7@
--
-- -   @Red Hat Enterprise Linux 7@
--
-- -   A supported Windows operating system, such as
--     @Microsoft Windows Server 2012 R2 Base@,
--     @Microsoft Windows Server 2012 R2 with SQL Server Express@,
--     @Microsoft Windows Server 2012 R2 with SQL Server Standard@, or
--     @Microsoft Windows Server 2012 R2 with SQL Server Web@.
--
-- For more information about supported operating systems, see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-os.html AWS OpsWorks Stacks Operating Systems>.
--
-- The default option is the current Amazon Linux version. If you set this
-- parameter to @Custom@, you must use the AmiId parameter to specify the
-- custom AMI that you want to use. For more information about supported
-- operating systems, see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-os.html Operating Systems>.
-- For more information about how to use custom AMIs with OpsWorks, see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-custom-ami.html Using Custom AMIs>.
--
-- You can specify a different Linux operating system for the updated
-- stack, but you cannot change from Linux to Windows or Windows to Linux.
--
-- 'autoScalingType', 'updateInstance_autoScalingType' - For load-based or time-based instances, the type. Windows stacks can use
-- only time-based instances.
--
-- 'layerIds', 'updateInstance_layerIds' - The instance\'s layer IDs.
--
-- 'architecture', 'updateInstance_architecture' - The instance architecture. Instance types do not necessarily support
-- both architectures. For a list of the architectures that are supported
-- by the different instance types, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html Instance Families and Types>.
--
-- 'amiId', 'updateInstance_amiId' - The ID of the AMI that was used to create the instance. The value of
-- this parameter must be the same AMI ID that the instance is already
-- using. You cannot apply a new AMI to an instance by running
-- UpdateInstance. UpdateInstance does not work on instances that are using
-- custom AMIs.
--
-- 'instanceId', 'updateInstance_instanceId' - The instance ID.
newUpdateInstance ::
  -- | 'instanceId'
  Prelude.Text ->
  UpdateInstance
newUpdateInstance :: Text -> UpdateInstance
newUpdateInstance Text
pInstanceId_ =
  UpdateInstance' :: Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Bool
-> Maybe Text
-> Maybe AutoScalingType
-> Maybe [Text]
-> Maybe Architecture
-> Maybe Text
-> Text
-> UpdateInstance
UpdateInstance'
    { $sel:installUpdatesOnBoot:UpdateInstance' :: Maybe Bool
installUpdatesOnBoot =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:hostname:UpdateInstance' :: Maybe Text
hostname = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:sshKeyName:UpdateInstance' :: Maybe Text
sshKeyName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:agentVersion:UpdateInstance' :: Maybe Text
agentVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:instanceType:UpdateInstance' :: Maybe Text
instanceType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:ebsOptimized:UpdateInstance' :: Maybe Bool
ebsOptimized = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:os:UpdateInstance' :: Maybe Text
os = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:autoScalingType:UpdateInstance' :: Maybe AutoScalingType
autoScalingType = Maybe AutoScalingType
forall a. Maybe a
Prelude.Nothing,
      $sel:layerIds:UpdateInstance' :: Maybe [Text]
layerIds = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:architecture:UpdateInstance' :: Maybe Architecture
architecture = Maybe Architecture
forall a. Maybe a
Prelude.Nothing,
      $sel:amiId:UpdateInstance' :: Maybe Text
amiId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:instanceId:UpdateInstance' :: Text
instanceId = Text
pInstanceId_
    }

-- | Whether to install operating system and package updates when the
-- instance boots. The default value is @true@. To control when updates are
-- installed, set this value to @false@. You must then update your
-- instances manually by using CreateDeployment to run the
-- @update_dependencies@ stack command or by manually running @yum@ (Amazon
-- Linux) or @apt-get@ (Ubuntu) on the instances.
--
-- We strongly recommend using the default value of @true@, to ensure that
-- your instances have the latest security updates.
updateInstance_installUpdatesOnBoot :: Lens.Lens' UpdateInstance (Prelude.Maybe Prelude.Bool)
updateInstance_installUpdatesOnBoot :: (Maybe Bool -> f (Maybe Bool))
-> UpdateInstance -> f UpdateInstance
updateInstance_installUpdatesOnBoot = (UpdateInstance -> Maybe Bool)
-> (UpdateInstance -> Maybe Bool -> UpdateInstance)
-> Lens UpdateInstance UpdateInstance (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateInstance' {Maybe Bool
installUpdatesOnBoot :: Maybe Bool
$sel:installUpdatesOnBoot:UpdateInstance' :: UpdateInstance -> Maybe Bool
installUpdatesOnBoot} -> Maybe Bool
installUpdatesOnBoot) (\s :: UpdateInstance
s@UpdateInstance' {} Maybe Bool
a -> UpdateInstance
s {$sel:installUpdatesOnBoot:UpdateInstance' :: Maybe Bool
installUpdatesOnBoot = Maybe Bool
a} :: UpdateInstance)

-- | The instance host name.
updateInstance_hostname :: Lens.Lens' UpdateInstance (Prelude.Maybe Prelude.Text)
updateInstance_hostname :: (Maybe Text -> f (Maybe Text))
-> UpdateInstance -> f UpdateInstance
updateInstance_hostname = (UpdateInstance -> Maybe Text)
-> (UpdateInstance -> Maybe Text -> UpdateInstance)
-> Lens UpdateInstance UpdateInstance (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateInstance' {Maybe Text
hostname :: Maybe Text
$sel:hostname:UpdateInstance' :: UpdateInstance -> Maybe Text
hostname} -> Maybe Text
hostname) (\s :: UpdateInstance
s@UpdateInstance' {} Maybe Text
a -> UpdateInstance
s {$sel:hostname:UpdateInstance' :: Maybe Text
hostname = Maybe Text
a} :: UpdateInstance)

-- | The instance\'s Amazon EC2 key name.
updateInstance_sshKeyName :: Lens.Lens' UpdateInstance (Prelude.Maybe Prelude.Text)
updateInstance_sshKeyName :: (Maybe Text -> f (Maybe Text))
-> UpdateInstance -> f UpdateInstance
updateInstance_sshKeyName = (UpdateInstance -> Maybe Text)
-> (UpdateInstance -> Maybe Text -> UpdateInstance)
-> Lens UpdateInstance UpdateInstance (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateInstance' {Maybe Text
sshKeyName :: Maybe Text
$sel:sshKeyName:UpdateInstance' :: UpdateInstance -> Maybe Text
sshKeyName} -> Maybe Text
sshKeyName) (\s :: UpdateInstance
s@UpdateInstance' {} Maybe Text
a -> UpdateInstance
s {$sel:sshKeyName:UpdateInstance' :: Maybe Text
sshKeyName = Maybe Text
a} :: UpdateInstance)

-- | The default AWS OpsWorks Stacks agent version. You have the following
-- options:
--
-- -   @INHERIT@ - Use the stack\'s default agent version setting.
--
-- -   /version_number/ - Use the specified agent version. This value
--     overrides the stack\'s default setting. To update the agent version,
--     you must edit the instance configuration and specify a new version.
--     AWS OpsWorks Stacks then automatically installs that version on the
--     instance.
--
-- The default setting is @INHERIT@. To specify an agent version, you must
-- use the complete version number, not the abbreviated number shown on the
-- console. For a list of available agent version numbers, call
-- DescribeAgentVersions.
--
-- AgentVersion cannot be set to Chef 12.2.
updateInstance_agentVersion :: Lens.Lens' UpdateInstance (Prelude.Maybe Prelude.Text)
updateInstance_agentVersion :: (Maybe Text -> f (Maybe Text))
-> UpdateInstance -> f UpdateInstance
updateInstance_agentVersion = (UpdateInstance -> Maybe Text)
-> (UpdateInstance -> Maybe Text -> UpdateInstance)
-> Lens UpdateInstance UpdateInstance (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateInstance' {Maybe Text
agentVersion :: Maybe Text
$sel:agentVersion:UpdateInstance' :: UpdateInstance -> Maybe Text
agentVersion} -> Maybe Text
agentVersion) (\s :: UpdateInstance
s@UpdateInstance' {} Maybe Text
a -> UpdateInstance
s {$sel:agentVersion:UpdateInstance' :: Maybe Text
agentVersion = Maybe Text
a} :: UpdateInstance)

-- | The instance type, such as @t2.micro@. For a list of supported instance
-- types, open the stack in the console, choose __Instances__, and choose
-- __+ Instance__. The __Size__ list contains the currently supported
-- types. For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html Instance Families and Types>.
-- The parameter values that you use to specify the various types are in
-- the __API Name__ column of the __Available Instance Types__ table.
updateInstance_instanceType :: Lens.Lens' UpdateInstance (Prelude.Maybe Prelude.Text)
updateInstance_instanceType :: (Maybe Text -> f (Maybe Text))
-> UpdateInstance -> f UpdateInstance
updateInstance_instanceType = (UpdateInstance -> Maybe Text)
-> (UpdateInstance -> Maybe Text -> UpdateInstance)
-> Lens UpdateInstance UpdateInstance (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateInstance' {Maybe Text
instanceType :: Maybe Text
$sel:instanceType:UpdateInstance' :: UpdateInstance -> Maybe Text
instanceType} -> Maybe Text
instanceType) (\s :: UpdateInstance
s@UpdateInstance' {} Maybe Text
a -> UpdateInstance
s {$sel:instanceType:UpdateInstance' :: Maybe Text
instanceType = Maybe Text
a} :: UpdateInstance)

-- | This property cannot be updated.
updateInstance_ebsOptimized :: Lens.Lens' UpdateInstance (Prelude.Maybe Prelude.Bool)
updateInstance_ebsOptimized :: (Maybe Bool -> f (Maybe Bool))
-> UpdateInstance -> f UpdateInstance
updateInstance_ebsOptimized = (UpdateInstance -> Maybe Bool)
-> (UpdateInstance -> Maybe Bool -> UpdateInstance)
-> Lens UpdateInstance UpdateInstance (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateInstance' {Maybe Bool
ebsOptimized :: Maybe Bool
$sel:ebsOptimized:UpdateInstance' :: UpdateInstance -> Maybe Bool
ebsOptimized} -> Maybe Bool
ebsOptimized) (\s :: UpdateInstance
s@UpdateInstance' {} Maybe Bool
a -> UpdateInstance
s {$sel:ebsOptimized:UpdateInstance' :: Maybe Bool
ebsOptimized = Maybe Bool
a} :: UpdateInstance)

-- | The instance\'s operating system, which must be set to one of the
-- following. You cannot update an instance that is using a custom AMI.
--
-- -   A supported Linux operating system: An Amazon Linux version, such as
--     @Amazon Linux 2018.03@, @Amazon Linux 2017.09@,
--     @Amazon Linux 2017.03@, @Amazon Linux 2016.09@,
--     @Amazon Linux 2016.03@, @Amazon Linux 2015.09@, or
--     @Amazon Linux 2015.03@.
--
-- -   A supported Ubuntu operating system, such as @Ubuntu 16.04 LTS@,
--     @Ubuntu 14.04 LTS@, or @Ubuntu 12.04 LTS@.
--
-- -   @CentOS Linux 7@
--
-- -   @Red Hat Enterprise Linux 7@
--
-- -   A supported Windows operating system, such as
--     @Microsoft Windows Server 2012 R2 Base@,
--     @Microsoft Windows Server 2012 R2 with SQL Server Express@,
--     @Microsoft Windows Server 2012 R2 with SQL Server Standard@, or
--     @Microsoft Windows Server 2012 R2 with SQL Server Web@.
--
-- For more information about supported operating systems, see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-os.html AWS OpsWorks Stacks Operating Systems>.
--
-- The default option is the current Amazon Linux version. If you set this
-- parameter to @Custom@, you must use the AmiId parameter to specify the
-- custom AMI that you want to use. For more information about supported
-- operating systems, see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-os.html Operating Systems>.
-- For more information about how to use custom AMIs with OpsWorks, see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-custom-ami.html Using Custom AMIs>.
--
-- You can specify a different Linux operating system for the updated
-- stack, but you cannot change from Linux to Windows or Windows to Linux.
updateInstance_os :: Lens.Lens' UpdateInstance (Prelude.Maybe Prelude.Text)
updateInstance_os :: (Maybe Text -> f (Maybe Text))
-> UpdateInstance -> f UpdateInstance
updateInstance_os = (UpdateInstance -> Maybe Text)
-> (UpdateInstance -> Maybe Text -> UpdateInstance)
-> Lens UpdateInstance UpdateInstance (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateInstance' {Maybe Text
os :: Maybe Text
$sel:os:UpdateInstance' :: UpdateInstance -> Maybe Text
os} -> Maybe Text
os) (\s :: UpdateInstance
s@UpdateInstance' {} Maybe Text
a -> UpdateInstance
s {$sel:os:UpdateInstance' :: Maybe Text
os = Maybe Text
a} :: UpdateInstance)

-- | For load-based or time-based instances, the type. Windows stacks can use
-- only time-based instances.
updateInstance_autoScalingType :: Lens.Lens' UpdateInstance (Prelude.Maybe AutoScalingType)
updateInstance_autoScalingType :: (Maybe AutoScalingType -> f (Maybe AutoScalingType))
-> UpdateInstance -> f UpdateInstance
updateInstance_autoScalingType = (UpdateInstance -> Maybe AutoScalingType)
-> (UpdateInstance -> Maybe AutoScalingType -> UpdateInstance)
-> Lens
     UpdateInstance
     UpdateInstance
     (Maybe AutoScalingType)
     (Maybe AutoScalingType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateInstance' {Maybe AutoScalingType
autoScalingType :: Maybe AutoScalingType
$sel:autoScalingType:UpdateInstance' :: UpdateInstance -> Maybe AutoScalingType
autoScalingType} -> Maybe AutoScalingType
autoScalingType) (\s :: UpdateInstance
s@UpdateInstance' {} Maybe AutoScalingType
a -> UpdateInstance
s {$sel:autoScalingType:UpdateInstance' :: Maybe AutoScalingType
autoScalingType = Maybe AutoScalingType
a} :: UpdateInstance)

-- | The instance\'s layer IDs.
updateInstance_layerIds :: Lens.Lens' UpdateInstance (Prelude.Maybe [Prelude.Text])
updateInstance_layerIds :: (Maybe [Text] -> f (Maybe [Text]))
-> UpdateInstance -> f UpdateInstance
updateInstance_layerIds = (UpdateInstance -> Maybe [Text])
-> (UpdateInstance -> Maybe [Text] -> UpdateInstance)
-> Lens UpdateInstance UpdateInstance (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateInstance' {Maybe [Text]
layerIds :: Maybe [Text]
$sel:layerIds:UpdateInstance' :: UpdateInstance -> Maybe [Text]
layerIds} -> Maybe [Text]
layerIds) (\s :: UpdateInstance
s@UpdateInstance' {} Maybe [Text]
a -> UpdateInstance
s {$sel:layerIds:UpdateInstance' :: Maybe [Text]
layerIds = Maybe [Text]
a} :: UpdateInstance) ((Maybe [Text] -> f (Maybe [Text]))
 -> UpdateInstance -> f UpdateInstance)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> UpdateInstance
-> f UpdateInstance
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The instance architecture. Instance types do not necessarily support
-- both architectures. For a list of the architectures that are supported
-- by the different instance types, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html Instance Families and Types>.
updateInstance_architecture :: Lens.Lens' UpdateInstance (Prelude.Maybe Architecture)
updateInstance_architecture :: (Maybe Architecture -> f (Maybe Architecture))
-> UpdateInstance -> f UpdateInstance
updateInstance_architecture = (UpdateInstance -> Maybe Architecture)
-> (UpdateInstance -> Maybe Architecture -> UpdateInstance)
-> Lens
     UpdateInstance
     UpdateInstance
     (Maybe Architecture)
     (Maybe Architecture)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateInstance' {Maybe Architecture
architecture :: Maybe Architecture
$sel:architecture:UpdateInstance' :: UpdateInstance -> Maybe Architecture
architecture} -> Maybe Architecture
architecture) (\s :: UpdateInstance
s@UpdateInstance' {} Maybe Architecture
a -> UpdateInstance
s {$sel:architecture:UpdateInstance' :: Maybe Architecture
architecture = Maybe Architecture
a} :: UpdateInstance)

-- | The ID of the AMI that was used to create the instance. The value of
-- this parameter must be the same AMI ID that the instance is already
-- using. You cannot apply a new AMI to an instance by running
-- UpdateInstance. UpdateInstance does not work on instances that are using
-- custom AMIs.
updateInstance_amiId :: Lens.Lens' UpdateInstance (Prelude.Maybe Prelude.Text)
updateInstance_amiId :: (Maybe Text -> f (Maybe Text))
-> UpdateInstance -> f UpdateInstance
updateInstance_amiId = (UpdateInstance -> Maybe Text)
-> (UpdateInstance -> Maybe Text -> UpdateInstance)
-> Lens UpdateInstance UpdateInstance (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateInstance' {Maybe Text
amiId :: Maybe Text
$sel:amiId:UpdateInstance' :: UpdateInstance -> Maybe Text
amiId} -> Maybe Text
amiId) (\s :: UpdateInstance
s@UpdateInstance' {} Maybe Text
a -> UpdateInstance
s {$sel:amiId:UpdateInstance' :: Maybe Text
amiId = Maybe Text
a} :: UpdateInstance)

-- | The instance ID.
updateInstance_instanceId :: Lens.Lens' UpdateInstance Prelude.Text
updateInstance_instanceId :: (Text -> f Text) -> UpdateInstance -> f UpdateInstance
updateInstance_instanceId = (UpdateInstance -> Text)
-> (UpdateInstance -> Text -> UpdateInstance)
-> Lens UpdateInstance UpdateInstance Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateInstance' {Text
instanceId :: Text
$sel:instanceId:UpdateInstance' :: UpdateInstance -> Text
instanceId} -> Text
instanceId) (\s :: UpdateInstance
s@UpdateInstance' {} Text
a -> UpdateInstance
s {$sel:instanceId:UpdateInstance' :: Text
instanceId = Text
a} :: UpdateInstance)

instance Core.AWSRequest UpdateInstance where
  type
    AWSResponse UpdateInstance =
      UpdateInstanceResponse
  request :: UpdateInstance -> Request UpdateInstance
request = Service -> UpdateInstance -> Request UpdateInstance
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateInstance
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateInstance)))
response =
    AWSResponse UpdateInstance
-> Logger
-> Service
-> Proxy UpdateInstance
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateInstance)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse UpdateInstance
UpdateInstanceResponse
UpdateInstanceResponse'

instance Prelude.Hashable UpdateInstance

instance Prelude.NFData UpdateInstance

instance Core.ToHeaders UpdateInstance where
  toHeaders :: UpdateInstance -> [Header]
toHeaders =
    [Header] -> UpdateInstance -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"OpsWorks_20130218.UpdateInstance" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON UpdateInstance where
  toJSON :: UpdateInstance -> Value
toJSON UpdateInstance' {Maybe Bool
Maybe [Text]
Maybe Text
Maybe Architecture
Maybe AutoScalingType
Text
instanceId :: Text
amiId :: Maybe Text
architecture :: Maybe Architecture
layerIds :: Maybe [Text]
autoScalingType :: Maybe AutoScalingType
os :: Maybe Text
ebsOptimized :: Maybe Bool
instanceType :: Maybe Text
agentVersion :: Maybe Text
sshKeyName :: Maybe Text
hostname :: Maybe Text
installUpdatesOnBoot :: Maybe Bool
$sel:instanceId:UpdateInstance' :: UpdateInstance -> Text
$sel:amiId:UpdateInstance' :: UpdateInstance -> Maybe Text
$sel:architecture:UpdateInstance' :: UpdateInstance -> Maybe Architecture
$sel:layerIds:UpdateInstance' :: UpdateInstance -> Maybe [Text]
$sel:autoScalingType:UpdateInstance' :: UpdateInstance -> Maybe AutoScalingType
$sel:os:UpdateInstance' :: UpdateInstance -> Maybe Text
$sel:ebsOptimized:UpdateInstance' :: UpdateInstance -> Maybe Bool
$sel:instanceType:UpdateInstance' :: UpdateInstance -> Maybe Text
$sel:agentVersion:UpdateInstance' :: UpdateInstance -> Maybe Text
$sel:sshKeyName:UpdateInstance' :: UpdateInstance -> Maybe Text
$sel:hostname:UpdateInstance' :: UpdateInstance -> Maybe Text
$sel:installUpdatesOnBoot:UpdateInstance' :: UpdateInstance -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"InstallUpdatesOnBoot" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
installUpdatesOnBoot,
            (Text
"Hostname" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
hostname,
            (Text
"SshKeyName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
sshKeyName,
            (Text
"AgentVersion" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
agentVersion,
            (Text
"InstanceType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
instanceType,
            (Text
"EbsOptimized" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
ebsOptimized,
            (Text
"Os" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
os,
            (Text
"AutoScalingType" Text -> AutoScalingType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (AutoScalingType -> Pair) -> Maybe AutoScalingType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AutoScalingType
autoScalingType,
            (Text
"LayerIds" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
layerIds,
            (Text
"Architecture" Text -> Architecture -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Architecture -> Pair) -> Maybe Architecture -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Architecture
architecture,
            (Text
"AmiId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
amiId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"InstanceId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
instanceId)
          ]
      )

instance Core.ToPath UpdateInstance where
  toPath :: UpdateInstance -> ByteString
toPath = ByteString -> UpdateInstance -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery UpdateInstance where
  toQuery :: UpdateInstance -> QueryString
toQuery = QueryString -> UpdateInstance -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newUpdateInstanceResponse' smart constructor.
data UpdateInstanceResponse = UpdateInstanceResponse'
  {
  }
  deriving (UpdateInstanceResponse -> UpdateInstanceResponse -> Bool
(UpdateInstanceResponse -> UpdateInstanceResponse -> Bool)
-> (UpdateInstanceResponse -> UpdateInstanceResponse -> Bool)
-> Eq UpdateInstanceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateInstanceResponse -> UpdateInstanceResponse -> Bool
$c/= :: UpdateInstanceResponse -> UpdateInstanceResponse -> Bool
== :: UpdateInstanceResponse -> UpdateInstanceResponse -> Bool
$c== :: UpdateInstanceResponse -> UpdateInstanceResponse -> Bool
Prelude.Eq, ReadPrec [UpdateInstanceResponse]
ReadPrec UpdateInstanceResponse
Int -> ReadS UpdateInstanceResponse
ReadS [UpdateInstanceResponse]
(Int -> ReadS UpdateInstanceResponse)
-> ReadS [UpdateInstanceResponse]
-> ReadPrec UpdateInstanceResponse
-> ReadPrec [UpdateInstanceResponse]
-> Read UpdateInstanceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateInstanceResponse]
$creadListPrec :: ReadPrec [UpdateInstanceResponse]
readPrec :: ReadPrec UpdateInstanceResponse
$creadPrec :: ReadPrec UpdateInstanceResponse
readList :: ReadS [UpdateInstanceResponse]
$creadList :: ReadS [UpdateInstanceResponse]
readsPrec :: Int -> ReadS UpdateInstanceResponse
$creadsPrec :: Int -> ReadS UpdateInstanceResponse
Prelude.Read, Int -> UpdateInstanceResponse -> ShowS
[UpdateInstanceResponse] -> ShowS
UpdateInstanceResponse -> String
(Int -> UpdateInstanceResponse -> ShowS)
-> (UpdateInstanceResponse -> String)
-> ([UpdateInstanceResponse] -> ShowS)
-> Show UpdateInstanceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateInstanceResponse] -> ShowS
$cshowList :: [UpdateInstanceResponse] -> ShowS
show :: UpdateInstanceResponse -> String
$cshow :: UpdateInstanceResponse -> String
showsPrec :: Int -> UpdateInstanceResponse -> ShowS
$cshowsPrec :: Int -> UpdateInstanceResponse -> ShowS
Prelude.Show, (forall x. UpdateInstanceResponse -> Rep UpdateInstanceResponse x)
-> (forall x.
    Rep UpdateInstanceResponse x -> UpdateInstanceResponse)
-> Generic UpdateInstanceResponse
forall x. Rep UpdateInstanceResponse x -> UpdateInstanceResponse
forall x. UpdateInstanceResponse -> Rep UpdateInstanceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateInstanceResponse x -> UpdateInstanceResponse
$cfrom :: forall x. UpdateInstanceResponse -> Rep UpdateInstanceResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateInstanceResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
newUpdateInstanceResponse ::
  UpdateInstanceResponse
newUpdateInstanceResponse :: UpdateInstanceResponse
newUpdateInstanceResponse = UpdateInstanceResponse
UpdateInstanceResponse'

instance Prelude.NFData UpdateInstanceResponse