text:
# ----------------------------------
# -- Reference
# Planetary Mission Entry Vehicles Quick Reference Guide. Version 3.0
# Davies, Carol (Eloret Corp. Moffett Field, CA, United States), Arcadi, Marla
# January 1, 2006
# https://ntrs.nasa.gov/citations/20070022789
# ----------------------------------

using Printf

function cal_area1()
    n = 20
    r = 0.202
    finx, finy = -0.15724, 0.12971

    x1 = zeros(n)
    y1 = zeros(n)

    t = asin(finy/r)
    dt = t/n

    for i in 1:n
        x1[i] = -r * cos(dt*(i-1))
        y1[i] =  r * sin(dt*(i-1))
    end
    return x1,y1
end

function cal_area2()
    n = 5
    stax, stay = -0.15724, 0.12971
    finx, finy = -0.085, 0.202

    x2 = zeros(n)
    y2 = zeros(n)

    l   = ((stax-finx)^2 + (stay-finy)^2)^0.5
    dx  = l/n

    templ = 0.0
    for i in 1:n
        x2[i] = (l-templ)/l*stax + templ/l*finx
        y2[i] = (l-templ)/l*stay + templ/l*finy
        templ += dx
    end
    return x2,y2
end

function cal_area3()
    n = 5
    stax, stay = -0.085, 0.202
    finx, finy = 0.0, 0.117

    x3 = zeros(n)
    y3 = zeros(n)

    l   = ((stax-finx)^2 + (stay-finy)^2)^0.5
    dx  = l/n

    templ = 0.0
    for i in 1:n
        x3[i] = (l-templ)/l*stax + templ/l*finx
        y3[i] = (l-templ)/l*stay + templ/l*finy
        templ += dx
    end
    return x3,y3
end

function cal_area4()
    n = 5
    stax, stay = 0.0, 0.117
    finx, finy = 0.0, 0.0

    x4 = zeros(n+1)
    y4 = zeros(n+1)

    l   = ((stax-finx)^2 + (stay-finy)^2)^0.5
    dx  = l/n

    templ = 0.0
    for i in 1:n
        x4[i] = (l-templ)/l*stax + templ/l*finx
        y4[i] = (l-templ)/l*stay + templ/l*finy
        templ += dx
    end
    x4[n+1] = finx
    y4[n+1] = finy

    return x4,y4
end

function matome(x1,x2,x3,x4,y1,y2,y3,y4)
    n = length(x1) + length(x2) + length(x3) + length(x4)

    x = zeros(n)
    y = zeros(n)

    n1 = length(x1)
    n2 = length(x1) + length(x2)
    n3 = length(x1) + length(x2) + length(x3)
    n4 = length(x1) + length(x2) + length(x3) + length(x4)
    for i in 1:n1
        x[i] = x1[i]
        y[i] = y1[i]
    end
    for i in n1+1:n2
        x[i] = x2[i-n1]
        y[i] = y2[i-n1]
    end
    for i in n2+1:n3
        x[i] = x3[i-n2]
        y[i] = y3[i-n2]
    end
    for i in n3+1:n4
        x[i] = x4[i-n3]
        y[i] = y4[i-n3]
    end
    return x, y
end

function cal_bot(topx, topy)
    n = length(topx)
    botx = zeros(n)
    boty = zeros(n)

    for i in 1:n
        botx[i] = topx[i]
        boty[i] = -topy[i]
    end

    tx = zeros(n-2)
    ty = zeros(n-2)
    for i in 1:n-2
        tx[i] = topx[i+1]
        ty[i] = topy[i+1]
    end

    return tx,ty,botx,boty
end

function main()
    fout = "hayabusa_shape"

    x1, y1 = cal_area1()
    x2, y2 = cal_area2()
    x3, y3 = cal_area3()
    x4, y4 = cal_area4()

    topx, topy = matome(x1,x2,x3,x4,y1,y2,y3,y4)
    topx, topy, botx, boty = cal_bot(topx, topy)

    nt = length(topx)
    nb = length(botx)
    open(fout,"w") do f
        write(f,"hayabusa \n")
        a1 = string(nt)
        a2 = string(nb)
        write(f, a1*" "*a2*"\n")
        write(f, "\n")

        for i in 1:nt
            a1 = @sprintf("%8.8e", topx[i])
            a2 = @sprintf("%8.8e", topy[i])
            write(f, a1*" "*a2*"\n")
        end
        write(f, "\n")
        for i in 1:nb
            a1 = @sprintf("%8.8e", botx[i])
            a2 = @sprintf("%8.8e", boty[i])
            write(f, a1*" "*a2*"\n")
        end
    end
end

# ---------------------------------
main()


text:
module CoolPropExtensions
import CoolProp
using QuadGK

export update, keyed_output, first_partial_deriv, free
export InputPair, Property, WorkingFluid

include("Types.jl")
include("abstractstate_wrapper.jl")
include("constant_property_path_integral.jl")

end # module

ext: jl


text:
import PyCall

#Test basic rospy interactions
init_node("jltest", anonymous=true)

#Parameters
@test length(RobotOS.get_param_names()) > 0
@test has_param("rosdistro")
@test chomp(get_param("rosdistro")) in ["hydro", "indigo", "jade", "kinetic", "lunar", "melodic"]
@test ! has_param("some_param")
@test_throws KeyError get_param("some_param")
@test_throws KeyError delete_param("some_param")
@test get_param("some_param", 1.1) == 1.1
@test get_param("some_param", "some_val") == "some_val"
set_param("some_param", "val")
@test get_param("some_param", 1.1) == "val"
delete_param("some_param")
@test ! has_param("some_param")

#Really just running this stuff for coverage

#Logging
logdebug("testing: %s", "debug")
loginfo("testing: %s", "info")
logwarn("testing: %s", "warn")
logerr("testing: %s", "err")
logfatal("testing: %s", "fatal")
@test ! is_shutdown()

#Generic stuff
@test startswith(RobotOS.get_name()[2:end], "jltest")
@test RobotOS.get_namespace() == "/"
RobotOS.get_node_uri()
RobotOS.get_caller_id()
RobotOS.get_published_topics()
RobotOS.get_ros_root()

#Issue 73 - Corruption of Python sys.argv
PyCall.py"""
import argparse
argparse.ArgumentParser()
"""


text:
"""
cond(m::MixedModel)

Return a vector of condition numbers of the λ matrices for the random-effects terms
"""
LinearAlgebra.cond(m::MixedModel) = cond.(m.λ)

"""
    issingular(m::MixedModel, θ=m.θ)

Test whether the model `m` is singular if the parameter vector is `θ`.

Equality comparisons are used b/c small non-negative θ values are replaced by 0 in `fit!`.
"""
issingular(m::MixedModel, θ=m.θ) = any(lowerbd(m) .== θ)

function retbl(mat, trm)
    merge(
        NamedTuple{(fname(trm),)}((trm.levels,)),
        columntable(Tables.table(transpose(mat), header=Symbol.(trm.cnames))),
        )
end

"""
    raneftables(m::LinearMixedModel; uscale = false)

Return the conditional means of the random effects as a NamedTuple of columntables
"""
function raneftables(m::MixedModel{T}; uscale = false) where {T}
    NamedTuple{fnames(m)}((map(retbl, ranef(m, uscale=uscale), m.reterms)...,))
end

function σs(m::MixedModel)
    σ = dispersion(m)
    NamedTuple{fnames(m)}(((σs(t, σ) for t in m.reterms)...,))
end

function σρs(m::MixedModel)
    σ = dispersion(m)
    NamedTuple{fnames(m)}(((σρs(t, σ) for t in m.reterms)...,))
end

"""
    vcov(m::MixedModel; corr=false)

Returns the variance-covariance matrix of the fixed effects.
If `corr=true`, then correlation of fixed effects is returned instead.
"""
function StatsBase.vcov(m::MixedModel; corr=false)
    Xtrm = first(m isa GeneralizedLinearMixedModel ? m.LMM.feterms : m.feterms)
    iperm = invperm(Xtrm.piv)
    p = length(iperm)
    r = Xtrm.rank
    Linv = inv(feL(m))
    T = eltype(Linv)
    permvcov = dispersion(m, true) * (Linv'Linv)
    if p == Xtrm.rank
        vv = permvcov[iperm, iperm]
    else
        covmat = fill(zero(T) / zero(T), (p, p))
        for j = 1:r, i = 1:r
            covmat[i, j] = permvcov[i, j]
        end
        vv = covmat[iperm, iperm]
    end

    corr ?  StatsBase.cov2cor!(vv, stderror(m)) : vv
end


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

using AWS.Compat
using AWS.UUIDs
"""
    BatchDeleteWorlds()

Deletes one or more worlds in a batch operation.

# Required Parameters
- `worlds`: A list of Amazon Resource Names (arns) that correspond to worlds to delete.

"""

batch_delete_worlds(worlds; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/batchDeleteWorlds", Dict{String, Any}("worlds"=>worlds); aws_config=aws_config)
batch_delete_worlds(worlds, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/batchDeleteWorlds", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("worlds"=>worlds), args)); aws_config=aws_config)

"""
    BatchDescribeSimulationJob()

Describes one or more simulation jobs.

# Required Parameters
- `jobs`: A list of Amazon Resource Names (ARNs) of simulation jobs to describe.

"""

batch_describe_simulation_job(jobs; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/batchDescribeSimulationJob", Dict{String, Any}("jobs"=>jobs); aws_config=aws_config)
batch_describe_simulation_job(jobs, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/batchDescribeSimulationJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("jobs"=>jobs), args)); aws_config=aws_config)

"""
    CancelDeploymentJob()

Cancels the specified deployment job.

# Required Parameters
- `job`: The deployment job ARN to cancel.

"""

cancel_deployment_job(job; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/cancelDeploymentJob", Dict{String, Any}("job"=>job); aws_config=aws_config)
cancel_deployment_job(job, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/cancelDeploymentJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("job"=>job), args)); aws_config=aws_config)

"""
    CancelSimulationJob()

Cancels the specified simulation job.

# Required Parameters
- `job`: The simulation job ARN to cancel.

"""

cancel_simulation_job(job; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/cancelSimulationJob", Dict{String, Any}("job"=>job); aws_config=aws_config)
cancel_simulation_job(job, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/cancelSimulationJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("job"=>job), args)); aws_config=aws_config)

