text:
using LinearAlgebra

include("../src/NMRSpectraSimulator.jl")
import .NMRSpectraSimulator

import Kronecker
import Graphs

include("./helpers/operators.jl")

# machine settings.
fs = 14005.602240896402
SW = 20.0041938620844
ν_0ppm = 10656.011933076665

hz2ppmfunc = uu->(uu - ν_0ppm)*SW/fs
ppm2hzfunc = pp->(ν_0ppm + pp*fs/SW)

# operators in Zeeman basis.
Id = NMRSpectraSimulator.getsingleId()
Ix = NMRSpectraSimulator.getsingleIx()
Iy_no_im = NMRSpectraSimulator.getsingleIynoim()
Iy = NMRSpectraSimulator.getsingleIy()
Iz = NMRSpectraSimulator.getsingleIz()

N = 4
Ixs = collect( getIja(Ix, i, N) for i = 1:N )
Iys = collect( getIja(Iy, i, N) for i = 1:N )
Izs = collect( getIja(Iz, i, N) for i = 1:N )

# # sanity check.
# out1 = productIaIb(Ixs, Iys, Izs, 1, 3)
# out2 = productIjIk(Ixs, Iys, Izs, [1;], [3;])

# # sanity check.
# out1 = pairwiseproductIa(Ixs, Iys, Izs, [1; 2; 3])
# out2 = productIaIb(Ixs, Iys, Izs, 1, 3) + productIaIb(Ixs, Iys, Izs, 2, 3) + productIaIb(Ixs, Iys, Izs, 1, 2)

#inds = [ [1;2;3]; [4;]; ]
#css = [3.4; 4.1]

# user input.
H_IDs = collect(1:4)
H_css = [2.3; 2.3; 2.3; 4.1; 4.1]

J_IDs = [ (1,2); (1,3); (1,4); (2,3); (2,4); (3,4)]
J_vals = [ 3.4; 3.4; 3.4; -5.8; -5.8; -5.8]

#load_path = "/home/roy/Documents/repo/NMRData/input/coupling_info/Maybridge_Ro3_Fragment_10_A08_simulation_1.json"
load_path = "/home/roy/Documents/repo/NMRData/input/coupling_info/bmse000860_simulation_1.json"
H_IDs, H_css, J_IDs, J_vals = GISSMOReader.loadcouplinginfojson(load_path)

# end user input.

ω_css = ppm2hzfunc.(H_css)

H_inds = collect(1:length(H_IDs))
J_inds = convertJIDstoJinds(J_IDs, H_IDs)

dict_H_ID_to_ind = Dict(H_IDs .=> collect(1:length(H_IDs)))
dict_ind_to_H_ID = Dict( collect(1:length(H_IDs)) .=> H_IDs)

dict_J_ID_to_val = Dict(J_IDs .=> J_vals)
dict_J_ind_to_val = Dict(J_inds .=> J_vals)

dict_J_ID_to_ind = Dict(J_IDs .=> J_inds)
dict_J_ind_to_ID = Dict(J_inds .=> J_IDs)

g = constructspinsystemsgraphforcompound(length(H_IDs), J_inds)

systems_g = Graphs.connected_components(g) # node inds for spin systems.
C = Graphs.maximal_cliques(g)

nodes = C[1]
# I am here. use getmageqinfo() to get some real database spin systems.
# especially see if ignoring the NON-magnetic eq between nuclei 10 and 11 of valine
# would still give a commuting [A,B] and [B,Q] operators.
# http://gissmo.nmrfam.wisc.edu/entry/bmse000860/simulation_1

# A1 = sum(w[k] .* sum(Izs[inds[k]]) for k = 1:length(w))
# A2 =
# B = Ixs[1]*Ixs[2]
# A36 = (A*B - B*A) # equation A.36 of Levitt's Spin Dynamics, "J-couplings and magnetic equivalence".
# println("N = $(N), norm(A36) = ", norm(A36))

@assert 1==2

N = 3
Ixs = collect( getIja(Ix, i, N) for i = 1:N )
Iys = collect( getIja(Iy, i, N) for i = 1:N )
Izs = collect( getIja(Iz, i, N) for i = 1:N )

A = (Ixs[1]+Ixs[2])*Ixs[3]
B = Ixs[1]*Ixs[2]
A36 = (A*B - B*A) # equation A.36 of Levitt's Spin Dynamics, "J-couplings and magnetic equivalence".
println("N = $(N), norm(A36) = ", norm(A36))

## book example of magnetic equivalence.
w12 = 11474.887839493498
w3 = 13205.050246451618
J13 = 5.8
J23 = 5.8
J12 = -7.9

# ## explore.
# w12 = 11474.887839493498
# w3 = 13205.050246451618
# #w3 = w12
# J13 = 0.0
# J23 = -7.9
# J12 = 0.0

A = w12*(Izs[1]+Izs[2]) + w3*Izs[3] + 2*π*J13*(Ixs[1]*Ixs[3] + Iys[1]*Iys[3] + Izs[1]*Izs[3]) +
    2*π*J23*(Ixs[2]*Ixs[3] + Iys[2]*Iys[3] + Izs[2]*Izs[3])
#B = real.(2*π*J12*(Ixs[1]*Ixs[2] + Iys[1]*Iys[2] + Izs[1]*Izs[2]))
B = 2*π*J12*(Ixs[1]*Ixs[2] + Iys[1]*Iys[2] + Izs[1]*Izs[2])

result = A*B - B*A # claim by Levitt just before equation A.36 of A and B commuting.
println("N = $(N), norm([A,B]) = ", norm(result))

Q = sum(Ixs)
result = B*Q - Q*B
println("N = $(N), norm([B,Q]) = ", norm(result))
println()

# observation operators (total angular moment along an axis) is always commutative to B.
C = Ixs[1]+Ixs[2]+Ixs[3]
Q_x = B*C - C*B # always 0.

C = Iys[1]+Iys[2]+Iys[3]
Q_y = B*C - C*B # always 0.

C = Izs[1]+Izs[2]+Izs[3]
Q_z = B*C - C*B # always 0.

Q = sum(Ixs)
#B = 2*π*J12*(pairwiseproductIa(Ixs, Iys, Izs, [1;2;]))
B2 = 2*π*J12*(productIaIb(Ixs, Iys, Izs, 1, 2)) #+ 2*π*(-5.2)*(productIaIb(Ixs, Iys, Izs, 2, 3))
result = B2*Q - Q*B2
println("N = $(N), norm([B2,Q]) = ", norm(result))

result = A*B2 - B2*A
println("N = $(N), norm([A,B2]) = ", norm(result))
println()

@assert 1==43

### book example, 4 spins.

N = 4
Ixs = collect( getIja(Ix, i, N) for i = 1:N )
Iys = collect( getIja(Iy, i, N) for i = 1:N )
Izs = collect( getIja(Iz, i, N) for i = 1:N )

A = sum(Ixs[1:3])*Ixs[4]
B = Ixs[1]*Ixs[2] + Ixs[2]*Ixs[3] + Ixs[1]*Ixs[3]
A36 = (A*B - B*A) # equation A.36 of Levitt's Spin Dynamics, "J-couplings and magnetic equivalence".
println("N = $(N), norm(A36) = ", norm(A36))

# book example of magnetic equivalence.
w123 = 11474.887839493498
w4 = 13205.050246451618
J12 = -7.9
J13 = J12
J23 = J12

J14 = 5.8
J24 = J14
J34 = J14

A = w123*sum(Izs[1:3]) + w4*Izs[4] + 2*π*J12*(addIa(Ixs, Iys, Izs, [1;2;3]), )
#B = real.(2*π*J12*(Ixs[1]*Ixs[2] + Iys[1]*Iys[2] + Izs[1]*Izs[2]))
B = 2*π*J12*(Ixs[1]*Ixs[2] + Iys[1]*Iys[2] + Izs[1]*Izs[2])

result = A*B - B*A # claim by Levitt just before equation A.36 of A and B commuting.
println("N = $(N), norm(result) = ", norm(result))

# observation operators (total angular moment along an axis) is always commutative to B.
C = Ixs[1]+Ixs[2]+Ixs[3]
Q_x = B*C - C*B # always 0.

C = Iys[1]+Iys[2]+Iys[3]
Q_y = B*C - C*B # always 0.

C = Izs[1]+Izs[2]+Izs[3]
Q_z = B*C - C*B # always 0.

### arbitrary number of spins, common J coupling values.

@assert 1==2444

# test loading.
load_path = "/home/roy/MEGAsync/inputs/NMR/debug/ethanol.json"

H_IDs, H_css, J_IDs, J_vals = GISSMOReader.loadcouplinginfojson(load_path)

dict_H_IDs_to_g = Dict(H_IDs .=> collect(1:length(H_IDs)))
J_inds = collect( (dict_H_IDs_to_g[J_IDs[i][1]], dict_H_IDs_to_g[J_IDs[i][2]]) for i = 1:length(J_IDs) )
H_inds = collect( dict_H_IDs_to_g[H_IDs[i]] for i = 1:length(H_IDs))

@assert 1==2

# others.
Id, Ix, Iy_no_im, Iz, Ip, Im, Iy,
    Im_full, Iz_full, Ix_full, Iys_no_im_full = NMRSpectraSimulator.prepcouplingalgorithm(3)

s, Q = eigen(A+B)

sr, Qr = eigen(A)

import Distances
#dist = Distances.Hamming()
dist = Distances.Euclidean()
d = Distances.colwise(dist, Q, Qr)
d2 = Distances.pairwise(dist, Q, Qr, dims=2)

@assert 1==2

tol_coherence = 1e-2

Id, Ix, Iy_no_im, Iz, Ip, Im, Iy,
        Im_full, Iz_full, Ix_full, Iys_no_im_full = NMRSpectraSimulator.prepcouplingalgorithm(length(H_IDs))

