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 AWS Audit Manager.

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

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

"""
    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 AWS 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.

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

"""
    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 AWS Audit Manager.

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

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

"""
    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 AWS Audit Manager assessment.

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

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

"""
    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 AWS 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.

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

"""
    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 AWS
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.

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

"""
    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 AWS 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.
"""
create_assessment(assessmentReportsDestination, frameworkId, name, roles, scope; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("POST", "/assessments", Dict{String, Any}("assessmentReportsDestination"=>assessmentReportsDestination, "frameworkId"=>frameworkId, "name"=>name, "roles"=>roles, "scope"=>scope); aws_config=aws_config)
create_assessment(assessmentReportsDestination, frameworkId, name, roles, scope, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = 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)

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

 Creates a custom framework in AWS 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.
"""
create_assessment_framework(controlSets, name; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("POST", "/assessmentFrameworks", Dict{String, Any}("controlSets"=>controlSets, "name"=>name); aws_config=aws_config)
create_assessment_framework(controlSets, name, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("POST", "/assessmentFrameworks", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("controlSets"=>controlSets, "name"=>name), params)); aws_config=aws_config)

"""
    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.
"""
create_assessment_report(assessmentId, name; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("POST", "/assessments/$(assessmentId)/reports", Dict{String, Any}("name"=>name); aws_config=aws_config)
create_assessment_report(assessmentId, name, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("POST", "/assessments/$(assessmentId)/reports", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("name"=>name), params)); aws_config=aws_config)

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

 Creates a new custom control in AWS 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.
"""
create_control(controlMappingSources, name; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("POST", "/controls", Dict{String, Any}("controlMappingSources"=>controlMappingSources, "name"=>name); aws_config=aws_config)
create_control(controlMappingSources, name, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("POST", "/controls", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("controlMappingSources"=>controlMappingSources, "name"=>name), params)); aws_config=aws_config)

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

 Deletes an assessment in AWS Audit Manager.

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

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

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

 Deletes a custom framework in AWS Audit Manager.

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

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

"""
    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 AWS Audit Manager.

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

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

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

 Deletes a custom control in AWS Audit Manager.

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

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

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

 Deregisters an account in AWS Audit Manager.

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

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

 Deregisters the delegated AWS administrator account from the AWS organization.

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

"""
    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 AWS Audit
Manager.

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

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

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

 Returns the registration status of an account in AWS Audit Manager.

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

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

 Returns an assessment from AWS Audit Manager.

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

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

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

 Returns a framework from AWS Audit Manager.

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

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

"""
    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 AWS Audit Manager.

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

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

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

 Returns a list of changelogs from AWS 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.
"""
get_change_logs(assessmentId; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/assessments/$(assessmentId)/changelogs"; aws_config=aws_config)
get_change_logs(assessmentId, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/assessments/$(assessmentId)/changelogs", params; aws_config=aws_config)

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

 Returns a control from AWS Audit Manager.

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

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

"""
    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.
"""
get_delegations(; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/delegations"; aws_config=aws_config)
get_delegations(params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/delegations", params; aws_config=aws_config)

"""
    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 AWS 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.

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