"""
    CancelSimulationJobBatch()

Cancels a simulation job batch. When you cancel a simulation job batch, you are also cancelling all of the active simulation jobs created as part of the batch.

# Required Parameters
- `batch`: The id of the batch to cancel.

"""

cancel_simulation_job_batch(batch; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/cancelSimulationJobBatch", Dict{String, Any}("batch"=>batch); aws_config=aws_config)
cancel_simulation_job_batch(batch, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/cancelSimulationJobBatch", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("batch"=>batch), args)); aws_config=aws_config)

"""
    CancelWorldExportJob()

Cancels the specified export job.

# Required Parameters
- `job`: The Amazon Resource Name (arn) of the world export job to cancel.

"""

cancel_world_export_job(job; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/cancelWorldExportJob", Dict{String, Any}("job"=>job); aws_config=aws_config)
cancel_world_export_job(job, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/cancelWorldExportJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("job"=>job), args)); aws_config=aws_config)

"""
    CancelWorldGenerationJob()

Cancels the specified world generator job.

# Required Parameters
- `job`: The Amazon Resource Name (arn) of the world generator job to cancel.

"""

cancel_world_generation_job(job; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/cancelWorldGenerationJob", Dict{String, Any}("job"=>job); aws_config=aws_config)
cancel_world_generation_job(job, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/cancelWorldGenerationJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("job"=>job), args)); aws_config=aws_config)

"""
    CreateDeploymentJob()

Deploys a specific version of a robot application to robots in a fleet. The robot application must have a numbered applicationVersion for consistency reasons. To create a new version, use CreateRobotApplicationVersion or see Creating a Robot Application Version.   After 90 days, deployment jobs expire and will be deleted. They will no longer be accessible.

# Required Parameters
- `clientRequestToken`: Unique, case-sensitive identifier that you provide to ensure the idempotency of the request.
- `deploymentApplicationConfigs`: The deployment application configuration.
- `fleet`: The Amazon Resource Name (ARN) of the fleet to deploy.

# Optional Parameters
- `deploymentConfig`: The requested deployment configuration.
- `tags`: A map that contains tag keys and tag values that are attached to the deployment job.
"""

create_deployment_job(clientRequestToken, deploymentApplicationConfigs, fleet; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/createDeploymentJob", Dict{String, Any}("clientRequestToken"=>clientRequestToken, "deploymentApplicationConfigs"=>deploymentApplicationConfigs, "fleet"=>fleet); aws_config=aws_config)
create_deployment_job(clientRequestToken, deploymentApplicationConfigs, fleet, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/createDeploymentJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("clientRequestToken"=>clientRequestToken, "deploymentApplicationConfigs"=>deploymentApplicationConfigs, "fleet"=>fleet), args)); aws_config=aws_config)

"""
    CreateFleet()

Creates a fleet, a logical group of robots running the same robot application.

# Required Parameters
- `name`: The name of the fleet.

# Optional Parameters
- `tags`: A map that contains tag keys and tag values that are attached to the fleet.
"""