# spin Hamiltonian
ω0 = ppm2hzfunc.(H_css)
H, H1, H2 = NMRSpectraSimulator.getgenericHamiltoniantest( Id,
    Ix,
    Iy_no_im,
    Iz,
    ω0,
    J_vals,
    J_inds)

#s_H, Q_H = eigen(H)

a_H, F_H, p_H, s_H, Q_H, coherence_labels_H, M_array_H = NMRSpectraSimulator.getaΩ(Iz_full, H,
        Iys_no_im_full, Ix_full; tol = tol_coherence)

###

# test loading.
load_path = "/home/roy/MEGAsync/inputs/NMR/debug/ethanol_eq.json"
#load_path = "/home/roy/MEGAsync/inputs/NMR/debug/ethanol2.json"
H_IDs, H_css, J_IDs, J_vals = GISSMOReader.loadcouplinginfojson(load_path)

dict_H_IDs_to_g = Dict(H_IDs .=> collect(1:length(H_IDs)))
J_inds = collect( (dict_H_IDs_to_g[J_IDs[i][1]], dict_H_IDs_to_g[J_IDs[i][2]]) for i = 1:length(J_IDs) )
H_inds = collect( dict_H_IDs_to_g[H_IDs[i]] for i = 1:length(H_IDs))

ω0 = ppm2hzfunc.(H_css)
G, G1, G2 = NMRSpectraSimulator.getgenericHamiltoniantest( Id,
    Ix,
    Iy_no_im,
    Iz,
    ω0,
    J_vals,
    J_inds)
#
#s_G, Q_G = eigen(G)

a_G, F_G, p_G, s_G, Q_G, coherence_labels_G, M_array_G = NMRSpectraSimulator.getaΩ(Iz_full, G,
        Iys_no_im_full, Ix_full; tol = tol_coherence)


text:
import Images
using Color, FixedPointNumbers, Base.Test

const writedir = joinpath(tempdir(), "Images")

if !isdir(writedir)
    mkdir(writedir)
end

a = rand(2,2)
aa = convert(Array{Ufixed8}, a)
fn = joinpath(writedir, "2by2.png")
Images.imwrite(a, fn)
b = Images.imread(fn)
@test convert(Array, b) == aa
Images.imwrite(aa, fn)
b = Images.imread(fn)
@test convert(Array, b) == aa
aaimg = Images.grayim(aa)
open(fn, "w") do file
    writemime(file, "image/png", aaimg)
end
b = Images.imread(fn)
@test b == aaimg
aa = convert(Array{Ufixed16}, a)
Images.imwrite(aa, fn)
b = Images.imread(fn)
@test convert(Array, b) == aa
aa = Ufixed12[0.6 0.2;
              1.4 0.8]
open(fn, "w") do file
    writemime(file, "image/png", Images.grayim(aa))
end
b = Images.imread(fn)
@test Images.data(b) == Ufixed8[0.6 0.2;
                                1.0 0.8]

# test writemime's use of restrict
abig = Images.grayim(rand(Uint8, 1024, 1023))
fn = joinpath(writedir, "big.png")
open(fn, "w") do file
    writemime(file, "image/png", abig)
end
b = Images.imread(fn)
@test Images.data(b) == convert(Array{Ufixed8,2}, Images.data(Images.restrict(abig, (1,2))))

# More writemime tests
a = Images.colorim(rand(Uint8, 3, 2, 2))
fn = joinpath(writedir, "2by2.png")
open(fn, "w") do file
    writemime(file, "image/png", a)
end
b = Images.imread(fn)
@test Images.data(b) == Images.data(a)

abig = Images.colorim(rand(Uint8, 3, 1021, 1026))
fn = joinpath(writedir, "big.png")
open(fn, "w") do file
    writemime(file, "image/png", abig)
end
b = Images.imread(fn)
@test Images.data(b) == convert(Array{RGB{Ufixed8},2}, Images.data(Images.restrict(abig, (1,2))))

using Color
datafloat = reshape(linspace(0.5, 1.5, 6), 2, 3)
dataint = iround(Uint8, 254*(datafloat .- 0.5) .+ 1)  # ranges from 1 to 255
# build our colormap
b = RGB(0,0,1)
w = RGB(1,1,1)
r = RGB(1,0,0)
cmaprgb = Array(RGB{Float64}, 255)
f = linspace(0,1,128)
cmaprgb[1:128] = [(1-x)*b + x*w for x in f]
cmaprgb[129:end] = [(1-x)*w + x*r for x in f[2:end]]
img = Images.ImageCmap(dataint, cmaprgb)
Images.imwrite(img,joinpath(writedir,"cmap.jpg"))

ext: jl


text:
include("r3frac.jl")
include("r3mv.jl")
include("LatticeVars.jl")
include("AtomicVars.jl")
include("AtomicSpeciesVars.jl")
include("MuffinTinRadialVars.jl")
include("APWLOVars.jl")
include("readspecies.jl")
include("mtdmin.jl")

function create_lattice_vars()
    LatVecs = zeros(3,3)
    LatVecs[1,:] = [10.0, 10.0, 0.0]
    LatVecs[2,:] = [10.0, 0.0, 10.0]
    LatVecs[3,:] = [0.0, 10.0, 10.0]
    lattice_vars = LatticeVars( LatVecs )
    return lattice_vars
end

function create_atomic_vars(lattice_vars)

    maxatoms = 200
    maxspecies = 8
    atposl = zeros(3,maxatoms,maxspecies)

    nspecies = 2
    natoms = [1,1]

    # species 1, atom 1
    atposl[:,1,1] = [0.0, 0.0, 0.0]
    # species 2, atom 1
    atposl[:,1,2] = [0.25, 0.25, 0.25]

    atomic_vars = AtomicVars(nspecies, natoms, atposl, lattice_vars)
end

function main()

    latt_vars = create_lattice_vars()
    atm_vars = create_atomic_vars(latt_vars)

    Nspecies = 2
    atsp_vars = AtomicSpeciesVars(Nspecies)
    mtr_vars = MuffinTinRadialVars(Nspecies)
    #apwlo_vars = APWLOVars(Nspecies, mtr_vars.maxlapw) # XXX use lmaxapw instead of maxlapw?
    apwlo_vars = APWLOVars(Nspecies, mtr_vars.lmaxapw)

    readspecies!(1, "DATA_species/Si.in", atsp_vars, mtr_vars, apwlo_vars)
    readspecies!(2, "DATA_species/Pt.in", atsp_vars, mtr_vars, apwlo_vars)

    dmin, is, js = mtdmin( latt_vars, atm_vars, mtr_vars.rmt )

    println("is = ", is)
    println("js = ", js)
    println("dmin = ", dmin)

    println("Pass here")

end

main()


text:
struct ClusterBatchQs <: BatchPQs
    k::Int

    function ClusterBatchQs(; k::Int)::ClusterBatchQs
        (k < 1) && throw(ArgumentError("Invalid batch size k=$(k)."))
        return new(k)
    end
end

"""
For maximum diversity in batch selection.
Compute k-medoids clustering with k=batchsize, return cluster medoids
"""
function select_batch(qs::ClusterBatchQs, x::Array{T, 2}, labels::Dict{Symbol, Vector{Int}}, candidate_indices::Vector{Int})::Vector{Int} where T <: Real
    num_observations = length(candidate_indices)
    if num_observations <= qs.k
        return candidate_indices
    end

    candidates = x[:, candidate_indices]
    distances = Distances.pairwise(Distances.Euclidean(), candidates, dims=2)
    clustering = kmedoids(distances, qs.k)

    medoid_indices = clustering.medoids

    return candidate_indices[medoid_indices]
end


text:
# This file is a part of Julia. License is MIT: https://julialang.org/license

cmd = `$(Base.julia_cmd()) --depwarn=no --startup-file=no download_exec.jl`
if !success(pipeline(cmd; stdout=stdout, stderr=stderr))
    error("download test failed, cmd : $cmd")
end

max_stars_repo_name: vanillajonathan/julia

max_issues_repo_name: vanillajonathan/julia

max_forks_repo_name: vanillajonathan/julia


text:
# This file is auto-generated by AWSMetadata.jl
using AWS
using AWS.AWSServices: codedeploy
using AWS.Compat
using AWS.UUIDs

"""
    add_tags_to_on_premises_instances(instance_names, tags)
    add_tags_to_on_premises_instances(instance_names, tags, params::Dict{String,<:Any})

Adds tags to on-premises instances.

# Arguments
- `instance_names`: The names of the on-premises instances to which to add tags.
- `tags`: The tag key-value pairs to add to the on-premises instances. Keys and values are
  both required. Keys cannot be null or empty strings. Value-only tags are not allowed.

"""
add_tags_to_on_premises_instances(instanceNames, tags; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("AddTagsToOnPremisesInstances", Dict{String, Any}("instanceNames"=>instanceNames, "tags"=>tags); aws_config=aws_config)
add_tags_to_on_premises_instances(instanceNames, tags, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("AddTagsToOnPremisesInstances", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("instanceNames"=>instanceNames, "tags"=>tags), params)); aws_config=aws_config)

"""
    batch_get_application_revisions(application_name, revisions)
    batch_get_application_revisions(application_name, revisions, params::Dict{String,<:Any})

Gets information about one or more application revisions. The maximum number of application
revisions that can be returned is 25.

# Arguments
- `application_name`: The name of an AWS CodeDeploy application about which to get revision
  information.
- `revisions`: An array of RevisionLocation objects that specify information to get about
  the application revisions, including type and location. The maximum number of
  RevisionLocation objects you can specify is 25.

"""
batch_get_application_revisions(applicationName, revisions; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("BatchGetApplicationRevisions", Dict{String, Any}("applicationName"=>applicationName, "revisions"=>revisions); aws_config=aws_config)
batch_get_application_revisions(applicationName, revisions, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("BatchGetApplicationRevisions", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("applicationName"=>applicationName, "revisions"=>revisions), params)); aws_config=aws_config)