"""
    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 AWS 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.
"""
get_evidence_by_evidence_folder(assessmentId, controlSetId, evidenceFolderId; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/assessments/$(assessmentId)/controlSets/$(controlSetId)/evidenceFolders/$(evidenceFolderId)/evidence"; aws_config=aws_config)
get_evidence_by_evidence_folder(assessmentId, controlSetId, evidenceFolderId, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/assessments/$(assessmentId)/controlSets/$(controlSetId)/evidenceFolders/$(evidenceFolderId)/evidence", params; aws_config=aws_config)

"""
    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 AWS 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.

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

"""
    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 AWS 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.
"""
get_evidence_folders_by_assessment(assessmentId; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/assessments/$(assessmentId)/evidenceFolders"; aws_config=aws_config)
get_evidence_folders_by_assessment(assessmentId, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/assessments/$(assessmentId)/evidenceFolders", params; aws_config=aws_config)

"""
    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
AWS 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.
"""
get_evidence_folders_by_assessment_control(assessmentId, controlId, controlSetId; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/assessments/$(assessmentId)/evidenceFolders-by-assessment-control/$(controlSetId)/$(controlId)"; aws_config=aws_config)
get_evidence_folders_by_assessment_control(assessmentId, controlId, controlSetId, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/assessments/$(assessmentId)/evidenceFolders-by-assessment-control/$(controlSetId)/$(controlId)", params; aws_config=aws_config)

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

 Returns the name of the delegated AWS administrator account for the AWS organization.

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

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

 Returns a list of the in-scope AWS services for the specified assessment.

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

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

 Returns the settings for the specified AWS account.

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

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

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

 Returns a list of the frameworks available in the AWS 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.
"""
list_assessment_frameworks(frameworkType; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/assessmentFrameworks", Dict{String, Any}("frameworkType"=>frameworkType); aws_config=aws_config)
list_assessment_frameworks(frameworkType, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/assessmentFrameworks", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("frameworkType"=>frameworkType), params)); aws_config=aws_config)

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

 Returns a list of assessment reports created in AWS 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.
"""
list_assessment_reports(; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/assessmentReports"; aws_config=aws_config)
list_assessment_reports(params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/assessmentReports", params; aws_config=aws_config)

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

 Returns a list of current and past assessments from AWS 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.
"""
list_assessments(; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/assessments"; aws_config=aws_config)
list_assessments(params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/assessments", params; aws_config=aws_config)

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

 Returns a list of controls from AWS 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.
"""
list_controls(controlType; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/controls", Dict{String, Any}("controlType"=>controlType); aws_config=aws_config)
list_controls(controlType, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/controls", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("controlType"=>controlType), params)); aws_config=aws_config)

"""
    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.
"""
list_keywords_for_data_source(source; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/dataSourceKeywords", Dict{String, Any}("source"=>source); aws_config=aws_config)
list_keywords_for_data_source(source, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/dataSourceKeywords", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("source"=>source), params)); aws_config=aws_config)

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

 Returns a list of all AWS 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.
"""
list_notifications(; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/notifications"; aws_config=aws_config)
list_notifications(params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/notifications", params; aws_config=aws_config)

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

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

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

"""
list_tags_for_resource(resourceArn; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/tags/$(resourceArn)"; aws_config=aws_config)
list_tags_for_resource(resourceArn, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("GET", "/tags/$(resourceArn)", params; aws_config=aws_config)

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

 Enables AWS Audit Manager for the specified AWS account.

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

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

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

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

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

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

 Tags the specified resource in AWS Audit Manager.

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

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

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

 Removes a tag from a resource in AWS Audit Manager.

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

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

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

 Edits an AWS 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.
"""
update_assessment(assessmentId, scope; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("PUT", "/assessments/$(assessmentId)", Dict{String, Any}("scope"=>scope); aws_config=aws_config)
update_assessment(assessmentId, scope, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("PUT", "/assessments/$(assessmentId)", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("scope"=>scope), params)); aws_config=aws_config)

"""
    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 AWS 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.
"""
update_assessment_control(assessmentId, controlId, controlSetId; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("PUT", "/assessments/$(assessmentId)/controlSets/$(controlSetId)/controls/$(controlId)"; aws_config=aws_config)
update_assessment_control(assessmentId, controlId, controlSetId, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("PUT", "/assessments/$(assessmentId)/controlSets/$(controlSetId)/controls/$(controlId)", params; aws_config=aws_config)

"""
    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 AWS 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.

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

"""
    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 AWS 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.
"""
update_assessment_framework(controlSets, frameworkId, name; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("PUT", "/assessmentFrameworks/$(frameworkId)", Dict{String, Any}("controlSets"=>controlSets, "name"=>name); aws_config=aws_config)
update_assessment_framework(controlSets, frameworkId, name, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("PUT", "/assessmentFrameworks/$(frameworkId)", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("controlSets"=>controlSets, "name"=>name), params)); aws_config=aws_config)

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

 Updates the status of an assessment in AWS Audit Manager.

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

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

"""
    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 AWS 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.
"""
update_control(controlId, controlMappingSources, name; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("PUT", "/controls/$(controlId)", Dict{String, Any}("controlMappingSources"=>controlMappingSources, "name"=>name); aws_config=aws_config)
update_control(controlId, controlMappingSources, name, params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("PUT", "/controls/$(controlId)", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("controlMappingSources"=>controlMappingSources, "name"=>name), params)); aws_config=aws_config)

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

 Updates AWS 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 AWS KMS key details.
- `"snsTopic"`:  The Amazon Simple Notification Service (Amazon SNS) topic to which AWS
  Audit Manager sends notifications.
"""
update_settings(; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("PUT", "/settings"; aws_config=aws_config)
update_settings(params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = auditmanager("PUT", "/settings", params; aws_config=aws_config)

"""
    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 AWS Audit Manager.

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

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


text:
using Feather
using ProgressMeter
using JSON

df = Feather.read("save.feather")
size(df, 1)

counts = Dict{String, Dict}()
for key in ["a", "img", "script", "link"]
    counts[key] = Dict{String, Dict}()
end

p = Progress(size(df, 1), 0.1)
for i in 1:size(df, 1)
    sdom = get(df[i, 1])
    ddom = get(df[i, 2])
    key = get(df[i, 3])
    if isascii(sdom) && isascii(ddom)
        if ~haskey(counts[key], sdom)
            counts[key][sdom] = Dict{String, Int}()
        end
        if ~haskey(counts[key][sdom], ddom)
            counts[key][sdom][ddom] = 0
        end
        counts[key][sdom][ddom] += 1
    end
    next!(p)
end

open("save.json", "w") do f
    write(f, JSON.json(counts))
end

ext: jl

max_stars_repo_name: jpfairbanks/NewsGraphing

max_issues_repo_name: jpfairbanks/NewsGraphing

max_forks_repo_name: jpfairbanks/NewsGraphing


text:
module SavGol
using DSP, LinearAlgebra

export SG,apply_filter

function vandermonde(halfwindow::Int, polyDeg::Int, T::Type=Float64)
    @assert halfwindow>=0
    @assert polyDeg>=0
    x = T[i for i in -halfwindow:halfwindow]
    n = polyDeg+1
    m = length(x)
    V = Array{T}(undef, m,n)
    for i in 1:m
        V[i,1]=T(1)
    end
    for j in 2:n
        for i in 1:m
            V[i,j] = x[i] *V[i,j-1]
        end
    end
    return V
end

function SG(halfWindow::Int, polyDeg::Int, T::Type=Float64)
    @assert 2*halfWindow > polyDeg

    V = vandermonde(halfWindow, polyDeg,T)
    Q,R = qr(V)
    D = [factorial(i) for i in 0:polyDeg] |> Diagonal
    SG = D*R \ Matrix(I, size(V')...) * Q'
    return SG'
end

function apply_filter(filter::Vector, signal::Vector)
    @assert isodd(length(filter))

    halfWindow = round(Int, (length(filter)-1)/2)
    padded_signal = vcat(signal[1]*ones(halfWindow),signal,signal[end] * ones(halfWindow))
    filter_cross_signal = conv(filter[end:-1:1], padded_signal)
    return filter_cross_signal[2*halfWindow+1:end-2*halfWindow]
end

end # module


text:
# This file includes ODE networks.

"""
    $TYPEDSIGNATURES

Returns the differential equaiton problem of `net`. `tspan` is the time interval of the problem.
"""
function netproblem(net::SDENetwork, tspan = (0.0, 10.0), args...; kwargs...)
    f = function drift(dx, x, (net, args...), t)
        @views for (i, idx) in Iterators.partition(1:length(x), size(net.coupling, 1)) |> enumerate
            net.nodes[i](dx[idx], x[idx], nothing, t)
        end
        W = laplacian_matrix(net.graph)
        C = W ./ diag(W)
        dx .+= -net.ϵ * kron(C, net.coupling) * x
    end
    g = function diffusion(dx, x, (net, args...), t)
        dx .= kron(net.noisemat, net.coupling)
    end
    x0 = vcat([node.x for node in net.nodes]...)
    SDEProblem(f, g, x0, tspan, (net, args...); kwargs...)
end

function get_noise_rate_prototype(net::SDENetwork)
    n, l = size(net.noisemat)
    d = size(net.coupling, 1)
    zeros(n * d, l * d)
end


text:
using LocalRegistry
using LocalRegistry: find_package_path, find_registry_path, check_git_registry,
                     do_register
using Test
using Random
using Pkg
using CodecZlib

const TEST_GITCONFIG = Dict(
    "user.name" => "LocalRegistryTests",
    "user.email" => "localregistrytests@example.com",
)

include("utils.jl")

# Since these tests will need to modify active registries and we don't
# want interference from, e.g. the General registry, use a temporary
# DEPOT_PATH. But first add some packages while we have the General
# registry available. These will be used for some tests later.
Pkg.add("AutoHashEquals")
# Same as `pkg"dev --local Multibreak"` but properly using the API function.
Pkg.develop("Multibreak", shared = false)
empty!(DEPOT_PATH)
depot_path = mktempdir(@__DIR__)
push!(DEPOT_PATH, depot_path)

# We don't want Pkg to try to update our local registries since they
# contain fake URLs.
Pkg.UPDATED_REGISTRY_THIS_SESSION[] = true

@testset "Regression tests" begin
    include("regression.jl")
end

@testset "Register tests" begin
    include("register.jl")
end

@testset "Find package path" begin
    include("find_package_path.jl")
end

@testset "Find registry path" begin
    include("find_registry_path.jl")
end

@testset "Check git registry" begin
    include("check_git_registry.jl")
end

if VERSION < v"1.2"
    rm(depot_path, recursive = true)
end


text:
using Cliffords, BenchmarkTools

rand_phases = rand([1,-1,im,-im], 10_000)
function benchpauliphase(ns)
    r = Id
    XX = kron(X,X)
    for n in ns
        r = n ∘ XX
    end
    return r
end

rand_paulis = rand(allpaulis(2), 10_000)
benchpaulis(ps) = reduce(*, ps)

rand_c1seq = rand(1:24, 1_000)
benchc1(seq) = reduce(*, localclifford(n) for n in seq)

# create some of C2
C2 = Clifford[]
for _ in 1:100
    c = kron(localclifford(rand(1:24)), localclifford(rand(1:24)))
    if rand() > 0.5
        push!(C2, c)
    else
        push!(C2, c * CNOT * c)
    end
end

rand_c2seq = rand(1:100, 1_000)
benchc2(seq) = reduce(*, C2[n] for n in seq)

function benchpaulicliff()
    c = rand(C2)
    r = paulieye(2)
    IX = kron(Id, X)
    XI = kron(X, Id)
    for _ in 1:10_000
        r = c * IX
        r = c * XI
    end
    r
end

println("Pauli phase multiplication benchmarking:\n")
r0 = @benchmark benchpauliphase(rand_phases)
println(r0)

println("Pauli benchmarking:\n")
r1 = @benchmark benchpaulis(rand_paulis)
println(r1)

println("C1 benchmarking:\n")
r2 = @benchmark benchc1(rand_c1seq)
println(r2)

println("C2 benchmarking:\n")
r3 = @benchmark benchc2(rand_c2seq)
println(r3)


text:
using CardioModels
using Test

N = 100

@testset "Baselli" begin
    @test_throws DomainError getModel(5)
    model = getModel(1)
    result = predict(model, N)
    @test length(result) == 3
    @test length(result[1]) == N

    model_est = fitBaselli(result...)
    @test typeof(model_est) == BaselliModel

    post = postprocess(model_est, result[1], result[2])
    @test length(post) == 8
end

@testset "DeBoer" begin
    model = DeBoerModel()
    result = predict(model, N)
    @test length(result) == 5
    @test length(result[1]) == N

    result = predict!(model, N)
    @test model.hasState

    result = predict!(model, 1)
    @test length(result[1]) == 1
    @test model.S[end] == result[1][1]

end

@testset "Karemaker" begin
    model = KaremakerModel()
    result = predict(model, N)
    @test length(result) == 6
    @test length(result[1]) == N
end


text:
include("test_identical.jl")
include("test_atoms.jl")
include("test_molecules.jl")
include("test_unitconversions.jl")
include("test_clusters.jl")
include("test_sample.jl")

include("test_restarttools.jl")


text:
using Test, Bitcoin, Sockets

tests = ["rpc", "script", "tx", "CompactSizeUInt", "murmur3", "bloomfilter",  "address", "op", "helper", "network", "block"]

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


text:
using ModelingToolkit

@parameters t x
domains = [t ∈ IntervalDomain(0.0,1.0),
           x ∈ IntervalDomain(0.0,1.0)]

@parameters z
z ∈ (IntervalDomain(0.0,1.0) ⊗ IntervalDomain(0.0,1.0))

@parameters y
(x,y) ∈ CircleDomain()
@parameters r θ
(r,θ) ∈ CircleDomain(true)


text:
using Parameters
using QuantEcon: rouwenhorst
using Interpolations
using Optim
using LineSearches

# transformation functions
# closed interval [a, b]
function tab(x; a = 0, b = 1)
    (b + a)/2 + (b - a)/2 * ((2x)/(1 + x^2))
end

# open interval (a, b)
function logit(x; a = 0, b = 1)
    (b - a) * (1/(1 + exp(-x))) + a
end

function solvelast!(dp::NamedTuple, Ldict, Cdict, A1dict, Vdict, convdict; alg=GoldenSection())
    utility = dp.utility
    grid_A = dp.grid_A
    n = dp.n
    w = dp.w
    r = dp.r
    T = dp.T
    β = dp.β
    ρ = dp.ρ
    σ = dp.σ
    μ = dp.μ

    # discretize ar(1) process in wages: rouwenhorst(n, ρ, σ, μ)
    mc = rouwenhorst(n, ρ, σ, μ)
    ξ = exp.(mc.state_values)
    ℙ = mc.p

    for i in 1:n
        for s in 1:length(grid_A)
            # use bisection here
            opt = optimize(x -> -utility(x*(w[T] + ξ[i]) + grid_A[s]*(1+r), x), 0.0, 1.0, alg)
            xstar = Optim.minimizer(opt)
            Ldict[s, i, T] = xstar
            A1dict[s, i, T] = 0.0
            Cdict[s, i, T] = (w[T] + ξ[i])*Ldict[s, i, T] + grid_A[s]*(1+r)
            Vdict[s, i, T] = -Optim.minimum(opt)
            convdict[s, i, T] = Optim.converged(opt)
        end
    end
    return Ldict, Cdict, A1dict, Vdict, convdict
end

function solverest!(dp::NamedTuple, Ldict, Cdict, A1dict, Vdict, convdict;
                    t0::Int=1, transf=tab, alg=GradientDescent(linesearch=LineSearches.BackTracking()),
                    autodiff=:forward,
                    options=Optim.Options(iterations=1_000, g_tol=1e-4, x_tol=1e-4, f_tol=1e-4))
    utility = dp.utility
    grid_A = dp.grid_A
    n = dp.n
    w = dp.w
    r = dp.r
    T = dp.T
    β = dp.β
    ρ = dp.ρ
    σ = dp.σ
    μ = dp.μ

    # discretize ar(1) process in wages: rouwenhorst(n, ρ, σ, μ)
    mc = rouwenhorst(n, ρ, σ, μ)
    ξ = exp.(mc.state_values)
    ℙ = mc.p

    for t in T-1:-1:t0
        #=@time=# for i in 1:n
            EV = LinearInterpolation( grid_A, sum(ℙ[i, i′] .* Vdict[:, i′, t+1] for i′ in 1:n), extrapolation_bc = Line() )
            for s in 1:length(grid_A)
                # skip optimization for situations in which consumption would be negative
                if (w[t] + ξ[i]) + grid_A[s] * (1+r) < 0
                    convdict[s, i, t] = true
                    Ldict[s, i, t] = NaN
                    A1dict[s, i, t] = NaN
                    Cdict[s, i, t] = NaN
                    Vdict[s, i, t] = -Inf
                    continue
                end
                # x[1] is assets to carry forward, x[2] is labor supply
                a1_0 = isnan(A1dict[s, i, t+1]) ? 0.0 : A1dict[s, i, t+1]
                l_0 = isnan(Ldict[s, i, t+1]) ? 0.0 : Ldict[s, i, t+1]
                initial_x = [a1_0, l_0]
                opt = optimize(x -> -( utility(transf(x[2])*(w[t] + ξ[i]) + grid_A[s]*(1+r) - x[1], transf(x[2])) + β*EV(x[1]) ),
                        initial_x,
                        alg,
                        options,
                        autodiff = autodiff)
                xstar = Optim.minimizer(opt)
                convdict[s, i, t] = Optim.converged(opt)
                Ldict[s, i, t] = transf(xstar[2])
                A1dict[s, i, t] = xstar[1]
                Cdict[s, i, t] = (w[t] + ξ[i])*Ldict[s, i, t] + grid_A[s]*(1+r)
                Vdict[s, i, t] = -Optim.minimum(opt)
            end
        end
        #println("period ", t, " finished")
    end
    return Ldict, Cdict, A1dict, Vdict, convdict
end

function solvemodel!(dp::NamedTuple, Ldict, Cdict, A1dict, Vdict, convdict;
                    t0::Int=1, transf=tab, alg=GradientDescent(linesearch=LineSearches.BackTracking()),
                    autodiff=:forward,
                    options=Optim.Options(iterations=1_000, g_tol=1e-4, x_tol=1e-4, f_tol=1e-4))
    solvelast!(dp, Ldict, Cdict, A1dict, Vdict, convdict)
    solverest!(dp, Ldict, Cdict, A1dict, Vdict, convdict;
                t0=t0, transf=transf, alg=alg, autodiff=autodiff, options=options)
    return Ldict, Cdict, A1dict, Vdict, convdict
end

function utility(c, L)
    if c <= 0 || 1 - L <= 0
        return -1e9
    else
        return log(c) + log(1 - L)
    end
end

T = 65
w = Vector{Float64}(undef, T) # exogenous wages
w .= (900 .+ 20.0 .* (1:T) .- 0.5 .* (1:T).^2)

# create model object with default values for some parameters
Model = @with_kw (utility=utility, n=15, w, r=0.05, T=65, β=0.95,
                                grid_A=-1_000:10.0:10_000, ρ=0.9, σ=0.8, μ=0.0)

dp = Model(w=w)

Vdict = Array{Float64}(undef, (length(dp.grid_A), dp.n, dp.T))
Cdict = Array{Float64}(undef, (length(dp.grid_A), dp.n, dp.T))
Ldict = Array{Float64}(undef, (length(dp.grid_A), dp.n, dp.T))
A1dict = Array{Float64}(undef, (length(dp.grid_A), dp.n, dp.T))
convdict = Array{Bool}(undef, (length(dp.grid_A), dp.n, dp.T))

#@time solvemodel!(dp, Ldict, Cdict, A1dict, Vdict, convdict);

max_stars_repo_name: amrods/vfi-fh-dp

max_issues_repo_name: amrods/vfi-fh-dp

max_forks_repo_name: amrods/vfi-fh-dp


text:
using CSV
test = CSV.read("/Users/Matthias/.julia/dev/ExoplanetsSysSim/data/q1q17_dr25_gaia_fgk.csv",allowmissing=:all)

include("clusters.jl")
sim_param = setup_sim_param_model()

##### To generate the underlying systems:

@time cat_phys = generate_kepler_physical_catalog(sim_param)

##### For saving the underlying/true planets/systems:

f = open("physical_catalog_planets.txt", "w")
write_model_params(f, sim_param)
println(f, "target_id star_id planet_mass planet_radius period ecc")
for (i,targ) in enumerate(cat_phys.target)
    if length(targ.sys) > 1 #this should never happen
        println("There is more than one system for a given target? Check index: ", i)
    end
    if length(targ.sys[1].planet) > 0
        for (j,planet) in enumerate(targ.sys[1].planet)
            println(f, join([i, targ.sys[1].star.id, planet.mass, planet.radius, targ.sys[1].orbit[j].P, targ.sys[1].orbit[j].ecc], " "))
        end
    end
end
close(f)

f = open("physical_catalog_stars.txt", "w")
write_model_params(f, sim_param)
println(f, "target_id star_id star_mass star_radius num_planets")
for (i,targ) in enumerate(cat_phys.target)
    if length(targ.sys) > 1 #this should never happen
        println("There is more than one system for a given target? Check index: ", i)
    end
    println(f, join([i, targ.sys[1].star.id, targ.sys[1].star.mass, targ.sys[1].star.radius, length(targ.sys[1].planet)], " "))
end
close(f)

f = open("periods_all.out", "w")
write_model_params(f, sim_param)
for (i,targ) in enumerate(cat_phys.target)
    if length(targ.sys[1].orbit) > 0
        periods_sys = Array{Float64}(undef, length(targ.sys[1].orbit))
        for (j,planet) in enumerate(targ.sys[1].orbit)
            periods_sys[j] = planet.P #days
        end
        println(f, periods_sys)
    end
end
close(f)

f = open("eccentricities_all.out", "w")
write_model_params(f, sim_param)
for (i,targ) in enumerate(cat_phys.target)
    if length(targ.sys[1].orbit) > 0
        ecc_sys = Array{Float64}(undef, length(targ.sys[1].orbit))
        for (j,planet) in enumerate(targ.sys[1].orbit)
            ecc_sys[j] = planet.ecc
        end
        println(f, ecc_sys)
    end
end
close(f)

f = open("radii_all.out", "w")
write_model_params(f, sim_param)
for (i,targ) in enumerate(cat_phys.target)
    if length(targ.sys[1].planet) > 0
        radii_sys = Array{Float64}(undef, length(targ.sys[1].planet))
        for (j,planet) in enumerate(targ.sys[1].planet)
            radii_sys[j] = planet.radius #solar radii
        end
        println(f, radii_sys)
    end
end
close(f)

f = open("masses_all.out", "w")
write_model_params(f, sim_param)
for (i,targ) in enumerate(cat_phys.target)
    if length(targ.sys[1].planet) > 0
        masses_sys = Array{Float64}(undef, length(targ.sys[1].planet))
        for (j,planet) in enumerate(targ.sys[1].planet)
            masses_sys[j] = planet.mass #solar masses
        end
        println(f, masses_sys)
    end
end
close(f)

##### For saving the stellar properties of all the systems:

f = open("stellar_masses_with_planets.out", "w")
write_model_params(f, sim_param)
for (i,targ) in enumerate(cat_phys.target)
    if length(targ.sys[1].planet) > 0
        star_mass = targ.sys[1].star.mass #solar masses
        println(f, star_mass)
    end
end
close(f)

f = open("stellar_radii_with_planets.out", "w")
write_model_params(f, sim_param)
for (i,targ) in enumerate(cat_phys.target)
    if length(targ.sys[1].planet) > 0
        star_radius = targ.sys[1].star.radius #solar radii
        println(f, star_radius)
    end
end
close(f)

##### To generate the observed systems:

@time begin
    cat_phys_cut = ExoplanetsSysSim.generate_obs_targets(cat_phys,sim_param)
    cat_obs = observe_kepler_targets_single_obs(cat_phys_cut,sim_param)
    summary_stat = calc_summary_stats_model(cat_obs,sim_param)
end

##### For saving the observed planets/systems:

f = open("observed_catalog_planets.txt", "w")
write_model_params(f, sim_param)
println(f, "target_id star_id period depth duration")
for num_pl_in_sys in 1:length(summary_stat.cache["idx_n_tranets"])
    num_targets = length(summary_stat.cache["idx_n_tranets"][num_pl_in_sys])
    for (i,j) in enumerate(summary_stat.cache["idx_n_tranets"][num_pl_in_sys])
        for k in 1:num_pl_in_sys
            println(f, join([j, cat_phys.target[j].sys[1].star.id, map(ExoplanetsSysSim.period, cat_obs.target[j].obs)[k], map(ExoplanetsSysSim.depth, cat_obs.target[j].obs)[k], map(ExoplanetsSysSim.duration, cat_obs.target[j].obs)[k]], " "))
        end
    end
end
close(f)

f = open("observed_catalog_stars.txt", "w")
write_model_params(f, sim_param)
println(f, "target_id star_id star_mass star_radius num_obs_planets")
for num_pl_in_sys in 1:length(summary_stat.cache["idx_n_tranets"])
    num_targets = length(summary_stat.cache["idx_n_tranets"][num_pl_in_sys])
    for (i,j) in enumerate(summary_stat.cache["idx_n_tranets"][num_pl_in_sys])
        println(f, join([j, cat_phys.target[j].sys[1].star.id, cat_obs.target[j].star.mass, cat_obs.target[j].star.radius, length(cat_obs.target[j].obs)], " "))
    end
end
close(f)

f = open("periods.out", "w")
write_model_params(f, sim_param)
for num_pl_in_sys in 1:length(summary_stat.cache["idx_n_tranets"])
    num_targets = length(summary_stat.cache["idx_n_tranets"][num_pl_in_sys])
    period_array = Array{Float64}(undef, num_pl_in_sys, num_targets)
    for (i,j) in enumerate(summary_stat.cache["idx_n_tranets"][num_pl_in_sys])
        period_array[:,i] = map(ExoplanetsSysSim.period, cat_obs.target[j].obs)[1:num_pl_in_sys]
    end
    println(f,"# Periods of systems with ", num_pl_in_sys, " detected planets.")
    if length(period_array) > 0
        println(f,period_array')
    end
end
close(f)

f = open("depths.out", "w")
write_model_params(f, sim_param)
for num_pl_in_sys in 1:length(summary_stat.cache["idx_n_tranets"])
    num_targets = length(summary_stat.cache["idx_n_tranets"][num_pl_in_sys])
    depths_array = Array{Float64}(undef, num_pl_in_sys, num_targets)
    for (i,j) in enumerate(summary_stat.cache["idx_n_tranets"][num_pl_in_sys])
        depths_array[:,i] = map(ExoplanetsSysSim.depth, cat_obs.target[j].obs)[1:num_pl_in_sys]
    end
    println(f,"# Transit depths of systems with ", num_pl_in_sys, " detected planets.")
    if length(depths_array) > 0
        println(f,depths_array')
    end
end
close(f)

f = open("durations.out", "w")
write_model_params(f, sim_param)
for num_pl_in_sys in 1:length(summary_stat.cache["idx_n_tranets"])
    num_targets = length(summary_stat.cache["idx_n_tranets"][num_pl_in_sys])
    duration_array = Array{Float64}(undef, num_pl_in_sys, num_targets)
    for (i,j) in enumerate(summary_stat.cache["idx_n_tranets"][num_pl_in_sys])
        duration_array[:,i] = map(ExoplanetsSysSim.duration, cat_obs.target[j].obs)[1:num_pl_in_sys]
    end
    println(f,"# Transit durations of systems with ", num_pl_in_sys, " detected planets.")
    if length(duration_array) > 0
        println(f,duration_array')
    end
end
close(f)

#=
f = open("eccentricities.out", "w")
for num_pl_in_sys in 1:length(summary_stat.cache["idx_n_tranets"])
    num_targets = length(summary_stat.cache["idx_n_tranets"][num_pl_in_sys])
    ecc_array = Array{Float64}(num_pl_in_sys,num_targets)
    for (i,j) in enumerate(summary_stat.cache["idx_n_tranets"][num_pl_in_sys])
        ecc_array[:,i] = map(ExoplanetsSysSim.eccentricity, cat_obs.target[j].obs)[1:num_pl_in_sys]
    end
    println(f,"# Eccentricities of systems with ", num_pl_in_sys, " detected planets.")
    if length(ecc_array) > 0
        println(f,ecc_array')
    end
end
close(f)
=#

##### For saving the stellar properties of the systems with observed planets:

f = open("stellar_masses_obs.out", "w")
write_model_params(f, sim_param)
for num_pl_in_sys in 1:length(summary_stat.cache["idx_n_tranets"])
    num_targets = length(summary_stat.cache["idx_n_tranets"][num_pl_in_sys])
    stellar_mass_array = Array{Float64}(undef, num_targets)
    for (i,j) in enumerate(summary_stat.cache["idx_n_tranets"][num_pl_in_sys])
        stellar_mass_array[i] = cat_obs.target[j].star.mass
    end
    println(f,"# Stellar masses of systems with ", num_pl_in_sys, " detected planets.")
    if length(stellar_mass_array) > 0
        println(f, stellar_mass_array)
    end
end
close(f)

f = open("stellar_radii_obs.out", "w")
write_model_params(f, sim_param)
for num_pl_in_sys in 1:length(summary_stat.cache["idx_n_tranets"])
    num_targets = length(summary_stat.cache["idx_n_tranets"][num_pl_in_sys])
    stellar_radius_array = Array{Float64}(undef, num_targets)
    for (i,j) in enumerate(summary_stat.cache["idx_n_tranets"][num_pl_in_sys])
        stellar_radius_array[i] = cat_obs.target[j].star.radius
    end
    println(f,"# Stellar radii of systems with ", num_pl_in_sys, " detected planets.")
    if length(stellar_radius_array) > 0
        println(f, stellar_radius_array)
    end
end
close(f)


text:
# This file exemplifies the workflow from data input to optimization result generation

using ClustForOpt
using Clp
#using ClustForOpt_priv
#using Gurobi

# load data
ts_input_data = load_timeseries_data("CEP", "GER_18"; T=24, years=[2015]) #CEP

cep_input_data_GER=load_cep_data_provided"GER_18")

 # define simple extreme days of interest
 ev1 = SimpleExtremeValueDescr("wind-dena42","max","absolute")
 ev2 = SimpleExtremeValueDescr("solar-dena42","min","integral")
 ev3 = SimpleExtremeValueDescr("el_demand-dena21","max","absolute")
 ev = [ev1, ev2, ev3]
 # simple extreme day selection
 ts_input_data_mod,extr_vals,extr_idcs = simple_extr_val_sel(ts_input_data,ev;rep_mod_method="feasibility")

 # run clustering
ts_clust_res = run_clust(ts_input_data_mod;method="kmeans",representation="centroid",n_init=10,n_clust=5) # default k-means

# representation modification
ts_clust_extr = representation_modification(extr_vals,ts_clust_res.best_results)

 # optimization
opt_res = run_opt(ts_clust_extr,cep_input_data_GER;optimizer=Clp.Optimizer,co2_limit=1000.0)


text:
#############################################################################
# log_determinant.jl
# given V = {1, 2, ..., n}, M ∈ ℜ^{n×n}, F(S) = logdet(M_S)
#############################################################################

import Base.logdet

export logdet
export sign, monotonicity, modularity, evaluate

mutable struct LogDeterminantAtom <: SubmodFunc
  head::Symbol
  id_hash::UInt64
  children::Tuple{AbstractMatrix, CombiSet}
  size::Tuple{Int, Int}
  matrix::AbstractMatrix
  setvariables::Array{CombiSet}

  function LogDeterminantAtom(matrix::AbstractMatrix, S::CombiSet)
    if size(matrix)[1] != S.cardinality
      error("Cannot define a log determinant function when the number of volumns of the matrix is different from the size of the set variable.")
    else
      children = (matrix, S)
      setvariables = get_sv(S)
      return new(:logdet, hash(children), children, (1, 1), matrix, setvariables)
    end
  end
end

logdet(matrix::AbstractMatrix, S::CombiSet) = LogDeterminantAtom(matrix, S)

function sign(F::LogDeterminantAtom)
  return NoSign()
end

function monotonicity(F::LogDeterminantAtom)
  return (NoMonotonicity(), )
end

function modularity(F::LogDeterminantAtom)
  if isposdef(F.matrix)
    return SubModularity()
  elseif isposdef(-F.matrix)
    return SuperModularity()
  else
    return NotDetermined()
  end
end

function evaluate(F::LogDeterminantAtom)
  set = get_elements(F.children[2])
  if length(set) == 0
    return 0
  end
  matrix = F.matrix[]
  return logdet(F.matrix[set, set])
end


text:
using Ballistics

drone = scenario.createTarget(1.0,[800.0,0.0,-1000.0],[0.0,0.0,0.0])
lat = 45.0
lw = 0.0
X2w = 0.0

ΔAZ = 0.0

u₀ = 205.0
g₀ = 9.80665*(1-0.0026*cosd(2*lat))
#QE0 = 1/2*asin(g₀*range_/u₀^2)

lw = 0.0
X2w = 0.0
ΔAZ = 0.0
tc = 18.0 #calibers/turn
d = 0.1048 #m

w_bar = [0.0, 0.0, 0.0]

m = 14.97 #kg
yaw = 0.0
Ixx = 0.02326
It = 0.23118

projectile = scenario.createProjectile(d, m, [0.0, 0.0, 0.0],[0.0,0.0,0.0])
projectile.inertia = [Ixx, It]

gun = scenario.createCanon(tc, lw, X2w)

QE, AZ = ExternalBallistics.SixDof.QEfinderSixDof!(drone, projectile, u₀, g₀, gun, w_bar,lat)

#QE = 45.0
#AZ = 0.0
u0 = ExternalBallistics.SixDof.iniCondSixDof(deg2rad(QE), deg2rad(AZ), u₀, gun, d)

projectile = scenario.createProjectile(d,m,[u0[5],u0[6],u0[7]],[u0[11],u0[12],u0[13]],inertia=[Ixx,It])

tspan  = (0.0,1000.0)
Rz = 6.356766*1e6 #m
Ω = 7.292115*1e-5 #rad/s
ω_bar = [Ω*cosd(lat)*cosd(AZ), Ω*sind(lat), -Ω*cosd(lat)*sind(AZ)]
#αₑ_bar = [0.0,0.0,0.0]
#p = [projectile.inertia[1],w_bar, projectile.calibre, R, g₀, ω_bar, projectile.mass,drone.position,5.0]
p = [projectile.calibre, projectile.mass, projectile.inertia[1], projectile.inertia[2], ω_bar,g₀, Rz,drone.position,0.0]
#αₑ_bar  = ExternalBallistics.Mpmm.trajectoryMPMM!(u0, tspan, p, projectile, drone)
ExternalBallistics.SixDof.trajectorySixDof!(u0, tspan, p, projectile, drone)


text:
# TODO expand tests here
let
    f(x) = x[1]^4
    function g!(x, storage)
        storage[1] = 4 * x[1]^3
        return
    end

    d = DifferentiableFunction(f, g!)

    initial_x = [1.0]

    Optim.optimize(d, initial_x,
                   method = AcceleratedGradientDescent()
                   show_trace = true,
                   iterations = 10)
end


text:
using KitBase, FluxReconstruction, OrdinaryDiffEq, Langevin, LinearAlgebra, Plots
using ProgressMeter: @showprogress

begin
    x0 = 0
    x1 = 1
    ncell = 100
    nface = ncell + 1
    dx = (x1 - x0) / ncell
    deg = 2 # polynomial degree
    nsp = deg + 1
    γ = 7 / 5
    cfl = 0.05
    dt = cfl * dx / (2.0)
    t = 0.0
    tspan = (0.0, 0.15)

    uqMethod = "galerkin"
    nr = 9
    nRec = 18
    opType = "uniform"
    parameter1 = 0.95
    parameter2 = 1.05
end
ps = FRPSpace1D(x0, x1, ncell, deg)
uq = UQ1D(nr, nRec, parameter1, parameter2, opType, uqMethod)
V = vandermonde_matrix(ps.deg,ps.xpl)
VInv = inv(Array(ps.V))
l2 = [uq.t2Product[j-1, j-1] for j = 1:uq.nm+1]

cd(@__DIR__)
include("rhs.jl")
include("../filter.jl")

begin
    isRandomLocation = false#true
    isPrefilter = false#true

    u = zeros(ncell, nsp, 3, uq.nm+1)
    if isRandomLocation
        # stochastic location
        for i = 1:ncell, j = 1:nsp
            prim = zeros(3, uq.nq)

            for k = 1:uq.nq
                if ps.x[i] <= 0.5 + 0.05 * uq.op.quad.nodes[k]
                    prim[:, k] .= [1.0, 0.0, 0.5]
                else
                    prim[:, k] .= [0.125, 0.0, 0.625]
                end
            end

            prim_chaos = zeros(3, uq.nm+1)
            for k = 1:3
                prim_chaos[k, :] .= ran_chaos(prim[k, :], uq)
            end

            u[i, j, :, :] .= uq_prim_conserve(prim_chaos, γ, uq)
        end
    else
        # stochastic density
        for i = 1:ncell, j = 1:nsp
            prim = zeros(3, uq.nm+1)
            if ps.x[i] <= 0.5
                #prim[1, :] .= uq.pce
                prim[1, 1] = 1.0
                prim[2, 1] = 0.0
                prim[3, 1] = 0.5
            else
                prim[:, 1] .= [0.125, 0.0, 0.625]
            end

            u[i, j, :, :] .= uq_prim_conserve(prim, γ, uq)
        end
    end

    if isPrefilter
        # pre-filtering
        for j = 1:size(u, 1)
            for s = 1:size(u, 3)
                uModal = VInv * u[j, :, s, :]
                #FR.modal_filter!(uModal, 15e-2, 10e-5; filter = :l2opt)
                #FR.modal_filter!(uModal, 5e-2, 5e-2; filter = :l2)
                #FR.modal_filter!(uModal, 5, 5; filter = :exp)
                FR.modal_filter!(uModal; filter = :lasso)
                u[j, :, s, :] .= V * uModal
            end
        end
    end
end

p = (ps.J, ps.ll, ps.lr, ps.dl, ps.dhl, ps.dhr, γ, uq)
prob = ODEProblem(dudt!, u, tspan, p)
nt = tspan[2] ÷ dt |> Int
itg = init(prob, Midpoint(), saveat = tspan[2], adaptive = false, dt = dt)

@showprogress for iter = 1:nt
    step!(itg)

    for i = 1:size(itg.u, 1)
        #=
        ũ = VInv * itg.u[i, :, 1, 1]
        su = log10(ũ[end]^2 / sum(ũ.^2))
        isShock = detector(su, ps.deg)
        if isShock
            for j in axes(itg.u, 3), k in axes(itg.u, 4)
                û = VInv * itg.u[i, :, j, k]
                FR.modal_filter!(û, 1e-2; filter = :l2)
                itg.u[i, :, j, k] .= ps.V * û
            end
        end

        ṽ = itg.u[i, end÷2, 1, :]
        sv = log10(ṽ[end]^2 / sum(ṽ.^2))
        isShock = detector(sv, ps.deg)
        if isShock
            for j in axes(itg.u, 2), k in axes(itg.u, 3)
                ṽ = @view itg.u[i, j, k, :]
                FR.modal_filter!(ṽ, 5e-4; filter = :l2)
            end
        end=#

        #=ũ = VInv * itg.u[i, :, 1, 1]
        ṽ = itg.u[i, end÷2, 1, :]
        su = log10(ũ[end]^2 / sum(ũ.^2))
        sv = log10(ṽ[end]^2 / sum(ṽ.^2))
        isShock = max(shock_detector(su, ps.deg), shock_detector(sv, ps.deg))
        if isShock
            for s = 1:size(itg.u, 3)
                û = VInv * itg.u[i, :, s, :]
                #FR.filter_exp!(û, 10, 100)
                #FR.modal_filter!(û, 0.8e-2, 1e-6; filter = :l2)
                FR.modal_filter!(û, 10e-2, 5e-5; filter = :l2opt)
                #FR.modal_filter!(û, 5e-2, 5e-5; filter = :l2)
                #FR.modal_filter!(û, 5e-2, 5e-5; filter = :l2)
                itg.u[i, :, s, :] .= ps.V * û
            end
        end=#

        ũ = VInv * itg.u[i, :, 1, :]
        su = maximum([ũ[end, j]^2 / sum(ũ[:, j].^2) for j = 1:uq.nm+1])
        sv = maximum([ũ[j, end]^2 * uq.t2Product[uq.nm, uq.nm] / sum(ũ[j, :].^2 .* l2) for j = 1:nsp])
        isShock = max(shock_detector(log10(su), ps.deg), shock_detector(log10(sv), ps.deg))
        if isShock
            λ1 = dt * (su)
            λ2 = dt * (sv)

            for s = 1:size(itg.u, 3)
                û = VInv * itg.u[i, :, s, :]
                #FR.modal_filter!(û, λ1, λ2; filter = :l2)
                #FR.modal_filter!(û, λ1, λ2; filter = :l2opt)
                #FR.modal_filter!(û, 1e-2, 1e-3; filter = :l2)
                FR.modal_filter!(û; filter = :lasso)

                itg.u[i, :, s, :] .= ps.V * û
            end
        end

        tmp = @view itg.u[i, :, :, 1]
        positive_limiter(tmp, γ, ps.wp/2, ps.ll, ps.lr)

    end
end

begin
    x = zeros(ncell * nsp)
    w = zeros(ncell * nsp, 3, uq.nm+1)
    for i = 1:ncell
        idx0 = (i - 1) * nsp

        for j = 1:nsp
            idx = idx0 + j
            x[idx] = ps.xpg[i, j]

            w[idx, :, :] .= itg.u[i, j, :, :]
        end
    end

    sol = zeros(ncell*nsp, 3, 2)
    for i in axes(sol, 1)
        p1 = zeros(3, uq.nm+1)
        p1 = uq_conserve_prim(w[i, :, :], γ, uq)
        p1[end, :] .= lambda_tchaos(p1[end, :], 1.0, uq)

        for k = 1:3
            sol[i, k, 1] = mean(p1[k, :], uq.op)
            sol[i, k, 2] = std(p1[k, :], uq.op)
        end
    end

    pic1 = plot(x, sol[:, 1, 1], label="ρ", xlabel="x", ylabel="mean")
    plot!(pic1, x, sol[:, 2, 1], label="U")
    plot!(pic1, x, sol[:, 3, 1], label="T")
    pic2 = plot(x, sol[:, 1, 2], label="ρ", xlabel="x", ylabel="std")
    plot!(pic2, x, sol[:, 2, 2], label="U")
    plot!(pic2, x, sol[:, 3, 2], label="T")
    plot(pic1, pic2)
end

plot(x, sol0[:, 1, 2], label="No filter", xlabel="x", ylabel="ρ")
plot!(x, sol[:, 1, 2], label="adaptive L²")

sol0 = deepcopy(sol)

max_stars_repo_name: CSMMLab/FRSG

max_issues_repo_name: CSMMLab/FRSG

max_forks_repo_name: CSMMLab/FRSG


text:
using TimeZones.TZData: ARCHIVE_DIR, isarchive, readarchive, extract, tzdata_download

# Retrieve an archive only for testing purposes.
const ARCHIVE_PATH = tzdata_download(TZDATA_VERSION, ARCHIVE_DIR)

@test isarchive(ARCHIVE_PATH)
@test !isarchive(@__FILE__)

files = readarchive(ARCHIVE_PATH)
@test !isempty(files)
@test_throws ProcessFailedException readarchive(@__FILE__)

mktempdir() do temp_dir
    @test isempty(readdir(temp_dir))

    # Extract entire archive
    extract(ARCHIVE_PATH, temp_dir)
    @test !isempty(readdir(temp_dir))

    files = readarchive(ARCHIVE_PATH)
    for file in files
        rm(joinpath(temp_dir, file))
    end

    # Extract a single file
    extract(ARCHIVE_PATH, temp_dir, files[1])
    @test readdir(temp_dir) == files[1:1]

    # Extract multiple files and overwrite the first file
    extract(ARCHIVE_PATH, temp_dir, files[1:2])
    @test readdir(temp_dir) == files[1:2]

    # Attempt to decompress a non-archive
    @test_throws ProcessFailedException extract(@__FILE__, temp_dir)
end


text:
export LinearRelative, PackedLinearRelative

"""
$(TYPEDEF)

Default linear offset between two scalar variables.

```math
X_2 = X_1 + η_Z
```
"""
struct LinearRelative{N, T <: SamplableBelief} <: AbstractRelativeRoots
  Z::T
end

# need several helper constructors since the dimension over which LinearRelative will be used is unknown at this point
function LinearRelative{N}( z0::T=MvNormal(zeros(N), diagm(ones(N))) ) where {N, T <: SamplableBelief}
  #
  LinearRelative{N, T}(z0)
end

LinearRelative(::UniformScaling=LinearAlgebra.I) = LinearRelative{1}(MvNormal(zeros(1), diagm(ones(1))))
LinearRelative(nm::Distributions.ContinuousUnivariateDistribution) = LinearRelative{1, typeof(nm)}(nm)
LinearRelative(nm::MvNormal) = LinearRelative{length(nm.μ), typeof(nm)}(nm)
LinearRelative(nm::BallTreeDensity) = LinearRelative{Ndim(nm), typeof(nm)}(nm)

getDimension(::InstanceType{LinearRelative{N,<:SamplableBelief}}) where {N} = N
getManifolds(::InstanceType{LinearRelative{N,<:SamplableBelief}}) where {N} = tuple([:Euclid for i in 1:N]...)

getDomain(::InstanceType{LinearRelative{N,<:SamplableBelief}}) where N = ContinuousEuclid{N}
# getManifolds(fctType::Type{LinearRelative}) = getManifolds(getDomain(fctType))

getSample(cf::CalcFactor{<:LinearRelative}, N::Int=1) = (reshape(rand(cf.factor.Z,N),:,N), )

# new and simplified interface for both nonparametric and parametric
function (s::CalcFactor{<:LinearRelative})(z, x1, x2)
  # TODO convert to distance(distance(x2,x1),z) # or use dispatch on `-` -- what to do about `.-`
   # v0.21+, should return residual
  return z .- (x2 .- x1)
end

"""
$(TYPEDEF)
Serialization type for `LinearRelative` binary factor.
"""
mutable struct PackedLinearRelative <: PackedInferenceType
  Z::String
  PackedLinearRelative() = new()
  PackedLinearRelative(z::AS) where {AS <: AbstractString} = new(z)
end
function convert(::Type{PackedLinearRelative}, d::LinearRelative)
  PackedLinearRelative(convert(PackedSamplableBelief, d.Z))
end
function convert(::Type{LinearRelative}, d::PackedLinearRelative)
  LinearRelative(convert(SamplableBelief, d.Z))
end

#


text:
const Coord = SVector{4, Float64}
const Coord234 = Union{SVector{2, Float64}, SVector{3, Float64}, SVector{4, Float64}}

"""
    Transformation(source_crs, target_crs; area=C_NULL, ctx=C_NULL, always_xy=false)

Create a Transformation that is a pipeline between two known coordinate reference systems.
Transformation implements the
[CoordinateTransformations.jl](https://github.com/JuliaGeometry/CoordinateTransformations.jl)
API.

`source_crs` and `target_crs` can be:
- a "AUTHORITY:CODE", like EPSG:25832. When using that syntax for a source CRS, the created
  pipeline will expect that the coordinates respect the axis order and axis unit of the
  official definition (so for example, for EPSG:4326, with latitude first and longitude
  next, in degrees). Similarly, when using that syntax for a target CRS, output values will
  be emitted according to the official definition of this CRS. This behavior can be
  overruled by passing `always_xy=true`.
- a PROJ string, like "+proj=longlat +datum=WGS84". When using that syntax, the axis order
  and unit for geographic CRS will be longitude, latitude, and the unit degrees.
- the name of a CRS as found in the PROJ database, e.g "WGS84", "NAD27", etc.
- more generally any string accepted by `proj_create` representing a CRS
- besides an `AbstractString`, it can also accept a `Ptr{PJ}`, pointing to a CRS that was
  already created with `proj_create`

`area` sets the "area of use" for the Transformation. When it is supplied, the more accurate
transformation between two given systems can be chosen. When no area of use is specific and
several coordinate operations are possible depending on the area of use, this function will
internally store those candidate coordinate operations in the return PJ object. Each
subsequent coordinate transformation will then select the appropriate coordinate operation
by comparing the input coordinates with the area of use of the candidate coordinate
operations. The `area` pointer needs to be created using `proj_area_create`, filled using
`proj_area_set_bbox`, and destroyed using `proj_area_destroy`.

`ctx` determines the threading context. By default it is set to the global context. For
thread safety, use separate contexts created with `proj_context_create` or
`proj_context_clone`, and destroyed with `proj_context_destroy`.

`always_xy` can optionally fix the axis orderding to x,y or lon,lat order. By default it is
`false`, meaning the order is defined by the authority in charge of a given coordinate
reference system, as explained in [this PROJ FAQ
entry](https://proj.org/faq.html#why-is-the-axis-ordering-in-proj-not-consistent).

# Examples
```julia
julia> trans = Proj4.Transformation("EPSG:4326", "EPSG:28992", always_xy=true)
Transformation
    source: WGS 84 (with axis order normalized for visualization)
    target: Amersfoort / RD New

julia> trans((5.39, 52.16))  # this is in lon,lat order, since we set always_xy to true
2-element StaticArrays.SVector{2, Float64} with indices SOneTo(2):
 155191.3538124342
 463537.1362732911
```
"""
mutable struct Transformation <: CoordinateTransformations.Transformation
    pj::Ptr{PJ}
    function Transformation(pj::Ptr{PJ})
        trans = new(pj)
        finalizer(trans) do trans
            trans.pj = proj_destroy(trans.pj)
        end
        return trans
    end
end

function Transformation(
    source_crs::AbstractString,
    target_crs::AbstractString;
    area::Ptr{PJ_AREA} = C_NULL,
    ctx::Ptr{PJ_CONTEXT} = C_NULL,
    always_xy::Bool = false,
)
    pj = proj_create_crs_to_crs(source_crs, target_crs, area, ctx)
    pj = always_xy ? normalize_axis_order!(pj; ctx=ctx) : pj
    return Transformation(pj)
end

function Transformation(
    source_crs::Ptr{PJ},
    target_crs::Ptr{PJ};
    area::Ptr{PJ_AREA} = C_NULL,
    ctx::Ptr{PJ_CONTEXT} = C_NULL,
    always_xy::Bool = false,
)
    pj = proj_create_crs_to_crs_from_pj(source_crs, target_crs, area, ctx)
    pj = always_xy ? normalize_axis_order!(pj; ctx=ctx) : pj
    return Transformation(pj)
end

function Base.show(io::IO, trans::Transformation)
    source_crs = proj_get_source_crs(trans.pj)
    target_crs = proj_get_target_crs(trans.pj)
    source_info = proj_pj_info(source_crs)
    target_info = proj_pj_info(target_crs)
    source_description = unsafe_string(source_info.description)
    target_description = unsafe_string(target_info.description)
    print(io, """
    Transformation
        source: $source_description
        target: $target_description""")
end

"""
    normalize_axis_order!(pj::Ptr{PJ}; ctx = C_NULL)

Call proj_normalize_for_visualization on an object, and return the new object after freeing
the input object.
"""
function normalize_axis_order!(pj::Ptr{PJ}; ctx = C_NULL)
    pj_for_gis = proj_normalize_for_visualization(pj, ctx)
    proj_destroy(pj)
    return pj_for_gis
end

function Base.inv(
    trans::Transformation;
    area::Ptr{PJ_AREA} = C_NULL,
    ctx::Ptr{PJ_CONTEXT} = C_NULL,
    always_xy::Bool = false,
)
    target_crs = proj_get_source_crs(trans.pj)
    source_crs = proj_get_target_crs(trans.pj)
    return Transformation(source_crs, target_crs; area=area, ctx=ctx, always_xy=always_xy)
end

function (trans::Transformation)(coord::StaticVector{2,<:AbstractFloat})
    T = similar_type(coord)
    coord = SVector{4, Float64}(coord[1], coord[2], 0.0, Inf)
    p = proj_trans(trans.pj, PJ_FWD, coord)
    return T(p[1], p[2])
end

function (trans::Transformation)(coord::StaticVector{3,<:AbstractFloat})
    T = similar_type(coord)
    coord = SVector{4, Float64}(coord[1], coord[2], coord[3], Inf)
    p = proj_trans(trans.pj, PJ_FWD, coord)
    return T(p[1], p[2], p[3])
end

function (trans::Transformation)(coord::StaticVector{4,<:AbstractFloat})
    T = similar_type(coord)
    coord = SVector{4, Float64}(coord[1], coord[2], coord[3], coord[4])
    p = proj_trans(trans.pj, PJ_FWD, coord)
    return T(p)
end

function (trans::Transformation)(coord)::Coord234
    # avoid splatting for performance
    n = length(coord)
    coord = if n == 2
        proj_coord(coord[1], coord[2])
    elseif n == 3
        proj_coord(coord[1], coord[2], coord[3])
    elseif n == 4
        proj_coord(coord[1], coord[2], coord[3], coord[4])
    else
        throw(ArgumentError("input should be length 2, 3 or 4"))
    end

    p = proj_trans(trans.pj, PJ_FWD, coord)

    if n == 2
        return SVector{2, Float64}(p[1], p[2])
    elseif n == 3
        return SVector{3, Float64}(p[1], p[2], p[3])
    else
        return p
    end
end

function CoordinateTransformations.compose(
    trans1::Transformation,
    trans2::Transformation;
    area::Ptr{PJ_AREA} = C_NULL,
    ctx::Ptr{PJ_CONTEXT} = C_NULL,
    always_xy::Bool = false,
)
    # create a new Transformation from trans1 source to trans2 target
    # can also be typed as trans1 ∘ trans2, typed with \circ
    # a → b ∘ c → d doesn't make much sense if b != c, though we don't enforce it
    source_crs = proj_get_source_crs(trans1.pj)
    target_crs = proj_get_target_crs(trans2.pj)
    return Transformation(source_crs, target_crs; area=area, ctx=ctx, always_xy=always_xy)
end

"""
    enable_network!(active::Bool = true, ctx::Ptr{PJ_CONTEXT} = C_NULL)::Bool

Enable PROJ network access, if `active` is true, disable it if it is false. Optionally pass
a context to set it for that context, instead of the global one.

Returns true if network access is possible.
"""
function enable_network!(active::Bool = true, ctx::Ptr{PJ_CONTEXT} = C_NULL)
    enabled = proj_context_set_enable_network(Cint(active), ctx)
    return Bool(enabled)
end

"""
    network_enabled(ctx::Ptr{PJ_CONTEXT} = C_NULL)::Bool

Returns true if PROJ network access is enabled, false otherwise. Optionally pass a context
to check for that context, instead of the global one.
"""
function network_enabled(ctx::Ptr{PJ_CONTEXT} = C_NULL)
    enabled = proj_context_is_network_enabled(ctx)
    return Bool(enabled)
end


text:
"""
    DiscreteNonParametricSampler(xs, ps)

Data structure for efficiently sampling from an arbitrary probability mass
function defined by support `xs` and probabilities `ps`.
"""
struct DiscreteNonParametricSampler{T<:Real, S<:AbstractVector{T}} <: Sampleable{Univariate,Discrete}
    support::S
    aliastable::AliasTable

    DiscreteNonParametricSampler{T,S}(support::S, probs::AbstractVector{<:Real}) where {T<:Real,S<:AbstractVector{T}} =
        new(support, AliasTable(probs))
end

DiscreteNonParametricSampler(support::S, probs::AbstractVector{<:Real}) where {T<:Real,S<:AbstractVector{T}} =
    DiscreteNonParametricSampler{T,S}(support, probs)

rand(s::DiscreteNonParametricSampler) =
    (@inbounds v = s.support[rand(s.aliastable)]; v)


text:
using HTTP
using Dash

app = dash()
app.layout = html_div() do
    dcc_input(id = "input", value = "ab"),
    html_div(id = "output")
end

callback!(app,
    Output("output", "children"),
    Input("input", "value")
) do value
    cookie = HTTP.Cookie("dash_cookie", value * " - cookie")

    println(String(cookie, false))
    http_response = callback_context().response
    push!(http_response.headers, "Set-Cookie"=>String(cookie, false))
    return value * " - output"
end

run_server(app)