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

"""
    add_attributes_to_findings(attributes, finding_arns)
    add_attributes_to_findings(attributes, finding_arns, params::Dict{String,<:Any})

Assigns attributes (key and value pairs) to the findings that are specified by the ARNs of
the findings.

# Arguments
- `attributes`: The array of attributes that you want to assign to specified findings.
- `finding_arns`: The ARNs that specify the findings that you want to assign attributes to.

"""
function add_attributes_to_findings(
    attributes, findingArns; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "AddAttributesToFindings",
        Dict{String,Any}("attributes" => attributes, "findingArns" => findingArns);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function add_attributes_to_findings(
    attributes,
    findingArns,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "AddAttributesToFindings",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}("attributes" => attributes, "findingArns" => findingArns),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Creates a new assessment target using the ARN of the resource group that is generated by
CreateResourceGroup. If resourceGroupArn is not specified, all EC2 instances in the current
AWS account and region are included in the assessment target. If the service-linked role
isn’t already registered, this action also creates and registers a service-linked role to
grant Amazon Inspector access to AWS Services needed to perform security assessments. You
can create up to 50 assessment targets per AWS account. You can run up to 500 concurrent
agents per AWS account. For more information, see  Amazon Inspector Assessment Targets.

# Arguments
- `assessment_target_name`: The user-defined name that identifies the assessment target
  that you want to create. The name must be unique within the AWS account.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"resourceGroupArn"`: The ARN that specifies the resource group that is used to create
  the assessment target. If resourceGroupArn is not specified, all EC2 instances in the
  current AWS account and region are included in the assessment target.
"""
function create_assessment_target(
    assessmentTargetName; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "CreateAssessmentTarget",
        Dict{String,Any}("assessmentTargetName" => assessmentTargetName);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function create_assessment_target(
    assessmentTargetName,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "CreateAssessmentTarget",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}("assessmentTargetName" => assessmentTargetName),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    create_assessment_template(assessment_target_arn, assessment_template_name, duration_in_seconds, rules_package_arns)
    create_assessment_template(assessment_target_arn, assessment_template_name, duration_in_seconds, rules_package_arns, params::Dict{String,<:Any})

Creates an assessment template for the assessment target that is specified by the ARN of
the assessment target. If the service-linked role isn’t already registered, this action
also creates and registers a service-linked role to grant Amazon Inspector access to AWS
Services needed to perform security assessments.

# Arguments
- `assessment_target_arn`: The ARN that specifies the assessment target for which you want
  to create the assessment template.
- `assessment_template_name`: The user-defined name that identifies the assessment template
  that you want to create. You can create several assessment templates for an assessment
  target. The names of the assessment templates that correspond to a particular assessment
  target must be unique.
- `duration_in_seconds`: The duration of the assessment run in seconds.
- `rules_package_arns`: The ARNs that specify the rules packages that you want to attach to
  the assessment template.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"userAttributesForFindings"`: The user-defined attributes that are assigned to every
  finding that is generated by the assessment run that uses this assessment template. An
  attribute is a key and value pair (an Attribute object). Within an assessment template,
  each key must be unique.
"""
function create_assessment_template(
    assessmentTargetArn,
    assessmentTemplateName,
    durationInSeconds,
    rulesPackageArns;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "CreateAssessmentTemplate",
        Dict{String,Any}(
            "assessmentTargetArn" => assessmentTargetArn,
            "assessmentTemplateName" => assessmentTemplateName,
            "durationInSeconds" => durationInSeconds,
            "rulesPackageArns" => rulesPackageArns,
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function create_assessment_template(
    assessmentTargetArn,
    assessmentTemplateName,
    durationInSeconds,
    rulesPackageArns,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "CreateAssessmentTemplate",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "assessmentTargetArn" => assessmentTargetArn,
                    "assessmentTemplateName" => assessmentTemplateName,
                    "durationInSeconds" => durationInSeconds,
                    "rulesPackageArns" => rulesPackageArns,
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Starts the generation of an exclusions preview for the specified assessment template. The
exclusions preview lists the potential exclusions (ExclusionPreview) that Inspector can
detect before it runs the assessment.

# Arguments
- `assessment_template_arn`: The ARN that specifies the assessment template for which you
  want to create an exclusions preview.

"""
function create_exclusions_preview(
    assessmentTemplateArn; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "CreateExclusionsPreview",
        Dict{String,Any}("assessmentTemplateArn" => assessmentTemplateArn);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function create_exclusions_preview(
    assessmentTemplateArn,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "CreateExclusionsPreview",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}("assessmentTemplateArn" => assessmentTemplateArn),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Creates a resource group using the specified set of tags (key and value pairs) that are
used to select the EC2 instances to be included in an Amazon Inspector assessment target.
The created resource group is then used to create an Amazon Inspector assessment target.
For more information, see CreateAssessmentTarget.

# Arguments
- `resource_group_tags`: A collection of keys and an array of possible values,
  '[{\"key\":\"key1\",\"values\":[\"Value1\",\"Value2\"]},{\"key\":\"Key2\",\"values\":[\"Valu
  e3\"]}]'. For example,'[{\"key\":\"Name\",\"values\":[\"TestEC2Instance\"]}]'.

"""
function create_resource_group(
    resourceGroupTags; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "CreateResourceGroup",
        Dict{String,Any}("resourceGroupTags" => resourceGroupTags);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function create_resource_group(
    resourceGroupTags,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "CreateResourceGroup",
        Dict{String,Any}(
            mergewith(
                _merge, Dict{String,Any}("resourceGroupTags" => resourceGroupTags), params
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Deletes the assessment run that is specified by the ARN of the assessment run.

# Arguments
- `assessment_run_arn`: The ARN that specifies the assessment run that you want to delete.

"""
function delete_assessment_run(
    assessmentRunArn; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "DeleteAssessmentRun",
        Dict{String,Any}("assessmentRunArn" => assessmentRunArn);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function delete_assessment_run(
    assessmentRunArn,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "DeleteAssessmentRun",
        Dict{String,Any}(
            mergewith(
                _merge, Dict{String,Any}("assessmentRunArn" => assessmentRunArn), params
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Deletes the assessment target that is specified by the ARN of the assessment target.

# Arguments
- `assessment_target_arn`: The ARN that specifies the assessment target that you want to
  delete.

"""
function delete_assessment_target(
    assessmentTargetArn; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "DeleteAssessmentTarget",
        Dict{String,Any}("assessmentTargetArn" => assessmentTargetArn);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function delete_assessment_target(
    assessmentTargetArn,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "DeleteAssessmentTarget",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}("assessmentTargetArn" => assessmentTargetArn),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Deletes the assessment template that is specified by the ARN of the assessment template.

# Arguments
- `assessment_template_arn`: The ARN that specifies the assessment template that you want
  to delete.

"""
function delete_assessment_template(
    assessmentTemplateArn; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "DeleteAssessmentTemplate",
        Dict{String,Any}("assessmentTemplateArn" => assessmentTemplateArn);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function delete_assessment_template(
    assessmentTemplateArn,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "DeleteAssessmentTemplate",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}("assessmentTemplateArn" => assessmentTemplateArn),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Describes the assessment runs that are specified by the ARNs of the assessment runs.

# Arguments
- `assessment_run_arns`: The ARN that specifies the assessment run that you want to
  describe.

"""
function describe_assessment_runs(
    assessmentRunArns; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "DescribeAssessmentRuns",
        Dict{String,Any}("assessmentRunArns" => assessmentRunArns);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function describe_assessment_runs(
    assessmentRunArns,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "DescribeAssessmentRuns",
        Dict{String,Any}(
            mergewith(
                _merge, Dict{String,Any}("assessmentRunArns" => assessmentRunArns), params
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Describes the assessment targets that are specified by the ARNs of the assessment targets.

# Arguments
- `assessment_target_arns`: The ARNs that specifies the assessment targets that you want to
  describe.

"""
function describe_assessment_targets(
    assessmentTargetArns; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "DescribeAssessmentTargets",
        Dict{String,Any}("assessmentTargetArns" => assessmentTargetArns);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function describe_assessment_targets(
    assessmentTargetArns,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "DescribeAssessmentTargets",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}("assessmentTargetArns" => assessmentTargetArns),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Describes the assessment templates that are specified by the ARNs of the assessment
templates.

# Arguments
- `assessment_template_arns`:

"""
function describe_assessment_templates(
    assessmentTemplateArns; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "DescribeAssessmentTemplates",
        Dict{String,Any}("assessmentTemplateArns" => assessmentTemplateArns);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function describe_assessment_templates(
    assessmentTemplateArns,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "DescribeAssessmentTemplates",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}("assessmentTemplateArns" => assessmentTemplateArns),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Describes the IAM role that enables Amazon Inspector to access your AWS account.

"""
function describe_cross_account_access_role(;
    aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "DescribeCrossAccountAccessRole";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function describe_cross_account_access_role(
    params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "DescribeCrossAccountAccessRole",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Describes the exclusions that are specified by the exclusions' ARNs.

# Arguments
- `exclusion_arns`: The list of ARNs that specify the exclusions that you want to describe.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"locale"`: The locale into which you want to translate the exclusion's title,
  description, and recommendation.
"""
function describe_exclusions(
    exclusionArns; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "DescribeExclusions",
        Dict{String,Any}("exclusionArns" => exclusionArns);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function describe_exclusions(
    exclusionArns,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "DescribeExclusions",
        Dict{String,Any}(
            mergewith(_merge, Dict{String,Any}("exclusionArns" => exclusionArns), params)
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Describes the findings that are specified by the ARNs of the findings.

# Arguments
- `finding_arns`: The ARN that specifies the finding that you want to describe.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"locale"`: The locale into which you want to translate a finding description,
  recommendation, and the short description that identifies the finding.
"""
function describe_findings(findingArns; aws_config::AbstractAWSConfig=global_aws_config())
    return inspector(
        "DescribeFindings",
        Dict{String,Any}("findingArns" => findingArns);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function describe_findings(
    findingArns,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "DescribeFindings",
        Dict{String,Any}(
            mergewith(_merge, Dict{String,Any}("findingArns" => findingArns), params)
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Describes the resource groups that are specified by the ARNs of the resource groups.

# Arguments
- `resource_group_arns`: The ARN that specifies the resource group that you want to
  describe.

"""
function describe_resource_groups(
    resourceGroupArns; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "DescribeResourceGroups",
        Dict{String,Any}("resourceGroupArns" => resourceGroupArns);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function describe_resource_groups(
    resourceGroupArns,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "DescribeResourceGroups",
        Dict{String,Any}(
            mergewith(
                _merge, Dict{String,Any}("resourceGroupArns" => resourceGroupArns), params
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Describes the rules packages that are specified by the ARNs of the rules packages.

# Arguments
- `rules_package_arns`: The ARN that specifies the rules package that you want to describe.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"locale"`: The locale that you want to translate a rules package description into.
"""
function describe_rules_packages(
    rulesPackageArns; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "DescribeRulesPackages",
        Dict{String,Any}("rulesPackageArns" => rulesPackageArns);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function describe_rules_packages(
    rulesPackageArns,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "DescribeRulesPackages",
        Dict{String,Any}(
            mergewith(
                _merge, Dict{String,Any}("rulesPackageArns" => rulesPackageArns), params
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    get_assessment_report(assessment_run_arn, report_file_format, report_type)
    get_assessment_report(assessment_run_arn, report_file_format, report_type, params::Dict{String,<:Any})

Produces an assessment report that includes detailed and comprehensive results of a
specified assessment run.

# Arguments
- `assessment_run_arn`: The ARN that specifies the assessment run for which you want to
  generate a report.
- `report_file_format`: Specifies the file format (html or pdf) of the assessment report
  that you want to generate.
- `report_type`: Specifies the type of the assessment report that you want to generate.
  There are two types of assessment reports: a finding report and a full report. For more
  information, see Assessment Reports.

"""
function get_assessment_report(
    assessmentRunArn,
    reportFileFormat,
    reportType;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "GetAssessmentReport",
        Dict{String,Any}(
            "assessmentRunArn" => assessmentRunArn,
            "reportFileFormat" => reportFileFormat,
            "reportType" => reportType,
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_assessment_report(
    assessmentRunArn,
    reportFileFormat,
    reportType,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "GetAssessmentReport",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "assessmentRunArn" => assessmentRunArn,
                    "reportFileFormat" => reportFileFormat,
                    "reportType" => reportType,
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    get_exclusions_preview(assessment_template_arn, preview_token)
    get_exclusions_preview(assessment_template_arn, preview_token, params::Dict{String,<:Any})

Retrieves the exclusions preview (a list of ExclusionPreview objects) specified by the
preview token. You can obtain the preview token by running the CreateExclusionsPreview API.

# Arguments
- `assessment_template_arn`: The ARN that specifies the assessment template for which the
  exclusions preview was requested.
- `preview_token`: The unique identifier associated of the exclusions preview.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"locale"`: The locale into which you want to translate the exclusion's title,
  description, and recommendation.
- `"maxResults"`: You can use this parameter to indicate the maximum number of items you
  want in the response. The default value is 100. The maximum value is 500.
- `"nextToken"`: You can use this parameter when paginating results. Set the value of this
  parameter to null on your first call to the GetExclusionsPreviewRequest action. Subsequent
  calls to the action fill nextToken in the request with the value of nextToken from the
  previous response to continue listing data.
"""
function get_exclusions_preview(
    assessmentTemplateArn, previewToken; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "GetExclusionsPreview",
        Dict{String,Any}(
            "assessmentTemplateArn" => assessmentTemplateArn, "previewToken" => previewToken
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_exclusions_preview(
    assessmentTemplateArn,
    previewToken,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "GetExclusionsPreview",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "assessmentTemplateArn" => assessmentTemplateArn,
                    "previewToken" => previewToken,
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Information about the data that is collected for the specified assessment run.

# Arguments
- `assessment_run_arn`: The ARN that specifies the assessment run that has the telemetry
  data that you want to obtain.

"""
function get_telemetry_metadata(
    assessmentRunArn; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "GetTelemetryMetadata",
        Dict{String,Any}("assessmentRunArn" => assessmentRunArn);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_telemetry_metadata(
    assessmentRunArn,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "GetTelemetryMetadata",
        Dict{String,Any}(
            mergewith(
                _merge, Dict{String,Any}("assessmentRunArn" => assessmentRunArn), params
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Lists the agents of the assessment runs that are specified by the ARNs of the assessment
runs.

# Arguments
- `assessment_run_arn`: The ARN that specifies the assessment run whose agents you want to
  list.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"filter"`: You can use this parameter to specify a subset of data to be included in the
  action's response. For a record to match a filter, all specified filter attributes must
  match. When multiple values are specified for a filter attribute, any of the values can
  match.
- `"maxResults"`: You can use this parameter to indicate the maximum number of items that
  you want in the response. The default value is 10. The maximum value is 500.
- `"nextToken"`: You can use this parameter when paginating results. Set the value of this
  parameter to null on your first call to the ListAssessmentRunAgents action. Subsequent
  calls to the action fill nextToken in the request with the value of NextToken from the
  previous response to continue listing data.
"""
function list_assessment_run_agents(
    assessmentRunArn; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "ListAssessmentRunAgents",
        Dict{String,Any}("assessmentRunArn" => assessmentRunArn);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function list_assessment_run_agents(
    assessmentRunArn,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "ListAssessmentRunAgents",
        Dict{String,Any}(
            mergewith(
                _merge, Dict{String,Any}("assessmentRunArn" => assessmentRunArn), params
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Lists the assessment runs that correspond to the assessment templates that are specified by
the ARNs of the assessment templates.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"assessmentTemplateArns"`: The ARNs that specify the assessment templates whose
  assessment runs you want to list.
- `"filter"`: You can use this parameter to specify a subset of data to be included in the
  action's response. For a record to match a filter, all specified filter attributes must
  match. When multiple values are specified for a filter attribute, any of the values can
  match.
- `"maxResults"`: You can use this parameter to indicate the maximum number of items that
  you want in the response. The default value is 10. The maximum value is 500.
- `"nextToken"`: You can use this parameter when paginating results. Set the value of this
  parameter to null on your first call to the ListAssessmentRuns action. Subsequent calls to
  the action fill nextToken in the request with the value of NextToken from the previous
  response to continue listing data.
"""
function list_assessment_runs(; aws_config::AbstractAWSConfig=global_aws_config())
    return inspector(
        "ListAssessmentRuns"; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end
function list_assessment_runs(
    params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "ListAssessmentRuns", params; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end

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

Lists the ARNs of the assessment targets within this AWS account. For more information
about assessment targets, see Amazon Inspector Assessment Targets.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"filter"`: You can use this parameter to specify a subset of data to be included in the
  action's response. For a record to match a filter, all specified filter attributes must
  match. When multiple values are specified for a filter attribute, any of the values can
  match.
- `"maxResults"`: You can use this parameter to indicate the maximum number of items you
  want in the response. The default value is 10. The maximum value is 500.
- `"nextToken"`: You can use this parameter when paginating results. Set the value of this
  parameter to null on your first call to the ListAssessmentTargets action. Subsequent calls
  to the action fill nextToken in the request with the value of NextToken from the previous
  response to continue listing data.
"""
function list_assessment_targets(; aws_config::AbstractAWSConfig=global_aws_config())
    return inspector(
        "ListAssessmentTargets"; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end
function list_assessment_targets(
    params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "ListAssessmentTargets",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Lists the assessment templates that correspond to the assessment targets that are specified
by the ARNs of the assessment targets.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"assessmentTargetArns"`: A list of ARNs that specifies the assessment targets whose
  assessment templates you want to list.
- `"filter"`: You can use this parameter to specify a subset of data to be included in the
  action's response. For a record to match a filter, all specified filter attributes must
  match. When multiple values are specified for a filter attribute, any of the values can
  match.
- `"maxResults"`: You can use this parameter to indicate the maximum number of items you
  want in the response. The default value is 10. The maximum value is 500.
- `"nextToken"`: You can use this parameter when paginating results. Set the value of this
  parameter to null on your first call to the ListAssessmentTemplates action. Subsequent
  calls to the action fill nextToken in the request with the value of NextToken from the
  previous response to continue listing data.
"""
function list_assessment_templates(; aws_config::AbstractAWSConfig=global_aws_config())
    return inspector(
        "ListAssessmentTemplates"; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end
function list_assessment_templates(
    params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "ListAssessmentTemplates",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Lists all the event subscriptions for the assessment template that is specified by the ARN
of the assessment template. For more information, see SubscribeToEvent and
UnsubscribeFromEvent.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"maxResults"`: You can use this parameter to indicate the maximum number of items you
  want in the response. The default value is 10. The maximum value is 500.
- `"nextToken"`: You can use this parameter when paginating results. Set the value of this
  parameter to null on your first call to the ListEventSubscriptions action. Subsequent calls
  to the action fill nextToken in the request with the value of NextToken from the previous
  response to continue listing data.
- `"resourceArn"`: The ARN of the assessment template for which you want to list the
  existing event subscriptions.
"""
function list_event_subscriptions(; aws_config::AbstractAWSConfig=global_aws_config())
    return inspector(
        "ListEventSubscriptions"; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end
function list_event_subscriptions(
    params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "ListEventSubscriptions",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

List exclusions that are generated by the assessment run.

# Arguments
- `assessment_run_arn`: The ARN of the assessment run that generated the exclusions that
  you want to list.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"maxResults"`: You can use this parameter to indicate the maximum number of items you
  want in the response. The default value is 100. The maximum value is 500.
- `"nextToken"`: You can use this parameter when paginating results. Set the value of this
  parameter to null on your first call to the ListExclusionsRequest action. Subsequent calls
  to the action fill nextToken in the request with the value of nextToken from the previous
  response to continue listing data.
"""
function list_exclusions(
    assessmentRunArn; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "ListExclusions",
        Dict{String,Any}("assessmentRunArn" => assessmentRunArn);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function list_exclusions(
    assessmentRunArn,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "ListExclusions",
        Dict{String,Any}(
            mergewith(
                _merge, Dict{String,Any}("assessmentRunArn" => assessmentRunArn), params
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Lists findings that are generated by the assessment runs that are specified by the ARNs of
the assessment runs.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"assessmentRunArns"`: The ARNs of the assessment runs that generate the findings that
  you want to list.
- `"filter"`: You can use this parameter to specify a subset of data to be included in the
  action's response. For a record to match a filter, all specified filter attributes must
  match. When multiple values are specified for a filter attribute, any of the values can
  match.
- `"maxResults"`: You can use this parameter to indicate the maximum number of items you
  want in the response. The default value is 10. The maximum value is 500.
- `"nextToken"`: You can use this parameter when paginating results. Set the value of this
  parameter to null on your first call to the ListFindings action. Subsequent calls to the
  action fill nextToken in the request with the value of NextToken from the previous response
  to continue listing data.
"""
function list_findings(; aws_config::AbstractAWSConfig=global_aws_config())
    return inspector("ListFindings"; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET)
end
function list_findings(
    params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "ListFindings", params; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end

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

Lists all available Amazon Inspector rules packages.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"maxResults"`: You can use this parameter to indicate the maximum number of items you
  want in the response. The default value is 10. The maximum value is 500.
- `"nextToken"`: You can use this parameter when paginating results. Set the value of this
  parameter to null on your first call to the ListRulesPackages action. Subsequent calls to
  the action fill nextToken in the request with the value of NextToken from the previous
  response to continue listing data.
"""
function list_rules_packages(; aws_config::AbstractAWSConfig=global_aws_config())
    return inspector(
        "ListRulesPackages"; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end
function list_rules_packages(
    params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "ListRulesPackages", params; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end

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

Lists all tags associated with an assessment template.

# Arguments
- `resource_arn`: The ARN that specifies the assessment template whose tags you want to
  list.

"""
function list_tags_for_resource(
    resourceArn; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "ListTagsForResource",
        Dict{String,Any}("resourceArn" => resourceArn);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function list_tags_for_resource(
    resourceArn,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "ListTagsForResource",
        Dict{String,Any}(
            mergewith(_merge, Dict{String,Any}("resourceArn" => resourceArn), params)
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Previews the agents installed on the EC2 instances that are part of the specified
assessment target.

# Arguments
- `preview_agents_arn`: The ARN of the assessment target whose agents you want to preview.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"maxResults"`: You can use this parameter to indicate the maximum number of items you
  want in the response. The default value is 10. The maximum value is 500.
- `"nextToken"`: You can use this parameter when paginating results. Set the value of this
  parameter to null on your first call to the PreviewAgents action. Subsequent calls to the
  action fill nextToken in the request with the value of NextToken from the previous response
  to continue listing data.
"""
function preview_agents(previewAgentsArn; aws_config::AbstractAWSConfig=global_aws_config())
    return inspector(
        "PreviewAgents",
        Dict{String,Any}("previewAgentsArn" => previewAgentsArn);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function preview_agents(
    previewAgentsArn,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "PreviewAgents",
        Dict{String,Any}(
            mergewith(
                _merge, Dict{String,Any}("previewAgentsArn" => previewAgentsArn), params
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Registers the IAM role that grants Amazon Inspector access to AWS Services needed to
perform security assessments.

# Arguments
- `role_arn`: The ARN of the IAM role that grants Amazon Inspector access to AWS Services
  needed to perform security assessments.

"""
function register_cross_account_access_role(
    roleArn; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "RegisterCrossAccountAccessRole",
        Dict{String,Any}("roleArn" => roleArn);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function register_cross_account_access_role(
    roleArn, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "RegisterCrossAccountAccessRole",
        Dict{String,Any}(mergewith(_merge, Dict{String,Any}("roleArn" => roleArn), params));
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    remove_attributes_from_findings(attribute_keys, finding_arns)
    remove_attributes_from_findings(attribute_keys, finding_arns, params::Dict{String,<:Any})

Removes entire attributes (key and value pairs) from the findings that are specified by the
ARNs of the findings where an attribute with the specified key exists.

# Arguments
- `attribute_keys`: The array of attribute keys that you want to remove from specified
  findings.
- `finding_arns`: The ARNs that specify the findings that you want to remove attributes
  from.

"""
function remove_attributes_from_findings(
    attributeKeys, findingArns; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "RemoveAttributesFromFindings",
        Dict{String,Any}("attributeKeys" => attributeKeys, "findingArns" => findingArns);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function remove_attributes_from_findings(
    attributeKeys,
    findingArns,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "RemoveAttributesFromFindings",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "attributeKeys" => attributeKeys, "findingArns" => findingArns
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Sets tags (key and value pairs) to the assessment template that is specified by the ARN of
the assessment template.

# Arguments
- `resource_arn`: The ARN of the assessment template that you want to set tags to.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"tags"`: A collection of key and value pairs that you want to set to the assessment
  template.
"""
function set_tags_for_resource(
    resourceArn; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "SetTagsForResource",
        Dict{String,Any}("resourceArn" => resourceArn);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function set_tags_for_resource(
    resourceArn,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "SetTagsForResource",
        Dict{String,Any}(
            mergewith(_merge, Dict{String,Any}("resourceArn" => resourceArn), params)
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Starts the assessment run specified by the ARN of the assessment template. For this API to
function properly, you must not exceed the limit of running up to 500 concurrent agents per
AWS account.

# Arguments
- `assessment_template_arn`: The ARN of the assessment template of the assessment run that
  you want to start.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"assessmentRunName"`: You can specify the name for the assessment run. The name must be
  unique for the assessment template whose ARN is used to start the assessment run.
"""
function start_assessment_run(
    assessmentTemplateArn; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "StartAssessmentRun",
        Dict{String,Any}("assessmentTemplateArn" => assessmentTemplateArn);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function start_assessment_run(
    assessmentTemplateArn,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "StartAssessmentRun",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}("assessmentTemplateArn" => assessmentTemplateArn),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Stops the assessment run that is specified by the ARN of the assessment run.

# Arguments
- `assessment_run_arn`: The ARN of the assessment run that you want to stop.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"stopAction"`: An input option that can be set to either START_EVALUATION or
  SKIP_EVALUATION. START_EVALUATION (the default value), stops the AWS agent from collecting
  data and begins the results evaluation and the findings generation process. SKIP_EVALUATION
  cancels the assessment run immediately, after which no findings are generated.
"""
function stop_assessment_run(
    assessmentRunArn; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "StopAssessmentRun",
        Dict{String,Any}("assessmentRunArn" => assessmentRunArn);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function stop_assessment_run(
    assessmentRunArn,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "StopAssessmentRun",
        Dict{String,Any}(
            mergewith(
                _merge, Dict{String,Any}("assessmentRunArn" => assessmentRunArn), params
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    subscribe_to_event(event, resource_arn, topic_arn)
    subscribe_to_event(event, resource_arn, topic_arn, params::Dict{String,<:Any})

Enables the process of sending Amazon Simple Notification Service (SNS) notifications about
a specified event to a specified SNS topic.

# Arguments
- `event`: The event for which you want to receive SNS notifications.
- `resource_arn`: The ARN of the assessment template that is used during the event for
  which you want to receive SNS notifications.
- `topic_arn`: The ARN of the SNS topic to which the SNS notifications are sent.

"""
function subscribe_to_event(
    event, resourceArn, topicArn; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "SubscribeToEvent",
        Dict{String,Any}(
            "event" => event, "resourceArn" => resourceArn, "topicArn" => topicArn
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function subscribe_to_event(
    event,
    resourceArn,
    topicArn,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "SubscribeToEvent",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "event" => event, "resourceArn" => resourceArn, "topicArn" => topicArn
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    unsubscribe_from_event(event, resource_arn, topic_arn)
    unsubscribe_from_event(event, resource_arn, topic_arn, params::Dict{String,<:Any})

Disables the process of sending Amazon Simple Notification Service (SNS) notifications
about a specified event to a specified SNS topic.

# Arguments
- `event`: The event for which you want to stop receiving SNS notifications.
- `resource_arn`: The ARN of the assessment template that is used during the event for
  which you want to stop receiving SNS notifications.
- `topic_arn`: The ARN of the SNS topic to which SNS notifications are sent.

"""
function unsubscribe_from_event(
    event, resourceArn, topicArn; aws_config::AbstractAWSConfig=global_aws_config()
)
    return inspector(
        "UnsubscribeFromEvent",
        Dict{String,Any}(
            "event" => event, "resourceArn" => resourceArn, "topicArn" => topicArn
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function unsubscribe_from_event(
    event,
    resourceArn,
    topicArn,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "UnsubscribeFromEvent",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "event" => event, "resourceArn" => resourceArn, "topicArn" => topicArn
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    update_assessment_target(assessment_target_arn, assessment_target_name)
    update_assessment_target(assessment_target_arn, assessment_target_name, params::Dict{String,<:Any})

Updates the assessment target that is specified by the ARN of the assessment target. If
resourceGroupArn is not specified, all EC2 instances in the current AWS account and region
are included in the assessment target.

# Arguments
- `assessment_target_arn`: The ARN of the assessment target that you want to update.
- `assessment_target_name`: The name of the assessment target that you want to update.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"resourceGroupArn"`: The ARN of the resource group that is used to specify the new
  resource group to associate with the assessment target.
"""
function update_assessment_target(
    assessmentTargetArn,
    assessmentTargetName;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "UpdateAssessmentTarget",
        Dict{String,Any}(
            "assessmentTargetArn" => assessmentTargetArn,
            "assessmentTargetName" => assessmentTargetName,
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function update_assessment_target(
    assessmentTargetArn,
    assessmentTargetName,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return inspector(
        "UpdateAssessmentTarget",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "assessmentTargetArn" => assessmentTargetArn,
                    "assessmentTargetName" => assessmentTargetName,
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end


text:
module VSCodeDebugger

our_findfirst(ch::AbstractChar, string::AbstractString) = findfirst(==(ch), string)
our_findnext(ch::AbstractChar, string::AbstractString, ind::Integer) = findnext(==(ch), string, ind)

include("../error_handler.jl")

include("../packages/VSCodeServer/src/repl.jl")

# This patches JuliaInterpreter.jl to use our private copy of CodeTracking.jl
filename_of_juliainterpreter = joinpath(@__DIR__, "..", "packages", "JuliaInterpreter", "src", "JuliaInterpreter.jl")
filename_of_codetracking = joinpath(@__DIR__, "..", "packages", "CodeTracking", "src", "CodeTracking.jl")
filename_of_codetracking = replace(filename_of_codetracking, "\\"=>"\\\\")
jlinterp_code = read(filename_of_juliainterpreter, String)
jlinterp_code_patched = replace(jlinterp_code, "using CodeTracking"=>"include(\"$filename_of_codetracking\"); using .CodeTracking")
withpath(filename_of_juliainterpreter) do
    include_string(VSCodeDebugger, jlinterp_code_patched, filename_of_juliainterpreter)
end

import .JuliaInterpreter
import Sockets, Base64

include("debugger_rcp.jl")
include("debugger_utils.jl")
include("debugger_core.jl")
include("debugger_requests.jl")

function clean_up_ARGS_in_launch_mode()
    pipename = ARGS[1]
    crashreporting_pipename = ARGS[2]
    deleteat!(ARGS, 1)
    deleteat!(ARGS, 1)

    if ENV["JL_ARGS"] != ""
        cmd_ln_args_encoded = split(ENV["JL_ARGS"], ';')

        delete!(ENV, "JL_ARGS")

        cmd_ln_args_decoded = map(i->String(Base64.base64decode(i)), cmd_ln_args_encoded)

        for arg in cmd_ln_args_decoded
            push!(ARGS, arg)
        end
    end

    return pipename, crashreporting_pipename
end

function startdebug(pipename)
    @debug "Trying to connect to debug adapter."
    conn = Sockets.connect(pipename)
    @debug "Connected to debug adapter."
    try
        state = DebuggerState()

        request_handlers = Dict{String,Function}()
        request_handlers["DISCONNECT"] = disconnect_request
        request_handlers["RUN"] = run_request
        request_handlers["DEBUG"] = debug_request
        request_handlers["EXEC"] = exec_request
        request_handlers["SETBREAKPOINTS"] = setbreakpoints_request
        request_handlers["SETEXCEPTIONBREAKPOINTS"] = setexceptionbreakpoints_request
        request_handlers["SETFUNCBREAKPOINTS"] = setfunctionbreakpoints_request
        request_handlers["GETSTACKTRACE"] = getstacktrace_request
        request_handlers["GETSCOPE"] = getscope_request
        request_handlers["GETSOURCE"] = getsource_request
        request_handlers["GETVARIABLES"] = getvariables_request
        request_handlers["CONTINUE"] = continue_request
        request_handlers["NEXT"] = next_request
        request_handlers["STEPIN"] = stepin_request
        request_handlers["STEPOUT"] = stepout_request
        request_handlers["EVALUATE"] = evaluate_request
        request_handlers["TERMINATE"] = terminate_request
        request_handlers["GETEXCEPTIONINFO"] = getexceptioninfo_request
        request_handlers["RESTARTFRAME"] = restartframe_request
        request_handlers["SETVARIABLE"] = setvariable_request

        while true
            @debug "Waiting for next command from debug adapter."
            le = readline(conn)

            msg_id, msg_cmd, msg_body = decode_msg(le)

            @debug "Received command '$msg_cmd' from debug adapter."

            if haskey(request_handlers, msg_cmd)
                ret_val = request_handlers[msg_cmd](conn, state, msg_body, msg_id)

                ret_val == :break && break
            else
                error("Unknown debug command.")
            end
        end

        @debug "Finished debugging"
    finally
        close(conn)
    end
end

end

ext: jl


text:
srand(1)

# --- return a (n,ne,np) preserved shuffled version of a network
function shufflenet (intr,slf)
    n = length(slf)
    nw = similar(intr)                  # this will be the randomized version
    shf = shuffle(slf)                  # keep number of self degredating genes
    tl = tril(intr)                     # remove diag and join upper/lower triang
    tu = triu(intr)
    rect = tu[:,2:end]+tl[:,1:end-1]    # shuffle this
    rect = reshape(shuffle(reshape(rect,length(rect),1)[:,1]),n,n-1)
    rrect = [rect zeros(Int64,n)]       # now insert back the shuffled diagonal
    lrect = [zeros(Int64,n) rect]
    nw = tril(rrect - diagm(diag(rrect))) + triu(lrect-diagm(diag(lrect)))
    return (nw,shf)
end

# --- generate the symmetric adjacency matrix with elements 0,1 ---
function symadj(m)
    n = length(m[:,1])
    ad = zeros(Int64,n,n)
    for (i=1:n) for (j=i+1:n)       # adjacency matrix - without diagonals
        ad[i,j] = m[i,j]==0 && m[j,i]==0 ? 0 : 1
        ad[j,i] = ad[i,j]
    end end
    return ad
end

## --- check connectivity -----------
function isconnected (adj)
    n = length(adj[:,1])                # number of nodes
    nsq = n*n
    dum = adj
    (sumprev,sumdum) = (0,0)
    for (i=1:n)
        dum = sign(dum + dum*adj)
        sumdum = sum(dum)
        if (sumdum == sumprev)
            break
        end
        sumprev = sumdum
    end
    return (sumdum==nsq)
end

## --- node update function (integrator): yeast's majority rule -----------
function upd(s,intr,slf,n)
    sss = similar(s)
    inp = intr*s
    for (i=1:n)
        sss[i] = (inp[i]>0)?1:(inp[i]<0)?0:(slf[i]==1)?0:s[i]
    end
    return sss
end

## ---- output is the attractor list + basin sizes ---
## ---- calculated from a subset of initial conditions ---
function getcyclessample(intr,slf,ninit)

    n = length(slf)
    attrlist = zeros(Int64,n)           # s=0 is always an attractor
    keyzeros = join(zeros(Int64,n))
    attdict = [keyzeros=>0]    # values are the basin sizes
    for (i=1:ninit)       # calculate basins using ninit initial states
        s = rand(0:1,n)
        skey = join(s)
        pathdict = Dict()
        while (!haskey(attdict,skey) && !haskey(pathdict,skey))
            pathdict[skey] = "-"
            s = upd(s,intr,slf,n)
            skey=join(s)
        end
        if (haskey(attdict,skey)) attdict[skey] += 1
        else                        # this is a new cycle or fp
            attdict[skey] = 1
            attrlist = [attrlist s]
        end
    end
    basinlist = [attdict[join(attrlist[:,i])]/ninit for i in 1:length(attrlist[1,:])]
    return attrlist,basinlist
end

## ---- find number of coop nodes in a state ---
function ncoop (s,intr)
    n = length(s)
    act = intr*diagm(s) # keep only the columns for active nodes
    nc=0
    for (i=1:n)
#        if (abs(sum(act[i,:])) == sum(abs(act[i,:])))
        if (!in(1,act[i,:]) || !in(-1,act[i,:]))
            nc += 1
        end
    end
    return nc
end

## ---- find coop coef for sampled cycles of a network ---
function coopattr (intr,slf,ninit)
    n = length(slf)
    (listatt,listb) = getcyclessample(intr,slf,ninit)
    listperiod=Int64[];
    listcop=Float64[];
    listact=Float64[];
    npointattr = 0;
    for (i=1:length(listatt[1,:]))        # go over each attractor
        s = listatt[:,i]
#        if (sum(s) != 0)
        ncp = ncoop(s,intr)
#            nac = sum(abs(intr)*s)
        nac = sum(s)
        period = 1
        s=upd(s,intr,slf,n)
        while (s != listatt[:,i])
            ncp += ncoop(s,intr)
#            nac += sum(abs(intr)*s)
            nac += sum(s)
            period += 1
            s=upd(s,intr,slf,n)
        end
        push!(listperiod,period)
        push!(listcop,ncp/period)
        push!(listact,nac/period)
        if (period==1) npointattr += 1 end
    #        end
    end
#    if (length(listperiod)==1)  return -1,-1,-1,-1 # no fixed point other than (0,..0)
#    else                    # also returns the fracion of active nodes
#        return (1.0*mean(listcop)/n,mean(listact)/n,length(listc[1,:]),npointattr)
    return listatt,listb,listperiod,listcop,listact
#    end
end

function step (nw,pth,visnodes,cdict)

    sizenw = length(nw[:,1])
    p = copy(pth)
    last = pop!(p)
    if in(last,p)                       # found cycle
        pp = copy(p)                    # make a copy of the path (something like 1-2-10-3)
        c = Int64[]       # cycle nodes ordered with correct direction
        mini = last       # stores the minimum index in cycle
        unshift!(c,last)
        n=pop!(pp)
        while n != last
            unshift!(c,n)
            if(n<mini)
                mini = n
            end
            n=pop!(pp)
        end

        while c[1] != mini      # bring the min index to the beginning
            n = shift!(c)
            push!(c,n)
        end
        cyckey = join(c,"-")

        lcyc = length(c)
        if (!haskey(cdict,cyckey))
            cdict[cyckey]=1
            for i=1:lcyc-1
                cdict[cyckey] *= nw[c[i+1],c[i]]
            end
            cdict[cyckey] *= nw[c[1],c[lcyc]]
        end
    else                                # move one more step if possible
        push!(p,last)
        for i=1:sizenw
            if nw[i,last] != 0
                push!(p,i)
                visnodes[i] = 1
                step(nw,p,visnodes,cdict)
                pop!(p)
            end
        end
    end
end

function getcycles(nw)
    visnodes = Dict()                       # set of visited nodes
    path=Int64[]                            # ordered list of path nodes
    cycdict = Dict()                        # set of cycles found so far
    sizenw=length(nw[:,1])

    ncycles=0
    for j=1:sizenw
        if !haskey(visnodes,j)
            push!(path,j)
            step(nw,path,visnodes,cycdict)
            pop!(path)
        end
    end
    return cycdict
end

nw = readdlm("7org_nw/d.melanogaster")      # interaction matrix
cycdict = getcycles(nw)
println(sum(values(cycdict))/length(cycdict),"\t",length(cycdict))

## # --- calculate average cooperativity over random networks
n = 0
ntotal = 1000000           # ensemble size
numinit = 2^11              # num of initial cond for fp determination

path="7org_nw"
## ## ## for f=["a.thaliana","d.melanogaster","lymphocyte","mammalian","myeloid","s.cerevisiae","s.pombe"
#for f=["a.thaliana","lymphocyte","mammalian","myeloid","s.cerevisiae","s.pombe"]
for f=["s.cerevisiae","s.pombe"]
    nw = readdlm("$path/$f")
    println("&$f")
    selfsh = diag(nw)
    intersh = nw-diagm(selfsh)
    n = length(nw[:,1])
    i=0
    while (i<ntotal)
        (intersh,selfsh) = shufflenet(intersh,selfsh) # shuffle
        if (isconnected(symadj(intersh))) # check if connected
            (attlist,basinlist,listperiod,listcop,listact) = coopattr(intersh,selfsh,numinit)
            if (length(attlist) > 1)
                i += 1              # increase network count
                nw = intersh + diagm(selfsh)
                cycdict = getcycles(nw)
                cyccount = length(cycdict)
                cycscore = sum(values(cycdict))/cyccount
                println("$i\t$cyccount\t$cycscore")
                if (mean(listcop/n)==1) # perfect coherence
                    println("*$i\t$cyccount\t$cycscore")
                end
            end
        end
    end
end

max_stars_repo_name: akabakcioglu/network-motifs

max_issues_repo_name: akabakcioglu/network-motifs

max_forks_repo_name: akabakcioglu/network-motifs


text:
#
#  Initial values from:
#         "Achieving Brouwer law with implicit Runge-Kutta methods"
#                 E. Hairer, R.I. McLachlan and A. Razakarivony
#
#          (solution is chaotic)

function InitialHenon(T=Float64)

    q=[parse(BigFloat,"0.0"), parse(BigFloat,"0.3")]

    p=[parse(BigFloat,"0.0"), parse(BigFloat,"0.2")]

    H0=1/8
    V0=V=1/2*(q[1]^2+q[2]^2)+q[1]^2*q[2]-1/3*q[2]^3
    p[1]=sqrt(2*H0-2*V0-p[2]^2)

    u0=convert.(T,[q; p])

    return u0

end


text:
"""
    MeshTriangleModule

Module  for generation of meshes composed of triangles.
"""
module MeshTriangleModule

using FinEtools.FTypesModule: FInt, FFlt, FCplxFlt, FFltVec, FIntVec, FFltMat, FIntMat, FMat, FVec, FDataDict
import FinEtools.FESetModule: FESet, FESetT3, FESetT6, FESetQ4, connasarray
import FinEtools.FENodeSetModule: FENodeSet
import FinEtools.MeshUtilModule: makecontainer, addhyperface!, findhyperface!, linearspace

"""
    T3blockx(xs::FFltVec, ys::FFltVec, orientation::Symbol=:a)

T3 Mesh of a rectangle.
"""
function T3blockx(xs::FFltVec, ys::FFltVec, orientation::Symbol=:a)
    if (orientation!=:a) && (orientation!=:b)
        error("Cannot handle orientation : $orientation")
    end
    nL =length(xs)-1;
    nW =length(ys)-1;
    nnodes=(nL+1)*(nW+1);
    ncells=2*(nL)*(nW);
    xys=zeros(FFlt,nnodes,2);
    conns=zeros(FInt,ncells,3);
    f=1;
    for j=1:(nW+1)
        for i=1:(nL+1)
            xys[f, 1] = xs[i]
            xys[f, 2] = ys[j]
            f=f+1;
        end
    end
    fens = FENodeSet(xys);

    gc=1;
    for i=1:nL
        for j=1:nW
            f=(j-1)*(nL+1)+i;
            if     (orientation==:a)
                nn=[f (f+1) f+(nL+1)];
            elseif (orientation==:b)
                nn=[f (f+1) f+(nL+1)+1];
            end
            conns[gc,:]=nn;
            gc=gc+1;
            if     (orientation==:a)
                nn=[(f+1)  f+(nL+1)+1 f+(nL+1)];
            elseif (orientation==:b)
                nn=[f  f+(nL+1)+1 f+(nL+1)];
            end
            conns[gc,:]=nn;
            gc=gc+1;
        end
    end
    fes = FESetT3(conns);
    return fens,fes
end

function T3blockx(xs::FFltMat,ys::FFltMat,orientation::Symbol=:a)
    return T3blockx(vec(xs),vec(ys),orientation)
end

"""
    T3block(Length::FFlt, Width::FFlt, nL::FInt, nW::FInt, orientation::Symbol=:a)

T3 Mesh of a rectangle.
"""
function T3block(Length::FFlt, Width::FFlt, nL::FInt, nW::FInt, orientation::Symbol=:a)
    return T3blockx(FFltVec(linearspace(0.0,Length,nL+1)), FFltVec(linearspace(0.0,Width,nW+1)), orientation)
end

"""
    T3toT6(fens::FENodeSet, fes::FESetT3)

Convert a mesh of triangle T3 (three-node) to triangle T6.
"""
function T3toT6(fens::FENodeSet, fes::FESetT3)
    nedges=3;
    ec = [1 2; 2 3; 3 1];
    conns = connasarray(fes);
    # Additional node numbers are numbered from here
    newn=count(fens)+1;
    # make a search structure for edges
    edges=makecontainer();
    for i= 1:size(conns,1)
        conn = conns[i,:];
        for J = 1:nedges
            ev=conn[ec[J,:]];
            newn = addhyperface!(edges, ev, newn);
        end
    end
    xyz1 =fens.xyz;             # Pre-existing nodes
    # Allocate for vertex nodes plus edge nodes plus face nodes
    xyz =zeros(FFlt,newn-1,size(fens.xyz,2));
    xyz[1:size(xyz1,1),:] = xyz1; # existing nodes are copied over
    # calculate the locations of the new nodes
    # and construct the new nodes
    for i in keys(edges)
        C=edges[i];
        for J = 1:length(C)
            ix = vec([item for item in C[J].o])
            push!(ix,  i)
            xyz[C[J].n, :] = mean(xyz[ix, :], dims = 1);
        end
    end
    # construct new geometry cells
    nconns =zeros(FInt,size(conns,1),6);
    nc=1;
    for i= 1:size(conns,1)
        conn = conns[i,:];
        econn=zeros(FInt,1,nedges);
        for J = 1:nedges
            ev=conn[ec[J,:]];
            h,n=findhyperface!(edges, ev);
            econn[J]=n;
        end
        nconns[nc,:] =vcat(vec(conn), vec(econn));
        nc= nc+ 1;
    end
    fens =FENodeSet(xyz);
    fes = FESetT6(nconns) ;
    return fens,fes;
end

"""
    T6block(Length::FFlt, Width::FFlt, nL::FInt, nW::FInt, orientation::Symbol=:a)

Mesh of a rectangle of T6 elements.
"""
function T6block(Length::FFlt, Width::FFlt, nL::FInt, nW::FInt, orientation::Symbol=:a)
    fens,fes = T3block(Length,Width,nL,nW,orientation);
    fens,fes = T3toT6(fens,fes);
end

"""
    T6blockx(xs::FFltVec, ys::FFltVec, orientation::Symbol=:a)

Graded mesh of a 2-D block of T6 finite elements.
"""
function T6blockx(xs::FFltVec, ys::FFltVec, orientation::Symbol=:a)
    fens, fes = T3blockx(xs, ys, orientation);
    fens, fes = T3toT6(fens, fes);
end

"""
    Q4toT3(fens::FENodeSet, fes::FESetQ4, orientation::Symbol=:default)

Convert a mesh of quadrilateral Q4's to two T3 triangles  each.
"""
function Q4toT3(fens::FENodeSet, fes::FESetQ4, orientation::Symbol=:default)
    connl1=[1  2  3];
    connl2=[1  3  4];
    if orientation==:alternate
        connl1=[1, 2, 4];
        connl2=[3, 4, 2];
    end
    nedges=4;
    nconns=zeros(FInt,2*count(fes),3);
    conns = connasarray(fes)
    nc=1;
    for i= 1:size(conns, 1)
        conn = conns[i,:];
        nconns[nc,:] =conn[connl1];
        nc= nc+ 1;
        nconns[nc,:] =conn[connl2];
        nc= nc+ 1;
    end
    nfes = FESetT3(nconns);
    return fens,nfes            # I think I should not be overwriting the input!
end

"""
    T3refine(fens::FENodeSet,fes::FESetT3)

Refine a mesh of 3-node tetrahedra by quadrisection.
"""
function T3refine(fens::FENodeSet,fes::FESetT3)
    fens,fes = T3toT6(fens,fes);
    nconn=zeros(FInt,4*size(fes.conn,1),3);
    conns = connasarray(fes)
    nc=1;
    for i= 1:size(conns,1)
        c=conns[i,:];
        nconn[nc,:] =c[[1,4,6]];        nc= nc+ 1;
        nconn[nc,:] =c[[2,5,4]];        nc= nc+ 1;
        nconn[nc,:] =c[[3,6,5]];        nc= nc+ 1;
        nconn[nc,:] =c[[4,5,6]];        nc= nc+ 1;
    end
    nfes = FESetT3(nconn);
    return fens,nfes            # I think I should not be overwriting the input!
end

end


text:
# Copyright (c) 2021 Daniel C. Moura
# https://towardsdatascience.com/r-vs-python-vs-julia-90456a2bcbab
# linkedin.com/in/dmoura
# twitter.com/daniel_c_moura

# running this file:
# julia --optimize=3 --check-bounds=no linear_search.jl

using CPUTime

### functions under evaluation ###

# 0.37 seconds
in_search(vec, x) = x in vec

# 0.32 seconds
ff_search(vec, x) = findfirst(el -> el == x, vec) != nothing

# 0.38 seconds
mapr_search(vec, x) = mapreduce(el -> el == x, |, vec)

# 1.10 seconds
vec_search(vec, x) = any(vec .== x)

gen_search(vec, x) = !isempty(nothing for v in vec if v == x)

# 0.33 seconds
function foreach_search(vec, x)
    @simd for v in vec
        if v == x
            return true
        end
    end
    false
end

# 0.32 seconds
function for_search(vec, x)
    @inbounds @simd for i in eachindex(vec)
        if vec[i] == x
            return true
        end
    end
    false
end

### aux functions ###

function bench(label, f, v)
    f(v[1:10], 0) #warmup

    println("$label:")
    for r in 1:3 # three runs
        print("\t")
        GC.gc() #cleaning the garbage before each measurement
        @CPUtime begin
            nmatches = 0
            for i = 1:1000 # one thousand searches per run
                if f(v, i)
                    nmatches += 1
                end
            end
        end
        println("\t\tmatches: $nmatches")
    end
    println()
end

# reads a vector of Ints from a text file
function readvec(filename)
    open(filename, "r") do f
        map(line -> parse(Int, line), eachline(f))
    end
end

# reads a vector of Ints from a text file, but the result is
#   a vector of Any... will hurt performance
function readvec_bad(filename)
	a = [] # this is the problem... it should be `a = Int[]`
    open(filename, "r") do f
        for line in eachline(f)
            push!(a, parse(Int, line))
        end
    end
    a
end

### main ###

function main()
    a = readvec("vec.txt")
    #a = readvec_bad("vec.txt")
    println("$(length(a)) records")

    bench("IN",         in_search,      a)
    bench("FINDFIRST",  ff_search,      a)
    bench("MAPR",       mapr_search,    a)
    bench("VEC",        vec_search,     a)
    bench("FOREACH",    foreach_search, a)
    bench("FOR",        for_search,     a)
end

main()

max_stars_repo_name: dcmoura/blogposts

max_issues_repo_name: dcmoura/blogposts

max_forks_repo_name: dcmoura/blogposts


text:
struct DecPOMDP
    γ  # discount factor
    ℐ  # agents
    𝒮  # state space
    𝒜  # joint action space
    𝒪  # joint observation space
    T  # transition function
    O  # joint observation function
    R  # reward function
end


text:
using SmartShockFinder

datatyp = "NNPPh"
n_dims = 1
η = 0.001                # learning rate
β = 0.0001                # regularization paramater
number_epochs = 100
Sb = 500                 # batch size
L = 10                   # early stopping parameter
hidden_units_1 = 20
hidden_units_2 = 20
hidden_units_3 = 20
hidden_units_4 = 20
hidden_units_5 = 20

traindata = joinpath(@__DIR__, "traindata1dNNPPh.h5")
download("https://gist.github.com/JuliaOd/f4d10153e539c026daf7076f087dc937/raw/traindata1dNNPPh.h5", traindata)
validdata = joinpath(@__DIR__, "validdata1dNNPPh.h5")
download("https://gist.github.com/JuliaOd/f4d10153e539c026daf7076f087dc937/raw/validdata1dNNPPh.h5", validdata)

train_network1d(datatyp, n_dims, η, β, number_epochs, Sb, L,
                hidden_units_1, hidden_units_2, hidden_units_3,
                hidden_units_4, hidden_units_5)


text:
export SpiralTrajectoryVarDens, spiralVarDensNodes, spiralVarDensDensity

"""
    SpiralTrajectoryVarDens(numProfiles, numSamplingPerProfile
                  ; TE::Float64=0.0
                  , AQ::Float64=1.e-3
                  , windings::Real= 6.25
                  , alpha=2.0
                  , angleOffset= :equispaced
                  , kargs...)

returns a 2d spiral trajectory with variable density

# Arguments
* `numProfiles::Int64`            - number of profiles
* `numSamplingPerProfile::Int64`  - number of sampling points per profile
* (`TE::Float64=0.0`)             - echo time in s
* (`AQ::Float64=1.e-3`)           - readout duration in s (per profile)
* (`windings::Real= 6.25`)        - number of windings of the spiral profiles
* (`alpha=2.0`)                   - exponent describing the evolution of the magnitude of the sampling points along the profiles
* (`angleOffset= :equispaced`)    - spacing of profile angles (`:equispaced` sampling, `:golden` angle sampling or `:random` sampling)
"""
function SpiralTrajectoryVarDens(::Type{T}, numProfiles, numSamplingPerProfile
                  ; TE=0.0
                  , AQ=1.e-3
                  , windings::Real= 6.25
                  , alpha::Real=2.0
                  , kmax::Real=0.5
                  , angleOffset::String="equispaced"
                  , kargs...) where T
  nodes = spiralVarDensNodes(T, numProfiles, numSamplingPerProfile; windings=windings,
                             alpha=alpha, angleOffset=angleOffset, kmax=kmax)
  times = readoutTimes(T, numProfiles, numSamplingPerProfile; TE=TE, AQ=AQ)
  return  Trajectory("SpiralVarDens", nodes, times, TE, AQ, numProfiles, numSamplingPerProfile, 1, false, true)
end

# Constructing the amplitude limited case of the variable density spiral Trajectory
function spiralVarDensNodes(::Type{T}, numProfiles::Int64
                        , numSamplingPerProfile::Int64
                        ; windings::Real=6.25
                        , alpha::Real=2.0
                        , kmax::Real=0.5
                        , angleOffset::String= "equispaced" #:equispaced
                        , kargs...) where T

  nodes = zeros(T, 2, numSamplingPerProfile, numProfiles)

  if angleOffset == "golden" #:golden
      angles = [i*(3-sqrt(5))/2  for i=0:numProfiles-1 ]
  elseif angleOffset == "random" #:random
      # angles = sort(rand(numProfiles))
      angles = collect((0:numProfiles-1)/numProfiles)
      Random.seed!(1234)
      angles = angles .+ 1.0/numProfiles*rand(numProfiles)
  elseif angleOffset == "equispaced" #:equispaced
      angles = collect((0:numProfiles-1)/numProfiles)
  end

  times = range(0,stop=1,length=numSamplingPerProfile)
  for l = 1:numProfiles
    for k = 1:numSamplingPerProfile
      tau = (times[k])^(1/(alpha+1))
      nodes[1,k,l] = kmax*tau^alpha*cos(2*pi*( windings*tau + angles[l] ))
      nodes[2,k,l] = kmax*tau^alpha*sin(2*pi*( windings*tau + angles[l] ))
    end
  end
  return reshape(nodes, 2, numSamplingPerProfile*numProfiles)
end

function spiralVarDensDensity(numProfiles::Int64, numSamplingPerProfile::Int64)
  error("Not implemented!")
end


text:
## JL-ML SPGL Comparison
export jl_cs

"""
An example of using implicit JOLI operators to solve a system using GenSPGL

Use: x, r, g, info, SNR = jl_cs()
"""
function jl_cs()
    n = 1024
    k = 200

    # Create a system
    p = randperm(n)
    x0 = zeros(n)
    x0[p[1:k]] = sign.(randn(k))

    # Create a modelling op
    F = joDCT(n)

    # Create a restriction op
    ind = randperm(n)
    ind = ind[1:Int(floor(0.6*n))]
    R = joRestriction(n,ind, DDT = Float64, RDT = Float64)

    # Create data
    b = R*F*x0

    # Solve
    opts = spgOptions(optTol = 1e-4,
                         verbosity = 1)

    @time x, r, g, info = spgl1(R*F, vec(b), tau = 0., sigma = 1e-3, options = opts)

    # Calc SNR of recovery
    SNR = -20*log10(norm(x0-x)/norm(x0));

    return x, r, g, info, SNR
end


text:
using Test
using SmartShockFinder

# Various Tests for the NNPP. Tests are limited to only 1 mesh & polydegree

@time @testset "Test_2d_Networks" begin
    n_dims = 2

    # add mesh and polynomdegrees to then generate Traindata
    coordinates_min = (-1, -1)
    coordinates_max = (1, 1)
    mesh = SmartShockFinder.TreeMesh(coordinates_min, coordinates_max,
                  initial_refinement_level=2,
                  n_cells_max=10_000
                  )
    meshes = [mesh]
    polydeg = [2]

    train_setup = Traindata_Settings(polydeg, meshes)

    # datasets path should be cleared before testing
    path_datsets = joinpath("datasets", "2d")
    rm(path_datsets, recursive=true, force=true)

    @testset "Test2dNNPP" begin

        @test_nowarn mkpath(joinpath("datasets", "2d"))
        @test_nowarn mkpath(joinpath("networks", "2d"))
        network_type = NNPP(n_dims)

        # run test that generates a Train dataset for the NNPP
        @testset "Test_generate_Traindata_2dNNPP" begin
            @test_nowarn generate_traindataset2d(network_type, train_setup)
            @test isfile(joinpath(path_datsets, "traindata2dNNPP.h5"))
        end

        # run test similar to traindata. Now for Validation dataset
        @testset "Test_generate_Validdata_2dNNPP" begin
            @test_nowarn generate_validdataset2d(network_type, train_setup)
            @test isfile(joinpath(path_datsets, "validdata2dNNPP.h5"))
        end

        # now tested the training process with only 2 epochs
        @testset "Test_TrainNetwork_2dNNPP" begin

            # Parameters to train the Net
            η = 0.005                # learning rate
            β = 0.005               # regularization paramater
            number_epochs = 2
            Sb = 500                 # batch size
            L = 10                   # early stopping parameter
            hidden_units = [32, 16, 16, 8, 8]

            model_setup = Model_Settings(η, β, number_epochs, Sb, L, hidden_units)

            @test_nowarn train_network(network_type, model_setup)
            @test_nowarn length(readdir(joinpath("networks", "2d"))) > 0
            @test_nowarn rm(joinpath("networks", "2d"), recursive=true, force=true)
            @test_nowarn rm(joinpath("datasets", "2d"), recursive=true, force=true)
        end
    end

    @testset "Test2dNNRH" begin

        @test_nowarn mkpath(joinpath("datasets", "2d"))
        @test_nowarn mkpath(joinpath("networks", "2d"))
        network_type = NNRH(n_dims)

        # run test that generates a Train dataset for the NNRH
        @testset "Test_generate_Traindata_2dNNRH" begin
            @test_nowarn generate_traindataset2d(network_type, train_setup)
            @test isfile(joinpath("datasets", "2d", "traindata2dNNRH.h5"))
        end

        # run test similar to traindata. Now for Validation dataset
        @testset "Test_generate_Validdata_2dNNRH" begin
            @test_nowarn generate_validdataset2d(network_type, train_setup)
            @test isfile(joinpath("datasets", "2d", "validdata2dNNRH.h5"))
        end

        # now tested the training process with only 2 epochs
        @testset "Test_TrainNetwork_2dNNRH" begin

            # Parameters to train the Net
            η = 0.002             # learning rate
            β = 0.009             # regularization paramater
            number_epochs = 2
            Sb = 500                 # batch size
            L = 10                   # early stopping parameter
            hidden_units = [10, 10, 10, 10, 10]

            model_setup = Model_Settings(η, β, number_epochs, Sb, L, hidden_units)

            @test_nowarn train_network(network_type, model_setup)
            @test_nowarn length(readdir(joinpath("networks", "2d"))) > 0
            @test_nowarn rm(joinpath("networks", "2d"), recursive=true, force=true)
            @test_nowarn rm(joinpath("datasets", "2d"), recursive=true, force=true)
        end
    end

    @testset "Test2dCNN" begin

        @test_nowarn mkpath(joinpath("datasets", "2d"))
        @test_nowarn mkpath(joinpath("networks", "2d"))
        network_type = CNN(n_dims)

        # run test that generates a Train dataset for the CNN
        @testset "Test_generate_Traindata_2dCNN" begin
            @test_nowarn generate_traindataset2d(network_type, train_setup)
            @test isfile(joinpath("datasets", "2d", "traindata2dCNN.h5"))
        end

        # run test similar to traindata. Now for Validation dataset
        @testset "Test_generate_Validdata_2dCNN" begin
            @test_nowarn generate_validdataset2d(network_type, train_setup)
            @test isfile(joinpath("datasets", "2d", "validdata2dCNN.h5"))
        end

        # now tested the training process with only 2 epochs
        @testset "Test_TrainNetwork_2dNNCNN" begin

            # Parameters to train the Net
            η = 0.001               # learning rate
            β = 0.001                # regularization paramater
            number_epochs = 2
            Sb = 500                 # batch size
            L = 10                   # early stopping parameter
            hidden_units = []

            model_setup = Model_Settings(η, β, number_epochs, Sb, L, hidden_units)

            @test_nowarn train_network2dcnn(network_type, model_setup)
            @test_nowarn length(readdir(joinpath("networks", "2d"))) > 0
            @test_nowarn rm(joinpath("networks", "2d"), recursive=true, force=true)
            @test_nowarn rm(joinpath("datasets", "2d"), recursive=true, force=true)
        end
    end
end


text:
function TargetPointing(arg0::Frame, arg1::Frame, arg2::Vector3D)
    return TargetPointing((Frame, Frame, Vector3D), arg0, arg1, arg2)
end

function TargetPointing(arg0::Frame, arg1::GeodeticPoint, arg2::BodyShape)
    return TargetPointing((Frame, GeodeticPoint, BodyShape), arg0, arg1, arg2)
end

function get_target_pv(obj::TargetPointing, arg0::FieldPVCoordinatesProvider, arg1::FieldAbsoluteDate, arg2::Frame)
    return jcall(obj, "getTargetPV", TimeStampedFieldPVCoordinates, (FieldPVCoordinatesProvider, FieldAbsoluteDate, Frame), arg0, arg1, arg2)
end

function get_target_pv(obj::TargetPointing, arg0::PVCoordinatesProvider, arg1::AbsoluteDate, arg2::Frame)
    return jcall(obj, "getTargetPV", TimeStampedPVCoordinates, (PVCoordinatesProvider, AbsoluteDate, Frame), arg0, arg1, arg2)
end


text:
#
# Calculates requests per second from client to server without response
# Results: rps: 4553.17424843039, time: 219.6269998550415
#
include("../../src/global/ImportFolders.jl")

import Config
import Server
import Connection
import Event

function onBeforeResponse(sock::Base.TCPSocket, cmd::Connection.Command, ans::Connection.Answer)
  for i=1:1000000 Server.request(sock, 1) end
end

con = Server.create(ip"127.0.0.1", Config.val(:conServerPort))
Event.on(con.observer, Connection.EVENT_BEFORE_RESPONSE, onBeforeResponse)
Server.run(con)

max_stars_repo_name: tmptrash/jevo

max_issues_repo_name: tmptrash/jevo

max_forks_repo_name: tmptrash/jevo


text:
@testset "compacctable.jl" begin
    @testset "cleanTable(variables::Vector{<:AbstractIntVar}, table::Matrix{Int})::Matrix{Int}" begin
        trailer = SeaPearl.Trailer()
        x = SeaPearl.IntVar(1, 3, "x", trailer)
        y = SeaPearl.IntVar(2, 3, "y", trailer)
        z = SeaPearl.IntVar(2, 3, "Z", trailer)
        vec = Vector{SeaPearl.AbstractIntVar}([x, y, z])
        table = [
            1 2 2;
            3 3 3;
            1 2 3
        ]
        res = SeaPearl.cleanTable(vec, table)
        @test all(res .== [2 2; 3 3; 2 3])
    end
    @testset "buildSupport(variables::Vector{<:AbstractIntVar}, table::Matrix{Int})::Dict{Pair{Int,Int},BitVector}" begin
        trailer = SeaPearl.Trailer()
        x = SeaPearl.IntVar(1, 3, "x", trailer)
        y = SeaPearl.IntVar(2, 3, "y", trailer)
        z = SeaPearl.IntVar(2, 3, "Z", trailer)
        vec = Vector{SeaPearl.AbstractIntVar}([x, y, z])
        table = [
            1 2 2;
            3 3 3;
            1 2 3
        ]
        table = SeaPearl.cleanTable(vec, table)
        support = SeaPearl.buildSupport(vec, table)
        @test support[2 => 3] == [1,1]
        @test support[1 => 1] == [0,0]
    end
    @testset "cleanSupports!(supports::Dict{Pair{Int,Int},BitVector}, variables::Vector{<:AbstractIntVar})::Nothing" begin
        trailer = SeaPearl.Trailer()
        x = SeaPearl.IntVar(1, 3, "x", trailer)
        y = SeaPearl.IntVar(2, 3, "y", trailer)
        z = SeaPearl.IntVar(2, 3, "Z", trailer)
        vec = [x, y, z]
        table = [
            1 2 2;
            3 3 3;
            1 2 3
        ]
        table = SeaPearl.cleanTable(vec, table)
        support = SeaPearl.buildSupport(vec,table)
        @test all([(i => j) in keys(support) for i = 1:3, j = 2:3])
        @test (1 => 1) in keys(support)
        SeaPearl.cleanSupports!(support, vec)
        @test !((1 => 1) in keys(support))
        @test !((1 => 3) in keys(support))
        @test !((2 => 2) in keys(support))
        @test !((3 => 1) in keys(support))
        @test length(keys(support)) == 4
    end
    @testset "TableConstraint(variables::Vector{<:AbstractIntVar}, table::Matrix{Int}, supports::Dict{Pair{Int,Int},BitVector}, trailer)" begin
        trailer = SeaPearl.Trailer()
        x = SeaPearl.IntVar(1, 3, "x", trailer)
        y = SeaPearl.IntVar(1, 3, "y", trailer)
        z = SeaPearl.IntVar(1, 3, "Z", trailer)
        vec1 = [x, y, z]
        vec2 = [z, y, x]
        table = [
            1 2 2;
            3 3 3;
            1 2 3
        ]
        supports = SeaPearl.buildSupport(vec1, table)
        SeaPearl.cleanSupports!(supports, vec1)
        table = SeaPearl.cleanTable(vec1, table)
        constraint1 = SeaPearl.TableConstraint(vec1, table, supports, trailer)
        constraint2 = SeaPearl.TableConstraint(vec2, table, supports, trailer)
        @test size(constraint1.table, 2)==3
        @test size(constraint2.table, 2)==3
        @test (constraint1.supports[3=>2] == [0,1,0])
        @test (constraint2.supports[3=>2] == [0,1,0])
        @test(isempty(constraint1.modifiedVariables))
        @test(isempty(constraint2.modifiedVariables))
        @test(constraint1.residues[3=>2]==1)
        @test(constraint2.residues[3=>2]==1)
    end
    @testset "TableConstraint(variables::Vector{<:AbstractIntVar}, table::Matrix{Int}, trailer)" begin
        trailer = SeaPearl.Trailer()
        x = SeaPearl.IntVar(1, 3, "x", trailer)
        y = SeaPearl.IntVar(2, 3, "y", trailer)
        z = SeaPearl.IntVar(2, 3, "Z", trailer)
        vec = [x, y, z]
        table = [
            1 2 2;
            3 3 3;
            1 2 3
        ]
        constraint = SeaPearl.TableConstraint(vec, table, trailer)
        @test size(constraint.table, 2)==2
        @test (constraint.supports[3=>2] == [1,0])
        @test(isempty(constraint.modifiedVariables))
        @test(constraint.residues[3=>2]==1)
    end
    @testset "propagate!(constraint::TableConstraint, toPropagate::Set{Constraint}, prunedDomains::CPModification)" begin
        trailer = SeaPearl.Trailer()
        x = SeaPearl.IntVar(1, 3, "x", trailer)
        y = SeaPearl.IntVar(2, 3, "y", trailer)
        z = SeaPearl.IntVar(2, 3, "z", trailer)
        a = SeaPearl.IntVar(2, 4, "a", trailer)
        SeaPearl.remove!(a.domain, 3)
        b = SeaPearl.IntVar(3, 6, "b", trailer)
        c = SeaPearl.IntVar(5, 7, "c", trailer)

        table = [
            1 2 2;
            3 3 3;
            1 2 3;
            2 5 4;
            3 7 6;
            5 7 7
        ]
        vec = [x, y, z, a, b, c]
        table = SeaPearl.cleanTable(vec,table)

        constraint = SeaPearl.TableConstraint(vec, table, trailer)

        toPropagate = Set{SeaPearl.Constraint}([constraint])
        modif = SeaPearl.CPModification()
        res = SeaPearl.propagate!(constraint, toPropagate, modif)

        @test !(constraint in toPropagate)

        @test length(x.domain) == 1
        @test length(y.domain) == 1
        @test length(z.domain) == 1
        @test length(a.domain) == 1
        @test length(b.domain) == 1
        @test length(c.domain) == 1
        @test 2 in x.domain
        @test 3 in y.domain
        @test 3 in z.domain
        @test 4 in a.domain
        @test 6 in b.domain
        @test 7 in c.domain
    end

    @testset "compactTable fullPropagation" begin
        trailer = SeaPearl.Trailer()
        model = SeaPearl.CPModel(trailer)

        x = SeaPearl.IntVar(1, 3, "x", trailer)
        y = SeaPearl.IntVar(1, 3, "y", trailer)
        z = SeaPearl.IntVar(1, 3, "z", trailer)
        a = SeaPearl.IntVar(1, 3, "a", trailer)
        b = SeaPearl.IntVar(1, 3, "b", trailer)
        c = SeaPearl.IntVar(1, 3, "c", trailer)

        SeaPearl.addVariable!(model, x)
        SeaPearl.addVariable!(model, y)
        SeaPearl.addVariable!(model, z)
        SeaPearl.addVariable!(model, a)
        SeaPearl.addVariable!(model, b)
        SeaPearl.addVariable!(model, c)
        table1 = [
            1 2 3 1 2 3;
            1 1 2 2 3 3;
            1 1 1 3 3 3;
            3 2 1 3 2 1
        ]
        table2 = [
            1 2 3;
            1 2 3;
            1 2 3
        ]

        constraint1 = SeaPearl.TableConstraint([x, y, z, a], table1, trailer)
        constraint2 = SeaPearl.TableConstraint([a, b, c], table2, trailer)

        SeaPearl.addConstraint!(model, constraint1)
        SeaPearl.addConstraint!(model, constraint2)

        variableSelection = SeaPearl.MinDomainVariableSelection{false}()
        SeaPearl.solve!(model; variableHeuristic=variableSelection)

        @test length(model.statistics.solutions) == 6
        @test Dict("c" => 2, "x" => 2, "b" => 2, "z" => 3, "a" => 2, "y" => 3) in model.statistics.solutions
        @test Dict("c" => 1, "x" => 3, "b" => 1, "z" => 3, "a" => 1, "y" => 3) in model.statistics.solutions
        @test Dict("c" => 3, "x" => 1, "b" => 3, "z" => 3, "a" => 3, "y" => 2) in model.statistics.solutions
        @test Dict("c" => 1, "x" => 3, "b" => 1, "z" => 1, "a" => 1, "y" => 2) in model.statistics.solutions
        @test Dict("c" => 3, "x" => 1, "b" => 3, "z" => 1, "a" => 3, "y" => 1) in model.statistics.solutions
        @test Dict("c" => 2, "x" => 2, "b" => 2, "z" => 1, "a" => 2, "y" => 1) in model.statistics.solutions
    end
end


text:
# f(x,y)=x'+y'

FXtransposePYtranspose(x::Float64,y::Float64)=Fxpy(x,y)
FXtransposePYtranspose(x::Float64,y)=Fxpy(x,y')

FXtransposePYtranspose(x,y::Float64)=Fxpy(x,y')

FXtransposePYtranspose(x::Array,y::Array)=Fxpy(x',y')

FXtransposePYtranspose_inplace(value,auxvalue,x::Array,y::Array)=Fxpy_inplace(value,auxvalue,x',y')

function DXtransposePYtranspose(derivativeIDX,f_c,faux_c,grad_c,grad_n,x::Array,y::Array)
    if size(x)==(1,1) && derivativeIDX==1
        axpy!(1.0,[sum(grad_c)],grad_n)
    elseif size(y)==(1,1) && derivativeIDX==2
        axpy!(1.0,[sum(grad_c)],grad_n)
    else
        axpy!(1.0,grad_c',grad_n)
    end
end

if PROC=="GPU"
    function FXtransposePYtranspose_inplace(value,auxvalue,x::CudaArray,y::CudaArray)
        if size(x)==(1,1)
            FXPYtranspose_inplace(value,auxvalue,x::CudaArray,y::CudaArray)
        elseif size(y)==(1,1)
            FXtransposePY_inplace(value,auxvalue,x::CudaArray,y::CudaArray)
        else
            CUBLAS.geam!('T','T',1.0,x,1.0,y,value)
        end
    end

    function DXtransposePYtranspose(derivativeIDX,f_c,faux_c,grad_c,grad_n,x::CudaArray,y::CudaArray)
        if derivativeIDX==1
            DXtransposePY(derivativeIDX,f_c,faux_c,grad_c,grad_n,x::CudaArray,y::CudaArray)
        elseif derivativeIDX==2
            DXPYtranspose(derivativeIDX,f_c,faux_c,grad_c,grad_n,x::CudaArray,y::CudaArray)
        end
    end

end

Derivative[FXtransposePYtranspose]=DXtransposePYtranspose
Inplace[FXtransposePYtranspose]=FXtransposePYtranspose_inplace

export FXtransposePYtranspose

max_stars_repo_name: davidbarber/AutoDiff

max_issues_repo_name: davidbarber/AutoDiff

max_forks_repo_name: davidbarber/AutoDiff


text:
x0 = 0
x1 = 1
nx = 5

KitBase.linspace(x0, x1, nx)
KitBase.heaviside(x0)
KitBase.fortsign(x0, x1)

KitBase.mat_split(randn(2, 2))
KitBase.mat_split(randn(3, 3))

KB.convergence_order(1e-2, 1e-3)
KB.L1_error(rand(3), rand(3), 1e-2)
KB.L2_error(rand(3), rand(3), 1e-2)
KB.L∞_error(rand(3), rand(3), 1e-2)

u = Float64[0, 1, 2, 3, 2, 1, 0]
dx = 1.0
KitBase.finite_difference(u, dx; method = :central, bc = :period)
KitBase.finite_difference(u, dx; method = :central, bc = :none)
KitBase.finite_difference(u, dx, -1; method = :upwind, bc = :none)

x = randn(16)
y = randn(16)
KitBase.@nametuple x y # NamedTuple constructor
KitBase.central_diff(y, x)
KitBase.central_diff(y, x0)
KitBase.central_diff2(y, x)
KitBase.central_diff2(y, x0)

res = similar(x)
KitBase.central_diff!(res, y, x)
KitBase.central_diff!(res, y, x0)
KitBase.central_diff2!(res, y, x)
KitBase.central_diff2!(res, y, x0)

KitBase.upwind_diff(y, x; stream = :right)
KitBase.upwind_diff(y, x; stream = :left)
KitBase.upwind_diff(y, x0)

KitBase.upwind_diff!(res, y, x)
KitBase.upwind_diff!(res, y, x0)

KitBase.unstruct_diff(y, x, 4; mode = :central)
KitBase.unstruct_diff(y, x, 4; mode = :upwind)
KitBase.unstruct_diff(sin, randn(12), 4, 1)
KitBase.unstruct_diff(sin, randn(12), 4, 2)

KitBase.lgwt(12, -1, 1)

KitBase.extract_last(randn(2, 3), 2; mode = :view)
KitBase.extract_last(randn(2, 3), 2; mode = :copy)

#--- entropy closure ---#
KitBase.maxwell_boltzmann(rand())
KitBase.maxwell_boltzmann_prime(rand())
KitBase.maxwell_boltzmann_dual(rand())
KitBase.maxwell_boltzmann_dual_prime(rand())

quadratureorder = 2
points, triangulation = KitBase.octa_quadrature(quadratureorder)
weights = KitBase.quadrature_weights(points, triangulation)
nq = size(points, 1)
L = 1
ne = (L + 1)^2

α = zeros(ne)
u = [2.0, 0.0, 0.0, 0.0]
m = KitBase.eval_spherharmonic(points, L)

KitBase.eval_sphermonomial(rand(6), L)
KitBase.eval_sphermonomial(points, L)

KitBase.kinetic_entropy(α, m, weights)

using KitBase.TypedPolynomials
@polyvar _x _y _z
KitBase.rlylm(2, 2, _x, _y, _z)

res = KitBase.optimize_closure(α, m, weights, u, KitBase.maxwell_boltzmann_dual)
u1 = KitBase.realizable_reconstruct(
    res.minimizer,
    m,
    weights,
    KitBase.maxwell_boltzmann_dual_prime,
)


text:
using JSON

export writejson, readjson

function writejson(filename::AbstractString, ne::Union{NestedEinsum, SlicedEinsum})
    if ne isa NestedEinsum
        dict = _todict(ne)
    else
        dict = _todict(ne.eins)
        dict["slices"] = ne.slicing.legs
    end
    open(filename, "w") do f
        JSON.print(f, dict, 0)
    end
end
function _todict(ne::NestedEinsum)
    LT = labeltype(ne)
    dict = Dict{String,Any}("label-type"=>LT, "inputs"=>getixsv(ne), "output"=>getiyv(ne))
    dict["tree"] = todict(ne)
    return dict
end
function readjson(filename::AbstractString)
    dict = JSON.parsefile(filename)
    lt = dict["label-type"]
    LT = if lt == "Char"
        Char
    elseif lt ∈ ("Int64", "Int", "Int32")
        Int
    else
        error("label type `$lt` not known.")
    end
    ne = fromdict(LT, dict["tree"])
    if haskey(dict, "slices")
        return SlicedEinsum(Slicing(_convert.(LT, dict["slices"])), ne)
    else
        return ne
    end
end

function todict(ne::NestedEinsum)
    dict = Dict{String,Any}()
    if OMEinsum.isleaf(ne)
        dict["isleaf"] = true
        dict["tensorindex"] = ne.tensorindex
        return dict
    end
    dict["args"] = collect(todict.(ne.args))
    dict["eins"] = einstodict(ne.eins)
    dict["isleaf"] = false
    return dict
end
function einstodict(eins::EinCode)
    ixs = getixsv(eins)
    iy = getiyv(eins)
    return Dict("ixs"=>ixs, "iy"=>iy)
end

function fromdict(::Type{LT}, dict::Dict) where LT
    if dict["isleaf"]
        return NestedEinsum{DynamicEinCode{LT}}(dict["tensorindex"])
    end
    eins = einsfromdict(LT, dict["eins"])
    return NestedEinsum(fromdict.(LT, dict["args"]), eins)
end

function einsfromdict(::Type{LT}, dict::Dict) where LT
    return EinCode([collect(LT, _convert.(LT, ix)) for ix in dict["ixs"]], collect(LT, _convert.(LT, dict["iy"])))
end

_convert(::Type{LT}, x) where LT = convert(LT, x)
_convert(::Type{Char}, x::String) where LT = (@assert length(x)==1; x[1])