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

"""
    associate_assessment_report_evidence_folder(assessment_id, evidence_folder_id)
    associate_assessment_report_evidence_folder(assessment_id, evidence_folder_id, params::Dict{String,<:Any})

 Associates an evidence folder to the specified assessment report in Audit Manager.

# Arguments
- `assessment_id`:  The identifier for the specified assessment.
- `evidence_folder_id`:  The identifier for the folder in which evidence is stored.

"""
function associate_assessment_report_evidence_folder(
    assessmentId, evidenceFolderId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "PUT",
        "/assessments/$(assessmentId)/associateToAssessmentReport",
        Dict{String,Any}("evidenceFolderId" => evidenceFolderId);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function associate_assessment_report_evidence_folder(
    assessmentId,
    evidenceFolderId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "PUT",
        "/assessments/$(assessmentId)/associateToAssessmentReport",
        Dict{String,Any}(
            mergewith(
                _merge, Dict{String,Any}("evidenceFolderId" => evidenceFolderId), params
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    batch_associate_assessment_report_evidence(assessment_id, evidence_folder_id, evidence_ids)
    batch_associate_assessment_report_evidence(assessment_id, evidence_folder_id, evidence_ids, params::Dict{String,<:Any})

 Associates a list of evidence to an assessment report in an Audit Manager assessment.

# Arguments
- `assessment_id`:  The unique identifier for the specified assessment.
- `evidence_folder_id`:  The identifier for the folder in which the evidence is stored.
- `evidence_ids`:  The list of evidence identifiers.

"""
function batch_associate_assessment_report_evidence(
    assessmentId,
    evidenceFolderId,
    evidenceIds;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "PUT",
        "/assessments/$(assessmentId)/batchAssociateToAssessmentReport",
        Dict{String,Any}(
            "evidenceFolderId" => evidenceFolderId, "evidenceIds" => evidenceIds
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function batch_associate_assessment_report_evidence(
    assessmentId,
    evidenceFolderId,
    evidenceIds,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "PUT",
        "/assessments/$(assessmentId)/batchAssociateToAssessmentReport",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "evidenceFolderId" => evidenceFolderId, "evidenceIds" => evidenceIds
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    batch_create_delegation_by_assessment(assessment_id, create_delegation_requests)
    batch_create_delegation_by_assessment(assessment_id, create_delegation_requests, params::Dict{String,<:Any})

 Create a batch of delegations for a specified assessment in Audit Manager.

# Arguments
- `assessment_id`:  The identifier for the specified assessment.
- `create_delegation_requests`:  The API request to batch create delegations in Audit
  Manager.

"""
function batch_create_delegation_by_assessment(
    assessmentId,
    createDelegationRequests;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "POST",
        "/assessments/$(assessmentId)/delegations",
        Dict{String,Any}("createDelegationRequests" => createDelegationRequests);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function batch_create_delegation_by_assessment(
    assessmentId,
    createDelegationRequests,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "POST",
        "/assessments/$(assessmentId)/delegations",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}("createDelegationRequests" => createDelegationRequests),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    batch_delete_delegation_by_assessment(assessment_id, delegation_ids)
    batch_delete_delegation_by_assessment(assessment_id, delegation_ids, params::Dict{String,<:Any})

 Deletes the delegations in the specified Audit Manager assessment.

# Arguments
- `assessment_id`:  The identifier for the specified assessment.
- `delegation_ids`:  The identifiers for the specified delegations.

"""
function batch_delete_delegation_by_assessment(
    assessmentId, delegationIds; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "PUT",
        "/assessments/$(assessmentId)/delegations",
        Dict{String,Any}("delegationIds" => delegationIds);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function batch_delete_delegation_by_assessment(
    assessmentId,
    delegationIds,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "PUT",
        "/assessments/$(assessmentId)/delegations",
        Dict{String,Any}(
            mergewith(_merge, Dict{String,Any}("delegationIds" => delegationIds), params)
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    batch_disassociate_assessment_report_evidence(assessment_id, evidence_folder_id, evidence_ids)
    batch_disassociate_assessment_report_evidence(assessment_id, evidence_folder_id, evidence_ids, params::Dict{String,<:Any})

 Disassociates a list of evidence from the specified assessment report in Audit Manager.

# Arguments
- `assessment_id`:  The identifier for the specified assessment.
- `evidence_folder_id`:  The identifier for the folder in which evidence is stored.
- `evidence_ids`:  The list of evidence identifiers.

"""
function batch_disassociate_assessment_report_evidence(
    assessmentId,
    evidenceFolderId,
    evidenceIds;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "PUT",
        "/assessments/$(assessmentId)/batchDisassociateFromAssessmentReport",
        Dict{String,Any}(
            "evidenceFolderId" => evidenceFolderId, "evidenceIds" => evidenceIds
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function batch_disassociate_assessment_report_evidence(
    assessmentId,
    evidenceFolderId,
    evidenceIds,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "PUT",
        "/assessments/$(assessmentId)/batchDisassociateFromAssessmentReport",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "evidenceFolderId" => evidenceFolderId, "evidenceIds" => evidenceIds
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    batch_import_evidence_to_assessment_control(assessment_id, control_id, control_set_id, manual_evidence)
    batch_import_evidence_to_assessment_control(assessment_id, control_id, control_set_id, manual_evidence, params::Dict{String,<:Any})

 Uploads one or more pieces of evidence to the specified control in the assessment in Audit
Manager.

# Arguments
- `assessment_id`:  The identifier for the specified assessment.
- `control_id`:  The identifier for the specified control.
- `control_set_id`:  The identifier for the specified control set.
- `manual_evidence`:  The list of manual evidence objects.

"""
function batch_import_evidence_to_assessment_control(
    assessmentId,
    controlId,
    controlSetId,
    manualEvidence;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "POST",
        "/assessments/$(assessmentId)/controlSets/$(controlSetId)/controls/$(controlId)/evidence",
        Dict{String,Any}("manualEvidence" => manualEvidence);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function batch_import_evidence_to_assessment_control(
    assessmentId,
    controlId,
    controlSetId,
    manualEvidence,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "POST",
        "/assessments/$(assessmentId)/controlSets/$(controlSetId)/controls/$(controlId)/evidence",
        Dict{String,Any}(
            mergewith(_merge, Dict{String,Any}("manualEvidence" => manualEvidence), params)
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    create_assessment(assessment_reports_destination, framework_id, name, roles, scope)
    create_assessment(assessment_reports_destination, framework_id, name, roles, scope, params::Dict{String,<:Any})

 Creates an assessment in Audit Manager.

# Arguments
- `assessment_reports_destination`:  The assessment report storage destination for the
  specified assessment that is being created.
- `framework_id`:  The identifier for the specified framework.
- `name`:  The name of the assessment to be created.
- `roles`:  The list of roles for the specified assessment.
- `scope`:

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"description"`:  The optional description of the assessment to be created.
- `"tags"`:  The tags associated with the assessment.
"""
function create_assessment(
    assessmentReportsDestination,
    frameworkId,
    name,
    roles,
    scope;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "POST",
        "/assessments",
        Dict{String,Any}(
            "assessmentReportsDestination" => assessmentReportsDestination,
            "frameworkId" => frameworkId,
            "name" => name,
            "roles" => roles,
            "scope" => scope,
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function create_assessment(
    assessmentReportsDestination,
    frameworkId,
    name,
    roles,
    scope,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "POST",
        "/assessments",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "assessmentReportsDestination" => assessmentReportsDestination,
                    "frameworkId" => frameworkId,
                    "name" => name,
                    "roles" => roles,
                    "scope" => scope,
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    create_assessment_framework(control_sets, name)
    create_assessment_framework(control_sets, name, params::Dict{String,<:Any})

 Creates a custom framework in Audit Manager.

# Arguments
- `control_sets`:  The control sets to be associated with the framework.
- `name`:  The name of the new custom framework.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"complianceType"`:  The compliance type that the new custom framework supports, such as
  CIS or HIPAA.
- `"description"`:  An optional description for the new custom framework.
- `"tags"`:  The tags associated with the framework.
"""
function create_assessment_framework(
    controlSets, name; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "POST",
        "/assessmentFrameworks",
        Dict{String,Any}("controlSets" => controlSets, "name" => name);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function create_assessment_framework(
    controlSets,
    name,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "POST",
        "/assessmentFrameworks",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}("controlSets" => controlSets, "name" => name),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    create_assessment_report(assessment_id, name)
    create_assessment_report(assessment_id, name, params::Dict{String,<:Any})

 Creates an assessment report for the specified assessment.

# Arguments
- `assessment_id`:  The identifier for the specified assessment.
- `name`:  The name of the new assessment report.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"description"`:  The description of the assessment report.
"""
function create_assessment_report(
    assessmentId, name; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "POST",
        "/assessments/$(assessmentId)/reports",
        Dict{String,Any}("name" => name);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function create_assessment_report(
    assessmentId,
    name,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "POST",
        "/assessments/$(assessmentId)/reports",
        Dict{String,Any}(mergewith(_merge, Dict{String,Any}("name" => name), params));
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    create_control(control_mapping_sources, name)
    create_control(control_mapping_sources, name, params::Dict{String,<:Any})

 Creates a new custom control in Audit Manager.

# Arguments
- `control_mapping_sources`:  The data mapping sources for the specified control.
- `name`:  The name of the control.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"actionPlanInstructions"`:  The recommended actions to carry out if the control is not
  fulfilled.
- `"actionPlanTitle"`:  The title of the action plan for remediating the control.
- `"description"`:  The description of the control.
- `"tags"`:  The tags associated with the control.
- `"testingInformation"`:  The steps to follow to determine if the control has been
  satisfied.
"""
function create_control(
    controlMappingSources, name; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "POST",
        "/controls",
        Dict{String,Any}("controlMappingSources" => controlMappingSources, "name" => name);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function create_control(
    controlMappingSources,
    name,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "POST",
        "/controls",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "controlMappingSources" => controlMappingSources, "name" => name
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Deletes an assessment in Audit Manager.

# Arguments
- `assessment_id`:  The identifier for the specified assessment.

"""
function delete_assessment(assessmentId; aws_config::AbstractAWSConfig=global_aws_config())
    return auditmanager(
        "DELETE",
        "/assessments/$(assessmentId)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function delete_assessment(
    assessmentId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "DELETE",
        "/assessments/$(assessmentId)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Deletes a custom framework in Audit Manager.

# Arguments
- `framework_id`:  The identifier for the specified framework.

"""
function delete_assessment_framework(
    frameworkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "DELETE",
        "/assessmentFrameworks/$(frameworkId)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function delete_assessment_framework(
    frameworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "DELETE",
        "/assessmentFrameworks/$(frameworkId)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    delete_assessment_report(assessment_id, assessment_report_id)
    delete_assessment_report(assessment_id, assessment_report_id, params::Dict{String,<:Any})

 Deletes an assessment report from an assessment in Audit Manager.

# Arguments
- `assessment_id`:  The identifier for the specified assessment.
- `assessment_report_id`:  The unique identifier for the assessment report.

"""
function delete_assessment_report(
    assessmentId, assessmentReportId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "DELETE",
        "/assessments/$(assessmentId)/reports/$(assessmentReportId)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function delete_assessment_report(
    assessmentId,
    assessmentReportId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "DELETE",
        "/assessments/$(assessmentId)/reports/$(assessmentReportId)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Deletes a custom control in Audit Manager.

# Arguments
- `control_id`:  The identifier for the specified control.

"""
function delete_control(controlId; aws_config::AbstractAWSConfig=global_aws_config())
    return auditmanager(
        "DELETE",
        "/controls/$(controlId)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function delete_control(
    controlId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "DELETE",
        "/controls/$(controlId)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Deregisters an account in Audit Manager.

"""
function deregister_account(; aws_config::AbstractAWSConfig=global_aws_config())
    return auditmanager(
        "POST",
        "/account/deregisterAccount";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function deregister_account(
    params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "POST",
        "/account/deregisterAccount",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Removes the specified member account as a delegated administrator for Audit Manager.   When
you remove a delegated administrator from your Audit Manager settings, or when you
deregister a delegated administrator from Organizations, you continue to have access to the
evidence that you previously collected under that account. However, Audit Manager will stop
collecting and attaching evidence to that delegated administrator account moving forward.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"adminAccountId"`:  The identifier for the specified administrator account.
"""
function deregister_organization_admin_account(;
    aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "POST",
        "/account/deregisterOrganizationAdminAccount";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function deregister_organization_admin_account(
    params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "POST",
        "/account/deregisterOrganizationAdminAccount",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    disassociate_assessment_report_evidence_folder(assessment_id, evidence_folder_id)
    disassociate_assessment_report_evidence_folder(assessment_id, evidence_folder_id, params::Dict{String,<:Any})

 Disassociates an evidence folder from the specified assessment report in Audit Manager.

# Arguments
- `assessment_id`:  The identifier for the specified assessment.
- `evidence_folder_id`:  The identifier for the folder in which evidence is stored.

"""
function disassociate_assessment_report_evidence_folder(
    assessmentId, evidenceFolderId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "PUT",
        "/assessments/$(assessmentId)/disassociateFromAssessmentReport",
        Dict{String,Any}("evidenceFolderId" => evidenceFolderId);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function disassociate_assessment_report_evidence_folder(
    assessmentId,
    evidenceFolderId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "PUT",
        "/assessments/$(assessmentId)/disassociateFromAssessmentReport",
        Dict{String,Any}(
            mergewith(
                _merge, Dict{String,Any}("evidenceFolderId" => evidenceFolderId), params
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Returns the registration status of an account in Audit Manager.

"""
function get_account_status(; aws_config::AbstractAWSConfig=global_aws_config())
    return auditmanager(
        "GET", "/account/status"; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end
function get_account_status(
    params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "GET",
        "/account/status",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Returns an assessment from Audit Manager.

# Arguments
- `assessment_id`:  The identifier for the specified assessment.

"""
function get_assessment(assessmentId; aws_config::AbstractAWSConfig=global_aws_config())
    return auditmanager(
        "GET",
        "/assessments/$(assessmentId)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_assessment(
    assessmentId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "GET",
        "/assessments/$(assessmentId)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Returns a framework from Audit Manager.

# Arguments
- `framework_id`:  The identifier for the specified framework.

"""
function get_assessment_framework(
    frameworkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "GET",
        "/assessmentFrameworks/$(frameworkId)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_assessment_framework(
    frameworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "GET",
        "/assessmentFrameworks/$(frameworkId)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    get_assessment_report_url(assessment_id, assessment_report_id)
    get_assessment_report_url(assessment_id, assessment_report_id, params::Dict{String,<:Any})

 Returns the URL of a specified assessment report in Audit Manager.

# Arguments
- `assessment_id`:  The identifier for the specified assessment.
- `assessment_report_id`:  The identifier for the assessment report.

"""
function get_assessment_report_url(
    assessmentId, assessmentReportId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "GET",
        "/assessments/$(assessmentId)/reports/$(assessmentReportId)/url";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_assessment_report_url(
    assessmentId,
    assessmentReportId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "GET",
        "/assessments/$(assessmentId)/reports/$(assessmentReportId)/url",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Returns a list of changelogs from Audit Manager.

# Arguments
- `assessment_id`:  The identifier for the specified assessment.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"controlId"`:  The identifier for the specified control.
- `"controlSetId"`:  The identifier for the specified control set.
- `"maxResults"`:  Represents the maximum number of results per page, or per API request
  call.
- `"nextToken"`:  The pagination token used to fetch the next set of results.
"""
function get_change_logs(assessmentId; aws_config::AbstractAWSConfig=global_aws_config())
    return auditmanager(
        "GET",
        "/assessments/$(assessmentId)/changelogs";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_change_logs(
    assessmentId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "GET",
        "/assessments/$(assessmentId)/changelogs",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Returns a control from Audit Manager.

# Arguments
- `control_id`:  The identifier for the specified control.

"""
function get_control(controlId; aws_config::AbstractAWSConfig=global_aws_config())
    return auditmanager(
        "GET",
        "/controls/$(controlId)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_control(
    controlId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "GET",
        "/controls/$(controlId)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Returns a list of delegations from an audit owner to a delegate.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"maxResults"`:  Represents the maximum number of results per page, or per API request
  call.
- `"nextToken"`:  The pagination token used to fetch the next set of results.
"""
function get_delegations(; aws_config::AbstractAWSConfig=global_aws_config())
    return auditmanager(
        "GET", "/delegations"; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end
function get_delegations(
    params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "GET",
        "/delegations",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    get_evidence(assessment_id, control_set_id, evidence_folder_id, evidence_id)
    get_evidence(assessment_id, control_set_id, evidence_folder_id, evidence_id, params::Dict{String,<:Any})

 Returns evidence from Audit Manager.

# Arguments
- `assessment_id`:  The identifier for the specified assessment.
- `control_set_id`:  The identifier for the specified control set.
- `evidence_folder_id`:  The identifier for the folder in which the evidence is stored.
- `evidence_id`:  The identifier for the evidence.

"""
function get_evidence(
    assessmentId,
    controlSetId,
    evidenceFolderId,
    evidenceId;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "GET",
        "/assessments/$(assessmentId)/controlSets/$(controlSetId)/evidenceFolders/$(evidenceFolderId)/evidence/$(evidenceId)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_evidence(
    assessmentId,
    controlSetId,
    evidenceFolderId,
    evidenceId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "GET",
        "/assessments/$(assessmentId)/controlSets/$(controlSetId)/evidenceFolders/$(evidenceFolderId)/evidence/$(evidenceId)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    get_evidence_by_evidence_folder(assessment_id, control_set_id, evidence_folder_id)
    get_evidence_by_evidence_folder(assessment_id, control_set_id, evidence_folder_id, params::Dict{String,<:Any})

 Returns all evidence from a specified evidence folder in Audit Manager.

# Arguments
- `assessment_id`:  The identifier for the specified assessment.
- `control_set_id`:  The identifier for the control set.
- `evidence_folder_id`:  The unique identifier for the folder in which the evidence is
  stored.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"maxResults"`:  Represents the maximum number of results per page, or per API request
  call.
- `"nextToken"`:  The pagination token used to fetch the next set of results.
"""
function get_evidence_by_evidence_folder(
    assessmentId,
    controlSetId,
    evidenceFolderId;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "GET",
        "/assessments/$(assessmentId)/controlSets/$(controlSetId)/evidenceFolders/$(evidenceFolderId)/evidence";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_evidence_by_evidence_folder(
    assessmentId,
    controlSetId,
    evidenceFolderId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "GET",
        "/assessments/$(assessmentId)/controlSets/$(controlSetId)/evidenceFolders/$(evidenceFolderId)/evidence",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    get_evidence_folder(assessment_id, control_set_id, evidence_folder_id)
    get_evidence_folder(assessment_id, control_set_id, evidence_folder_id, params::Dict{String,<:Any})

 Returns an evidence folder from the specified assessment in Audit Manager.

# Arguments
- `assessment_id`:  The identifier for the specified assessment.
- `control_set_id`:  The identifier for the specified control set.
- `evidence_folder_id`:  The identifier for the folder in which the evidence is stored.

"""
function get_evidence_folder(
    assessmentId,
    controlSetId,
    evidenceFolderId;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "GET",
        "/assessments/$(assessmentId)/controlSets/$(controlSetId)/evidenceFolders/$(evidenceFolderId)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_evidence_folder(
    assessmentId,
    controlSetId,
    evidenceFolderId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "GET",
        "/assessments/$(assessmentId)/controlSets/$(controlSetId)/evidenceFolders/$(evidenceFolderId)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Returns the evidence folders from a specified assessment in Audit Manager.

# Arguments
- `assessment_id`:  The identifier for the specified assessment.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"maxResults"`:  Represents the maximum number of results per page, or per API request
  call.
- `"nextToken"`:  The pagination token used to fetch the next set of results.
"""
function get_evidence_folders_by_assessment(
    assessmentId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "GET",
        "/assessments/$(assessmentId)/evidenceFolders";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_evidence_folders_by_assessment(
    assessmentId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "GET",
        "/assessments/$(assessmentId)/evidenceFolders",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    get_evidence_folders_by_assessment_control(assessment_id, control_id, control_set_id)
    get_evidence_folders_by_assessment_control(assessment_id, control_id, control_set_id, params::Dict{String,<:Any})

 Returns a list of evidence folders associated with a specified control of an assessment in
Audit Manager.

# Arguments
- `assessment_id`:  The identifier for the specified assessment.
- `control_id`:  The identifier for the specified control.
- `control_set_id`:  The identifier for the specified control set.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"maxResults"`:  Represents the maximum number of results per page, or per API request
  call.
- `"nextToken"`:  The pagination token used to fetch the next set of results.
"""
function get_evidence_folders_by_assessment_control(
    assessmentId, controlId, controlSetId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "GET",
        "/assessments/$(assessmentId)/evidenceFolders-by-assessment-control/$(controlSetId)/$(controlId)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_evidence_folders_by_assessment_control(
    assessmentId,
    controlId,
    controlSetId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "GET",
        "/assessments/$(assessmentId)/evidenceFolders-by-assessment-control/$(controlSetId)/$(controlId)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Returns the name of the delegated Amazon Web Services administrator account for the
organization.

"""
function get_organization_admin_account(; aws_config::AbstractAWSConfig=global_aws_config())
    return auditmanager(
        "GET",
        "/account/organizationAdminAccount";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_organization_admin_account(
    params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "GET",
        "/account/organizationAdminAccount",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Returns a list of the in-scope Amazon Web Services services for the specified assessment.

"""
function get_services_in_scope(; aws_config::AbstractAWSConfig=global_aws_config())
    return auditmanager(
        "GET", "/services"; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end
function get_services_in_scope(
    params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "GET", "/services", params; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end

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

 Returns the settings for the specified account.

# Arguments
- `attribute`:  The list of SettingAttribute enum values.

"""
function get_settings(attribute; aws_config::AbstractAWSConfig=global_aws_config())
    return auditmanager(
        "GET",
        "/settings/$(attribute)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_settings(
    attribute,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "GET",
        "/settings/$(attribute)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Returns a list of the frameworks available in the Audit Manager framework library.

# Arguments
- `framework_type`:  The type of framework, such as standard or custom.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"maxResults"`:  Represents the maximum number of results per page, or per API request
  call.
- `"nextToken"`:  The pagination token used to fetch the next set of results.
"""
function list_assessment_frameworks(
    frameworkType; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "GET",
        "/assessmentFrameworks",
        Dict{String,Any}("frameworkType" => frameworkType);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function list_assessment_frameworks(
    frameworkType,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "GET",
        "/assessmentFrameworks",
        Dict{String,Any}(
            mergewith(_merge, Dict{String,Any}("frameworkType" => frameworkType), params)
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Returns a list of assessment reports created in Audit Manager.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"maxResults"`:  Represents the maximum number of results per page, or per API request
  call.
- `"nextToken"`:  The pagination token used to fetch the next set of results.
"""
function list_assessment_reports(; aws_config::AbstractAWSConfig=global_aws_config())
    return auditmanager(
        "GET", "/assessmentReports"; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end
function list_assessment_reports(
    params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "GET",
        "/assessmentReports",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Returns a list of current and past assessments from Audit Manager.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"maxResults"`:  Represents the maximum number of results per page, or per API request
  call.
- `"nextToken"`:  The pagination token used to fetch the next set of results.
"""
function list_assessments(; aws_config::AbstractAWSConfig=global_aws_config())
    return auditmanager(
        "GET", "/assessments"; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end
function list_assessments(
    params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "GET",
        "/assessments",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Returns a list of controls from Audit Manager.

# Arguments
- `control_type`:  The type of control, such as standard or custom.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"maxResults"`:  Represents the maximum number of results per page, or per API request
  call.
- `"nextToken"`:  The pagination token used to fetch the next set of results.
"""
function list_controls(controlType; aws_config::AbstractAWSConfig=global_aws_config())
    return auditmanager(
        "GET",
        "/controls",
        Dict{String,Any}("controlType" => controlType);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function list_controls(
    controlType,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "GET",
        "/controls",
        Dict{String,Any}(
            mergewith(_merge, Dict{String,Any}("controlType" => controlType), params)
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Returns a list of keywords that pre-mapped to the specified control data source.

# Arguments
- `source`:  The control mapping data source to which the keywords apply.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"maxResults"`:  Represents the maximum number of results per page, or per API request
  call.
- `"nextToken"`:  The pagination token used to fetch the next set of results.
"""
function list_keywords_for_data_source(
    source; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "GET",
        "/dataSourceKeywords",
        Dict{String,Any}("source" => source);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function list_keywords_for_data_source(
    source, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "GET",
        "/dataSourceKeywords",
        Dict{String,Any}(mergewith(_merge, Dict{String,Any}("source" => source), params));
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Returns a list of all Audit Manager notifications.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"maxResults"`:  Represents the maximum number of results per page, or per API request
  call.
- `"nextToken"`:  The pagination token used to fetch the next set of results.
"""
function list_notifications(; aws_config::AbstractAWSConfig=global_aws_config())
    return auditmanager(
        "GET", "/notifications"; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end
function list_notifications(
    params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "GET",
        "/notifications",
        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})

 Returns a list of tags for the specified resource in Audit Manager.

# Arguments
- `resource_arn`:  The Amazon Resource Name (ARN) of the specified resource.

"""
function list_tags_for_resource(
    resourceArn; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "GET",
        "/tags/$(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 auditmanager(
        "GET",
        "/tags/$(resourceArn)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Enables Audit Manager for the specified account.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"delegatedAdminAccount"`:  The delegated administrator account for Audit Manager.
- `"kmsKey"`:  The KMS key details.
"""
function register_account(; aws_config::AbstractAWSConfig=global_aws_config())
    return auditmanager(
        "POST",
        "/account/registerAccount";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function register_account(
    params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "POST",
        "/account/registerAccount",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Enables an account within the organization as the delegated administrator for Audit
Manager.

# Arguments
- `admin_account_id`:  The identifier for the specified delegated administrator account.

"""
function register_organization_admin_account(
    adminAccountId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "POST",
        "/account/registerOrganizationAdminAccount",
        Dict{String,Any}("adminAccountId" => adminAccountId);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function register_organization_admin_account(
    adminAccountId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "POST",
        "/account/registerOrganizationAdminAccount",
        Dict{String,Any}(
            mergewith(_merge, Dict{String,Any}("adminAccountId" => adminAccountId), params)
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Tags the specified resource in Audit Manager.

# Arguments
- `resource_arn`:  The Amazon Resource Name (ARN) of the specified resource.
- `tags`:  The tags to be associated with the resource.

"""
function tag_resource(resourceArn, tags; aws_config::AbstractAWSConfig=global_aws_config())
    return auditmanager(
        "POST",
        "/tags/$(resourceArn)",
        Dict{String,Any}("tags" => tags);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function tag_resource(
    resourceArn,
    tags,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "POST",
        "/tags/$(resourceArn)",
        Dict{String,Any}(mergewith(_merge, Dict{String,Any}("tags" => tags), params));
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Removes a tag from a resource in Audit Manager.

# Arguments
- `resource_arn`:  The Amazon Resource Name (ARN) of the specified resource.
- `tag_keys`:  The name or key of the tag.

"""
function untag_resource(
    resourceArn, tagKeys; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "DELETE",
        "/tags/$(resourceArn)",
        Dict{String,Any}("tagKeys" => tagKeys);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function untag_resource(
    resourceArn,
    tagKeys,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "DELETE",
        "/tags/$(resourceArn)",
        Dict{String,Any}(mergewith(_merge, Dict{String,Any}("tagKeys" => tagKeys), params));
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    update_assessment(assessment_id, scope)
    update_assessment(assessment_id, scope, params::Dict{String,<:Any})

 Edits an Audit Manager assessment.

# Arguments
- `assessment_id`:  The identifier for the specified assessment.
- `scope`:  The scope of the specified assessment.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"assessmentDescription"`:  The description of the specified assessment.
- `"assessmentName"`:  The name of the specified assessment to be updated.
- `"assessmentReportsDestination"`:  The assessment report storage destination for the
  specified assessment that is being updated.
- `"roles"`:  The list of roles for the specified assessment.
"""
function update_assessment(
    assessmentId, scope; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "PUT",
        "/assessments/$(assessmentId)",
        Dict{String,Any}("scope" => scope);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function update_assessment(
    assessmentId,
    scope,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "PUT",
        "/assessments/$(assessmentId)",
        Dict{String,Any}(mergewith(_merge, Dict{String,Any}("scope" => scope), params));
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    update_assessment_control(assessment_id, control_id, control_set_id)
    update_assessment_control(assessment_id, control_id, control_set_id, params::Dict{String,<:Any})

 Updates a control within an assessment in Audit Manager.

# Arguments
- `assessment_id`:  The identifier for the specified assessment.
- `control_id`:  The identifier for the specified control.
- `control_set_id`:  The identifier for the specified control set.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"commentBody"`:  The comment body text for the specified control.
- `"controlStatus"`:  The status of the specified control.
"""
function update_assessment_control(
    assessmentId, controlId, controlSetId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "PUT",
        "/assessments/$(assessmentId)/controlSets/$(controlSetId)/controls/$(controlId)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function update_assessment_control(
    assessmentId,
    controlId,
    controlSetId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "PUT",
        "/assessments/$(assessmentId)/controlSets/$(controlSetId)/controls/$(controlId)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    update_assessment_control_set_status(assessment_id, comment, control_set_id, status)
    update_assessment_control_set_status(assessment_id, comment, control_set_id, status, params::Dict{String,<:Any})

 Updates the status of a control set in an Audit Manager assessment.

# Arguments
- `assessment_id`:  The identifier for the specified assessment.
- `comment`:  The comment related to the status update.
- `control_set_id`:  The identifier for the specified control set.
- `status`:  The status of the control set that is being updated.

"""
function update_assessment_control_set_status(
    assessmentId,
    comment,
    controlSetId,
    status;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "PUT",
        "/assessments/$(assessmentId)/controlSets/$(controlSetId)/status",
        Dict{String,Any}("comment" => comment, "status" => status);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function update_assessment_control_set_status(
    assessmentId,
    comment,
    controlSetId,
    status,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "PUT",
        "/assessments/$(assessmentId)/controlSets/$(controlSetId)/status",
        Dict{String,Any}(
            mergewith(
                _merge, Dict{String,Any}("comment" => comment, "status" => status), params
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    update_assessment_framework(control_sets, framework_id, name)
    update_assessment_framework(control_sets, framework_id, name, params::Dict{String,<:Any})

 Updates a custom framework in Audit Manager.

# Arguments
- `control_sets`:  The control sets associated with the framework.
- `framework_id`:  The identifier for the specified framework.
- `name`:  The name of the framework to be updated.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"complianceType"`:  The compliance type that the new custom framework supports, such as
  CIS or HIPAA.
- `"description"`:  The description of the framework that is to be updated.
"""
function update_assessment_framework(
    controlSets, frameworkId, name; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "PUT",
        "/assessmentFrameworks/$(frameworkId)",
        Dict{String,Any}("controlSets" => controlSets, "name" => name);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function update_assessment_framework(
    controlSets,
    frameworkId,
    name,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "PUT",
        "/assessmentFrameworks/$(frameworkId)",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}("controlSets" => controlSets, "name" => name),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    update_assessment_status(assessment_id, status)
    update_assessment_status(assessment_id, status, params::Dict{String,<:Any})

 Updates the status of an assessment in Audit Manager.

# Arguments
- `assessment_id`:  The identifier for the specified assessment.
- `status`:  The current status of the specified assessment.

"""
function update_assessment_status(
    assessmentId, status; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "PUT",
        "/assessments/$(assessmentId)/status",
        Dict{String,Any}("status" => status);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function update_assessment_status(
    assessmentId,
    status,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "PUT",
        "/assessments/$(assessmentId)/status",
        Dict{String,Any}(mergewith(_merge, Dict{String,Any}("status" => status), params));
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    update_control(control_id, control_mapping_sources, name)
    update_control(control_id, control_mapping_sources, name, params::Dict{String,<:Any})

 Updates a custom control in Audit Manager.

# Arguments
- `control_id`:  The identifier for the specified control.
- `control_mapping_sources`:  The data mapping sources for the specified control.
- `name`:  The name of the control to be updated.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"actionPlanInstructions"`:  The recommended actions to carry out if the control is not
  fulfilled.
- `"actionPlanTitle"`:  The title of the action plan for remediating the control.
- `"description"`:  The optional description of the control.
- `"testingInformation"`:  The steps that to follow to determine if the control has been
  satisfied.
"""
function update_control(
    controlId,
    controlMappingSources,
    name;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "PUT",
        "/controls/$(controlId)",
        Dict{String,Any}("controlMappingSources" => controlMappingSources, "name" => name);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function update_control(
    controlId,
    controlMappingSources,
    name,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "PUT",
        "/controls/$(controlId)",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "controlMappingSources" => controlMappingSources, "name" => name
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

 Updates Audit Manager settings for the current user account.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"defaultAssessmentReportsDestination"`:  The default storage destination for assessment
  reports.
- `"defaultProcessOwners"`:  A list of the default audit owners.
- `"kmsKey"`:  The KMS key details.
- `"snsTopic"`:  The Amazon Simple Notification Service (Amazon SNS) topic to which Audit
  Manager sends notifications.
"""
function update_settings(; aws_config::AbstractAWSConfig=global_aws_config())
    return auditmanager(
        "PUT", "/settings"; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end
function update_settings(
    params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "PUT", "/settings", params; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end

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

 Validates the integrity of an assessment report in Audit Manager.

# Arguments
- `s3_relative_path`:  The relative path of the specified Amazon S3 bucket in which the
  assessment report is stored.

"""
function validate_assessment_report_integrity(
    s3RelativePath; aws_config::AbstractAWSConfig=global_aws_config()
)
    return auditmanager(
        "POST",
        "/assessmentReports/integrity",
        Dict{String,Any}("s3RelativePath" => s3RelativePath);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function validate_assessment_report_integrity(
    s3RelativePath,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return auditmanager(
        "POST",
        "/assessmentReports/integrity",
        Dict{String,Any}(
            mergewith(_merge, Dict{String,Any}("s3RelativePath" => s3RelativePath), params)
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end


text:
using DataFrames
using DataStructures
using Logging

using ProgressMeter

const RESAMPLE_STRATEGIES = Set([:derivative_limit, :step_fixed, :step_min_max, :step_min, :step_max])
"""
Make resampling of a given fuction table data using a stragegy.
Supported strategies:
  - :derivative_limit, parameters - :angle_max, :last_points_number
  - :step_fixed, parameters - :step_value
  - :step_min_max, parameters - :step_min_value, :step_max_value
  - :step_min, parameters - :step_min_value
  - :step_max, parameters - :step_max_value
"""
function resample_data_frame(data::DataFrame, strategies::Set{Symbol}, parameters::Dict{Symbol, Any})
  Logging.configure(level=INFO)
  info("Data resampling with strategies $strategies...")
  @assert !isempty(data) prerequisite("The input data must not be empty.")
  @assert size(data)[2] >= 2 prerequisite("The input data must have two columns at least.")
  @assert !isempty(strategies) prerequisite("The strategy set must not be empty.")
  @assert issubset(strategies, RESAMPLE_STRATEGIES)
  @assert (:derivative_limit ∈ strategies) && length(strategies) == 1 prerequisite("Only :derivative_limit is supported at the moment.")

  @assert (:points_in_each_selection ∈ keys(parameters)) prerequisite(":points_in_each_selection ∈ {parameters}", ("parameters", parameters))
  @assert (typeof(parameters[:points_in_each_selection]) ∈ ℤ && parameters[:points_in_each_selection] > 0) prerequisite(":points_in_each_selection ∈ ℕ", (":points_in_each_selection", parameters[:points_in_each_selection]))
  points_in_each_selection = convert(UInt, parameters[:points_in_each_selection])
  @assert points_in_each_selection > 10 prerequisite(":points_in_each_selection > 10", (":points_in_each_selection", points_in_each_selection))

  # @assert (:preffered_step ∈ keys(parameters)) prerequisite(":preffered_step ∈ {parameters}", ("parameters", parameters))
  # @assert (typeof(parameters[:preffered_step]) ∈ ℝ) prerequisite(":preffered_step ∈ ℝ", )
  # preffered_step = convert(Float64, parameters[:preffered_step])
  # @assert preffered_step > 0 prerequisite(":preffered_step > 0", (":preffered_step", preffered_step))
  # @assert preffered_step > 1e-9 prerequisite(":preffered_step > 10⁻⁹", (":preffered_step", preffered_step))

  @assert (:maximum_function_angle ∈ keys(parameters)) prerequisite(":maximum_function_angle ∈ {parameters}", ("parameters", parameters))
  @assert (typeof(parameters[:maximum_function_angle]) ∈ ℝ) prerequisite("parameters[:maximum_function_angle] ∈ ℝ")
  maximum_function_angle = convert(Float64, parameters[:maximum_function_angle])
  @assert 0 < maximum_function_angle < π/2 prerequisite("0 < :maximum_function_angle < π/2 ($(π/2))", (":maximum_function_angle", maximum_function_angle))

  @assert (:keep_tail ∈ keys(parameters)) prerequisite(":keep_tail ∈ {parameters}", ("parameters", parameters))
  @assert (typeof(parameters[:keep_tail]) ∈ ℤ && parameters[:keep_tail] >= 0) prerequisite("parameters[:keep_tail] ∈ ℤ && > 0", ("keep_tail", parameters[:keep_tail]))
  keep_tail = convert(UInt, parameters[:keep_tail])

  info("Resampling data of length $(size(data)[1])...")
  result = resample_data_frame_derivative_limit(data, points_in_each_selection, maximum_function_angle, keep_tail)
  info("Done!")
  return result
end

function resample_data_frame_derivative_limit(data::DataFrame, Nᵖ::UInt, αᵐᵃˣ::Float64, tail::UInt)
  Logging.configure(level=INFO)
  info("Starting resample_data_frame_derivative_limit procedure...")
  X = Vector(data[:, 1])
  @assert issorted(X)
  F = data[:, 2:end]
  ΔX = filter(Δx -> 1e-9 < Δx < 1e2, X[2:end] - X[1:end-1])
  Δxᵐⁱⁿ = minimum(ΔX); Δxᵐᵃˣ = maximum(ΔX)
  Δxᵐᵉᵃⁿ = mean_base10(Δxᵐⁱⁿ, Δxᵐᵃˣ; meanf=weighted_mean_max)
  info("The grid steps: Δxᵐⁱⁿ=$Δxᵐⁱⁿ, Δxᵐᵃˣ=$Δxᵐᵃˣ, Δxᵐᵉᵃⁿ=$Δxᵐᵉᵃⁿ")
  αᵐᵃˣ¹ = if π/4 <= αᵐᵃˣ  π/2
    αᵐᵃˣ / 2
  elseif π/6 <= αᵐᵃˣ < π/4
    αᵐᵃˣ / 3
  elseif π/8 <= αᵐᵃˣ < π/6
    αᵐᵃˣ / 4
  elseif π/24 <= αᵐᵃˣ < π/8
    αᵐᵃˣ / 5
  else
    αᵐᵃˣ / 6
  end
  αᵐᵃˣ² = if π/4 <= αᵐᵃˣ  π/2
    αᵐᵃˣ
  elseif π/6 <= αᵐᵃˣ < π/4
    golden * αᵐᵃˣ
  elseif π/8 <= αᵐᵃˣ < π/6
    2 * αᵐᵃˣ
  elseif π/24 <= αᵐᵃˣ < π/8
    3 * αᵐᵃˣ
  else
    4 * αᵐᵃˣ
  end
  info("Angles: αᵐᵃˣ=$αᵐᵃˣ ($(rad2deg(αᵐᵃˣ))°), αᵐᵃˣ¹=$αᵐᵃˣ¹ ($(rad2deg(αᵐᵃˣ¹))°), π - αᵐᵃˣ¹ = $(π - αᵐᵃˣ¹) ($(rad2deg(π - αᵐᵃˣ¹))°)")

  info("Making spline interpolation for better resampling...")
  Fs = convert_functionDataFrame_to_Functions(data)
  info("Done...")
  Nᶜ = size(data)[2] - 1
  newdata = createDataFrameWithColumns(data.colindex.names; tp=Float64)
  cᵖ = 1
  i = 1
  ixˡᵃˢᵗ = 1
  #p = Progress(length(X), 1)
  while i <= length(X) - tail
    #ProgressMeter.update!(p, i)
    if cᵖ >= Nᵖ
      i¹ = i - cᵖ + 1; iᵉⁿᵈ = i
      # --- differences in the p-th interval of length Nᵖ ---
      ΔXᵖ = X[i¹+1:iᵉⁿᵈ] - X[i¹:iᵉⁿᵈ-1]
      ΔFᵖ = zeros(Float64, length(ΔXᵖ), Nᶜ)
      for j ∈ 1:Nᶜ
        ΔFᵖ[:, j] = collect(Float64, F[i¹+1:iᵉⁿᵈ, j] - F[i¹:iᵉⁿᵈ-1, j])
      end
      # -----------------------------------------------------

      # --- derivatives in the p-th interval ----------------
      tanαᵖ = zeros(Float64, size(ΔFᵖ)[1], Nᶜ)
      for j ∈ 1:Nᶜ
        tanαᵖ[:, j] = ΔFᵖ[:, j] ./ ΔXᵖ
      end
      αᵖ = atan(tanαᵖ)
      # -----------------------------------------------------

      # --- angles and their deltas in the p-th interval ----
      Δαᵖ = αᵖ[2:end, :] - αᵖ[1:end-1, :]
      ΣΔαᵖ = ones(Float64, 1, size(Δαᵖ)[1]) * Δαᵖ
      ΣΔαᵖ⁺ = ones(Float64, 1, size(Δαᵖ)[1]) * abs(Δαᵖ)
      ΔsignΣΔαᵖ = ones(Float64, 1, size(Δαᵖ)[1]) * sign(Δαᵖ)
      # -----------------------------------------------------

      if exists(ΣΔαᵖⱼ -> ΣΔαᵖⱼ >= αᵐᵃˣ, ΣΔαᵖ)
        for iᵖ = (i-Nᵖ+1):i
          push!(newdata, data_row_to_vector(data, convert(Int, iᵖ)))
        end
        ixˡᵃˢᵗ = i
      elseif exists(ΣΔαᵖ⁺ⱼ -> π/2 - αᵐᵃˣ <= ΣΔαᵖ⁺ⱼ <= π/2 + αᵐᵃˣ || π - αᵐᵃˣ¹ <= ΣΔαᵖ⁺ⱼ <= π + αᵐᵃˣ¹, ΣΔαᵖ⁺) && exists(ΔsignΣΔαᵖⱼ -> abs(ΔsignΣΔαᵖⱼ) <= Nᵖ/2+1, ΔsignΣΔαᵖ)
        info("Possible peak in [$(X[i-Nᵖ+1]), $(X[i])]; ΔsignΣΔαᵖ=$ΔsignΣΔαᵖ; max(Δαᵖ⁺)=$(maximum(ΣΔαᵖ⁺)) ($(rad2deg(maximum(ΣΔαᵖ⁺)))°)")
        for iᵖ = (i-Nᵖ+1):i
          push!(newdata, data_row_to_vector(data, convert(Int, iᵖ)))
        end
        ixˡᵃˢᵗ = i
      elseif exists(αᵖᵢⱼ -> abs(αᵖᵢⱼ) >= αᵐᵃˣ², αᵖ)
        xˡᵃˢᵗ = data[i-Nᵖ+1, 1]
        xᶜᵘʳʳᵉⁿᵗ = data[i, 1]
        xᵟ = (xˡᵃˢᵗ + xᶜᵘʳʳᵉⁿᵗ) / 2
        newrow = Vector{Float64}(Nᶜ + 1)
        newrow[1] = xᵟ
        for j ∈ 2:(Nᶜ+1)
          newrow[j] = Fs[j - 1](xᵟ)
        end
        push!(newdata, newrow)
        push!(newdata, data_row_to_vector(data, i))
      else
        push!(newdata, data_row_to_vector(data, i))
      end
      cᵖ = 0
    end
    cᵖ += 1;
    i += 1
  end
  for i ∈ (length(X) - tail + 1):length(X)
    push!(newdata, data_row_to_vector(data, convert(Int, i)))
  end
  info("The result has sizes $(size(newdata))")

  return newdata
end

ext: jl


text:
# solve the problem
a = 0;
b = 1;
n = 9;
f = 2*ones(n)
problem = SparseFiniteDifferenceBVPProblem(a, b, n, f);
assemble_system!(problem);
u = solve_bvp(problem);

# computer error
err = @. problem.x * (1-problem.x) - u;
# check error
norm(err, Inf)< 1e-14


text:
pvalue(dist, x) = min(2 * min(cdf(dist, x), ccdf(dist, x)), 1.0)

"""
    contrast(anovaresult::AnovaResult, groupassignment::Vector{Int})

Calculate a single-factor contrast against the groups specified in `groupassignment`.
Valid groups are "0", "1", and "2", where "0" excludes the group from the comparison.

Note: If you do nonorthogonal contrasts, use the Bonferroni or Šidák correction to adjust the
α level (the level at which you consider a result likely to be true):
  Bonferroni: α′ = α/c for c contrasts
  Šidák:      α′ = 1 - (1 - α)^(1 / c) (slightly better)
where c = number of contrasts

Note: Effect size is calcluated using the error term associated with the factor. Other choices are possible,
including average of each group error; or the error associated with a control.
"""
function contrast(anovaresult::AnovaData, groupassignment::Vector{Int}, factorindex::Int = 1)
    0 < factorindex ≤ anovaresult.ncrossedfactors                            || error("factor index must be a valid crossed factor")
    all(0 .≤ groupassignment .≤ 2)                                           || error("valid groups are 0, 1, and 2")
    length(groupassignment) == anovaresult.ncrossedfactorlevels[factorindex] || error("each level must be assigned to a group")

    lowerfactorlevels = prod(anovaresult.ncrossedfactorlevels[1:(factorindex-1)])
    upperfactorlevels = prod(anovaresult.ncrossedfactorlevels[(factorindex+1):anovaresult.ncrossedfactors])

    # factorindex is in the order the factors appear in the result
    # but the crossedcellmeans dimensions are in reverse order (as input)
    group1levels = repeat(groupassignment .== 1, outer = upperfactorlevels, inner = lowerfactorlevels)
    group2levels = repeat(groupassignment .== 2, outer = upperfactorlevels, inner = lowerfactorlevels)
    group1count = count(group1levels)
    group2count = count(group2levels)

    contrastcoefficients = zeros(anovaresult.ncrossedfactorlevels[factorindex] * lowerfactorlevels * upperfactorlevels)
    contrastcoefficients[group1levels] .= 1 / group1count
    contrastcoefficients[group2levels] .= -1 / group2count

    errorfactor = anovaresult.crossedfactorsdenominators[factorindex]
    ψ = sum(contrastcoefficients .* anovaresult.crossedcellmeans)
    contrast = anovaresult.npercrossedcell * ψ ^ 2
    error = sum(contrastcoefficients .^ 2) * errorfactor.ms

    f = contrast / error
    fdist = FDist(1, errorfactor.df)
    p = ccdf(fdist, f)

    effectsize = sqrt(f / (f  + errorfactor.df)) # t^2 == f
    #cohen's d: effectsize = ψ / sqrt(errorfactor.ms) ; preferred when group sizes very different

    AnovaContrastResult(contrast, errorfactor.df, f, p, effectsize)
end

"""
    differencecontrast(anovaresult::AnovaData, factorindex = 1, reverseorder = false)

Compute orthogonal contrasts on the factor levels in the original order. Forward direction also known as
a "Helmert" contrast; revere direction may also be called "Difference" (as in SPSS). See `contrast`
function for more.
"""
function differencecontrasts(anovaresult::AnovaData, reverseorder::Bool = false, factorindex::Int = 1)
    0 < factorindex ≤ anovaresult.ncrossedfactors || error("factor index must be a valid crossed factor")

    levels = anovaresult.ncrossedfactorlevels[1]
    groupassignments = [[repeat([0], i - 1); 1; repeat([2], levels - i)] for i ∈ 1:(levels - 1)]
    reverseorder && reverse!.(groupassignments)

    AnovaContrastResults(contrast.(Ref(anovaresult), groupassignments, factorindex))
end

"""
    repeatedcontrast(anovaresult::AnovaData, factorindex = 1)

Compute contrasts between neighboring levels. Non-orthogonal. See `contrast` function for more.
"""
function repeatedcontrasts(anovaresult::AnovaData, factorindex::Int = 1)
    0 < factorindex ≤ anovaresult.ncrossedfactors || error("factor index must be a valid crossed factor")

    levels = anovaresult.ncrossedfactorlevels[factorindex]
    groupassignments = [[repeat([0], i - 1); 1; 2; repeat([0], levels - i - 1)] for i ∈ 1:(levels - 1)]

    AnovaContrastResults(contrast.(Ref(anovaresult), groupassignments, factorindex))
end

"""
    simplecontrast(anovaresult::AnovaData, controlindex = 1, factorindex = 1)

Compute contrasts of each level to a single level (control). Non-orthogonal. See `contrast` function for more.
"""
function simplecontrasts(anovaresult::AnovaData, controlindex::Int = 1, factorindex::Int = 1)
    0 < factorindex ≤ anovaresult.ncrossedfactors || error("factor index must be a valid crossed factor")
    0 < controlindex ≤ anovaresult.ncrossedfactorlevels[factorindex] || error("index must be for a valid factor level")

    levels = anovaresult.ncrossedfactorlevels[factorindex]
    groupassignments = [zeros(Int, levels) for i ∈ 1:(levels - 1)]
    otherlevels = (1:levels)[Not(controlindex)]
    for i ∈ 1:(levels - 1)
        groupassignments[i][controlindex] = 1
        groupassignments[i][otherlevels[i]] = 2
    end

    AnovaContrastResults(contrast.(Ref(anovaresult), groupassignments, factorindex))
end

#= To do this one, need to be able to code a factor level as in both groups
"""
    deviationcontrasts(anovaresult::AnovaData, controlindex = 1, factorindex = 1)

Compute contrasts of each level except one (control) to all levels. Non-orthogonal.
See `contrast` function for more.
"""
function deviationcontrast(anovaresult::AnovaData, controlindex = 1, factorindex = 1)
    0 < factorindex ≤ anovaresult.ncrossedfactors || error("factor index must be a valid crossed factor")
    0 < controlindex ≤ anovaresult.ncrossedfactorlevels[1] || error("index must be for a valid factor level")

    levels = anovaresult.ncrossedfactorlevels[1]
    groupassignments = [zeros(Int, levels) for i ∈ 1:(levels - 1)]
    otherlevels = (1:levels)[Not(controlindex)]
    for i ∈ 1:(levels - 1)
        groupassignments[i][controlindex] = 1
        groupassignments[i][otherlevels[i]] = 2
    end

    [groupassignments[i][i] = 1 for i ∈ (1:levels)[Not(controlindex)]]
    [groupassignments[i][i] = 1 for i ∈ (1:levels)[Not(controlindex)]]

    contrast.(Ref(anovaresult), groupassignments)
end
=#


text:
@testset "Ideal class monoid of orders in number fields" begin

  Qx, x = FlintQQ["x"]
  f = x^3 + 31*x^2 + 43*x + 77
  K, a = number_field(f, "a")
  O = equation_order(K)
  icm = ideal_class_monoid(O)
  @test length(icm) == 59
  @test isisomorphic(evaluate(icm[1]), evaluate(icm[2]))[1] == false
  t, b = isisomorphic(O(2)*O, O(3)*O)
  @test t == true
  @test (O(3)*O)*(b*O) == K(2)*O
  t, b = isisomorphic(K(2)*O, K(3)*O)
  @test t == true
  @test (O(3)*O)*(b*O) == K(2)*O

  f = x^3 - 1000*x^2 - 1000*x - 1000
  K, a = number_field(f, "a")
  O = equation_order(K)
  icm = ideal_class_monoid(O)
  @test length(icm) == 69116

end

@testset "Ideal class monoid of orders in algebras" begin

  Qx, x = FlintQQ["x"]
  f = x^3 + 31*x^2 + 43*x + 77
  A = AlgAss(f)
  O = Order(A, basis(A))
  icm = ideal_class_monoid(O)
  @test length(icm) == 59
  @test isisomorphic(evaluate(icm[1]), evaluate(icm[2]))[1] == false
  t, b = isisomorphic(O(2)*O, O(3)*O)
  @test t == true
  @test (O(3)*O)*(b*O) == A(2)*O
  t, b = isisomorphic(A(2)*O, A(3)*O)
  @test t == true
  @test (O(3)*O)*(b*O) == A(2)*O

  f1 = x^2 + 4*x + 7
  f2 = x^3 - 9*x^2 - 3*x - 1
  A = AlgAss(f1*f2)
  O = Order(A, basis(A))
  icm = ideal_class_monoid(O)
  @test length(icm) == 852

end

@testset "Conjugacy of integral matrices" begin

  Zx, x = FlintZZ["x"]
  f = x^3 - 4x^2 + 8x + 5

  M = companion_matrix(f)
  U = identity_matrix(FlintZZ, nrows(M))
  for i = 1:nrows(M)
    for j = i + 1:ncols(M)
      U[i, j] = rand(-10:10)
    end
  end
  N = U*M*inv(U)

  b, V = isconjugate(M, N)
  @test b == true
  @test M == V*N*inv(V)

  N = identity_matrix(FlintZZ, nrows(M))
  b, V = isconjugate(M, N)
  @test b == false

  g = x^2 + 10x - 1
  h = x^2 - x + 5

  M = companion_matrix(f*g*h)
  U = identity_matrix(FlintZZ, nrows(M))
  for i = 1:nrows(M)
    for j = i + 1:ncols(M)
      U[i, j] = rand(-10:10)
    end
  end
  N = U*M*inv(U)

  b, V = isconjugate(M, N)
  @test b == true
  @test M == V*N*inv(V)

  N = identity_matrix(FlintZZ, nrows(M))
  b, V = isconjugate(M, N)
  @test b == false

end


text:
# "Uses spatially varying smoothness terms. That is
# V(p1,p2,l1,l2) = w_{p1,p2}*[min((l1-l2)*(l1-l2),4)], with
# w_{p1,p2} = p1+p2 if |p1-p2| == 1 and w_{p1,p2} = p1*p2 if |p1-p2| is not 1."
#
using GCoptimization

width = 10
height = 5
num_pixels = width * height
num_labels = 7
result = zeros(num_pixels)    # "stores result of optimization"

# "first set up the array for data costs"
data = Vector{Int}(num_pixels * num_labels)
for i = 0:num_pixels-1, l = 0:num_labels-1
    if i < 25
        if l == 0
            data[i*num_labels+l+1] = 0
        else
            data[i*num_labels+l+1] = 10
        end
    else
        if l == 5
            data[i*num_labels+l+1] = 0
        else
            data[i*num_labels+l+1] = 10
        end
    end
end

# "next set up the array for smooth costs"
smooth = Vector{Int}(num_labels * num_labels)
for l1 = 0:num_labels-1, l2 = 0:num_labels-1
    smooth[l1+l2*num_labels+1] = (l1-l2)*(l1-l2) <= 4  ? (l1-l2)*(l1-l2) : 4;
end

# "next set up spatially varying arrays V and H"
V = Vector{Int}(num_pixels)
H = Vector{Int}(num_pixels)

for i = 0:num_pixels-1
    H[i+1] = i+(i+1)%3
    V[i+1] = i*(i+width)%7
end

gco = GCoptimizationGridGraph(width, height, num_labels)

setDataCost(gco, data)
setSmoothCostVH(gco, smooth, V, H)

println("Before optimization energy is ", compute_energy(gco))
expansion(gco, 2)    # "run expansion for 2 iterations."
println("After optimization energy is ", compute_energy(gco))

for i = 0:num_pixels-1
    result[i+1] = whatLabel(gco, i)
end

showall(result)


text:
@testset "ece.jl" begin
    @testset "Trivial tests" begin
        ece = ECE(UniformBinning(10))
        for predictions in ([[0, 1], [1, 0]], ColVecs([0 1; 1 0]), RowVecs([0 1; 1 0]))
            @test iszero(@inferred(ece(predictions, [2, 1])))
        end
        for predictions in (
            [[0, 1], [0.5, 0.5], [0.5, 0.5], [1, 0]],
            ColVecs([0 0.5 0.5 1; 1 0.5 0.5 0]),
            RowVecs([0 1; 0.5 0.5; 0.5 0.5; 1 0]),
        )
            @test iszero(@inferred(ece(predictions, [2, 2, 1, 1])))
        end
    end

    @testset "Uniform binning: Basic properties" begin
        ece = ECE(UniformBinning(10))
        estimates = Vector{Float64}(undef, 1_000)

        for nclasses in (2, 10, 100)
            dist = Dirichlet(nclasses, 1.0)

            predictions = [Vector{Float64}(undef, nclasses) for _ in 1:20]
            targets = Vector{Int}(undef, 20)

            for i in 1:length(estimates)
                rand!.(Ref(dist), predictions)
                targets .= rand.(Categorical.(predictions))

                estimates[i] = ece(predictions, targets)
            end

            @test all(x -> zero(x) < x < one(x), estimates)
        end
    end

    @testset "Median variance binning: Basic properties" begin
        ece = ECE(MedianVarianceBinning(10))
        estimates = Vector{Float64}(undef, 1_000)

        for nclasses in (2, 10, 100)
            dist = Dirichlet(nclasses, 1.0)

            predictions = [Vector{Float64}(undef, nclasses) for _ in 1:20]
            targets = Vector{Int}(undef, 20)

            for i in 1:length(estimates)
                rand!.(Ref(dist), predictions)
                targets .= rand.(Categorical.(predictions))

                estimates[i] = ece(predictions, targets)
            end

            @test all(x -> zero(x) < x < one(x), estimates)
        end
    end
end


text:
"""
	inferARG(
		t1::Tree, t2::Tree, oa::OptArgs = OptArgs();
		naive = false, seqlengths = [1,1],
	)
"""
function inferARG(
	t1::Tree, t2::Tree, oa::OptArgs = OptArgs();
	naive = false,
)
	MCCs = computeMCCs(t1, t2, oa)
	arg = SRG.arg_from_trees(t1, t2, MCCs)[1]
	return arg[1]
end

"""
	computeMCCs(
		t1::Tree, t2::Tree, oa::OptArgs = OptArgs();
		naive = false, seqlengths = [1,1],
	)

Compute pairwise MCCs for trees. Return MCCs and resolved splits. The `computeMCCs!`
version resolves the input trees with newly found splits.

# Inputs
### `oa::OptArgs`
Controls parameters of the MCC inference (unless `naive=true`). See `?OptArgs` for details.

In general, this should be set to `true` if more than two trees are used, and to `false`
  for only two trees (for speed).

### `naive = false`
- If `true`, use a naive estimation for MCCs, *i.e.* find all clades that have an exactly
  matching topology in all trees.
- Else, use a pseudo-parsimonious method based (mostly) on topology. The method
  `runopt(oa,t1,t2)` is called on every pair of trees.
"""
function computeMCCs(
	t1::Tree, t2::Tree, oa::OptArgs=OptArgs();
	naive=false
)
	if naive
		return naive_mccs(t1, t2)
	else
		# oac = @set oa.seq_lengths = seqlengths
		return runopt(oa, t1, t2; output = :mccs)
	end
end

###############################################################################################################
########################################## Main inference function ############################################
###############################################################################################################

"""
		runopt(t1::Tree, t2::Tree; kwargs...)
		runopt(oa::OptArgs, t1::Tree, t2::Tree)
		runopt(oa::OptArgs, trees::Dict{<:Any,<:Tree})

Run optimization at constant γ. See `?Optargs` for arguments. In the first form, keyword
  arguments are given to `OptArgs`.
"""
runopt(t1::Tree, t2::Tree; kwargs...) = runopt(OptArgs(;kwargs...), t1, t2)

function runopt(oa::OptArgs, t1::Tree, t2::Tree; output = :mccs)
	datatype = TreeTools.EmptyData

	# Copying input trees for optimization
	# ot = Dict(k=>copy(t, datatype) for (k,t) in trees)
	ot1 = copy(t1)
	ot2 = copy(t2)

	# Resolve
	# oa.resolve && resolve!(values(ot)...)
	oa.resolve && resolve!(ot1, ot2)

	# iMCCs = naive_mccs(values(ot)...)
	iMCCs = naive_mccs(ot1, ot2)
	oa.verbose && @info "Initial state: $(length(iMCCs)) naive MCCs"

	MCCs = [] # All final MCCs found up to now

	it = 1
	while true
		flag = :init
		oa.verbose && @info "--- Iteration $it (max. $(oa.itmax)) - $(length(leaves(ot1))) leaves remaining ---\n"

		# Topology based inference
		oa.verbose && @info "Running optimization to find MCCs..."
		@assert share_labels(ot1, ot2) "Trees do not share leaves"
		M = Int(ceil(length(ot1.lleaves) * oa.nMCMC / length(oa.Trange)))
		mccs, Efinal, Ffinal, lk = SplitGraph.opttrees(
			ot1, ot2;
			γ=oa.γ, seq_lengths = oa.seq_lengths, M=M, Trange=oa.Trange,
			likelihood_sort=oa.likelihood_sort, resolve=oa.resolve, sa_rep = oa.sa_rep, oa.verbose
		)
		!isempty(mccs) && append!(MCCs, mccs)
		oa.verbose && @info "Found $(length(mccs)) new mccs."

		# Stopping condition
		oa.verbose && @info "Proceeding based on newly found MCCs..."
		flag, rMCCs = stop_conditions!(MCCs, mccs, oa, it, ot1, ot2; hardstop=true)

		#=
			Note on variables at this point
		- mccs: MCCs removed after simulated annealing (`opttrees` step)
		- rMCCs: remaining naive MCCs after removing the ones found in the `opttrees` step.
		- MCCs: all the MCCs found up to now (mccs + all the ones in the previous iters)
		=#

		# Checks
		@assert prod([check_tree(t) for t in (ot1, ot2)]) "Problem in a tree during opt."

		(flag == :stop) && break
		it += 1
	end

	if output == :all
		return TreeKnit.sort_mccs(MCCs), ot1, ot2
	else
		return sort_mccs(MCCs)
	end
end

function stop_conditions!(previous_mccs, new_mccs, oa, it, trees... ; hardstop=true)
	# If no solution was found
	if length(new_mccs) == 0
		# oa.verbose && print("No solution found... ")
		oa.verbose && @info "No solution found... "
		remaining_mccs = naive_mccs(trees)
		## If hardstop or maxit,  stop
		if hardstop || it > oa.itmax
			append!(previous_mccs, remaining_mccs)
			# oa.verbose && println("Stopping.")
			oa.verbose && @info "Stopping\n"
			return :stop, []
		else
		## Otherwise, continue
			# oa.verbose && println("Continuing.")
			oa.verbose && @info "Continuing\n"
			return :next, remaining_mccs # (can't call this after because of `pruneconf!` below)
		end
	end

	# If some new MCCs were found
	## If they cover all leaves of the tree: a final decomposition has been found.
	if sum(length(m) for m in new_mccs) == length(first(trees).lleaves)
		# oa.verbose && println("Found mccs cover all leaves: final decomposition found. Stopping.")
		oa.verbose && @info "Found mccs cover all leaves: final decomposition found. Stopping.\n"
		return :stop, []
	end
	## If they do not cover all leaves of the trees, remove them from the trees
	# oa.verbose && println("Found mccs do not cover all leaves. Pruning them from trees. ")
	oa.verbose && @info "Found mccs do not cover all leaves. Pruning them from trees."
	pruneconf!(new_mccs, trees...)
	oa.resolve && resolve!(trees...)
	remaining_mccs = naive_mccs(trees)
	### If they new trees have an obvious solution, append it to new_mccs and stop
	if length(remaining_mccs) == 1
		append!(new_mccs, remaining_mccs)
		append!(previous_mccs, remaining_mccs)
		# oa.verbose && println("Resulting trees are compatible: final decomposition found. Stopping.")
		oa.verbose && @info "Resulting trees are compatible: final decomposition found. Stopping.\n"
		return :stop, []
	### If we reached the maximum number of iterations, stop
	elseif it > oa.itmax
		append!(previous_mccs, remaining_mccs)
		# oa.verbose && println("Maximum number of iterations reached. Stopping.")
		oa.verbose && @info "Maximum number of iterations reached. Stopping.\n"
		return :stop, []
	### Otherwise, continue
	else
		# oa.verbose && println("Resulting trees have incompatibilities. Continuing.")
		oa.verbose && @info "Resulting trees have incompatibilities ($(length(remaining_mccs)) naive mccs left). Continuing.\n\n"
		return :next, remaining_mccs
	end
end

function getM(L, Md)
	if L < 10 && Md >= 1
		return 10
	else
		return _getM(L, Md)
	end
	tmp
end
_getM(n,Md) = ceil(Int, n/Md)

"""
	pruneconf!(clades, trees::Vararg{Tree})

Prune `clades` from `trees...`.
"""
function pruneconf!(clades, trees::Vararg{Tree})
	for t in trees
		for st in clades
			TreeTools.prunesubtree!(t, st, clade_only=false)
		end
		TreeTools.remove_internal_singletons!(t, ptau=true)
	end
end
"""
	pruneconf!(trees, mcc_names, mcc_conf)

Prune MCCs `mcc_names[x]` for all `x` in `mcc_conf` from trees `t...`.
"""
pruneconf!(trees, mcc_names, mcc_conf) = pruneconf!([mcc_names[x] for x in mcc_conf], trees...)

# function update_df!(df, nleaves::Int64, nMCCs::Int64, γ, M, Efinal, Ffinal, rMCCs, arMCCs, remainingMCCs, method)
# 	push!(df,
# 		Dict(:nleaves=>nleaves,
# 		:nMCCs=>nMCCs,
# 		:γ=>γ,
# 		:M=>M,
# 		:Efinal=>Efinal,
# 		:Ffinal=>Ffinal,
# 		:newMCCs=>copy(rMCCs),
# 		:AllFinalMCCs=>copy(arMCCs),
# 		:RemainingConsistentClades=>copy(remainingMCCs),
# 		:method=>method)
# 		)
# end

max_stars_repo_name: PierreBarrat/RecombTools

max_issues_repo_name: PierreBarrat/RecombTools

max_forks_repo_name: PierreBarrat/RecombTools


text:
using NativeXML
using Test

using NativeXML.Lexical
using NativeXML.Events

tests = [ "lexical",
          "events/attributes", "events/attribute_list_declarations",
          "events/cdata_ms", "events/comments", "events/conditional_section", "events/data_content", "events/doctype",
          "events/element_end", "events/element_start", "events/element_declarations",
          "events/entity_declarations", "events/entity_references",
          "events/markup_declarations", "events/miscellaneous", "events/notation_declarations", "events/pis", ]

for test ∈ tests
    include("$test.jl")
end

max_stars_repo_name: jlegare/NativeXML

max_issues_repo_name: jlegare/NativeXML

max_forks_repo_name: jlegare/NativeXML


text:
struct HessDense
    function HessDense(::Type{T}, ::Type{S}, n) where {T,S}
        return new()
    end
end
struct HessSparse
    function HessSparse(::Type{T}, ::Type{S}, n) where {T,S}
        return new()
    end
end
struct HessOp{S}
    Hv::S
    function HessOp(::Type{T}, ::Type{S}, n) where {T,S}
        return new{S}(S(undef, n))
    end
end
export HessDense, HessSparse, HessOp

function hessian!(workspace::HessDense, nlp, x)
    H = Matrix(hess(nlp, x))
    return H
end

function hessian!(workspace::HessOp, nlp, x)
    return hess_op!(nlp, x, workspace.Hv)
end

function hessian!(workspace::HessSparse, nlp, x)
    H = hess(nlp, x)
    return H
end