create_fleet(name; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/createFleet", Dict{String, Any}("name"=>name); aws_config=aws_config)
create_fleet(name, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/createFleet", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("name"=>name), args)); aws_config=aws_config)

"""
    CreateRobot()

Creates a robot.

# Required Parameters
- `architecture`: The target architecture of the robot.
- `greengrassGroupId`: The Greengrass group id.
- `name`: The name for the robot.

# Optional Parameters
- `tags`: A map that contains tag keys and tag values that are attached to the robot.
"""

create_robot(architecture, greengrassGroupId, name; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/createRobot", Dict{String, Any}("architecture"=>architecture, "greengrassGroupId"=>greengrassGroupId, "name"=>name); aws_config=aws_config)
create_robot(architecture, greengrassGroupId, name, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/createRobot", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("architecture"=>architecture, "greengrassGroupId"=>greengrassGroupId, "name"=>name), args)); aws_config=aws_config)

"""
    CreateRobotApplication()

Creates a robot application.

# Required Parameters
- `name`: The name of the robot application.
- `robotSoftwareSuite`: The robot software suite (ROS distribuition) used by the robot application.
- `sources`: The sources of the robot application.

# Optional Parameters
- `tags`: A map that contains tag keys and tag values that are attached to the robot application.
"""

create_robot_application(name, robotSoftwareSuite, sources; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/createRobotApplication", Dict{String, Any}("name"=>name, "robotSoftwareSuite"=>robotSoftwareSuite, "sources"=>sources); aws_config=aws_config)
create_robot_application(name, robotSoftwareSuite, sources, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/createRobotApplication", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("name"=>name, "robotSoftwareSuite"=>robotSoftwareSuite, "sources"=>sources), args)); aws_config=aws_config)

"""
    CreateRobotApplicationVersion()

Creates a version of a robot application.

# Required Parameters
- `application`: The application information for the robot application.

# Optional Parameters
- `currentRevisionId`: The current revision id for the robot application. If you provide a value and it matches the latest revision ID, a new version will be created.
"""

create_robot_application_version(application; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/createRobotApplicationVersion", Dict{String, Any}("application"=>application); aws_config=aws_config)
create_robot_application_version(application, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/createRobotApplicationVersion", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("application"=>application), args)); aws_config=aws_config)

"""
    CreateSimulationApplication()

Creates a simulation application.

# Required Parameters
- `name`: The name of the simulation application.
- `robotSoftwareSuite`: The robot software suite (ROS distribution) used by the simulation application.
- `simulationSoftwareSuite`: The simulation software suite used by the simulation application.
- `sources`: The sources of the simulation application.

# Optional Parameters
- `renderingEngine`: The rendering engine for the simulation application.
- `tags`: A map that contains tag keys and tag values that are attached to the simulation application.
"""

create_simulation_application(name, robotSoftwareSuite, simulationSoftwareSuite, sources; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/createSimulationApplication", Dict{String, Any}("name"=>name, "robotSoftwareSuite"=>robotSoftwareSuite, "simulationSoftwareSuite"=>simulationSoftwareSuite, "sources"=>sources); aws_config=aws_config)
create_simulation_application(name, robotSoftwareSuite, simulationSoftwareSuite, sources, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/createSimulationApplication", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("name"=>name, "robotSoftwareSuite"=>robotSoftwareSuite, "simulationSoftwareSuite"=>simulationSoftwareSuite, "sources"=>sources), args)); aws_config=aws_config)

"""
    CreateSimulationApplicationVersion()

Creates a simulation application with a specific revision id.

# Required Parameters
- `application`: The application information for the simulation application.

# Optional Parameters
- `currentRevisionId`: The current revision id for the simulation application. If you provide a value and it matches the latest revision ID, a new version will be created.
"""

create_simulation_application_version(application; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/createSimulationApplicationVersion", Dict{String, Any}("application"=>application); aws_config=aws_config)
create_simulation_application_version(application, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/createSimulationApplicationVersion", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("application"=>application), args)); aws_config=aws_config)

"""
    CreateSimulationJob()

Creates a simulation job.  After 90 days, simulation jobs expire and will be deleted. They will no longer be accessible.

# Required Parameters
- `iamRole`: The IAM role name that allows the simulation instance to call the AWS APIs that are specified in its associated policies on your behalf. This is how credentials are passed in to your simulation job.
- `maxJobDurationInSeconds`: The maximum simulation job duration in seconds (up to 14 days or 1,209,600 seconds. When maxJobDurationInSeconds is reached, the simulation job will status will transition to Completed.

# Optional Parameters
- `clientRequestToken`: Unique, case-sensitive identifier that you provide to ensure the idempotency of the request.
- `compute`: Compute information for the simulation job.
- `dataSources`: Specify data sources to mount read-only files from S3 into your simulation. These files are available under /opt/robomaker/datasources/data_source_name.   There is a limit of 100 files and a combined size of 25GB for all DataSourceConfig objects.
- `failureBehavior`: The failure behavior the simulation job.  Continue  Restart the simulation job in the same host instance.  Fail  Stop the simulation job and terminate the instance.
- `loggingConfig`: The logging configuration.
- `outputLocation`: Location for output files generated by the simulation job.
- `robotApplications`: The robot application to use in the simulation job.
- `simulationApplications`: The simulation application to use in the simulation job.
- `tags`: A map that contains tag keys and tag values that are attached to the simulation job.
- `vpcConfig`: If your simulation job accesses resources in a VPC, you provide this parameter identifying the list of security group IDs and subnet IDs. These must belong to the same VPC. You must provide at least one security group and one subnet ID.
"""

create_simulation_job(iamRole, maxJobDurationInSeconds; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/createSimulationJob", Dict{String, Any}("iamRole"=>iamRole, "maxJobDurationInSeconds"=>maxJobDurationInSeconds, "clientRequestToken"=>string(uuid4())); aws_config=aws_config)
create_simulation_job(iamRole, maxJobDurationInSeconds, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/createSimulationJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("iamRole"=>iamRole, "maxJobDurationInSeconds"=>maxJobDurationInSeconds, "clientRequestToken"=>string(uuid4())), args)); aws_config=aws_config)

"""
    CreateWorldExportJob()

Creates a world export job.

# Required Parameters
- `iamRole`: The IAM role that the world export process uses to access the Amazon S3 bucket and put the export.
- `outputLocation`:
- `worlds`: A list of Amazon Resource Names (arns) that correspond to worlds to export.

# Optional Parameters
- `clientRequestToken`: Unique, case-sensitive identifier that you provide to ensure the idempotency of the request.
- `tags`: A map that contains tag keys and tag values that are attached to the world export job.
"""

create_world_export_job(iamRole, outputLocation, worlds; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/createWorldExportJob", Dict{String, Any}("iamRole"=>iamRole, "outputLocation"=>outputLocation, "worlds"=>worlds, "clientRequestToken"=>string(uuid4())); aws_config=aws_config)
create_world_export_job(iamRole, outputLocation, worlds, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/createWorldExportJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("iamRole"=>iamRole, "outputLocation"=>outputLocation, "worlds"=>worlds, "clientRequestToken"=>string(uuid4())), args)); aws_config=aws_config)

"""
    CreateWorldGenerationJob()

Creates worlds using the specified template.

# Required Parameters
- `template`: The Amazon Resource Name (arn) of the world template describing the worlds you want to create.
- `worldCount`: Information about the world count.

# Optional Parameters
- `clientRequestToken`: Unique, case-sensitive identifier that you provide to ensure the idempotency of the request.
- `tags`: A map that contains tag keys and tag values that are attached to the world generator job.
"""

create_world_generation_job(template, worldCount; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/createWorldGenerationJob", Dict{String, Any}("template"=>template, "worldCount"=>worldCount, "clientRequestToken"=>string(uuid4())); aws_config=aws_config)
create_world_generation_job(template, worldCount, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/createWorldGenerationJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("template"=>template, "worldCount"=>worldCount, "clientRequestToken"=>string(uuid4())), args)); aws_config=aws_config)

"""
    CreateWorldTemplate()

Creates a world template.

# Optional Parameters
- `clientRequestToken`: Unique, case-sensitive identifier that you provide to ensure the idempotency of the request.
- `name`: The name of the world template.
- `tags`: A map that contains tag keys and tag values that are attached to the world template.
- `templateBody`: The world template body.
- `templateLocation`: The location of the world template.
"""

create_world_template(; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/createWorldTemplate"; aws_config=aws_config)
create_world_template(args::AbstractDict{String, Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/createWorldTemplate", args; aws_config=aws_config)

"""
    DeleteFleet()

Deletes a fleet.

# Required Parameters
- `fleet`: The Amazon Resource Name (ARN) of the fleet.

"""

delete_fleet(fleet; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/deleteFleet", Dict{String, Any}("fleet"=>fleet); aws_config=aws_config)
delete_fleet(fleet, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/deleteFleet", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("fleet"=>fleet), args)); aws_config=aws_config)

"""
    DeleteRobot()

Deletes a robot.

# Required Parameters
- `robot`: The Amazon Resource Name (ARN) of the robot.

"""

delete_robot(robot; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/deleteRobot", Dict{String, Any}("robot"=>robot); aws_config=aws_config)
delete_robot(robot, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/deleteRobot", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("robot"=>robot), args)); aws_config=aws_config)

"""
    DeleteRobotApplication()

Deletes a robot application.

# Required Parameters
- `application`: The Amazon Resource Name (ARN) of the the robot application.

# Optional Parameters
- `applicationVersion`: The version of the robot application to delete.
"""

delete_robot_application(application; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/deleteRobotApplication", Dict{String, Any}("application"=>application); aws_config=aws_config)
delete_robot_application(application, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/deleteRobotApplication", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("application"=>application), args)); aws_config=aws_config)

"""
    DeleteSimulationApplication()

Deletes a simulation application.

# Required Parameters
- `application`: The application information for the simulation application to delete.

# Optional Parameters
- `applicationVersion`: The version of the simulation application to delete.
"""

delete_simulation_application(application; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/deleteSimulationApplication", Dict{String, Any}("application"=>application); aws_config=aws_config)
delete_simulation_application(application, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/deleteSimulationApplication", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("application"=>application), args)); aws_config=aws_config)

"""
    DeleteWorldTemplate()

Deletes a world template.

# Required Parameters
- `template`: The Amazon Resource Name (arn) of the world template you want to delete.

"""

delete_world_template(template; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/deleteWorldTemplate", Dict{String, Any}("template"=>template); aws_config=aws_config)
delete_world_template(template, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/deleteWorldTemplate", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("template"=>template), args)); aws_config=aws_config)

"""
    DeregisterRobot()

Deregisters a robot.

# Required Parameters
- `fleet`: The Amazon Resource Name (ARN) of the fleet.
- `robot`: The Amazon Resource Name (ARN) of the robot.

"""

deregister_robot(fleet, robot; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/deregisterRobot", Dict{String, Any}("fleet"=>fleet, "robot"=>robot); aws_config=aws_config)
deregister_robot(fleet, robot, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/deregisterRobot", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("fleet"=>fleet, "robot"=>robot), args)); aws_config=aws_config)

"""
    DescribeDeploymentJob()

Describes a deployment job.

# Required Parameters
- `job`: The Amazon Resource Name (ARN) of the deployment job.

"""

describe_deployment_job(job; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/describeDeploymentJob", Dict{String, Any}("job"=>job); aws_config=aws_config)
describe_deployment_job(job, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/describeDeploymentJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("job"=>job), args)); aws_config=aws_config)

"""
    DescribeFleet()

Describes a fleet.

# Required Parameters
- `fleet`: The Amazon Resource Name (ARN) of the fleet.

"""

describe_fleet(fleet; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/describeFleet", Dict{String, Any}("fleet"=>fleet); aws_config=aws_config)
describe_fleet(fleet, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/describeFleet", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("fleet"=>fleet), args)); aws_config=aws_config)

"""
    DescribeRobot()

Describes a robot.

# Required Parameters
- `robot`: The Amazon Resource Name (ARN) of the robot to be described.

"""

describe_robot(robot; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/describeRobot", Dict{String, Any}("robot"=>robot); aws_config=aws_config)
describe_robot(robot, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/describeRobot", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("robot"=>robot), args)); aws_config=aws_config)

"""
    DescribeRobotApplication()

Describes a robot application.

# Required Parameters
- `application`: The Amazon Resource Name (ARN) of the robot application.

# Optional Parameters
- `applicationVersion`: The version of the robot application to describe.
"""

describe_robot_application(application; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/describeRobotApplication", Dict{String, Any}("application"=>application); aws_config=aws_config)
describe_robot_application(application, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/describeRobotApplication", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("application"=>application), args)); aws_config=aws_config)

"""
    DescribeSimulationApplication()

Describes a simulation application.

# Required Parameters
- `application`: The application information for the simulation application.

# Optional Parameters
- `applicationVersion`: The version of the simulation application to describe.
"""

describe_simulation_application(application; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/describeSimulationApplication", Dict{String, Any}("application"=>application); aws_config=aws_config)
describe_simulation_application(application, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/describeSimulationApplication", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("application"=>application), args)); aws_config=aws_config)

"""
    DescribeSimulationJob()

Describes a simulation job.

# Required Parameters
- `job`: The Amazon Resource Name (ARN) of the simulation job to be described.

"""

describe_simulation_job(job; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/describeSimulationJob", Dict{String, Any}("job"=>job); aws_config=aws_config)
describe_simulation_job(job, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/describeSimulationJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("job"=>job), args)); aws_config=aws_config)

"""
    DescribeSimulationJobBatch()

Describes a simulation job batch.

# Required Parameters
- `batch`: The id of the batch to describe.

"""

describe_simulation_job_batch(batch; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/describeSimulationJobBatch", Dict{String, Any}("batch"=>batch); aws_config=aws_config)
describe_simulation_job_batch(batch, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/describeSimulationJobBatch", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("batch"=>batch), args)); aws_config=aws_config)

"""
    DescribeWorld()

Describes a world.

# Required Parameters
- `world`: The Amazon Resource Name (arn) of the world you want to describe.

"""

describe_world(world; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/describeWorld", Dict{String, Any}("world"=>world); aws_config=aws_config)
describe_world(world, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/describeWorld", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("world"=>world), args)); aws_config=aws_config)

"""
    DescribeWorldExportJob()

Describes a world export job.

# Required Parameters
- `job`: The Amazon Resource Name (arn) of the world export job to describe.

"""

describe_world_export_job(job; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/describeWorldExportJob", Dict{String, Any}("job"=>job); aws_config=aws_config)
describe_world_export_job(job, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/describeWorldExportJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("job"=>job), args)); aws_config=aws_config)

"""
    DescribeWorldGenerationJob()

Describes a world generation job.

# Required Parameters
- `job`: The Amazon Resource Name (arn) of the world generation job to describe.

"""

describe_world_generation_job(job; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/describeWorldGenerationJob", Dict{String, Any}("job"=>job); aws_config=aws_config)
describe_world_generation_job(job, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/describeWorldGenerationJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("job"=>job), args)); aws_config=aws_config)

"""
    DescribeWorldTemplate()

Describes a world template.

# Required Parameters
- `template`: The Amazon Resource Name (arn) of the world template you want to describe.

"""

describe_world_template(template; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/describeWorldTemplate", Dict{String, Any}("template"=>template); aws_config=aws_config)
describe_world_template(template, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/describeWorldTemplate", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("template"=>template), args)); aws_config=aws_config)

"""
    GetWorldTemplateBody()

Gets the world template body.

# Optional Parameters
- `generationJob`: The Amazon Resource Name (arn) of the world generator job.
- `template`: The Amazon Resource Name (arn) of the world template.
"""

get_world_template_body(; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/getWorldTemplateBody"; aws_config=aws_config)
get_world_template_body(args::AbstractDict{String, Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/getWorldTemplateBody", args; aws_config=aws_config)

"""
    ListDeploymentJobs()

Returns a list of deployment jobs for a fleet. You can optionally provide filters to retrieve specific deployment jobs.

# Optional Parameters
- `filters`: Optional filters to limit results. The filter names status and fleetName are supported. When filtering, you must use the complete value of the filtered item. You can use up to three filters, but they must be for the same named item. For example, if you are looking for items with the status InProgress or the status Pending.
- `maxResults`: When this parameter is used, ListDeploymentJobs only returns maxResults results in a single page along with a nextToken response element. The remaining results of the initial request can be seen by sending another ListDeploymentJobs request with the returned nextToken value. This value can be between 1 and 200. If this parameter is not used, then ListDeploymentJobs returns up to 200 results and a nextToken value if applicable.
- `nextToken`: If the previous paginated request did not return all of the remaining results, the response object's nextToken parameter value is set to a token. To retrieve the next set of results, call ListDeploymentJobs again and assign that token to the request object's nextToken parameter. If there are no remaining results, the previous response object's NextToken parameter is set to null.
"""

list_deployment_jobs(; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/listDeploymentJobs"; aws_config=aws_config)
list_deployment_jobs(args::AbstractDict{String, Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/listDeploymentJobs", args; aws_config=aws_config)

"""
    ListFleets()

Returns a list of fleets. You can optionally provide filters to retrieve specific fleets.

# Optional Parameters
- `filters`: Optional filters to limit results. The filter name name is supported. When filtering, you must use the complete value of the filtered item. You can use up to three filters.
- `maxResults`: When this parameter is used, ListFleets only returns maxResults results in a single page along with a nextToken response element. The remaining results of the initial request can be seen by sending another ListFleets request with the returned nextToken value. This value can be between 1 and 200. If this parameter is not used, then ListFleets returns up to 200 results and a nextToken value if applicable.
- `nextToken`: If the previous paginated request did not return all of the remaining results, the response object's nextToken parameter value is set to a token. To retrieve the next set of results, call ListFleets again and assign that token to the request object's nextToken parameter. If there are no remaining results, the previous response object's NextToken parameter is set to null.   This token should be treated as an opaque identifier that is only used to retrieve the next items in a list and not for other programmatic purposes.
"""

list_fleets(; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/listFleets"; aws_config=aws_config)
list_fleets(args::AbstractDict{String, Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/listFleets", args; aws_config=aws_config)

"""
    ListRobotApplications()

Returns a list of robot application. You can optionally provide filters to retrieve specific robot applications.

# Optional Parameters
- `filters`: Optional filters to limit results. The filter name name is supported. When filtering, you must use the complete value of the filtered item. You can use up to three filters.
- `maxResults`: When this parameter is used, ListRobotApplications only returns maxResults results in a single page along with a nextToken response element. The remaining results of the initial request can be seen by sending another ListRobotApplications request with the returned nextToken value. This value can be between 1 and 100. If this parameter is not used, then ListRobotApplications returns up to 100 results and a nextToken value if applicable.
- `nextToken`: If the previous paginated request did not return all of the remaining results, the response object's nextToken parameter value is set to a token. To retrieve the next set of results, call ListRobotApplications again and assign that token to the request object's nextToken parameter. If there are no remaining results, the previous response object's NextToken parameter is set to null.
- `versionQualifier`: The version qualifier of the robot application.
"""

list_robot_applications(; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/listRobotApplications"; aws_config=aws_config)
list_robot_applications(args::AbstractDict{String, Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/listRobotApplications", args; aws_config=aws_config)

"""
    ListRobots()

Returns a list of robots. You can optionally provide filters to retrieve specific robots.

# Optional Parameters
- `filters`: Optional filters to limit results. The filter names status and fleetName are supported. When filtering, you must use the complete value of the filtered item. You can use up to three filters, but they must be for the same named item. For example, if you are looking for items with the status Registered or the status Available.
- `maxResults`: When this parameter is used, ListRobots only returns maxResults results in a single page along with a nextToken response element. The remaining results of the initial request can be seen by sending another ListRobots request with the returned nextToken value. This value can be between 1 and 200. If this parameter is not used, then ListRobots returns up to 200 results and a nextToken value if applicable.
- `nextToken`: If the previous paginated request did not return all of the remaining results, the response object's nextToken parameter value is set to a token. To retrieve the next set of results, call ListRobots again and assign that token to the request object's nextToken parameter. If there are no remaining results, the previous response object's NextToken parameter is set to null.
"""

list_robots(; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/listRobots"; aws_config=aws_config)
list_robots(args::AbstractDict{String, Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/listRobots", args; aws_config=aws_config)

"""
    ListSimulationApplications()

Returns a list of simulation applications. You can optionally provide filters to retrieve specific simulation applications.

# Optional Parameters
- `filters`: Optional list of filters to limit results. The filter name name is supported. When filtering, you must use the complete value of the filtered item. You can use up to three filters.
- `maxResults`: When this parameter is used, ListSimulationApplications only returns maxResults results in a single page along with a nextToken response element. The remaining results of the initial request can be seen by sending another ListSimulationApplications request with the returned nextToken value. This value can be between 1 and 100. If this parameter is not used, then ListSimulationApplications returns up to 100 results and a nextToken value if applicable.
- `nextToken`: If the previous paginated request did not return all of the remaining results, the response object's nextToken parameter value is set to a token. To retrieve the next set of results, call ListSimulationApplications again and assign that token to the request object's nextToken parameter. If there are no remaining results, the previous response object's NextToken parameter is set to null.
- `versionQualifier`: The version qualifier of the simulation application.
"""

list_simulation_applications(; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/listSimulationApplications"; aws_config=aws_config)
list_simulation_applications(args::AbstractDict{String, Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/listSimulationApplications", args; aws_config=aws_config)

"""
    ListSimulationJobBatches()

Returns a list simulation job batches. You can optionally provide filters to retrieve specific simulation batch jobs.

# Optional Parameters
- `filters`: Optional filters to limit results.
- `maxResults`: When this parameter is used, ListSimulationJobBatches only returns maxResults results in a single page along with a nextToken response element. The remaining results of the initial request can be seen by sending another ListSimulationJobBatches request with the returned nextToken value.
- `nextToken`: If the previous paginated request did not return all of the remaining results, the response object's nextToken parameter value is set to a token. To retrieve the next set of results, call ListSimulationJobBatches again and assign that token to the request object's nextToken parameter. If there are no remaining results, the previous response object's NextToken parameter is set to null.
"""

list_simulation_job_batches(; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/listSimulationJobBatches"; aws_config=aws_config)
list_simulation_job_batches(args::AbstractDict{String, Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/listSimulationJobBatches", args; aws_config=aws_config)

"""
    ListSimulationJobs()

Returns a list of simulation jobs. You can optionally provide filters to retrieve specific simulation jobs.

# Optional Parameters
- `filters`: Optional filters to limit results. The filter names status and simulationApplicationName and robotApplicationName are supported. When filtering, you must use the complete value of the filtered item. You can use up to three filters, but they must be for the same named item. For example, if you are looking for items with the status Preparing or the status Running.
- `maxResults`: When this parameter is used, ListSimulationJobs only returns maxResults results in a single page along with a nextToken response element. The remaining results of the initial request can be seen by sending another ListSimulationJobs request with the returned nextToken value. This value can be between 1 and 1000. If this parameter is not used, then ListSimulationJobs returns up to 1000 results and a nextToken value if applicable.
- `nextToken`: If the previous paginated request did not return all of the remaining results, the response object's nextToken parameter value is set to a token. To retrieve the next set of results, call ListSimulationJobs again and assign that token to the request object's nextToken parameter. If there are no remaining results, the previous response object's NextToken parameter is set to null.
"""

list_simulation_jobs(; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/listSimulationJobs"; aws_config=aws_config)
list_simulation_jobs(args::AbstractDict{String, Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/listSimulationJobs", args; aws_config=aws_config)

"""
    ListTagsForResource()

Lists all tags on a AWS RoboMaker resource.

# Required Parameters
- `resourceArn`: The AWS RoboMaker Amazon Resource Name (ARN) with tags to be listed.

"""

list_tags_for_resource(resourceArn; aws_config::AWSConfig=global_aws_config()) = robomaker("GET", "/tags/$(resourceArn)"; aws_config=aws_config)
list_tags_for_resource(resourceArn, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("GET", "/tags/$(resourceArn)", args; aws_config=aws_config)

"""
    ListWorldExportJobs()

Lists world export jobs.

# Optional Parameters
- `filters`: Optional filters to limit results. You can use generationJobId and templateId.
- `maxResults`: When this parameter is used, ListWorldExportJobs only returns maxResults results in a single page along with a nextToken response element. The remaining results of the initial request can be seen by sending another ListWorldExportJobs request with the returned nextToken value. This value can be between 1 and 100. If this parameter is not used, then ListWorldExportJobs returns up to 100 results and a nextToken value if applicable.
- `nextToken`: If the previous paginated request did not return all of the remaining results, the response object's nextToken parameter value is set to a token. To retrieve the next set of results, call ListWorldExportJobs again and assign that token to the request object's nextToken parameter. If there are no remaining results, the previous response object's NextToken parameter is set to null.
"""

list_world_export_jobs(; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/listWorldExportJobs"; aws_config=aws_config)
list_world_export_jobs(args::AbstractDict{String, Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/listWorldExportJobs", args; aws_config=aws_config)

"""
    ListWorldGenerationJobs()

Lists world generator jobs.

# Optional Parameters
- `filters`: Optional filters to limit results. You can use status and templateId.
- `maxResults`: When this parameter is used, ListWorldGeneratorJobs only returns maxResults results in a single page along with a nextToken response element. The remaining results of the initial request can be seen by sending another ListWorldGeneratorJobs request with the returned nextToken value. This value can be between 1 and 100. If this parameter is not used, then ListWorldGeneratorJobs returns up to 100 results and a nextToken value if applicable.
- `nextToken`: If the previous paginated request did not return all of the remaining results, the response object's nextToken parameter value is set to a token. To retrieve the next set of results, call ListWorldGenerationJobsRequest again and assign that token to the request object's nextToken parameter. If there are no remaining results, the previous response object's NextToken parameter is set to null.
"""

list_world_generation_jobs(; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/listWorldGenerationJobs"; aws_config=aws_config)
list_world_generation_jobs(args::AbstractDict{String, Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/listWorldGenerationJobs", args; aws_config=aws_config)

"""
    ListWorldTemplates()

Lists world templates.

# Optional Parameters
- `maxResults`: When this parameter is used, ListWorldTemplates only returns maxResults results in a single page along with a nextToken response element. The remaining results of the initial request can be seen by sending another ListWorldTemplates request with the returned nextToken value. This value can be between 1 and 100. If this parameter is not used, then ListWorldTemplates returns up to 100 results and a nextToken value if applicable.
- `nextToken`: If the previous paginated request did not return all of the remaining results, the response object's nextToken parameter value is set to a token. To retrieve the next set of results, call ListWorldTemplates again and assign that token to the request object's nextToken parameter. If there are no remaining results, the previous response object's NextToken parameter is set to null.
"""

list_world_templates(; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/listWorldTemplates"; aws_config=aws_config)
list_world_templates(args::AbstractDict{String, Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/listWorldTemplates", args; aws_config=aws_config)

"""
    ListWorlds()

Lists worlds.

# Optional Parameters
- `filters`: Optional filters to limit results. You can use status.
- `maxResults`: When this parameter is used, ListWorlds only returns maxResults results in a single page along with a nextToken response element. The remaining results of the initial request can be seen by sending another ListWorlds request with the returned nextToken value. This value can be between 1 and 100. If this parameter is not used, then ListWorlds returns up to 100 results and a nextToken value if applicable.
- `nextToken`: If the previous paginated request did not return all of the remaining results, the response object's nextToken parameter value is set to a token. To retrieve the next set of results, call ListWorlds again and assign that token to the request object's nextToken parameter. If there are no remaining results, the previous response object's NextToken parameter is set to null.
"""

list_worlds(; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/listWorlds"; aws_config=aws_config)
list_worlds(args::AbstractDict{String, Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/listWorlds", args; aws_config=aws_config)

"""
    RegisterRobot()

Registers a robot with a fleet.

# Required Parameters
- `fleet`: The Amazon Resource Name (ARN) of the fleet.
- `robot`: The Amazon Resource Name (ARN) of the robot.

"""

register_robot(fleet, robot; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/registerRobot", Dict{String, Any}("fleet"=>fleet, "robot"=>robot); aws_config=aws_config)
register_robot(fleet, robot, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/registerRobot", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("fleet"=>fleet, "robot"=>robot), args)); aws_config=aws_config)

"""
    RestartSimulationJob()

Restarts a running simulation job.

# Required Parameters
- `job`: The Amazon Resource Name (ARN) of the simulation job.

"""

restart_simulation_job(job; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/restartSimulationJob", Dict{String, Any}("job"=>job); aws_config=aws_config)
restart_simulation_job(job, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/restartSimulationJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("job"=>job), args)); aws_config=aws_config)

"""
    StartSimulationJobBatch()

Starts a new simulation job batch. The batch is defined using one or more SimulationJobRequest objects.

# Required Parameters
- `createSimulationJobRequests`: A list of simulation job requests to create in the batch.

# Optional Parameters
- `batchPolicy`: The batch policy.
- `clientRequestToken`: Unique, case-sensitive identifier that you provide to ensure the idempotency of the request.
- `tags`: A map that contains tag keys and tag values that are attached to the deployment job batch.
"""

start_simulation_job_batch(createSimulationJobRequests; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/startSimulationJobBatch", Dict{String, Any}("createSimulationJobRequests"=>createSimulationJobRequests, "clientRequestToken"=>string(uuid4())); aws_config=aws_config)
start_simulation_job_batch(createSimulationJobRequests, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/startSimulationJobBatch", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("createSimulationJobRequests"=>createSimulationJobRequests, "clientRequestToken"=>string(uuid4())), args)); aws_config=aws_config)

"""
    SyncDeploymentJob()

Syncrhonizes robots in a fleet to the latest deployment. This is helpful if robots were added after a deployment.

# Required Parameters
- `clientRequestToken`: Unique, case-sensitive identifier that you provide to ensure the idempotency of the request.
- `fleet`: The target fleet for the synchronization.

"""

sync_deployment_job(clientRequestToken, fleet; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/syncDeploymentJob", Dict{String, Any}("clientRequestToken"=>clientRequestToken, "fleet"=>fleet); aws_config=aws_config)
sync_deployment_job(clientRequestToken, fleet, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/syncDeploymentJob", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("clientRequestToken"=>clientRequestToken, "fleet"=>fleet), args)); aws_config=aws_config)

"""
    TagResource()

Adds or edits tags for a AWS RoboMaker resource. Each tag consists of a tag key and a tag value. Tag keys and tag values are both required, but tag values can be empty strings.  For information about the rules that apply to tag keys and tag values, see User-Defined Tag Restrictions in the AWS Billing and Cost Management User Guide.

# Required Parameters
- `resourceArn`: The Amazon Resource Name (ARN) of the AWS RoboMaker resource you are tagging.
- `tags`: A map that contains tag keys and tag values that are attached to the resource.

"""

tag_resource(resourceArn, tags; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/tags/$(resourceArn)", Dict{String, Any}("tags"=>tags); aws_config=aws_config)
tag_resource(resourceArn, tags, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/tags/$(resourceArn)", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("tags"=>tags), args)); aws_config=aws_config)

"""
    UntagResource()

Removes the specified tags from the specified AWS RoboMaker resource. To remove a tag, specify the tag key. To change the tag value of an existing tag key, use  TagResource .

# Required Parameters
- `resourceArn`: The Amazon Resource Name (ARN) of the AWS RoboMaker resource you are removing tags.
- `tagKeys`: A map that contains tag keys and tag values that will be unattached from the resource.

"""

untag_resource(resourceArn, tagKeys; aws_config::AWSConfig=global_aws_config()) = robomaker("DELETE", "/tags/$(resourceArn)", Dict{String, Any}("tagKeys"=>tagKeys); aws_config=aws_config)
untag_resource(resourceArn, tagKeys, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("DELETE", "/tags/$(resourceArn)", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("tagKeys"=>tagKeys), args)); aws_config=aws_config)

"""
    UpdateRobotApplication()

Updates a robot application.

# Required Parameters
- `application`: The application information for the robot application.
- `robotSoftwareSuite`: The robot software suite (ROS distribution) used by the robot application.
- `sources`: The sources of the robot application.

# Optional Parameters
- `currentRevisionId`: The revision id for the robot application.
"""

update_robot_application(application, robotSoftwareSuite, sources; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/updateRobotApplication", Dict{String, Any}("application"=>application, "robotSoftwareSuite"=>robotSoftwareSuite, "sources"=>sources); aws_config=aws_config)
update_robot_application(application, robotSoftwareSuite, sources, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/updateRobotApplication", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("application"=>application, "robotSoftwareSuite"=>robotSoftwareSuite, "sources"=>sources), args)); aws_config=aws_config)

"""
    UpdateSimulationApplication()

Updates a simulation application.

# Required Parameters
- `application`: The application information for the simulation application.
- `robotSoftwareSuite`: Information about the robot software suite (ROS distribution).
- `simulationSoftwareSuite`: The simulation software suite used by the simulation application.
- `sources`: The sources of the simulation application.

# Optional Parameters
- `currentRevisionId`: The revision id for the robot application.
- `renderingEngine`: The rendering engine for the simulation application.
"""

update_simulation_application(application, robotSoftwareSuite, simulationSoftwareSuite, sources; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/updateSimulationApplication", Dict{String, Any}("application"=>application, "robotSoftwareSuite"=>robotSoftwareSuite, "simulationSoftwareSuite"=>simulationSoftwareSuite, "sources"=>sources); aws_config=aws_config)
update_simulation_application(application, robotSoftwareSuite, simulationSoftwareSuite, sources, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/updateSimulationApplication", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("application"=>application, "robotSoftwareSuite"=>robotSoftwareSuite, "simulationSoftwareSuite"=>simulationSoftwareSuite, "sources"=>sources), args)); aws_config=aws_config)

"""
    UpdateWorldTemplate()

Updates a world template.

# Required Parameters
- `template`: The Amazon Resource Name (arn) of the world template to update.

# Optional Parameters
- `name`: The name of the template.
- `templateBody`: The world template body.
- `templateLocation`: The location of the world template.
"""

update_world_template(template; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/updateWorldTemplate", Dict{String, Any}("template"=>template); aws_config=aws_config)
update_world_template(template, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = robomaker("POST", "/updateWorldTemplate", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("template"=>template), args)); aws_config=aws_config)


text:
"""
```
eqcond(m::KrusellSmithCT)
```

Expresses the equilibrium conditions in canonical form using Γ0, Γ1, C, Ψ, and Π matrices.

### Outputs

* `Γ0` (`n_vars` x `n_vars`) holds coefficients of current time states.
* `Γ1` (`n_vars` x `n_vars`) holds coefficients of lagged states.
* `C`  (`n_vars` x `1`) is a vector of constants
* `Ψ`  (`n_vars` x `n_shocks_exogenous`) holds coefficients of iid shocks.
* `Π`  (`n_vars` x `n_states_expectational`) holds coefficients of expectational states.
"""
function eqcond(m::KrusellSmithCT)

    # Read in steady state vars, params, and grids
    nstates = n_states(m)
    x       = zeros(2 * nstates + n_shocks_expectational(m) + n_shocks_exogenous(m))

    γ::Float64     = m[:γ].value
    ρ::Float64     = m[:ρ].value
    δ::Float64     = m[:δ].value
    α::Float64     = m[:α].value

    σ_tfp::Float64 = m[:σ_tfp].value
    ρ_tfp::Float64 = m[:ρ_tfp].value

    λ1::Float64    = m[:λ1].value
    λ2::Float64    = m[:λ2].value

    μ::Float64     = m[:μ].value
    τ::Float64     = m[:τ].value
    I::Int64       = get_setting(m, :I)
    J::Int64       = get_setting(m, :J)
    IJ             = I*J

    amin::Float64  = get_setting(m, :amin)
    amax::Float64  = get_setting(m, :amax)
    da::Float64    = get_setting(m, :da)

    If_ss::Array{Float64,2} = m[:If_ss].value
    Ib_ss::Array{Float64,2} = m[:Ib_ss].value
    I0_ss::Array{Float64,2} = m[:I0_ss].value

    a::Array{Float64,1}     = get_setting(m, :a)
    aa::Array{Float64,2}    = get_setting(m, :aa)
    aaa::Array{Float64,2}   = get_setting(m, :aaa)
    z::Array{Float64,1}     = get_setting(m, :z)
    zz::Array{Float64,2}    = get_setting(m, :zz)
    zzz::Array{Float64,2}   = get_setting(m, :zzz)

    z_avg::Float64          = (λ1 * z[2] + λ2 * z[1]) / (λ1 + λ2)

    V_ss  = m[:V_ss].value
    gg_ss = m[:gg_ss].value
    K_ss  = m[:K_ss].value
    r_ss  = m[:r_ss].value
    w_ss  = m[:w_ss].value
    Y_ss  = m[:Y_ss].value
    C_ss  = m[:C_ss].value
    I_ss  = m[:I_ss].value

    A_switch = [-SparseMatrixCSC{Float64}(LinearAlgebra.I, I, I) * λ1 SparseMatrixCSC{Float64}(LinearAlgebra.I, I, I) * λ1; SparseMatrixCSC{Float64}(LinearAlgebra.I, I, I) * λ2 -SparseMatrixCSC{Float64}(LinearAlgebra.I, I, I) * λ2]

    function get_residuals(x::Vector{T}) where {T<:Real}

        # Unpack vars and convert all values to dual types (see JuliaDiff)
        V_vec             = x[1:2*I]       + V_ss
        gg                = x[2*I+1:4*I-1] + gg_ss
        # Ensures that distribution integrates to 1 when multiplied by da
        g_end             = 1/da - sum(gg)
        g                 = [gg;g_end]
        g_dot_da          = g * da
        log_aggregate_tfp = x[4*I]
        K_hat             = x[4*I+1] + K_ss
        r_hat             = x[4*I+2] + r_ss
        w_hat             = x[4*I+3] + w_ss
        output            = x[4*I+4] + Y_ss
        C_cur             = x[4*I+5] + C_ss
        investment        = x[4*I+6] + I_ss

        # Set up system of time derivatives
        V                     = reshape(V_vec, I, J)
        V_dot                 = x[  nstates + 1 : nstates + 2*I]
        g_dot                 = x[  nstates + 2*I + 1 : nstates + 4*I - 1]
        log_aggregate_tfp_dot = x[  nstates + 4*I]
        V_exp_errors          = x[2*nstates + 1 : 2*nstates + 2*I] # expected errors in the value function
        aggregate_tfp_shock   = x[end]

        # Instantiate variables for future use
        c = similar(V_vec)
        u = similar(V_vec)
        X = similar(V)
        Y = similar(V)
        Z = similar(V)

        # Get steady state values of K, r, w incorporating steady state aggregate_tfp level
        K = sum(aaa .* g_dot_da)
        r = exp(log_aggregate_tfp) * α * (K_hat ^ (α - 1)) * (z_avg ^ (1 - α)) - δ
        w = exp(log_aggregate_tfp) * (1 - α) * (K_hat ^ α) * (z_avg ^ (-α))

        #----------------------------------------------------------------
        # Compute one iteration of HJB Equation
        #----------------------------------------------------------------
        c0 = w * ((1 - τ) * zz + μ * (1 .- zz)) + r * aa

        for j=1:J, i=1:I
            # Compute consumption and derivative of value function for no drift
            dV0 = c0[i,j] ^ (-γ)

            if i==I
                dVf = dV0 # Will never be used, but impose state constraint a<=amax just in case
                dVb = (V[i,j] - V[i-1,j]) / da
            elseif i==1
                dVb = dV0                      # State constraint boundary condition
                dVf = (V[i+1,j] - V[i,j]) / da
            else
                dVf = (V[i+1,j] - V[i,j]) / da # Compute forward difference
                dVb = (V[i,j] - V[i-1,j]) / da # Compute backward difference
            end

            # Compute consumption and savings with forward difference
            ssf = c0[i,j] - dVf ^ (-1.0 / γ)

            # Compute consumption and savings with backward difference
            ssb = c0[i,j] - dVb ^ (-1.0 / γ)

            # Compute consumption and derivative of value function for no drift, then compute upwind difference
            c[(j-1)*I + i] = (dVf * If_ss[i,j] + dVb * Ib_ss[i,j] + dV0 * I0_ss[i,j]) ^ (-1.0 / γ)
            u[(j-1)*I + i] = (c[(j-1)*I + i] ^ (1.0 - γ)) / (1.0 - γ)

            # Construct A matrix
            X[i,j] = -ssb * (Ib_ss[i,j] / da)
            Z[i,j] =  ssf * (If_ss[i,j] / da)
            Y[i,j] = -X[i,j] - Z[i,j]

            # Note: Need to handle complex 0 case; should check if it ever gets there
            if i==I
                Z[i,j] = 0.
            elseif i==1
                X[i,j] = 0.
            end
        end

        A = spdiagm(0 => reshape(Y,IJ), -1 => reshape(X,IJ)[2:IJ], 1 => reshape(Z,IJ)[1:IJ-1]) + A_switch

        #----------------------------------------------------------------
        # Compute residuals of equilibrium conditions
        #----------------------------------------------------------------

        # HJB Equation
        hjb_residual = u + A * V_vec + V_dot + V_exp_errors - ρ * V_vec

        # KFE
        g_residual   = g_dot - (A' * g)[1:IJ-1, 1]

        # Law of motion for aggregate shocks
        tfp_residual = log_aggregate_tfp_dot + (1 - ρ_tfp) * log_aggregate_tfp - σ_tfp * aggregate_tfp_shock

        # Aggregates
        k_residual = K - K_hat
        r_residual = r - r_hat
        w_residual = w - w_hat
        y_residual = output - exp(log_aggregate_tfp) * (K ^ α) * (z_avg ^ (1 - α))
        c_residual = C_cur - sum(c .* g_dot_da)
        i_residual = investment - sum((reshape(c0, IJ) - c + δ * aaa) .* g_dot_da)

        return  [hjb_residual; g_residual; tfp_residual; k_residual; r_residual; w_residual;
                 y_residual; c_residual; i_residual]
    end

    #----------------------------------------------------------------
    # Calculate Jacobian, unpack output
    #----------------------------------------------------------------
    derivs = ForwardDiff.jacobian(get_residuals, x)

    Γ1::Array{Float64,2} = -derivs[:, 1 : nstates]
    Γ0::Array{Float64,2} =  derivs[:, nstates + 1 : 2 * nstates]
    Π::Array{Float64,2}  = -derivs[:, 2 * nstates + 1 : 2 * nstates + n_shocks_expectational(m)]
    Ψ::Array{Float64,2}  = -derivs[:, 2 * nstates + n_shocks_expectational(m) + 1 : end]
    C::Array{Float64,1}  = zeros(nstates)

    return Γ0, Γ1, Ψ, Π, C
end


text:
export get2DElemShapeData, get1DElemShapeData
function getShapeQuad4( ξ::Array{Float64,1} )
    #   gaussian point ordering:
    #   4 ---- 3
    #
    #   1 ---- 2
    #Check the dimension of physical space
    if length(ξ) != 2
        error("2D only")
    end

    sData       = zeros(4,3)

    #Calculate shape functions
    sData[1,1] = 0.25*(1.0-ξ[1])*(1.0-ξ[2])
    sData[2,1] = 0.25*(1.0+ξ[1])*(1.0-ξ[2])
    sData[3,1] = 0.25*(1.0+ξ[1])*(1.0+ξ[2])
    sData[4,1] = 0.25*(1.0-ξ[1])*(1.0+ξ[2])

    #Calculate derivatives of shape functions
    sData[1,2] = -0.25*(1.0-ξ[2])
    sData[2,2] =  0.25*(1.0-ξ[2])
    sData[3,2] =  0.25*(1.0+ξ[2])
    sData[4,2] = -0.25*(1.0+ξ[2])

    sData[1,3] = -0.25*(1.0-ξ[1])
    sData[2,3] = -0.25*(1.0+ξ[1])
    sData[3,3] =  0.25*(1.0+ξ[1])
    sData[4,3] =  0.25*(1.0-ξ[1])

    return sData
end

function getShapeQuad9( ξ::Array{Float64,1} )
    #todo!!
    #   gaussian point ordering:
    #   4 --7-- 3
    #   8   9   6
    #   1 --5-- 2
    #Check the dimension of physical space
    if length(ξ) != 2
        error("2D only")
    end

    sData       = zeros(9,3)

    #Calculate shape functions
    sData[1,1] = ξ[1] * (ξ[1] - 1) * ξ[2] * (ξ[2] - 1) / 4.0
    sData[2,1] = ξ[1] * (ξ[1] + 1) * ξ[2] * (ξ[2] - 1) / 4.0
    sData[3,1] = ξ[1] * (ξ[1] + 1) * ξ[2] * (ξ[2] + 1) / 4.0
    sData[4,1] = ξ[1] * (ξ[1] - 1) * ξ[2] * (ξ[2] + 1) / 4.0
    sData[5,1] =  -(ξ[1] * ξ[1] - 1) * ξ[2] * (ξ[2] - 1.) / 2.0
    sData[6,1] = -ξ[1] * (ξ[1] + 1) * (ξ[2] * ξ[2] - 1.) / 2.0
    sData[7,1] = -(ξ[1] * ξ[1] - 1) * ξ[2] * (ξ[2] + 1.) / 2.0
    sData[8,1] = -ξ[1] * (ξ[1] - 1) * (ξ[2] * ξ[2] - 1.) / 2.0
    sData[9,1] = (1 - ξ[1] * ξ[1]) * (1 - ξ[2] * ξ[2])

    #Calculate derivative of shape functions over ξ[1] and ξ[2]

    sData[1,2] = (2 * ξ[1] - 1) * ξ[2] * (ξ[2] - 1) / 4.0
    sData[2,2] = (2 * ξ[1] + 1) * ξ[2] * (ξ[2] - 1) / 4.0
    sData[3,2] = (2 * ξ[1] + 1) * ξ[2] * (ξ[2] + 1) / 4.0
    sData[4,2] = (2 * ξ[1] - 1) * ξ[2] * (ξ[2] + 1) / 4.0
    sData[5,2] = -(2 * ξ[1]) * ξ[2] * (ξ[2] - 1.) / 2.0
    sData[6,2] = -(2 * ξ[1] + 1) * (ξ[2] * ξ[2] - 1.) / 2.0
    sData[7,2] =  -(2 * ξ[1]) * ξ[2] * (ξ[2] + 1.) / 2.0
    sData[8,2] = -(2 * ξ[1] - 1) * (ξ[2] * ξ[2] - 1.) / 2.0
    sData[9,2] = (-2 * ξ[1]) * (1 - ξ[2] * ξ[2])

    sData[1,3] = ξ[1] * (ξ[1] - 1) * (2 * ξ[2] - 1) / 4.0
    sData[2,3] = ξ[1] * (ξ[1] + 1) * (2 * ξ[2] - 1) / 4.0
    sData[3,3] = ξ[1] * (ξ[1] + 1) * (2 * ξ[2] + 1) / 4.0
    sData[4,3] = ξ[1] * (ξ[1] - 1) * (2 * ξ[2] + 1) / 4.0
    sData[5,3] = -(ξ[1] * ξ[1] - 1) * (2 * ξ[2] - 1.) / 2.0
    sData[6,3] = -ξ[1] * (ξ[1] + 1) * (2 * ξ[2]) / 2.0
    sData[7,3] =  -(ξ[1] * ξ[1] - 1) * (2 * ξ[2] + 1.) / 2.0
    sData[8,3] =  -ξ[1] * (ξ[1] - 1) * (2 * ξ[2]) / 2.0
    sData[9,3] =   (1 - ξ[1] * ξ[1]) * (-2 * ξ[2])

    return sData
end

function getShapeLine2( ξ::Array{Float64,1} )
    #   gaussian point ordering:
    #   1 ---- 2
    #Check the dimension of physical space
    if length(ξ) != 1
        error("1D only")
    end

    sData       = zeros(2,2)

    #Calculate shape functions
    sData[1,1] = 0.5*(1.0-ξ[1])
    sData[2,1] = 0.5*(1.0+ξ[1])

    #Calculate derivatives of shape functions
    sData[1,2] = -0.5
    sData[2,2] =  0.5

    return sData
end

function getShapeLine3( ξ::Array{Float64,1} )
    #   gaussian point ordering:
    #   1 --3-- 2
    #Check the dimension of physical space
    if length(ξ) != 1
        error("1D only")
    end

    sData       = zeros(3,2)

    #Calculate shape functions
    sData[1,1] =  ξ[1] * (ξ[1] - 1) / 2.0
    sData[2,1] =  ξ[1] * (ξ[1] + 1) / 2.0
    sData[3,1] =-(ξ[1] * ξ[1] - 1)

    #Calculate derivatives of shape functions
    sData[1,2] =  (2*ξ[1] - 1) / 2.0
    sData[2,2] =  (2*ξ[1] + 1) / 2.0
    sData[3,2] =  -2* ξ[1]

    return sData
end

@doc """
    Return the Gauss quadrature points and weights in [-1,1]^n
""" ->
function getIntegrationPoints(nPoints::Int64, ndim::Int64)
    if nPoints == 1
        q1 = [0.0]
        w1 = [2.0]
    elseif nPoints == 2
        q1 = sqrt(1. /3.)*[-1.;1.]
        w1 = [1.; 1]
    elseif nPoints == 3
        q1 = sqrt(3. /5.)*[ 0.; -1.; 1.]
        w1 = 1. /9. *[ 8.; 5.; 5.]
    elseif nPoints == 4
        q1 = [sqrt(3. / 7. - 2. /7. *sqrt(6. /5.)) ; -sqrt(3. / 7. - 2. /7. *sqrt(6. /5.)) ; sqrt(3. / 7. + 2. /7. *sqrt(6. /5.)) ; -sqrt(3. / 7. + 2. /7. *sqrt(6. /5.)) ]
        w1 = 1. / 36. * [18. + sqrt(30.); 18. + sqrt(30.); 18. - sqrt(30.); 18. - sqrt(30.)]
    end

    if ndim == 1
        return q1, w1
    end

    q2 = zeros(nPoints*nPoints, 2)
    w2 = zeros(nPoints*nPoints)
    for i = 1:nPoints
        for j = 1:nPoints
            n = (i-1)*nPoints + j
            q2[n, :] = [q1[i]; q1[j]]
            w2[n] = w1[i]*w1[j]
        end
    end
    # #@show q2
    return q2, w2
end

@doc """
    :elemCoords nnodesx2, nnodes=4 => Quad4 ; nnodes=2 => Line2
    dhdx: list of ngp shape function first order derivatives dphi/dx (nf×ndim) on the Gaussian points
    weights: list of ngp weights,  gaussian point weight and Jacobian determinant
    hs: list of ngp shape function values(nf×1) on the Gaussian points

""" ->
function get2DElemShapeData( elem_coords::Array{Float64} , npoints::Int64 = 0)

  ele_size =  size(elem_coords)

  #set nDim and shape function from elemType
  ndim = 2

  (int_coords,int_weights) = getIntegrationPoints( npoints , ndim)
#   #@show intCrds, intWghts
  dhdx = Array{Float64}[]
  weights = Float64[]
  hs = Array{Float64}[]
  for k = 1:length(int_weights)
    ξ = int_coords[k,:]
    weight = int_weights[k]
    # println(ξ)
    if ele_size[1] == 4
        sData = getShapeQuad4(ξ)
    elseif ele_size[1] == 9
        sData = getShapeQuad9(ξ)
    else
        error("not implemented ele_size[1] = ", ele_size[1])
    end

    jac = elem_coords' * sData[:,2:end]

    push!(dhdx, sData[:,2:end] * inv( jac ))
    push!(weights, abs(det(jac)) * weight)
    push!(hs, sData[:,1])
  end

  return dhdx, weights, hs
end

@doc """
    :elemCoords nnodesx2, nnodes=3 => Line3 ; nnodes=2 => Line2
    dhdx: list of ngp shape function first order derivatives dphi/dx (nf×ndim) on the Gaussian points
    weights: list of ngp weights,  gaussian point weight and Jacobian determinant
    hs: list of ngp shape function values(nf×1) on the Gaussian points

""" ->
function get1DElemShapeData( elem_coords::Array{Float64} , npoints::Int64 = 0)

  ele_size =  size(elem_coords)

  #set nDim and shape function from elemType
  ndim = 1

  (int_coords,int_weights) = getIntegrationPoints( npoints , ndim)
#   #@show intCrds, intWghts
  dhdx = Array{Float64}[]
  weights = Float64[]
  hs = Array{Float64}[]
  for k = 1:length(int_weights)
    ξ = int_coords[k,:]
    weight = int_weights[k]

    if ele_size[1] == 2
        sData = getShapeLine2(ξ)
    elseif ele_size[1] == 3
        sData = getShapeLine3(ξ)
    else
        error("not implemented ele_size[1] = ", ele_size[1])
    end
    jac = elem_coords' * sData[:,2:end] #2×1
    push!(weights, sqrt(jac[1]^2 + jac[2]^2) * weight)
    push!(hs, sData[:,1])
  end

  return weights, hs
end


text:
# ---
# 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.6.2
#     language: julia
#     name: julia-1.6
# ---

# %%
f(x::Float64) = 2.0x + 1.0
@code_llvm debuginfo=:none f(1.2)

# %%
g(x) = 2x + 1
@code_llvm debuginfo=:none g(1.2)

# %%
?@code_llvm

# %%

max_stars_repo_path: 0014/@code_llvm example.jl

max_stars_repo_name: genkuroki/public

max_issues_repo_path: 0014/@code_llvm example.jl

max_issues_repo_name: genkuroki/public

max_forks_repo_path: 0014/@code_llvm example.jl

max_forks_repo_name: genkuroki/public


text:
using Pkg, Dates
Pkg.activate(".")

using Genie, Dates, HTTP
import Genie.Router: route, POST, @params
import Base.convert

convert(::Type{Float64}, s::SubString{String}) = parse(Float64, s)
convert(::Type{Int}, s::SubString{String}) = parse(Int, s)
convert(::Type{Date}, s::SubString{String}) = Date(s)

route("/getparams/:s::String/:f::Float64/:i::Int/:d::Date") do
  @show "s = $(@params(:s)) / f = $(@params(:f)) / i = $(@params(:i)) / $(@params(:d))"
end
Genie.AppServer.startup(; open_browser = false)

HTTP.get("http://localhost:8000/getparams/foo/23.43/18/2019-02-15")

exit(0)


text:
push!(LOAD_PATH,"../src/")

using Documenter, Spirit

makedocs(sitename="My Documentation")


text:
using Documenter, HeartRateVariability

makedocs(sitename = "HeartRateVariability.jl",
         authors = "Jasmin Walter",
         pages = [
                  "Introduction" => "introduction.md",
                  "Installation" => "installation.md",
                  "Quick Start" => "quickstart.md",
                   "API" => "index.md",
                   "License" => "LICENSE.md"
                  ],
          )

deploydocs(
    repo = "github.com/LiScI-Lab/HeartRateVariability.jl.git",
)


text:
to_gray_image(img::AbstractMatrix{<:Gray}) = img
to_gray_image(img::AbstractMatrix) = Gray.(img)

blur(img::AbstractMatrix, σ = 0.5f0) = imfilter(img, KernelFactors.gaussian((σ, σ)))

color_distance(a::Gray, b::Gray) = Float32(a - b)
color_distance(a::RGB, b::RGB) = norm.(a - b)
color_distance(a::RGB, b::Gray) = color_distance(Gray(a), b)
color_distance(a::Gray, b::RGB) = color_distance(a, Gray(b))

function floodfill!(
    img::AbstractMatrix{T},
    starting_point, color,
    threshold = 0.1
) where T <: Union{Gray{Float32}, RGB{Float32}}
    q = Queue{Tuple{Int, Int}}()
    img = float(img)
    y, x = starting_point
    c = img[y, x]
    enqueue!(q, (y, x))
    h, w = size(img)
    visited = zeros(Bool, (h, w))
    visited[y, x] = true
    @inbounds while length(q) > 0
        y, x = dequeue!(q)
        img[y, x] = color
        for (dy, dx) in (
            (-1, 0), (1, 0), (0, -1), (0, 1)
        )
            uy, ux = y + dy, x + dx
            if 0 < uy && uy ≤ h && 0 < ux && ux ≤ w && !visited[uy, ux]
                if color_distance(c, img[uy, ux]) < threshold
                    enqueue!(q, (uy, ux))
                    visited[uy, ux] = true
                end
            end
        end
    end
    img
end

floodfill(img, starting_point, color, threshold = 0.1) =
    floodfill!(float(copy(img)), starting_point, color, threshold)

function draw_outline!(img::AbstractMatrix, color = 0, width::Int = 1, threshold = 0.05)
    color = RGB(color)
    width < 1 && return img
    h, w = size(img)
    bg_color = img[1, 1]
    if color_distance(color, bg_color) < threshold
        return img
    end
    is_bg_color = map(img) do x
        color_distance(x, bg_color) < threshold
    end
    d = width
    @inbounds for x in 1:w
        for y in 1:h
            !is_bg_color[y, x] && continue
            for dx in -d:d, dy in -d:d
                uy, ux = y + dy, x + dx
                if 0 < uy && uy ≤ h && 0 < ux && ux ≤ w && !is_bg_color[uy, ux]
                    img[y, x] = color
                end
            end
        end
    end
    img
end
draw_outline(img, color=0, width=1) = draw_outline!(copy(img), color, width)

function cycled_translate(img::AbstractMatrix, (dy, dx))
    h, w = size(img)
    dy, dx = dy % h, dx % w
    if dy < 0
        dy += h
    end
    if dx < 0
        dx += w
    end
    img2 = similar(img)
    @inbounds begin
        img2[1:dy, 1:dx] = @view img[h - dy + 1:h, w - dx + 1:w]
        img2[1 + dy:h, 1 + dx:w] = @view img[1:h - dy, 1:w - dx]
        img2[1:dy, 1 + dx:w] = @view img[h - dy + 1:h, 1:w - dx]
        img2[1 + dy:h, 1:dx] = @view img[1:h - dy, w - dx + 1:w]
    end
    img2
end

function blend_color(blend::AbstractMatrix, base::AbstractMatrix)
    base = HSL.(base)
    blend = HSL.(blend)
    new_img = similar(base)
    chs = channelview(new_img)
    ax = axes(base)
    chs[3, ax...] = channelview(base)[3, ax...]
    chs[1:2, ax...] = channelview(blend)[1:2, ax...]
    RGB.(new_img)
end

function bounding_rect(img::AbstractMatrix, background_color)
    h, w = size(img)
    compare = !=(background_color)
    f = (func, xs, init) -> func((x for x in xs if !isnothing(x)), init = init)
    top = f(minimum, (findfirst(compare, view(img, :, x)) for x in 1:w), h)
    bottom = f(maximum, (findlast(compare, view(img, :, x)) for x in 1:w), 0)
    left = f(minimum, (findfirst(compare, view(img, y, :)) for y in 1:h), w)
    right = f(maximum, (findlast(compare, view(img, y, :)) for y in 1:h), 0)
    Rect((top, left), (bottom - top + 1, right - left + 1))
end

shrink(img::AbstractMatrix, background_color = img[1, 1]) = img[bounding_rect(img, background_color)]

function prepare_text_for_ocr(
    img::AbstractMatrix;
    threshold = 0.35f0,
    white_text = true
)
    img = Gray.(img)
    if white_text
        img = complement.(img)
    end
    img[img .> threshold] .= 1
    img
end


text:
function read_instructions(lines)
    instructions = Tuple{AbstractString, Int64}[]
    for line in lines
        op, value = split(line)
        push!(instructions, (op, parse(Int64, value)))
    end
    instructions
end

function run_program(instructions)
    n = length(instructions)
    visited = falses(n)
    ix = 1
    accumulator = 0
    while !visited[ix]
        (op, k) = instructions[ix]
        visited[ix] = true
        if op == "nop"
            ix += 1
        elseif op == "acc"
            accumulator += k
            ix += 1
        elseif op == "jmp"
            ix += k
        end
    end
    accumulator
end

function main()
    lines = readlines("../resources/input_08.txt")
    instructions = read_instructions(lines)
    result = run_program(instructions)
    println(result)
end

main()