"""
    batch_get_applications(application_names)
    batch_get_applications(application_names, params::Dict{String,<:Any})

Gets information about one or more applications. The maximum number of applications that
can be returned is 100.

# Arguments
- `application_names`: A list of application names separated by spaces. The maximum number
  of application names you can specify is 100.

"""
batch_get_applications(applicationNames; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("BatchGetApplications", Dict{String, Any}("applicationNames"=>applicationNames); aws_config=aws_config)
batch_get_applications(applicationNames, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("BatchGetApplications", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("applicationNames"=>applicationNames), params)); aws_config=aws_config)

"""
    batch_get_deployment_groups(application_name, deployment_group_names)
    batch_get_deployment_groups(application_name, deployment_group_names, params::Dict{String,<:Any})

Gets information about one or more deployment groups.

# Arguments
- `application_name`: The name of an AWS CodeDeploy application associated with the
  applicable IAM user or AWS account.
- `deployment_group_names`: The names of the deployment groups.

"""
batch_get_deployment_groups(applicationName, deploymentGroupNames; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("BatchGetDeploymentGroups", Dict{String, Any}("applicationName"=>applicationName, "deploymentGroupNames"=>deploymentGroupNames); aws_config=aws_config)
batch_get_deployment_groups(applicationName, deploymentGroupNames, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("BatchGetDeploymentGroups", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("applicationName"=>applicationName, "deploymentGroupNames"=>deploymentGroupNames), params)); aws_config=aws_config)

"""
    batch_get_deployment_instances(deployment_id, instance_ids)
    batch_get_deployment_instances(deployment_id, instance_ids, params::Dict{String,<:Any})

  This method works, but is deprecated. Use BatchGetDeploymentTargets instead.    Returns
an array of one or more instances associated with a deployment. This method works with
EC2/On-premises and AWS Lambda compute platforms. The newer BatchGetDeploymentTargets works
with all compute platforms. The maximum number of instances that can be returned is 25.

# Arguments
- `deployment_id`:  The unique ID of a deployment.
- `instance_ids`: The unique IDs of instances used in the deployment. The maximum number of
  instance IDs you can specify is 25.

"""
batch_get_deployment_instances(deploymentId, instanceIds; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("BatchGetDeploymentInstances", Dict{String, Any}("deploymentId"=>deploymentId, "instanceIds"=>instanceIds); aws_config=aws_config)
batch_get_deployment_instances(deploymentId, instanceIds, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("BatchGetDeploymentInstances", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("deploymentId"=>deploymentId, "instanceIds"=>instanceIds), params)); aws_config=aws_config)

"""
    batch_get_deployment_targets()
    batch_get_deployment_targets(params::Dict{String,<:Any})

 Returns an array of one or more targets associated with a deployment. This method works
with all compute types and should be used instead of the deprecated
BatchGetDeploymentInstances. The maximum number of targets that can be returned is 25.  The
type of targets returned depends on the deployment's compute platform or deployment method:
    EC2/On-premises: Information about EC2 instance targets.     AWS Lambda: Information
about Lambda functions targets.     Amazon ECS: Information about Amazon ECS service
targets.     CloudFormation: Information about targets of blue/green deployments initiated
by a CloudFormation stack update.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"deploymentId"`:  The unique ID of a deployment.
- `"targetIds"`:  The unique IDs of the deployment targets. The compute platform of the
  deployment determines the type of the targets and their formats. The maximum number of
  deployment target IDs you can specify is 25.    For deployments that use the
  EC2/On-premises compute platform, the target IDs are EC2 or on-premises instances IDs, and
  their target type is instanceTarget.     For deployments that use the AWS Lambda compute
  platform, the target IDs are the names of Lambda functions, and their target type is
  instanceTarget.     For deployments that use the Amazon ECS compute platform, the target
  IDs are pairs of Amazon ECS clusters and services specified using the format
  <clustername>:<servicename>. Their target type is ecsTarget.     For
  deployments that are deployed with AWS CloudFormation, the target IDs are CloudFormation
  stack IDs. Their target type is cloudFormationTarget.
"""
batch_get_deployment_targets(; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("BatchGetDeploymentTargets"; aws_config=aws_config)
batch_get_deployment_targets(params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("BatchGetDeploymentTargets", params; aws_config=aws_config)

"""
    batch_get_deployments(deployment_ids)
    batch_get_deployments(deployment_ids, params::Dict{String,<:Any})

Gets information about one or more deployments. The maximum number of deployments that can
be returned is 25.

# Arguments
- `deployment_ids`:  A list of deployment IDs, separated by spaces. The maximum number of
  deployment IDs you can specify is 25.

"""
batch_get_deployments(deploymentIds; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("BatchGetDeployments", Dict{String, Any}("deploymentIds"=>deploymentIds); aws_config=aws_config)
batch_get_deployments(deploymentIds, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("BatchGetDeployments", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("deploymentIds"=>deploymentIds), params)); aws_config=aws_config)

"""
    batch_get_on_premises_instances(instance_names)
    batch_get_on_premises_instances(instance_names, params::Dict{String,<:Any})

Gets information about one or more on-premises instances. The maximum number of on-premises
instances that can be returned is 25.

# Arguments
- `instance_names`: The names of the on-premises instances about which to get information.
  The maximum number of instance names you can specify is 25.

"""
batch_get_on_premises_instances(instanceNames; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("BatchGetOnPremisesInstances", Dict{String, Any}("instanceNames"=>instanceNames); aws_config=aws_config)
batch_get_on_premises_instances(instanceNames, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("BatchGetOnPremisesInstances", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("instanceNames"=>instanceNames), params)); aws_config=aws_config)

"""
    continue_deployment()
    continue_deployment(params::Dict{String,<:Any})

For a blue/green deployment, starts the process of rerouting traffic from instances in the
original environment to instances in the replacement environment without waiting for a
specified wait time to elapse. (Traffic rerouting, which is achieved by registering
instances in the replacement environment with the load balancer, can start as soon as all
instances have a status of Ready.)

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"deploymentId"`:  The unique ID of a blue/green deployment for which you want to start
  rerouting traffic to the replacement environment.
- `"deploymentWaitType"`:  The status of the deployment's waiting period. READY_WAIT
  indicates that the deployment is ready to start shifting traffic. TERMINATION_WAIT
  indicates that the traffic is shifted, but the original target is not terminated.
"""
continue_deployment(; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("ContinueDeployment"; aws_config=aws_config)
continue_deployment(params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("ContinueDeployment", params; aws_config=aws_config)

"""
    create_application(application_name)
    create_application(application_name, params::Dict{String,<:Any})

Creates an application.

# Arguments
- `application_name`: The name of the application. This name must be unique with the
  applicable IAM user or AWS account.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"computePlatform"`:  The destination platform type for the deployment (Lambda, Server,
  or ECS).
- `"tags"`:  The metadata that you apply to CodeDeploy applications to help you organize
  and categorize them. Each tag consists of a key and an optional value, both of which you
  define.
"""
create_application(applicationName; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("CreateApplication", Dict{String, Any}("applicationName"=>applicationName); aws_config=aws_config)
create_application(applicationName, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("CreateApplication", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("applicationName"=>applicationName), params)); aws_config=aws_config)

"""
    create_deployment(application_name)
    create_deployment(application_name, params::Dict{String,<:Any})

Deploys an application revision through the specified deployment group.

# Arguments
- `application_name`: The name of an AWS CodeDeploy application associated with the IAM
  user or AWS account.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"autoRollbackConfiguration"`: Configuration information for an automatic rollback that
  is added when a deployment is created.
- `"deploymentConfigName"`: The name of a deployment configuration associated with the IAM
  user or AWS account. If not specified, the value configured in the deployment group is used
  as the default. If the deployment group does not have a deployment configuration associated
  with it, CodeDeployDefault.OneAtATime is used by default.
- `"deploymentGroupName"`: The name of the deployment group.
- `"description"`: A comment about the deployment.
- `"fileExistsBehavior"`: Information about how AWS CodeDeploy handles files that already
  exist in a deployment target location but weren't part of the previous successful
  deployment. The fileExistsBehavior parameter takes any of the following values:   DISALLOW:
  The deployment fails. This is also the default behavior if no option is specified.
  OVERWRITE: The version of the file from the application revision currently being deployed
  replaces the version already on the instance.   RETAIN: The version of the file already on
  the instance is kept and used as part of the new deployment.
- `"ignoreApplicationStopFailures"`:  If true, then if an ApplicationStop,
  BeforeBlockTraffic, or AfterBlockTraffic deployment lifecycle event to an instance fails,
  then the deployment continues to the next deployment lifecycle event. For example, if
  ApplicationStop fails, the deployment continues with DownloadBundle. If BeforeBlockTraffic
  fails, the deployment continues with BlockTraffic. If AfterBlockTraffic fails, the
  deployment continues with ApplicationStop.   If false or not specified, then if a lifecycle
  event fails during a deployment to an instance, that deployment fails. If deployment to
  that instance is part of an overall deployment and the number of healthy hosts is not less
  than the minimum number of healthy hosts, then a deployment to the next instance is
  attempted.   During a deployment, the AWS CodeDeploy agent runs the scripts specified for
  ApplicationStop, BeforeBlockTraffic, and AfterBlockTraffic in the AppSpec file from the
  previous successful deployment. (All other scripts are run from the AppSpec file in the
  current deployment.) If one of these scripts contains an error and does not run
  successfully, the deployment can fail.   If the cause of the failure is a script from the
  last successful deployment that will never run successfully, create a new deployment and
  use ignoreApplicationStopFailures to specify that the ApplicationStop, BeforeBlockTraffic,
  and AfterBlockTraffic failures should be ignored.
- `"revision"`:  The type and location of the revision to deploy.
- `"targetInstances"`:  Information about the instances that belong to the replacement
  environment in a blue/green deployment.
- `"updateOutdatedInstancesOnly"`:  Indicates whether to deploy to all instances or only to
  instances that are not running the latest application revision.
"""
create_deployment(applicationName; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("CreateDeployment", Dict{String, Any}("applicationName"=>applicationName); aws_config=aws_config)
create_deployment(applicationName, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("CreateDeployment", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("applicationName"=>applicationName), params)); aws_config=aws_config)

"""
    create_deployment_config(deployment_config_name)
    create_deployment_config(deployment_config_name, params::Dict{String,<:Any})

 Creates a deployment configuration.

# Arguments
- `deployment_config_name`: The name of the deployment configuration to create.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"computePlatform"`: The destination platform type for the deployment (Lambda, Server, or
  ECS).
- `"minimumHealthyHosts"`: The minimum number of healthy instances that should be available
  at any time during the deployment. There are two parameters expected in the input: type and
  value. The type parameter takes either of the following values:   HOST_COUNT: The value
  parameter represents the minimum number of healthy instances as an absolute value.
  FLEET_PERCENT: The value parameter represents the minimum number of healthy instances as a
  percentage of the total number of instances in the deployment. If you specify
  FLEET_PERCENT, at the start of the deployment, AWS CodeDeploy converts the percentage to
  the equivalent number of instances and rounds up fractional instances.   The value
  parameter takes an integer. For example, to set a minimum of 95% healthy instance, specify
  a type of FLEET_PERCENT and a value of 95.
- `"trafficRoutingConfig"`: The configuration that specifies how the deployment traffic is
  routed.
"""
create_deployment_config(deploymentConfigName; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("CreateDeploymentConfig", Dict{String, Any}("deploymentConfigName"=>deploymentConfigName); aws_config=aws_config)
create_deployment_config(deploymentConfigName, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("CreateDeploymentConfig", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("deploymentConfigName"=>deploymentConfigName), params)); aws_config=aws_config)

"""
    create_deployment_group(application_name, deployment_group_name, service_role_arn)
    create_deployment_group(application_name, deployment_group_name, service_role_arn, params::Dict{String,<:Any})

Creates a deployment group to which application revisions are deployed.

# Arguments
- `application_name`: The name of an AWS CodeDeploy application associated with the IAM
  user or AWS account.
- `deployment_group_name`: The name of a new deployment group for the specified application.
- `service_role_arn`: A service role Amazon Resource Name (ARN) that allows AWS CodeDeploy
  to act on the user's behalf when interacting with AWS services.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"alarmConfiguration"`: Information to add about Amazon CloudWatch alarms when the
  deployment group is created.
- `"autoRollbackConfiguration"`: Configuration information for an automatic rollback that
  is added when a deployment group is created.
- `"autoScalingGroups"`: A list of associated Amazon EC2 Auto Scaling groups.
- `"blueGreenDeploymentConfiguration"`: Information about blue/green deployment options for
  a deployment group.
- `"deploymentConfigName"`: If specified, the deployment configuration name can be either
  one of the predefined configurations provided with AWS CodeDeploy or a custom deployment
  configuration that you create by calling the create deployment configuration operation.
  CodeDeployDefault.OneAtATime is the default deployment configuration. It is used if a
  configuration isn't specified for the deployment or deployment group. For more information
  about the predefined deployment configurations in AWS CodeDeploy, see Working with
  Deployment Configurations in CodeDeploy in the AWS CodeDeploy User Guide.
- `"deploymentStyle"`: Information about the type of deployment, in-place or blue/green,
  that you want to run and whether to route deployment traffic behind a load balancer.
- `"ec2TagFilters"`: The Amazon EC2 tags on which to filter. The deployment group includes
  EC2 instances with any of the specified tags. Cannot be used in the same call as ec2TagSet.
- `"ec2TagSet"`: Information about groups of tags applied to EC2 instances. The deployment
  group includes only EC2 instances identified by all the tag groups. Cannot be used in the
  same call as ec2TagFilters.
- `"ecsServices"`:  The target Amazon ECS services in the deployment group. This applies
  only to deployment groups that use the Amazon ECS compute platform. A target Amazon ECS
  service is specified as an Amazon ECS cluster and service name pair using the format
  <clustername>:<servicename>.
- `"loadBalancerInfo"`: Information about the load balancer used in a deployment.
- `"onPremisesInstanceTagFilters"`: The on-premises instance tags on which to filter. The
  deployment group includes on-premises instances with any of the specified tags. Cannot be
  used in the same call as OnPremisesTagSet.
- `"onPremisesTagSet"`: Information about groups of tags applied to on-premises instances.
  The deployment group includes only on-premises instances identified by all of the tag
  groups. Cannot be used in the same call as onPremisesInstanceTagFilters.
- `"outdatedInstancesStrategy"`: Indicates what happens when new EC2 instances are launched
  mid-deployment and do not receive the deployed application revision. If this option is set
  to UPDATE or is unspecified, CodeDeploy initiates one or more 'auto-update outdated
  instances' deployments to apply the deployed application revision to the new EC2 instances.
  If this option is set to IGNORE, CodeDeploy does not initiate a deployment to update the
  new EC2 instances. This may result in instances having different revisions.
- `"tags"`:  The metadata that you apply to CodeDeploy deployment groups to help you
  organize and categorize them. Each tag consists of a key and an optional value, both of
  which you define.
- `"triggerConfigurations"`: Information about triggers to create when the deployment group
  is created. For examples, see Create a Trigger for an AWS CodeDeploy Event in the AWS
  CodeDeploy User Guide.
"""
create_deployment_group(applicationName, deploymentGroupName, serviceRoleArn; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("CreateDeploymentGroup", Dict{String, Any}("applicationName"=>applicationName, "deploymentGroupName"=>deploymentGroupName, "serviceRoleArn"=>serviceRoleArn); aws_config=aws_config)
create_deployment_group(applicationName, deploymentGroupName, serviceRoleArn, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("CreateDeploymentGroup", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("applicationName"=>applicationName, "deploymentGroupName"=>deploymentGroupName, "serviceRoleArn"=>serviceRoleArn), params)); aws_config=aws_config)

"""
    delete_application(application_name)
    delete_application(application_name, params::Dict{String,<:Any})

Deletes an application.

# Arguments
- `application_name`: The name of an AWS CodeDeploy application associated with the IAM
  user or AWS account.

"""
delete_application(applicationName; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("DeleteApplication", Dict{String, Any}("applicationName"=>applicationName); aws_config=aws_config)
delete_application(applicationName, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("DeleteApplication", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("applicationName"=>applicationName), params)); aws_config=aws_config)

"""
    delete_deployment_config(deployment_config_name)
    delete_deployment_config(deployment_config_name, params::Dict{String,<:Any})

Deletes a deployment configuration.  A deployment configuration cannot be deleted if it is
currently in use. Predefined configurations cannot be deleted.

# Arguments
- `deployment_config_name`: The name of a deployment configuration associated with the IAM
  user or AWS account.

"""
delete_deployment_config(deploymentConfigName; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("DeleteDeploymentConfig", Dict{String, Any}("deploymentConfigName"=>deploymentConfigName); aws_config=aws_config)
delete_deployment_config(deploymentConfigName, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("DeleteDeploymentConfig", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("deploymentConfigName"=>deploymentConfigName), params)); aws_config=aws_config)

"""
    delete_deployment_group(application_name, deployment_group_name)
    delete_deployment_group(application_name, deployment_group_name, params::Dict{String,<:Any})

Deletes a deployment group.

# Arguments
- `application_name`: The name of an AWS CodeDeploy application associated with the IAM
  user or AWS account.
- `deployment_group_name`: The name of a deployment group for the specified application.

"""
delete_deployment_group(applicationName, deploymentGroupName; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("DeleteDeploymentGroup", Dict{String, Any}("applicationName"=>applicationName, "deploymentGroupName"=>deploymentGroupName); aws_config=aws_config)
delete_deployment_group(applicationName, deploymentGroupName, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("DeleteDeploymentGroup", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("applicationName"=>applicationName, "deploymentGroupName"=>deploymentGroupName), params)); aws_config=aws_config)

"""
    delete_git_hub_account_token()
    delete_git_hub_account_token(params::Dict{String,<:Any})

Deletes a GitHub account connection.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"tokenName"`: The name of the GitHub account connection to delete.
"""
delete_git_hub_account_token(; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("DeleteGitHubAccountToken"; aws_config=aws_config)
delete_git_hub_account_token(params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("DeleteGitHubAccountToken", params; aws_config=aws_config)

"""
    delete_resources_by_external_id()
    delete_resources_by_external_id(params::Dict{String,<:Any})

Deletes resources linked to an external ID.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"externalId"`: The unique ID of an external resource (for example, a CloudFormation
  stack ID) that is linked to one or more CodeDeploy resources.
"""
delete_resources_by_external_id(; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("DeleteResourcesByExternalId"; aws_config=aws_config)
delete_resources_by_external_id(params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("DeleteResourcesByExternalId", params; aws_config=aws_config)

"""
    deregister_on_premises_instance(instance_name)
    deregister_on_premises_instance(instance_name, params::Dict{String,<:Any})

Deregisters an on-premises instance.

# Arguments
- `instance_name`: The name of the on-premises instance to deregister.

"""
deregister_on_premises_instance(instanceName; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("DeregisterOnPremisesInstance", Dict{String, Any}("instanceName"=>instanceName); aws_config=aws_config)
deregister_on_premises_instance(instanceName, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("DeregisterOnPremisesInstance", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("instanceName"=>instanceName), params)); aws_config=aws_config)

"""
    get_application(application_name)
    get_application(application_name, params::Dict{String,<:Any})

Gets information about an application.

# Arguments
- `application_name`: The name of an AWS CodeDeploy application associated with the IAM
  user or AWS account.

"""
get_application(applicationName; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("GetApplication", Dict{String, Any}("applicationName"=>applicationName); aws_config=aws_config)
get_application(applicationName, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("GetApplication", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("applicationName"=>applicationName), params)); aws_config=aws_config)

"""
    get_application_revision(application_name, revision)
    get_application_revision(application_name, revision, params::Dict{String,<:Any})

Gets information about an application revision.

# Arguments
- `application_name`: The name of the application that corresponds to the revision.
- `revision`: Information about the application revision to get, including type and
  location.

"""
get_application_revision(applicationName, revision; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("GetApplicationRevision", Dict{String, Any}("applicationName"=>applicationName, "revision"=>revision); aws_config=aws_config)
get_application_revision(applicationName, revision, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("GetApplicationRevision", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("applicationName"=>applicationName, "revision"=>revision), params)); aws_config=aws_config)

"""
    get_deployment(deployment_id)
    get_deployment(deployment_id, params::Dict{String,<:Any})

Gets information about a deployment.   The content property of the appSpecContent object in
the returned revision is always null. Use GetApplicationRevision and the sha256 property of
the returned appSpecContent object to get the content of the deployment’s AppSpec file.

# Arguments
- `deployment_id`:  The unique ID of a deployment associated with the IAM user or AWS
  account.

"""
get_deployment(deploymentId; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("GetDeployment", Dict{String, Any}("deploymentId"=>deploymentId); aws_config=aws_config)
get_deployment(deploymentId, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("GetDeployment", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("deploymentId"=>deploymentId), params)); aws_config=aws_config)

"""
    get_deployment_config(deployment_config_name)
    get_deployment_config(deployment_config_name, params::Dict{String,<:Any})

Gets information about a deployment configuration.

# Arguments
- `deployment_config_name`: The name of a deployment configuration associated with the IAM
  user or AWS account.

"""
get_deployment_config(deploymentConfigName; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("GetDeploymentConfig", Dict{String, Any}("deploymentConfigName"=>deploymentConfigName); aws_config=aws_config)
get_deployment_config(deploymentConfigName, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("GetDeploymentConfig", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("deploymentConfigName"=>deploymentConfigName), params)); aws_config=aws_config)

"""
    get_deployment_group(application_name, deployment_group_name)
    get_deployment_group(application_name, deployment_group_name, params::Dict{String,<:Any})

Gets information about a deployment group.

# Arguments
- `application_name`: The name of an AWS CodeDeploy application associated with the IAM
  user or AWS account.
- `deployment_group_name`: The name of a deployment group for the specified application.

"""
get_deployment_group(applicationName, deploymentGroupName; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("GetDeploymentGroup", Dict{String, Any}("applicationName"=>applicationName, "deploymentGroupName"=>deploymentGroupName); aws_config=aws_config)
get_deployment_group(applicationName, deploymentGroupName, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("GetDeploymentGroup", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("applicationName"=>applicationName, "deploymentGroupName"=>deploymentGroupName), params)); aws_config=aws_config)

"""
    get_deployment_instance(deployment_id, instance_id)
    get_deployment_instance(deployment_id, instance_id, params::Dict{String,<:Any})

Gets information about an instance as part of a deployment.

# Arguments
- `deployment_id`:  The unique ID of a deployment.
- `instance_id`:  The unique ID of an instance in the deployment group.

"""
get_deployment_instance(deploymentId, instanceId; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("GetDeploymentInstance", Dict{String, Any}("deploymentId"=>deploymentId, "instanceId"=>instanceId); aws_config=aws_config)
get_deployment_instance(deploymentId, instanceId, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("GetDeploymentInstance", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("deploymentId"=>deploymentId, "instanceId"=>instanceId), params)); aws_config=aws_config)

"""
    get_deployment_target()
    get_deployment_target(params::Dict{String,<:Any})

 Returns information about a deployment target.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"deploymentId"`:  The unique ID of a deployment.
- `"targetId"`:  The unique ID of a deployment target.
"""
get_deployment_target(; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("GetDeploymentTarget"; aws_config=aws_config)
get_deployment_target(params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("GetDeploymentTarget", params; aws_config=aws_config)

"""
    get_on_premises_instance(instance_name)
    get_on_premises_instance(instance_name, params::Dict{String,<:Any})

 Gets information about an on-premises instance.

# Arguments
- `instance_name`:  The name of the on-premises instance about which to get information.

"""
get_on_premises_instance(instanceName; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("GetOnPremisesInstance", Dict{String, Any}("instanceName"=>instanceName); aws_config=aws_config)
get_on_premises_instance(instanceName, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("GetOnPremisesInstance", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("instanceName"=>instanceName), params)); aws_config=aws_config)

"""
    list_application_revisions(application_name)
    list_application_revisions(application_name, params::Dict{String,<:Any})

Lists information about revisions for an application.

# Arguments
- `application_name`:  The name of an AWS CodeDeploy application associated with the IAM
  user or AWS account.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"deployed"`:  Whether to list revisions based on whether the revision is the target
  revision of a deployment group:     include: List revisions that are target revisions of a
  deployment group.    exclude: Do not list revisions that are target revisions of a
  deployment group.    ignore: List all revisions.
- `"nextToken"`: An identifier returned from the previous ListApplicationRevisions call. It
  can be used to return the next set of applications in the list.
- `"s3Bucket"`:  An Amazon S3 bucket name to limit the search for revisions.   If set to
  null, all of the user's buckets are searched.
- `"s3KeyPrefix"`:  A key prefix for the set of Amazon S3 objects to limit the search for
  revisions.
- `"sortBy"`: The column name to use to sort the list results:    registerTime: Sort by the
  time the revisions were registered with AWS CodeDeploy.    firstUsedTime: Sort by the time
  the revisions were first used in a deployment.    lastUsedTime: Sort by the time the
  revisions were last used in a deployment.    If not specified or set to null, the results
  are returned in an arbitrary order.
- `"sortOrder"`:  The order in which to sort the list results:     ascending: ascending
  order.    descending: descending order.   If not specified, the results are sorted in
  ascending order. If set to null, the results are sorted in an arbitrary order.
"""
list_application_revisions(applicationName; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("ListApplicationRevisions", Dict{String, Any}("applicationName"=>applicationName); aws_config=aws_config)
list_application_revisions(applicationName, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("ListApplicationRevisions", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("applicationName"=>applicationName), params)); aws_config=aws_config)

"""
    list_applications()
    list_applications(params::Dict{String,<:Any})

Lists the applications registered with the IAM user or AWS account.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"nextToken"`: An identifier returned from the previous list applications call. It can be
  used to return the next set of applications in the list.
"""
list_applications(; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("ListApplications"; aws_config=aws_config)
list_applications(params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("ListApplications", params; aws_config=aws_config)

"""
    list_deployment_configs()
    list_deployment_configs(params::Dict{String,<:Any})

Lists the deployment configurations with the IAM user or AWS account.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"nextToken"`: An identifier returned from the previous ListDeploymentConfigs call. It
  can be used to return the next set of deployment configurations in the list.
"""
list_deployment_configs(; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("ListDeploymentConfigs"; aws_config=aws_config)
list_deployment_configs(params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("ListDeploymentConfigs", params; aws_config=aws_config)

"""
    list_deployment_groups(application_name)
    list_deployment_groups(application_name, params::Dict{String,<:Any})

Lists the deployment groups for an application registered with the IAM user or AWS account.

# Arguments
- `application_name`: The name of an AWS CodeDeploy application associated with the IAM
  user or AWS account.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"nextToken"`: An identifier returned from the previous list deployment groups call. It
  can be used to return the next set of deployment groups in the list.
"""
list_deployment_groups(applicationName; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("ListDeploymentGroups", Dict{String, Any}("applicationName"=>applicationName); aws_config=aws_config)
list_deployment_groups(applicationName, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("ListDeploymentGroups", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("applicationName"=>applicationName), params)); aws_config=aws_config)

"""
    list_deployment_instances(deployment_id)
    list_deployment_instances(deployment_id, params::Dict{String,<:Any})

  The newer BatchGetDeploymentTargets should be used instead because it works with all
compute types. ListDeploymentInstances throws an exception if it is used with a compute
platform other than EC2/On-premises or AWS Lambda.    Lists the instance for a deployment
associated with the IAM user or AWS account.

# Arguments
- `deployment_id`:  The unique ID of a deployment.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"instanceStatusFilter"`: A subset of instances to list by status:    Pending: Include
  those instances with pending deployments.    InProgress: Include those instances where
  deployments are still in progress.    Succeeded: Include those instances with successful
  deployments.    Failed: Include those instances with failed deployments.    Skipped:
  Include those instances with skipped deployments.    Unknown: Include those instances with
  deployments in an unknown state.
- `"instanceTypeFilter"`: The set of instances in a blue/green deployment, either those in
  the original environment (\"BLUE\") or those in the replacement environment (\"GREEN\"),
  for which you want to view instance information.
- `"nextToken"`: An identifier returned from the previous list deployment instances call.
  It can be used to return the next set of deployment instances in the list.
"""
list_deployment_instances(deploymentId; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("ListDeploymentInstances", Dict{String, Any}("deploymentId"=>deploymentId); aws_config=aws_config)
list_deployment_instances(deploymentId, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("ListDeploymentInstances", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("deploymentId"=>deploymentId), params)); aws_config=aws_config)

"""
    list_deployment_targets()
    list_deployment_targets(params::Dict{String,<:Any})

 Returns an array of target IDs that are associated a deployment.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"deploymentId"`:  The unique ID of a deployment.
- `"nextToken"`:  A token identifier returned from the previous ListDeploymentTargets call.
  It can be used to return the next set of deployment targets in the list.
- `"targetFilters"`:  A key used to filter the returned targets. The two valid values are:
    TargetStatus - A TargetStatus filter string can be Failed, InProgress, Pending, Ready,
  Skipped, Succeeded, or Unknown.     ServerInstanceLabel - A ServerInstanceLabel filter
  string can be Blue or Green.
"""
list_deployment_targets(; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("ListDeploymentTargets"; aws_config=aws_config)
list_deployment_targets(params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("ListDeploymentTargets", params; aws_config=aws_config)

"""
    list_deployments()
    list_deployments(params::Dict{String,<:Any})

Lists the deployments in a deployment group for an application registered with the IAM user
or AWS account.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"applicationName"`: The name of an AWS CodeDeploy application associated with the IAM
  user or AWS account.  If applicationName is specified, then deploymentGroupName must be
  specified. If it is not specified, then deploymentGroupName must not be specified.
- `"createTimeRange"`: A time range (start and end) for returning a subset of the list of
  deployments.
- `"deploymentGroupName"`: The name of a deployment group for the specified application.
  If deploymentGroupName is specified, then applicationName must be specified. If it is not
  specified, then applicationName must not be specified.
- `"externalId"`: The unique ID of an external resource for returning deployments linked to
  the external resource.
- `"includeOnlyStatuses"`: A subset of deployments to list by status:    Created: Include
  created deployments in the resulting list.    Queued: Include queued deployments in the
  resulting list.    In Progress: Include in-progress deployments in the resulting list.
  Succeeded: Include successful deployments in the resulting list.    Failed: Include failed
  deployments in the resulting list.    Stopped: Include stopped deployments in the resulting
  list.
- `"nextToken"`: An identifier returned from the previous list deployments call. It can be
  used to return the next set of deployments in the list.
"""
list_deployments(; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("ListDeployments"; aws_config=aws_config)
list_deployments(params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("ListDeployments", params; aws_config=aws_config)

"""
    list_git_hub_account_token_names()
    list_git_hub_account_token_names(params::Dict{String,<:Any})

Lists the names of stored connections to GitHub accounts.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"nextToken"`: An identifier returned from the previous ListGitHubAccountTokenNames call.
  It can be used to return the next set of names in the list.
"""
list_git_hub_account_token_names(; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("ListGitHubAccountTokenNames"; aws_config=aws_config)
list_git_hub_account_token_names(params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("ListGitHubAccountTokenNames", params; aws_config=aws_config)

"""
    list_on_premises_instances()
    list_on_premises_instances(params::Dict{String,<:Any})

Gets a list of names for one or more on-premises instances. Unless otherwise specified,
both registered and deregistered on-premises instance names are listed. To list only
registered or deregistered on-premises instance names, use the registration status
parameter.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"nextToken"`: An identifier returned from the previous list on-premises instances call.
  It can be used to return the next set of on-premises instances in the list.
- `"registrationStatus"`: The registration status of the on-premises instances:
  Deregistered: Include deregistered on-premises instances in the resulting list.
  Registered: Include registered on-premises instances in the resulting list.
- `"tagFilters"`: The on-premises instance tags that are used to restrict the on-premises
  instance names returned.
"""
list_on_premises_instances(; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("ListOnPremisesInstances"; aws_config=aws_config)
list_on_premises_instances(params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("ListOnPremisesInstances", params; aws_config=aws_config)

"""
    list_tags_for_resource(resource_arn)
    list_tags_for_resource(resource_arn, params::Dict{String,<:Any})

 Returns a list of tags for the resource identified by a specified Amazon Resource Name
(ARN). Tags are used to organize and categorize your CodeDeploy resources.

# Arguments
- `resource_arn`:  The ARN of a CodeDeploy resource. ListTagsForResource returns all the
  tags associated with the resource that is identified by the ResourceArn.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"NextToken"`: An identifier returned from the previous ListTagsForResource call. It can
  be used to return the next set of applications in the list.
"""
list_tags_for_resource(ResourceArn; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("ListTagsForResource", Dict{String, Any}("ResourceArn"=>ResourceArn); aws_config=aws_config)
list_tags_for_resource(ResourceArn, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("ListTagsForResource", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ResourceArn"=>ResourceArn), params)); aws_config=aws_config)

"""
    put_lifecycle_event_hook_execution_status()
    put_lifecycle_event_hook_execution_status(params::Dict{String,<:Any})

 Sets the result of a Lambda validation function. The function validates lifecycle hooks
during a deployment that uses the AWS Lambda or Amazon ECS compute platform. For AWS Lambda
deployments, the available lifecycle hooks are BeforeAllowTraffic and AfterAllowTraffic.
For Amazon ECS deployments, the available lifecycle hooks are BeforeInstall, AfterInstall,
AfterAllowTestTraffic, BeforeAllowTraffic, and AfterAllowTraffic. Lambda validation
functions return Succeeded or Failed. For more information, see AppSpec 'hooks' Section for
an AWS Lambda Deployment  and AppSpec 'hooks' Section for an Amazon ECS Deployment.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"deploymentId"`:  The unique ID of a deployment. Pass this ID to a Lambda function that
  validates a deployment lifecycle event.
- `"lifecycleEventHookExecutionId"`:  The execution ID of a deployment's lifecycle hook. A
  deployment lifecycle hook is specified in the hooks section of the AppSpec file.
- `"status"`: The result of a Lambda function that validates a deployment lifecycle event.
  Succeeded and Failed are the only valid values for status.
"""
put_lifecycle_event_hook_execution_status(; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("PutLifecycleEventHookExecutionStatus"; aws_config=aws_config)
put_lifecycle_event_hook_execution_status(params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("PutLifecycleEventHookExecutionStatus", params; aws_config=aws_config)

"""
    register_application_revision(application_name, revision)
    register_application_revision(application_name, revision, params::Dict{String,<:Any})

Registers with AWS CodeDeploy a revision for the specified application.

# Arguments
- `application_name`: The name of an AWS CodeDeploy application associated with the IAM
  user or AWS account.
- `revision`: Information about the application revision to register, including type and
  location.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"description"`: A comment about the revision.
"""
register_application_revision(applicationName, revision; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("RegisterApplicationRevision", Dict{String, Any}("applicationName"=>applicationName, "revision"=>revision); aws_config=aws_config)
register_application_revision(applicationName, revision, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("RegisterApplicationRevision", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("applicationName"=>applicationName, "revision"=>revision), params)); aws_config=aws_config)

"""
    register_on_premises_instance(instance_name)
    register_on_premises_instance(instance_name, params::Dict{String,<:Any})

Registers an on-premises instance.  Only one IAM ARN (an IAM session ARN or IAM user ARN)
is supported in the request. You cannot use both.

# Arguments
- `instance_name`: The name of the on-premises instance to register.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"iamSessionArn"`: The ARN of the IAM session to associate with the on-premises instance.
- `"iamUserArn"`: The ARN of the IAM user to associate with the on-premises instance.
"""
register_on_premises_instance(instanceName; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("RegisterOnPremisesInstance", Dict{String, Any}("instanceName"=>instanceName); aws_config=aws_config)
register_on_premises_instance(instanceName, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("RegisterOnPremisesInstance", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("instanceName"=>instanceName), params)); aws_config=aws_config)

"""
    remove_tags_from_on_premises_instances(instance_names, tags)
    remove_tags_from_on_premises_instances(instance_names, tags, params::Dict{String,<:Any})

Removes one or more tags from one or more on-premises instances.

# Arguments
- `instance_names`: The names of the on-premises instances from which to remove tags.
- `tags`: The tag key-value pairs to remove from the on-premises instances.

"""
remove_tags_from_on_premises_instances(instanceNames, tags; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("RemoveTagsFromOnPremisesInstances", Dict{String, Any}("instanceNames"=>instanceNames, "tags"=>tags); aws_config=aws_config)
remove_tags_from_on_premises_instances(instanceNames, tags, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("RemoveTagsFromOnPremisesInstances", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("instanceNames"=>instanceNames, "tags"=>tags), params)); aws_config=aws_config)

"""
    skip_wait_time_for_instance_termination()
    skip_wait_time_for_instance_termination(params::Dict{String,<:Any})

In a blue/green deployment, overrides any specified wait time and starts terminating
instances immediately after the traffic routing is complete.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"deploymentId"`:  The unique ID of a blue/green deployment for which you want to skip
  the instance termination wait time.
"""
skip_wait_time_for_instance_termination(; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("SkipWaitTimeForInstanceTermination"; aws_config=aws_config)
skip_wait_time_for_instance_termination(params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("SkipWaitTimeForInstanceTermination", params; aws_config=aws_config)

"""
    stop_deployment(deployment_id)
    stop_deployment(deployment_id, params::Dict{String,<:Any})

Attempts to stop an ongoing deployment.

# Arguments
- `deployment_id`:  The unique ID of a deployment.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"autoRollbackEnabled"`:  Indicates, when a deployment is stopped, whether instances that
  have been updated should be rolled back to the previous version of the application
  revision.
"""
stop_deployment(deploymentId; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("StopDeployment", Dict{String, Any}("deploymentId"=>deploymentId); aws_config=aws_config)
stop_deployment(deploymentId, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("StopDeployment", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("deploymentId"=>deploymentId), params)); aws_config=aws_config)

"""
    tag_resource(resource_arn, tags)
    tag_resource(resource_arn, tags, params::Dict{String,<:Any})

 Associates the list of tags in the input Tags parameter with the resource identified by
the ResourceArn input parameter.

# Arguments
- `resource_arn`:  The ARN of a resource, such as a CodeDeploy application or deployment
  group.
- `tags`:  A list of tags that TagResource associates with a resource. The resource is
  identified by the ResourceArn input parameter.

"""
tag_resource(ResourceArn, Tags; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("TagResource", Dict{String, Any}("ResourceArn"=>ResourceArn, "Tags"=>Tags); aws_config=aws_config)
tag_resource(ResourceArn, Tags, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("TagResource", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ResourceArn"=>ResourceArn, "Tags"=>Tags), params)); aws_config=aws_config)

"""
    untag_resource(resource_arn, tag_keys)
    untag_resource(resource_arn, tag_keys, params::Dict{String,<:Any})

 Disassociates a resource from a list of tags. The resource is identified by the
ResourceArn input parameter. The tags are identified by the list of keys in the TagKeys
input parameter.

# Arguments
- `resource_arn`:  The Amazon Resource Name (ARN) that specifies from which resource to
  disassociate the tags with the keys in the TagKeys input parameter.
- `tag_keys`:  A list of keys of Tag objects. The Tag objects identified by the keys are
  disassociated from the resource specified by the ResourceArn input parameter.

"""
untag_resource(ResourceArn, TagKeys; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("UntagResource", Dict{String, Any}("ResourceArn"=>ResourceArn, "TagKeys"=>TagKeys); aws_config=aws_config)
untag_resource(ResourceArn, TagKeys, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("UntagResource", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ResourceArn"=>ResourceArn, "TagKeys"=>TagKeys), params)); aws_config=aws_config)

"""
    update_application()
    update_application(params::Dict{String,<:Any})

Changes the name of an application.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"applicationName"`: The current name of the application you want to change.
- `"newApplicationName"`: The new name to give the application.
"""
update_application(; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("UpdateApplication"; aws_config=aws_config)
update_application(params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("UpdateApplication", params; aws_config=aws_config)

"""
    update_deployment_group(application_name, current_deployment_group_name)
    update_deployment_group(application_name, current_deployment_group_name, params::Dict{String,<:Any})

Changes information about a deployment group.

# Arguments
- `application_name`: The application name that corresponds to the deployment group to
  update.
- `current_deployment_group_name`: The current name of the deployment group.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"alarmConfiguration"`: Information to add or change about Amazon CloudWatch alarms when
  the deployment group is updated.
- `"autoRollbackConfiguration"`: Information for an automatic rollback configuration that
  is added or changed when a deployment group is updated.
- `"autoScalingGroups"`: The replacement list of Auto Scaling groups to be included in the
  deployment group, if you want to change them. To keep the Auto Scaling groups, enter their
  names. To remove Auto Scaling groups, do not enter any Auto Scaling group names.
- `"blueGreenDeploymentConfiguration"`: Information about blue/green deployment options for
  a deployment group.
- `"deploymentConfigName"`: The replacement deployment configuration name to use, if you
  want to change it.
- `"deploymentStyle"`: Information about the type of deployment, either in-place or
  blue/green, you want to run and whether to route deployment traffic behind a load balancer.
- `"ec2TagFilters"`: The replacement set of Amazon EC2 tags on which to filter, if you want
  to change them. To keep the existing tags, enter their names. To remove tags, do not enter
  any tag names.
- `"ec2TagSet"`: Information about groups of tags applied to on-premises instances. The
  deployment group includes only EC2 instances identified by all the tag groups.
- `"ecsServices"`:  The target Amazon ECS services in the deployment group. This applies
  only to deployment groups that use the Amazon ECS compute platform. A target Amazon ECS
  service is specified as an Amazon ECS cluster and service name pair using the format
  <clustername>:<servicename>.
- `"loadBalancerInfo"`: Information about the load balancer used in a deployment.
- `"newDeploymentGroupName"`: The new name of the deployment group, if you want to change
  it.
- `"onPremisesInstanceTagFilters"`: The replacement set of on-premises instance tags on
  which to filter, if you want to change them. To keep the existing tags, enter their names.
  To remove tags, do not enter any tag names.
- `"onPremisesTagSet"`: Information about an on-premises instance tag set. The deployment
  group includes only on-premises instances identified by all the tag groups.
- `"outdatedInstancesStrategy"`: Indicates what happens when new EC2 instances are launched
  mid-deployment and do not receive the deployed application revision. If this option is set
  to UPDATE or is unspecified, CodeDeploy initiates one or more 'auto-update outdated
  instances' deployments to apply the deployed application revision to the new EC2 instances.
  If this option is set to IGNORE, CodeDeploy does not initiate a deployment to update the
  new EC2 instances. This may result in instances having different revisions.
- `"serviceRoleArn"`: A replacement ARN for the service role, if you want to change it.
- `"triggerConfigurations"`: Information about triggers to change when the deployment group
  is updated. For examples, see Edit a Trigger in a CodeDeploy Deployment Group in the AWS
  CodeDeploy User Guide.
"""
update_deployment_group(applicationName, currentDeploymentGroupName; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("UpdateDeploymentGroup", Dict{String, Any}("applicationName"=>applicationName, "currentDeploymentGroupName"=>currentDeploymentGroupName); aws_config=aws_config)
update_deployment_group(applicationName, currentDeploymentGroupName, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = codedeploy("UpdateDeploymentGroup", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("applicationName"=>applicationName, "currentDeploymentGroupName"=>currentDeploymentGroupName), params)); aws_config=aws_config)


text:
import Base: isequal, push!, length, start, next, done, match, show, print, showerror, isempty
export LeafNode, name, length, _end, LeafNode, pprettily, AnyNode, MatchNode, ParentNode, Node, NodeVisitor, isempty, nodetext, print, show, DEFUNCT_visit, VisitationError, showerror, push!, lift_child, EmptyNode, textlength, pos

# I don't think EmptyNodes ever go in the tree. They are just used as a sort of
# error message. You return an EmptyNode when you fail to match, for example.

abstract MatchNode

immutable ParentNode{T} <: MatchNode
    match::SubString
    children::Tuple

    # TODO: More specific type for children
    # Array{AbstractNode, 1} or Array{Node, 1} or Array{Node{:}} don't seem to work
end

immutable LeafNode{T} <: MatchNode
    match::SubString
end

# Union does not serve my purposes
# Node = Union(ParentNode, EmptyNode, RegexNode, ChildlessNode)
# MatchNode = Union(ParentNode, ChildlessNode)
typealias EmptyNode LeafNode{:ifeelsoempty}
AnyNode = Union(EmptyNode, ParentNode, LeafNode)

# Convenience
## Parent
function Node(T::String, match::SubString, children)
    ParentNode{symbol(T)}(match, children)
end

## Leaf
function Node(T::String, match::SubString)
    LeafNode{symbol(T)}(match)
end

# Empty
EmptyNode() = LeafNode{:ifeelsoempty}(SubString("", 1))
Node() = EmptyNode()

function goodnode_iprint(io::IO, n::MatchNode, indent::ASCIIString = "")
    # TODO: Right justify the text
    nodeinfo = "$(pos(n)) $(typeof(n))"
    nodetext = lpad("'$(n.match)'\n", 80 - length(indent) - length(nodeinfo))
    print(io, indent, nodeinfo, nodetext)
end

function iprint(io::IO, n::ParentNode, indent::ASCIIString = "")
    goodnode_iprint(io, n, indent)
    for c in n.children
        iprint(io, c, indent * "  .  ")
    end
end

function iprint(io::IO, n::LeafNode, indent::ASCIIString = "")
    goodnode_iprint(io, n, indent)
end

show(io::IO, n::MatchNode) = iprint(io, n)

type VisitationError <:Exception
    node
    exc
end

#"""Something went wrong while traversing a parse tree.
#
#This exception exists to augment an underlying exception with information
#about where in the parse tree the error occurred. Otherwise, it could be
#tiresome to figure out what went wrong; you'd have to play back the whole
#tree traversal in your head.
#
#"""
## TODO: Make sure this is pickleable. Probably use @property pattern. Make
## the original exc and node available on it if they don't cause a whole
## raft of stack frames to be retained.

function showerror(io::IO, e::VisitationError)
    println(io, "VISITATION ERROR")
    print(io, "Exception: ")
    # TODO: showerror
    print(io, string(e.exc))
    print(io, "\nParse tree:\n")
    print(io, prettily(e.node, e.node))
end

## Really type-parameter but we're using that as the node's "name"
function name(n::AnyNode)
    s = string(typeof(n))
    if search(s, ':') == 0
        return ""
    end
    s[search(s, ':')+1:end-1]
end

isempty(::LeafNode{:ifeelsoempty}) = true
isempty(::AnyNode) = false

function base_isequal(a::MatchNode, b::MatchNode)
    typeof(a) == typeof(b) || return false
    length(a) == length(b) || return false
    a.match == b.match || return false
    true
end

isequal(a::LeafNode, b::LeafNode) = base_isequal(a::MatchNode, b::MatchNode)
isequal(a::ParentNode, b::LeafNode) = false
isequal(a::LeafNode, b::ParentNode) = false

function isequal(a::ParentNode, b::ParentNode)
    base_isequal(a, b) || return false

    for (childa, childb) in zip(a.children, b.children)
        childa == childb || return false
    end
    true
end

# TODO: Can't work with children a tuple. delete ... have to make a new tuple if necessary
#function push!(node::ParentNode, child::MatchNode...)
#    push!(node.children, child...)
#end

function indent(s,indstr="| ")
    return join([indstr * line for line in split(s, '\n')], "\n")
end

## Make an error string if the testnode is the errnode
function errstring(testnode, errnode)
    errnode === testnode ? " <-- *** Error here ***" : ""
end

# I don't think empty nodes go in tree ... maybe delete this:
function prettily(node::EmptyNode, errnode::AnyNode=EmptyNode())
    return "<empty>$(errstring(node, errnode))"
end

# function prettily{T}(node::Node{T}, err::Node=Node())
function prettily{T}(node::ParentNode{T}, errnode::AnyNode=EmptyNode())
    ret = ["<'$(T)' matching '$(escape_string(node.match))'>$(errstring(node, errnode))"]
    for child in node
        push!(ret, indent(prettily(child, errnode)))
    end
    return join(ret, "\n")
end

function prettily{T}(node::LeafNode{T}, errnode::AnyNode=EmptyNode())
    "<'$(T)' matching '$(escape_string(node.match))'>$(errstring(node, errnode))"
end

# TODO merge functions prettily and show which do very similar things
function pprettily(x...)
    println(prettily(x...))
end

## Thanks base/iterator.jl
## Iterate over Node children. I could turn this into the depth-first-search mechanism but that's not how Parsimonious does it.
length(n::ParentNode) = length(n.children)
start(n::ParentNode) = 1
function next(n::ParentNode, state)
    n.children[state], state+1
end
done(n::ParentNode, state) = state > length(n.children)

length(::EmptyNode) = 0
length(::LeafNode) = 0  # LeafNode

#
abstract NodeVisitor
#
## depth-first top-level visitation GO!
## Means you can't overload visit with less than 3 paramaeters without
## being very carefully. Maybe should give this it's own name like 'visit_all'
## Though I do appreciate the slickness of naming every function 'visit'
#
## Currently handled in Grammars but TODO: move back here
# Refactor: Pass around fulltext with every call. Seems fun.
# TODO: For child nodes

function DEFUNCT_visit_on_the_way_down(v::NodeVisitor, node::ParentNode)
    return [DEFUNCT_visit(v, n) for n in node]
end

# No children
DEFUNCT_visit_on_the_way_down(v::NodeVisitor, node::LeafNode) = []

function DEFUNCT_visit(v::NodeVisitor, node::MatchNode)
    visited_children = DEFUNCT_visit_on_the_way_down(v, node)
    try
        # TODO: Move this whole thing to tuples -- but not now
        # TODO: uncomment for debug mode
#        @show v
#        @show name(node)
#        @show visited_children
#        @which visit(v, node, visited_children)
        returns = DEFUNCT_visit(v, node, visited_children)
#        @show returns
        return returns
    catch e
        if isa(e, VisitationError)
            rethrow(e)
        else
            rethrow(VisitationError(node, e))
        end
    end
end

## generic_visit -- not implemented in base class as it were
function DEFUNCT_visit{T}(v::NodeVisitor, n::ParentNode{T}, visited_children)
    # TODO: backtrace broken
    # TODO: backtrace works on Linux, broken on OSX only?
    println("Go implement visit(::$(string(typeof(v))), ::Node{$(name(n))})) right now!")
    error("Go implement visit(::$(string(typeof(v))), ::Node{$(name(n))})) right now!")
end

## conveniently replace a node with its own visited_children
function lift_child(v::NodeVisitor, n::ParentNode, visited_children)
    return visited_children[1]
end

# Refactoring convenience
# TODO: test or remove
import Base.chr2ind

Node(T::String, fulltext::String, start::Int, endind::Int, children::Tuple) = Node(T, SubString(fulltext, start, endind), children)
Node(T::String, fulltext::String, start::Int, endind::Int) = Node(T, SubString(fulltext, start, endind))
_end(n::MatchNode) = n.match.endof == 0 ? prevind(n.match.string, pos(n) - 1) : n.match.offset + n.match.endof
pos(n::MatchNode) = n.match.offset + (n.match.endof == 0 ? 0 : 1)
# refactor pos -> ind since we deal in byte indecies now
# refactor _end
nodetext(n::MatchNode) = n.match

textlength(node::MatchNode) = endof(node.match)

##### new visitor ########

# TODO: RulesVisitor and test visitors to adopt new vararg visitor technolgy
function visit_on_the_way_down(v::NodeVisitor, node::ParentNode)
    return [govisit(v, n) for n in node]
end

# No children
visit_on_the_way_down(v::NodeVisitor, node::LeafNode) = []

# TODO: better debug mode that prints:
#   parse tree  --  rule --  visit(visitor, node, param, param, ...) -- return value
# The tree can be upside down in Visitor order
# Auto-spacing based on column matched.
# Then you can just accept the default visit rules and go through
# the debug to figure out how to process things
#
function govisit(v::NodeVisitor, node::MatchNode)
    visited_children = visit_on_the_way_down(v, node)
    visited_children = filter(x -> x != nothing, visited_children)
    try
        return visit(v, node, visited_children...)
    catch e
        if isa(e, VisitationError)
            rethrow(e)
        else
            rethrow(VisitationError(node, e))
        end
    end
end

function whicht(io::IO, f, types)
    for m in methods(f, types)
        lsd = m.func.code::LambdaStaticData
        d = f.env.defs
        while !is(d,())
            if is(d.func.code, lsd)
                print(io, f.env.name)
                show(io, d); println(io)
                return
            end
            d = d.next
        end
    end
end

which(io::IO, f, args...) = whicht(io, f, map(a->(isa(a,Type) ? Type{a} : typeof(a)), args))

function strwhich(f, args...)
    io = IOString()
    which(io, f, args...)
    seekstart(io)
    s = readline(io)
    replace(s, r"\)[^)]*$", ")")
end

type PrettyTable
    ncols::Int
    chars_per_col
    rows
    display_width
end

function PrettyTable(ncols)
    # TODO: many problems with `tput cols`
    #  * Linux / OSX only
    #  * What if the session changes size? (Should be in the print function)
    #  * What if it's going to a text file?
    term_width = int(readall(`tput cols`))
    PrettyTable(ncols, repeat([0], inner=[ncols]), Any[], term_width - 3 * (ncols+1))
end

function newrow(t::PrettyTable, row)
    row = [chomp(col) for col in row]
    push!(t.rows, row)
    for (i, col) in enumerate(row)
        t.chars_per_col[i] = max(t.chars_per_col[i], length(col))
    end
end
# TODO: header/fields; column justification, wrapping columns, adjust
# for width of verminal
import Base.print

function calc_display_chars_per_col(chars_per_col, display_width)
    display_chars_per_col = copy(chars_per_col)
    # Um why not just subtract one character from the longest column until it fits?
    for i in sum(chars_per_col):-1:display_width
        display_chars_per_col[indmax(display_chars_per_col)] -= 1
    end
    display_chars_per_col
end

# TODO: Unicode. Some function tells me how many display characters per unicode string.
# TODO: Break lines in more friendly places like space or commas
function print_columns(io::IO, t::PrettyTable, cols, display_chars_per_col)
    cols = copy(cols)
    while sum(map(length, cols)) > 0
        for (i, (colwidth, col)) in enumerate(zip(display_chars_per_col, cols))
            print(io, rpad(col[1:min(colwidth,end)], colwidth), " | ")
            cols[i] = col[colwidth+1:]
        end
        println(io)
    end
end

function print(io::IO, t::PrettyTable)
    display_chars_per_col = calc_display_chars_per_col(t.chars_per_col, t.display_width - 3 * t.ncols)
    horizl = "-" ^ min(3 * t.ncols + sum(t.chars_per_col), t.display_width) * "\n"
    print(io, horizl)
    for row in t.rows
        print_columns(io, t, row, display_chars_per_col)
    end
    print(io, horizl)
end

# TODO: Tutorial.jl
# TODO: Pretty.jl

#t = PrettyTable(3)
#newrow(t, ["hi", "derp", "blergityblerg"])
#newrow(t, ["derp", "do", strwhich(print, STDOUT, t)])
#println(t)

#f() = "hi"
#println("strwhich(f)", strwhich(f))
#println("strwhich(f, []...)", strwhich(f, []...))

function debug_visit_on_the_way_down(v::NodeVisitor, node::ParentNode, ptable, indent)
    return [debug_govisit(v, n, ptable, indent) for n in node]
end

debug_visit_on_the_way_down(v::NodeVisitor, node::LeafNode, ptable, indent) = []

function debug_govisit(v::NodeVisitor, node::MatchNode, ptable=PrettyTable(3), indent="")
    visited_children = debug_visit_on_the_way_down(v, node, ptable, indent * " . ")
    visited_children = filter(x -> x != nothing, visited_children)
    try
        whichvisitor = strwhich(visit, v, node, visited_children...)
        namenode = name(node)
        strchildren = isa(node, LeafNode)   ?
            "\"" * nodetext(node) * "\""    :
            join([sprint(show, vc) for vc in visited_children], ", ")
        returns = visit(v, node, visited_children...)
        returnstr = sprint(show, returns)
        newrow(ptable,[indent * whichvisitor, namenode, strchildren * " -> " * returnstr])
        if indent == ""
            println(ptable)
        end
        return returns
    catch e
        println(ptable)
        if isa(e, VisitationError)
            rethrow(e)
        else
            rethrow(VisitationError(node, e))
        end
    end
end

# Default visit methods
visit(::NodeVisitor, n::LeafNode) = nodetext(n)
visit(::NodeVisitor, n::ParentNode, visited_children...) = visited_children


text:
# -*- coding: utf-8 -*-
# ---
# jupyter:
#   jupytext:
#     formats: ipynb,jl:hydrogen
#     text_representation:
#       extension: .jl
#       format_name: hydrogen
#       format_version: '1.3'
#       jupytext_version: 1.11.2
#   kernelspec:
#     display_name: Julia 1.8.0-DEV
#     language: julia
#     name: julia-1.8
# ---

# %%
using Test, Statistics
L = 20;

# %%
function f(L)
    a = zeros(Int, 2^L)
    for j in 0:2^L-1
        for i in 0:L-1
            a[begin + (j ⊻ (1 << i))] += 1
        end
    end
    a
end
@test f(L) == fill(L, 2^L)

# %%
function f_ill_multithreaded(L)
    a = zeros(Int, 2^L)
    Threads.@threads for j in 0:2^L-1
        for i in 0:L-1
            a[begin + (j ⊻ (1 << i))] += 1
        end
    end
    a
end
@test f_ill_multithreaded(L) == fill(L, 2^L)

# %%
function f_well_multithreaded(L)
    a = zeros(Int, 2^L)
    for i in 0:L-1
        Threads.@threads for j in 0:2^L-1
            a[begin + (j ⊻ (1 << i))] += 1
        end
    end
    a
end
@test f_well_multithreaded(L) == fill(L, 2^L)

# %%
@show mean(f(L))
@show mean(f_ill_multithreaded(L))
@show mean(f_well_multithreaded(L));

# %%
[mean(f_ill_multithreaded(L)) for _ in 1:20]

# %%

max_stars_repo_path: 0015/Arpack/ill-multithreaded case.jl

max_stars_repo_name: genkuroki/public

max_issues_repo_path: 0015/Arpack/ill-multithreaded case.jl

max_issues_repo_name: genkuroki/public

max_forks_repo_path: 0015/Arpack/ill-multithreaded case.jl

max_forks_repo_name: genkuroki/public