text:
# This file is auto-generated by AWSMetadata.jl
using AWS
using AWS.AWSServices: guardduty
using AWS.Compat
using AWS.UUIDs
"""
    AcceptInvitation()

Accepts the invitation to be monitored by a master GuardDuty account.

# Required Parameters
- `detectorId`: The unique ID of the detector of the GuardDuty member account.
- `invitationId`: The value that is used to validate the master account to the member account.
- `masterId`: The account ID of the master GuardDuty account whose invitation you're accepting.

"""

accept_invitation(detectorId, invitationId, masterId; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/master", Dict{String, Any}("invitationId"=>invitationId, "masterId"=>masterId); aws_config=aws_config)
accept_invitation(detectorId, invitationId, masterId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/master", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("invitationId"=>invitationId, "masterId"=>masterId), args)); aws_config=aws_config)

"""
    ArchiveFindings()

Archives GuardDuty findings that are specified by the list of finding IDs.  Only the master account can archive findings. Member accounts don't have permission to archive findings from their accounts.

# Required Parameters
- `detectorId`: The ID of the detector that specifies the GuardDuty service whose findings you want to archive.
- `findingIds`: The IDs of the findings that you want to archive.

"""

archive_findings(detectorId, findingIds; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/findings/archive", Dict{String, Any}("findingIds"=>findingIds); aws_config=aws_config)
archive_findings(detectorId, findingIds, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/findings/archive", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("findingIds"=>findingIds), args)); aws_config=aws_config)

"""
    CreateDetector()

Creates a single Amazon GuardDuty detector. A detector is a resource that represents the GuardDuty service. To start using GuardDuty, you must create a detector in each Region where you enable the service. You can have only one detector per account per Region. All data sources are enabled in a new detector by default.

# Required Parameters
- `enable`: A Boolean value that specifies whether the detector is to be enabled.

# Optional Parameters
- `clientToken`: The idempotency token for the create request.
- `dataSources`: An object that describes which data sources will be enabled for the detector.
- `findingPublishingFrequency`: An enum value that specifies how frequently updated findings are exported.
- `tags`: The tags to be added to a new detector resource.
"""

create_detector(enable; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector", Dict{String, Any}("enable"=>enable, "clientToken"=>string(uuid4())); aws_config=aws_config)
create_detector(enable, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("enable"=>enable, "clientToken"=>string(uuid4())), args)); aws_config=aws_config)

"""
    CreateFilter()

Creates a filter using the specified finding criteria.

# Required Parameters
- `detectorId`: The unique ID of the detector of the GuardDuty account that you want to create a filter for.
- `findingCriteria`: Represents the criteria to be used in the filter for querying findings. You can only use the following attributes to query findings:   accountId   region   confidence   id   resource.accessKeyDetails.accessKeyId   resource.accessKeyDetails.principalId   resource.accessKeyDetails.userName   resource.accessKeyDetails.userType   resource.instanceDetails.iamInstanceProfile.id   resource.instanceDetails.imageId   resource.instanceDetails.instanceId   resource.instanceDetails.outpostArn   resource.instanceDetails.networkInterfaces.ipv6Addresses   resource.instanceDetails.networkInterfaces.privateIpAddresses.privateIpAddress   resource.instanceDetails.networkInterfaces.publicDnsName   resource.instanceDetails.networkInterfaces.publicIp   resource.instanceDetails.networkInterfaces.securityGroups.groupId   resource.instanceDetails.networkInterfaces.securityGroups.groupName   resource.instanceDetails.networkInterfaces.subnetId   resource.instanceDetails.networkInterfaces.vpcId   resource.instanceDetails.tags.key   resource.instanceDetails.tags.value   resource.resourceType   service.action.actionType   service.action.awsApiCallAction.api   service.action.awsApiCallAction.callerType   service.action.awsApiCallAction.remoteIpDetails.city.cityName   service.action.awsApiCallAction.remoteIpDetails.country.countryName   service.action.awsApiCallAction.remoteIpDetails.ipAddressV4   service.action.awsApiCallAction.remoteIpDetails.organization.asn   service.action.awsApiCallAction.remoteIpDetails.organization.asnOrg   service.action.awsApiCallAction.serviceName   service.action.dnsRequestAction.domain   service.action.networkConnectionAction.blocked   service.action.networkConnectionAction.connectionDirection   service.action.networkConnectionAction.localPortDetails.port   service.action.networkConnectionAction.protocol   service.action.networkConnectionAction.localIpDetails.ipAddressV4   service.action.networkConnectionAction.remoteIpDetails.city.cityName   service.action.networkConnectionAction.remoteIpDetails.country.countryName   service.action.networkConnectionAction.remoteIpDetails.ipAddressV4   service.action.networkConnectionAction.remoteIpDetails.organization.asn   service.action.networkConnectionAction.remoteIpDetails.organization.asnOrg   service.action.networkConnectionAction.remotePortDetails.port   service.additionalInfo.threatListName   service.archived When this attribute is set to TRUE, only archived findings are listed. When it's set to FALSE, only unarchived findings are listed. When this attribute is not set, all existing findings are listed.   service.resourceRole   severity   type   updatedAt Type: ISO 8601 string format: YYYY-MM-DDTHH:MM:SS.SSSZ or YYYY-MM-DDTHH:MM:SSZ depending on whether the value contains milliseconds.
- `name`: The name of the filter.

# Optional Parameters
- `action`: Specifies the action that is to be applied to the findings that match the filter.
- `clientToken`: The idempotency token for the create request.
- `description`: The description of the filter.
- `rank`: Specifies the position of the filter in the list of current filters. Also specifies the order in which this filter is applied to the findings.
- `tags`: The tags to be added to a new filter resource.
"""

create_filter(detectorId, findingCriteria, name; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/filter", Dict{String, Any}("findingCriteria"=>findingCriteria, "name"=>name, "clientToken"=>string(uuid4())); aws_config=aws_config)
create_filter(detectorId, findingCriteria, name, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/filter", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("findingCriteria"=>findingCriteria, "name"=>name, "clientToken"=>string(uuid4())), args)); aws_config=aws_config)

"""
    CreateIPSet()

Creates a new IPSet, which is called a trusted IP list in the console user interface. An IPSet is a list of IP addresses that are trusted for secure communication with AWS infrastructure and applications. GuardDuty doesn't generate findings for IP addresses that are included in IPSets. Only users from the master account can use this operation.

# Required Parameters
- `activate`: A Boolean value that indicates whether GuardDuty is to start using the uploaded IPSet.
- `detectorId`: The unique ID of the detector of the GuardDuty account that you want to create an IPSet for.
- `format`: The format of the file that contains the IPSet.
- `location`: The URI of the file that contains the IPSet. For example: https://s3.us-west-2.amazonaws.com/my-bucket/my-object-key.
- `name`: The user-friendly name to identify the IPSet.  Allowed characters are alphanumerics, spaces, hyphens (-), and underscores (_).

# Optional Parameters
- `clientToken`: The idempotency token for the create request.
- `tags`: The tags to be added to a new IP set resource.
"""

create_ipset(activate, detectorId, format, location, name; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/ipset", Dict{String, Any}("activate"=>activate, "format"=>format, "location"=>location, "name"=>name, "clientToken"=>string(uuid4())); aws_config=aws_config)
create_ipset(activate, detectorId, format, location, name, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/ipset", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("activate"=>activate, "format"=>format, "location"=>location, "name"=>name, "clientToken"=>string(uuid4())), args)); aws_config=aws_config)

"""
    CreateMembers()

Creates member accounts of the current AWS account by specifying a list of AWS account IDs. This step is a prerequisite for managing the associated member accounts either by invitation or through an organization. When using Create Members as an organizations delegated administrator this action will enable GuardDuty in the added member accounts, with the exception of the organization master account, which must enable GuardDuty prior to being added as a member. If you are adding accounts by invitation use this action after GuardDuty has been enabled in potential member accounts and before using  Invite Members .

# Required Parameters
- `accountDetails`: A list of account ID and email address pairs of the accounts that you want to associate with the master GuardDuty account.
- `detectorId`: The unique ID of the detector of the GuardDuty account that you want to associate member accounts with.

"""

create_members(accountDetails, detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/member", Dict{String, Any}("accountDetails"=>accountDetails); aws_config=aws_config)
create_members(accountDetails, detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/member", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("accountDetails"=>accountDetails), args)); aws_config=aws_config)

"""
    CreatePublishingDestination()

Creates a publishing destination to export findings to. The resource to export findings to must exist before you use this operation.

# Required Parameters
- `destinationProperties`: The properties of the publishing destination, including the ARNs for the destination and the KMS key used for encryption.
- `destinationType`: The type of resource for the publishing destination. Currently only Amazon S3 buckets are supported.
- `detectorId`: The ID of the GuardDuty detector associated with the publishing destination.

# Optional Parameters
- `clientToken`: The idempotency token for the request.
"""

create_publishing_destination(destinationProperties, destinationType, detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/publishingDestination", Dict{String, Any}("destinationProperties"=>destinationProperties, "destinationType"=>destinationType, "clientToken"=>string(uuid4())); aws_config=aws_config)
create_publishing_destination(destinationProperties, destinationType, detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/publishingDestination", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("destinationProperties"=>destinationProperties, "destinationType"=>destinationType, "clientToken"=>string(uuid4())), args)); aws_config=aws_config)

"""
    CreateSampleFindings()

Generates example findings of types specified by the list of finding types. If 'NULL' is specified for findingTypes, the API generates example findings of all supported finding types.

# Required Parameters
- `detectorId`: The ID of the detector to create sample findings for.

# Optional Parameters
- `findingTypes`: The types of sample findings to generate.
"""

create_sample_findings(detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/findings/create"; aws_config=aws_config)
create_sample_findings(detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/findings/create", args; aws_config=aws_config)

"""
    CreateThreatIntelSet()

Creates a new ThreatIntelSet. ThreatIntelSets consist of known malicious IP addresses. GuardDuty generates findings based on ThreatIntelSets. Only users of the master account can use this operation.

# Required Parameters
- `activate`: A Boolean value that indicates whether GuardDuty is to start using the uploaded ThreatIntelSet.
- `detectorId`: The unique ID of the detector of the GuardDuty account that you want to create a threatIntelSet for.
- `format`: The format of the file that contains the ThreatIntelSet.
- `location`: The URI of the file that contains the ThreatIntelSet. For example: https://s3.us-west-2.amazonaws.com/my-bucket/my-object-key.
- `name`: A user-friendly ThreatIntelSet name displayed in all findings that are generated by activity that involves IP addresses included in this ThreatIntelSet.

# Optional Parameters
- `clientToken`: The idempotency token for the create request.
- `tags`: The tags to be added to a new threat list resource.
"""

create_threat_intel_set(activate, detectorId, format, location, name; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/threatintelset", Dict{String, Any}("activate"=>activate, "format"=>format, "location"=>location, "name"=>name, "clientToken"=>string(uuid4())); aws_config=aws_config)
create_threat_intel_set(activate, detectorId, format, location, name, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/threatintelset", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("activate"=>activate, "format"=>format, "location"=>location, "name"=>name, "clientToken"=>string(uuid4())), args)); aws_config=aws_config)

"""
    DeclineInvitations()

Declines invitations sent to the current member account by AWS accounts specified by their account IDs.

# Required Parameters
- `accountIds`: A list of account IDs of the AWS accounts that sent invitations to the current member account that you want to decline invitations from.

"""

decline_invitations(accountIds; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/invitation/decline", Dict{String, Any}("accountIds"=>accountIds); aws_config=aws_config)
decline_invitations(accountIds, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/invitation/decline", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("accountIds"=>accountIds), args)); aws_config=aws_config)

"""
    DeleteDetector()

Deletes an Amazon GuardDuty detector that is specified by the detector ID.

# Required Parameters
- `detectorId`: The unique ID of the detector that you want to delete.

"""

delete_detector(detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("DELETE", "/detector/$(detectorId)"; aws_config=aws_config)
delete_detector(detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("DELETE", "/detector/$(detectorId)", args; aws_config=aws_config)

"""
    DeleteFilter()

Deletes the filter specified by the filter name.

# Required Parameters
- `detectorId`: The unique ID of the detector that the filter is associated with.
- `filterName`: The name of the filter that you want to delete.

"""

delete_filter(detectorId, filterName; aws_config::AWSConfig=global_aws_config()) = guardduty("DELETE", "/detector/$(detectorId)/filter/$(filterName)"; aws_config=aws_config)
delete_filter(detectorId, filterName, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("DELETE", "/detector/$(detectorId)/filter/$(filterName)", args; aws_config=aws_config)

"""
    DeleteIPSet()

Deletes the IPSet specified by the ipSetId. IPSets are called trusted IP lists in the console user interface.

# Required Parameters
- `detectorId`: The unique ID of the detector associated with the IPSet.
- `ipSetId`: The unique ID of the IPSet to delete.

"""

delete_ipset(detectorId, ipSetId; aws_config::AWSConfig=global_aws_config()) = guardduty("DELETE", "/detector/$(detectorId)/ipset/$(ipSetId)"; aws_config=aws_config)
delete_ipset(detectorId, ipSetId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("DELETE", "/detector/$(detectorId)/ipset/$(ipSetId)", args; aws_config=aws_config)

"""
    DeleteInvitations()

Deletes invitations sent to the current member account by AWS accounts specified by their account IDs.

# Required Parameters
- `accountIds`: A list of account IDs of the AWS accounts that sent invitations to the current member account that you want to delete invitations from.

"""

delete_invitations(accountIds; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/invitation/delete", Dict{String, Any}("accountIds"=>accountIds); aws_config=aws_config)
delete_invitations(accountIds, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/invitation/delete", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("accountIds"=>accountIds), args)); aws_config=aws_config)

"""
    DeleteMembers()

Deletes GuardDuty member accounts (to the current GuardDuty master account) specified by the account IDs.

# Required Parameters
- `accountIds`: A list of account IDs of the GuardDuty member accounts that you want to delete.
- `detectorId`: The unique ID of the detector of the GuardDuty account whose members you want to delete.

"""

delete_members(accountIds, detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/member/delete", Dict{String, Any}("accountIds"=>accountIds); aws_config=aws_config)
delete_members(accountIds, detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/member/delete", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("accountIds"=>accountIds), args)); aws_config=aws_config)

"""
    DeletePublishingDestination()

Deletes the publishing definition with the specified destinationId.

# Required Parameters
- `destinationId`: The ID of the publishing destination to delete.
- `detectorId`: The unique ID of the detector associated with the publishing destination to delete.

"""

delete_publishing_destination(destinationId, detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("DELETE", "/detector/$(detectorId)/publishingDestination/$(destinationId)"; aws_config=aws_config)
delete_publishing_destination(destinationId, detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("DELETE", "/detector/$(detectorId)/publishingDestination/$(destinationId)", args; aws_config=aws_config)

"""
    DeleteThreatIntelSet()

Deletes the ThreatIntelSet specified by the ThreatIntelSet ID.

# Required Parameters
- `detectorId`: The unique ID of the detector that the threatIntelSet is associated with.
- `threatIntelSetId`: The unique ID of the threatIntelSet that you want to delete.

"""

delete_threat_intel_set(detectorId, threatIntelSetId; aws_config::AWSConfig=global_aws_config()) = guardduty("DELETE", "/detector/$(detectorId)/threatintelset/$(threatIntelSetId)"; aws_config=aws_config)
delete_threat_intel_set(detectorId, threatIntelSetId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("DELETE", "/detector/$(detectorId)/threatintelset/$(threatIntelSetId)", args; aws_config=aws_config)

"""
    DescribeOrganizationConfiguration()

Returns information about the account selected as the delegated administrator for GuardDuty.

# Required Parameters
- `detectorId`: The ID of the detector to retrieve information about the delegated administrator from.

"""

describe_organization_configuration(detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)/admin"; aws_config=aws_config)
describe_organization_configuration(detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)/admin", args; aws_config=aws_config)

"""
    DescribePublishingDestination()

Returns information about the publishing destination specified by the provided destinationId.

# Required Parameters
- `destinationId`: The ID of the publishing destination to retrieve.
- `detectorId`: The unique ID of the detector associated with the publishing destination to retrieve.

"""

describe_publishing_destination(destinationId, detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)/publishingDestination/$(destinationId)"; aws_config=aws_config)
describe_publishing_destination(destinationId, detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)/publishingDestination/$(destinationId)", args; aws_config=aws_config)

"""
    DisableOrganizationAdminAccount()

Disables an AWS account within the Organization as the GuardDuty delegated administrator.

# Required Parameters
- `adminAccountId`: The AWS Account ID for the organizations account to be disabled as a GuardDuty delegated administrator.

"""

disable_organization_admin_account(adminAccountId; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/admin/disable", Dict{String, Any}("adminAccountId"=>adminAccountId); aws_config=aws_config)
disable_organization_admin_account(adminAccountId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/admin/disable", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("adminAccountId"=>adminAccountId), args)); aws_config=aws_config)

"""
    DisassociateFromMasterAccount()

Disassociates the current GuardDuty member account from its master account.

# Required Parameters
- `detectorId`: The unique ID of the detector of the GuardDuty member account.

"""

disassociate_from_master_account(detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/master/disassociate"; aws_config=aws_config)
disassociate_from_master_account(detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/master/disassociate", args; aws_config=aws_config)

"""
    DisassociateMembers()

Disassociates GuardDuty member accounts (to the current GuardDuty master account) specified by the account IDs.

# Required Parameters
- `accountIds`: A list of account IDs of the GuardDuty member accounts that you want to disassociate from the master account.
- `detectorId`: The unique ID of the detector of the GuardDuty account whose members you want to disassociate from the master account.

"""

disassociate_members(accountIds, detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/member/disassociate", Dict{String, Any}("accountIds"=>accountIds); aws_config=aws_config)
disassociate_members(accountIds, detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/member/disassociate", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("accountIds"=>accountIds), args)); aws_config=aws_config)

"""
    EnableOrganizationAdminAccount()

Enables an AWS account within the organization as the GuardDuty delegated administrator.

# Required Parameters
- `adminAccountId`: The AWS Account ID for the organization account to be enabled as a GuardDuty delegated administrator.

"""

enable_organization_admin_account(adminAccountId; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/admin/enable", Dict{String, Any}("adminAccountId"=>adminAccountId); aws_config=aws_config)
enable_organization_admin_account(adminAccountId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/admin/enable", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("adminAccountId"=>adminAccountId), args)); aws_config=aws_config)

"""
    GetDetector()

Retrieves an Amazon GuardDuty detector specified by the detectorId.

# Required Parameters
- `detectorId`: The unique ID of the detector that you want to get.

"""

get_detector(detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)"; aws_config=aws_config)
get_detector(detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)", args; aws_config=aws_config)

"""
    GetFilter()

Returns the details of the filter specified by the filter name.

# Required Parameters
- `detectorId`: The unique ID of the detector that the filter is associated with.
- `filterName`: The name of the filter you want to get.

"""

get_filter(detectorId, filterName; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)/filter/$(filterName)"; aws_config=aws_config)
get_filter(detectorId, filterName, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)/filter/$(filterName)", args; aws_config=aws_config)

"""
    GetFindings()

Describes Amazon GuardDuty findings specified by finding IDs.

# Required Parameters
- `detectorId`: The ID of the detector that specifies the GuardDuty service whose findings you want to retrieve.
- `findingIds`: The IDs of the findings that you want to retrieve.

# Optional Parameters
- `sortCriteria`: Represents the criteria used for sorting findings.
"""

get_findings(detectorId, findingIds; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/findings/get", Dict{String, Any}("findingIds"=>findingIds); aws_config=aws_config)
get_findings(detectorId, findingIds, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/findings/get", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("findingIds"=>findingIds), args)); aws_config=aws_config)

"""
    GetFindingsStatistics()

Lists Amazon GuardDuty findings statistics for the specified detector ID.

# Required Parameters
- `detectorId`: The ID of the detector that specifies the GuardDuty service whose findings' statistics you want to retrieve.
- `findingStatisticTypes`: The types of finding statistics to retrieve.

# Optional Parameters
- `findingCriteria`: Represents the criteria that is used for querying findings.
"""

get_findings_statistics(detectorId, findingStatisticTypes; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/findings/statistics", Dict{String, Any}("findingStatisticTypes"=>findingStatisticTypes); aws_config=aws_config)
get_findings_statistics(detectorId, findingStatisticTypes, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/findings/statistics", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("findingStatisticTypes"=>findingStatisticTypes), args)); aws_config=aws_config)

"""
    GetIPSet()

Retrieves the IPSet specified by the ipSetId.

# Required Parameters
- `detectorId`: The unique ID of the detector that the IPSet is associated with.
- `ipSetId`: The unique ID of the IPSet to retrieve.

"""

get_ipset(detectorId, ipSetId; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)/ipset/$(ipSetId)"; aws_config=aws_config)
get_ipset(detectorId, ipSetId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)/ipset/$(ipSetId)", args; aws_config=aws_config)

"""
    GetInvitationsCount()

Returns the count of all GuardDuty membership invitations that were sent to the current member account except the currently accepted invitation.

"""

get_invitations_count(; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/invitation/count"; aws_config=aws_config)
get_invitations_count(args::AbstractDict{String, Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/invitation/count", args; aws_config=aws_config)

"""
    GetMasterAccount()

Provides the details for the GuardDuty master account associated with the current GuardDuty member account.

# Required Parameters
- `detectorId`: The unique ID of the detector of the GuardDuty member account.

"""

get_master_account(detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)/master"; aws_config=aws_config)
get_master_account(detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)/master", args; aws_config=aws_config)

"""
    GetMemberDetectors()

Describes which data sources are enabled for the member account's detector.

# Required Parameters
- `accountIds`: The account ID of the member account.
- `detectorId`: The detector ID for the master account.

"""

get_member_detectors(accountIds, detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/member/detector/get", Dict{String, Any}("accountIds"=>accountIds); aws_config=aws_config)
get_member_detectors(accountIds, detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/member/detector/get", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("accountIds"=>accountIds), args)); aws_config=aws_config)

"""
    GetMembers()

Retrieves GuardDuty member accounts (to the current GuardDuty master account) specified by the account IDs.

# Required Parameters
- `accountIds`: A list of account IDs of the GuardDuty member accounts that you want to describe.
- `detectorId`: The unique ID of the detector of the GuardDuty account whose members you want to retrieve.

"""

get_members(accountIds, detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/member/get", Dict{String, Any}("accountIds"=>accountIds); aws_config=aws_config)
get_members(accountIds, detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/member/get", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("accountIds"=>accountIds), args)); aws_config=aws_config)

"""
    GetThreatIntelSet()

Retrieves the ThreatIntelSet that is specified by the ThreatIntelSet ID.

# Required Parameters
- `detectorId`: The unique ID of the detector that the threatIntelSet is associated with.
- `threatIntelSetId`: The unique ID of the threatIntelSet that you want to get.

"""

get_threat_intel_set(detectorId, threatIntelSetId; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)/threatintelset/$(threatIntelSetId)"; aws_config=aws_config)
get_threat_intel_set(detectorId, threatIntelSetId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)/threatintelset/$(threatIntelSetId)", args; aws_config=aws_config)

"""
    GetUsageStatistics()

Lists Amazon GuardDuty usage statistics over the last 30 days for the specified detector ID. For newly enabled detectors or data sources the cost returned will include only the usage so far under 30 days, this may differ from the cost metrics in the console, which projects usage over 30 days to provide a monthly cost estimate. For more information see Understanding How Usage Costs are Calculated.

# Required Parameters
- `detectorId`: The ID of the detector that specifies the GuardDuty service whose usage statistics you want to retrieve.
- `usageCriteria`: Represents the criteria used for querying usage.
- `usageStatisticsType`: The type of usage statistics to retrieve.

# Optional Parameters
- `maxResults`: The maximum number of results to return in the response.
- `nextToken`: A token to use for paginating results that are returned in the response. Set the value of this parameter to null for the first request to a list action. For subsequent calls, use the NextToken value returned from the previous request to continue listing results after the first page.
- `unit`: The currency unit you would like to view your usage statistics in. Current valid values are USD.
"""

get_usage_statistics(detectorId, usageCriteria, usageStatisticsType; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/usage/statistics", Dict{String, Any}("usageCriteria"=>usageCriteria, "usageStatisticsType"=>usageStatisticsType); aws_config=aws_config)
get_usage_statistics(detectorId, usageCriteria, usageStatisticsType, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/usage/statistics", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("usageCriteria"=>usageCriteria, "usageStatisticsType"=>usageStatisticsType), args)); aws_config=aws_config)

"""
    InviteMembers()

Invites other AWS accounts (created as members of the current AWS account by CreateMembers) to enable GuardDuty, and allow the current AWS account to view and manage these accounts' GuardDuty findings on their behalf as the master account.

# Required Parameters
- `accountIds`: A list of account IDs of the accounts that you want to invite to GuardDuty as members.
- `detectorId`: The unique ID of the detector of the GuardDuty account that you want to invite members with.

# Optional Parameters
- `disableEmailNotification`: A Boolean value that specifies whether you want to disable email notification to the accounts that you are inviting to GuardDuty as members.
- `message`: The invitation message that you want to send to the accounts that you're inviting to GuardDuty as members.
"""

invite_members(accountIds, detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/member/invite", Dict{String, Any}("accountIds"=>accountIds); aws_config=aws_config)
invite_members(accountIds, detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/member/invite", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("accountIds"=>accountIds), args)); aws_config=aws_config)

"""
    ListDetectors()

Lists detectorIds of all the existing Amazon GuardDuty detector resources.

# Optional Parameters
- `maxResults`: You can use this parameter to indicate the maximum number of items that you want in the response. The default value is 50. The maximum value is 50.
- `nextToken`: You can use this parameter when paginating results. Set the value of this parameter to null on your first call to the list action. For subsequent calls to the action, fill nextToken in the request with the value of NextToken from the previous response to continue listing data.
"""

list_detectors(; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector"; aws_config=aws_config)
list_detectors(args::AbstractDict{String, Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector", args; aws_config=aws_config)

"""
    ListFilters()

Returns a paginated list of the current filters.

# Required Parameters
- `detectorId`: The unique ID of the detector that the filter is associated with.

# Optional Parameters
- `maxResults`: You can use this parameter to indicate the maximum number of items that you want in the response. The default value is 50. The maximum value is 50.
- `nextToken`: You can use this parameter when paginating results. Set the value of this parameter to null on your first call to the list action. For subsequent calls to the action, fill nextToken in the request with the value of NextToken from the previous response to continue listing data.
"""

list_filters(detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)/filter"; aws_config=aws_config)
list_filters(detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)/filter", args; aws_config=aws_config)

"""
    ListFindings()

Lists Amazon GuardDuty findings for the specified detector ID.

# Required Parameters
- `detectorId`: The ID of the detector that specifies the GuardDuty service whose findings you want to list.

# Optional Parameters
- `findingCriteria`: Represents the criteria used for querying findings. Valid values include:   JSON field name   accountId   region   confidence   id   resource.accessKeyDetails.accessKeyId   resource.accessKeyDetails.principalId   resource.accessKeyDetails.userName   resource.accessKeyDetails.userType   resource.instanceDetails.iamInstanceProfile.id   resource.instanceDetails.imageId   resource.instanceDetails.instanceId   resource.instanceDetails.networkInterfaces.ipv6Addresses   resource.instanceDetails.networkInterfaces.privateIpAddresses.privateIpAddress   resource.instanceDetails.networkInterfaces.publicDnsName   resource.instanceDetails.networkInterfaces.publicIp   resource.instanceDetails.networkInterfaces.securityGroups.groupId   resource.instanceDetails.networkInterfaces.securityGroups.groupName   resource.instanceDetails.networkInterfaces.subnetId   resource.instanceDetails.networkInterfaces.vpcId   resource.instanceDetails.tags.key   resource.instanceDetails.tags.value   resource.resourceType   service.action.actionType   service.action.awsApiCallAction.api   service.action.awsApiCallAction.callerType   service.action.awsApiCallAction.remoteIpDetails.city.cityName   service.action.awsApiCallAction.remoteIpDetails.country.countryName   service.action.awsApiCallAction.remoteIpDetails.ipAddressV4   service.action.awsApiCallAction.remoteIpDetails.organization.asn   service.action.awsApiCallAction.remoteIpDetails.organization.asnOrg   service.action.awsApiCallAction.serviceName   service.action.dnsRequestAction.domain   service.action.networkConnectionAction.blocked   service.action.networkConnectionAction.connectionDirection   service.action.networkConnectionAction.localPortDetails.port   service.action.networkConnectionAction.protocol   service.action.networkConnectionAction.remoteIpDetails.city.cityName   service.action.networkConnectionAction.remoteIpDetails.country.countryName   service.action.networkConnectionAction.remoteIpDetails.ipAddressV4   service.action.networkConnectionAction.remoteIpDetails.organization.asn   service.action.networkConnectionAction.remoteIpDetails.organization.asnOrg   service.action.networkConnectionAction.remotePortDetails.port   service.additionalInfo.threatListName   service.archived When this attribute is set to 'true', only archived findings are listed. When it's set to 'false', only unarchived findings are listed. When this attribute is not set, all existing findings are listed.   service.resourceRole   severity   type   updatedAt Type: Timestamp in Unix Epoch millisecond format: 1486685375000
- `maxResults`: You can use this parameter to indicate the maximum number of items you want in the response. The default value is 50. The maximum value is 50.
- `nextToken`: You can use this parameter when paginating results. Set the value of this parameter to null on your first call to the list action. For subsequent calls to the action, fill nextToken in the request with the value of NextToken from the previous response to continue listing data.
- `sortCriteria`: Represents the criteria used for sorting findings.
"""

list_findings(detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/findings"; aws_config=aws_config)
list_findings(detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/findings", args; aws_config=aws_config)

"""
    ListIPSets()

Lists the IPSets of the GuardDuty service specified by the detector ID. If you use this operation from a member account, the IPSets returned are the IPSets from the associated master account.

# Required Parameters
- `detectorId`: The unique ID of the detector that the IPSet is associated with.

# Optional Parameters
- `maxResults`: You can use this parameter to indicate the maximum number of items you want in the response. The default value is 50. The maximum value is 50.
- `nextToken`: You can use this parameter when paginating results. Set the value of this parameter to null on your first call to the list action. For subsequent calls to the action, fill nextToken in the request with the value of NextToken from the previous response to continue listing data.
"""

list_ipsets(detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)/ipset"; aws_config=aws_config)
list_ipsets(detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)/ipset", args; aws_config=aws_config)

"""
    ListInvitations()

Lists all GuardDuty membership invitations that were sent to the current AWS account.

# Optional Parameters
- `maxResults`: You can use this parameter to indicate the maximum number of items that you want in the response. The default value is 50. The maximum value is 50.
- `nextToken`: You can use this parameter when paginating results. Set the value of this parameter to null on your first call to the list action. For subsequent calls to the action, fill nextToken in the request with the value of NextToken from the previous response to continue listing data.
"""

list_invitations(; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/invitation"; aws_config=aws_config)
list_invitations(args::AbstractDict{String, Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/invitation", args; aws_config=aws_config)

"""
    ListMembers()

Lists details about all member accounts for the current GuardDuty master account.

# Required Parameters
- `detectorId`: The unique ID of the detector the member is associated with.

# Optional Parameters
- `maxResults`: You can use this parameter to indicate the maximum number of items you want in the response. The default value is 50. The maximum value is 50.
- `nextToken`: You can use this parameter when paginating results. Set the value of this parameter to null on your first call to the list action. For subsequent calls to the action, fill nextToken in the request with the value of NextToken from the previous response to continue listing data.
- `onlyAssociated`: Specifies whether to only return associated members or to return all members (including members who haven't been invited yet or have been disassociated).
"""

list_members(detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)/member"; aws_config=aws_config)
list_members(detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)/member", args; aws_config=aws_config)

"""
    ListOrganizationAdminAccounts()

Lists the accounts configured as GuardDuty delegated administrators.

# Optional Parameters
- `maxResults`: The maximum number of results to return in the response.
- `nextToken`: A token to use for paginating results that are returned in the response. Set the value of this parameter to null for the first request to a list action. For subsequent calls, use the NextToken value returned from the previous request to continue listing results after the first page.
"""

list_organization_admin_accounts(; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/admin"; aws_config=aws_config)
list_organization_admin_accounts(args::AbstractDict{String, Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/admin", args; aws_config=aws_config)

"""
    ListPublishingDestinations()

Returns a list of publishing destinations associated with the specified dectectorId.

# Required Parameters
- `detectorId`: The ID of the detector to retrieve publishing destinations for.

# Optional Parameters
- `maxResults`: The maximum number of results to return in the response.
- `nextToken`: A token to use for paginating results that are returned in the response. Set the value of this parameter to null for the first request to a list action. For subsequent calls, use the NextToken value returned from the previous request to continue listing results after the first page.
"""

list_publishing_destinations(detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)/publishingDestination"; aws_config=aws_config)
list_publishing_destinations(detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)/publishingDestination", args; aws_config=aws_config)

"""
    ListTagsForResource()

Lists tags for a resource. Tagging is currently supported for detectors, finding filters, IP sets, and threat intel sets, with a limit of 50 tags per resource. When invoked, this operation returns all assigned tags for a given resource.

# Required Parameters
- `resourceArn`: The Amazon Resource Name (ARN) for the given GuardDuty resource.

"""

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

"""
    ListThreatIntelSets()

Lists the ThreatIntelSets of the GuardDuty service specified by the detector ID. If you use this operation from a member account, the ThreatIntelSets associated with the master account are returned.

# Required Parameters
- `detectorId`: The unique ID of the detector that the threatIntelSet is associated with.

# Optional Parameters
- `maxResults`: You can use this parameter to indicate the maximum number of items that you want in the response. The default value is 50. The maximum value is 50.
- `nextToken`: You can use this parameter to paginate results in the response. Set the value of this parameter to null on your first call to the list action. For subsequent calls to the action, fill nextToken in the request with the value of NextToken from the previous response to continue listing data.
"""

list_threat_intel_sets(detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)/threatintelset"; aws_config=aws_config)
list_threat_intel_sets(detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("GET", "/detector/$(detectorId)/threatintelset", args; aws_config=aws_config)

"""
    StartMonitoringMembers()

Turns on GuardDuty monitoring of the specified member accounts. Use this operation to restart monitoring of accounts that you stopped monitoring with the StopMonitoringMembers operation.

# Required Parameters
- `accountIds`: A list of account IDs of the GuardDuty member accounts to start monitoring.
- `detectorId`: The unique ID of the detector of the GuardDuty master account associated with the member accounts to monitor.

"""

start_monitoring_members(accountIds, detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/member/start", Dict{String, Any}("accountIds"=>accountIds); aws_config=aws_config)
start_monitoring_members(accountIds, detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/member/start", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("accountIds"=>accountIds), args)); aws_config=aws_config)

"""
    StopMonitoringMembers()

Stops GuardDuty monitoring for the specified member accounts. Use the StartMonitoringMembers operation to restart monitoring for those accounts.

# Required Parameters
- `accountIds`: A list of account IDs for the member accounts to stop monitoring.
- `detectorId`: The unique ID of the detector associated with the GuardDuty master account that is monitoring member accounts.

"""

stop_monitoring_members(accountIds, detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/member/stop", Dict{String, Any}("accountIds"=>accountIds); aws_config=aws_config)
stop_monitoring_members(accountIds, detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/member/stop", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("accountIds"=>accountIds), args)); aws_config=aws_config)

"""
    TagResource()

Adds tags to a resource.

# Required Parameters
- `resourceArn`: The Amazon Resource Name (ARN) for the GuardDuty resource to apply a tag to.
- `tags`: The tags to be added to a resource.

"""

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

"""
    UnarchiveFindings()

Unarchives GuardDuty findings specified by the findingIds.

# Required Parameters
- `detectorId`: The ID of the detector associated with the findings to unarchive.
- `findingIds`: The IDs of the findings to unarchive.

"""

unarchive_findings(detectorId, findingIds; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/findings/unarchive", Dict{String, Any}("findingIds"=>findingIds); aws_config=aws_config)
unarchive_findings(detectorId, findingIds, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/findings/unarchive", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("findingIds"=>findingIds), args)); aws_config=aws_config)

"""
    UntagResource()

Removes tags from a resource.

# Required Parameters
- `resourceArn`: The Amazon Resource Name (ARN) for the resource to remove tags from.
- `tagKeys`: The tag keys to remove from the resource.

"""

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

"""
    UpdateDetector()

Updates the Amazon GuardDuty detector specified by the detectorId.

# Required Parameters
- `detectorId`: The unique ID of the detector to update.

# Optional Parameters
- `dataSources`: An object that describes which data sources will be updated.
- `enable`: Specifies whether the detector is enabled or not enabled.
- `findingPublishingFrequency`: An enum value that specifies how frequently findings are exported, such as to CloudWatch Events.
"""

update_detector(detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)"; aws_config=aws_config)
update_detector(detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)", args; aws_config=aws_config)

"""
    UpdateFilter()

Updates the filter specified by the filter name.

# Required Parameters
- `detectorId`: The unique ID of the detector that specifies the GuardDuty service where you want to update a filter.
- `filterName`: The name of the filter.

# Optional Parameters
- `action`: Specifies the action that is to be applied to the findings that match the filter.
- `description`: The description of the filter.
- `findingCriteria`: Represents the criteria to be used in the filter for querying findings.
- `rank`: Specifies the position of the filter in the list of current filters. Also specifies the order in which this filter is applied to the findings.
"""

update_filter(detectorId, filterName; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/filter/$(filterName)"; aws_config=aws_config)
update_filter(detectorId, filterName, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/filter/$(filterName)", args; aws_config=aws_config)

"""
    UpdateFindingsFeedback()

Marks the specified GuardDuty findings as useful or not useful.

# Required Parameters
- `detectorId`: The ID of the detector associated with the findings to update feedback for.
- `feedback`: The feedback for the finding.
- `findingIds`: The IDs of the findings that you want to mark as useful or not useful.

# Optional Parameters
- `comments`: Additional feedback about the GuardDuty findings.
"""

update_findings_feedback(detectorId, feedback, findingIds; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/findings/feedback", Dict{String, Any}("feedback"=>feedback, "findingIds"=>findingIds); aws_config=aws_config)
update_findings_feedback(detectorId, feedback, findingIds, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/findings/feedback", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("feedback"=>feedback, "findingIds"=>findingIds), args)); aws_config=aws_config)

"""
    UpdateIPSet()

Updates the IPSet specified by the IPSet ID.

# Required Parameters
- `detectorId`: The detectorID that specifies the GuardDuty service whose IPSet you want to update.
- `ipSetId`: The unique ID that specifies the IPSet that you want to update.

# Optional Parameters
- `activate`: The updated Boolean value that specifies whether the IPSet is active or not.
- `location`: The updated URI of the file that contains the IPSet. For example: https://s3.us-west-2.amazonaws.com/my-bucket/my-object-key.
- `name`: The unique ID that specifies the IPSet that you want to update.
"""

update_ipset(detectorId, ipSetId; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/ipset/$(ipSetId)"; aws_config=aws_config)
update_ipset(detectorId, ipSetId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/ipset/$(ipSetId)", args; aws_config=aws_config)

"""
    UpdateMemberDetectors()

Contains information on member accounts to be updated.

# Required Parameters
- `accountIds`: A list of member account IDs to be updated.
- `detectorId`: The detector ID of the master account.

# Optional Parameters
- `dataSources`: An object describes which data sources will be updated.
"""

update_member_detectors(accountIds, detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/member/detector/update", Dict{String, Any}("accountIds"=>accountIds); aws_config=aws_config)
update_member_detectors(accountIds, detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/member/detector/update", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("accountIds"=>accountIds), args)); aws_config=aws_config)

"""
    UpdateOrganizationConfiguration()

Updates the delegated administrator account with the values provided.

# Required Parameters
- `autoEnable`: Indicates whether to automatically enable member accounts in the organization.
- `detectorId`: The ID of the detector to update the delegated administrator for.

# Optional Parameters
- `dataSources`: An object describes which data sources will be updated.
"""

update_organization_configuration(autoEnable, detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/admin", Dict{String, Any}("autoEnable"=>autoEnable); aws_config=aws_config)
update_organization_configuration(autoEnable, detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/admin", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("autoEnable"=>autoEnable), args)); aws_config=aws_config)

"""
    UpdatePublishingDestination()

Updates information about the publishing destination specified by the destinationId.

# Required Parameters
- `destinationId`: The ID of the publishing destination to update.
- `detectorId`: The ID of the detector associated with the publishing destinations to update.

# Optional Parameters
- `destinationProperties`: A DestinationProperties object that includes the DestinationArn and KmsKeyArn of the publishing destination.
"""

update_publishing_destination(destinationId, detectorId; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/publishingDestination/$(destinationId)"; aws_config=aws_config)
update_publishing_destination(destinationId, detectorId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/publishingDestination/$(destinationId)", args; aws_config=aws_config)

"""
    UpdateThreatIntelSet()

Updates the ThreatIntelSet specified by the ThreatIntelSet ID.

# Required Parameters
- `detectorId`: The detectorID that specifies the GuardDuty service whose ThreatIntelSet you want to update.
- `threatIntelSetId`: The unique ID that specifies the ThreatIntelSet that you want to update.

# Optional Parameters
- `activate`: The updated Boolean value that specifies whether the ThreateIntelSet is active or not.
- `location`: The updated URI of the file that contains the ThreateIntelSet. For example: https://s3.us-west-2.amazonaws.com/my-bucket/my-object-key.
- `name`: The unique ID that specifies the ThreatIntelSet that you want to update.
"""

update_threat_intel_set(detectorId, threatIntelSetId; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/threatintelset/$(threatIntelSetId)"; aws_config=aws_config)
update_threat_intel_set(detectorId, threatIntelSetId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = guardduty("POST", "/detector/$(detectorId)/threatintelset/$(threatIntelSetId)", args; aws_config=aws_config)


text:
## anisotropic_exponential.jl : implementation of anisotropic exponential covariance function

## AnisotropicExponential ##
struct AnisotropicExponential{T,M} <: AnisotropicCovarianceStructure{T}
    A::M
    σ::T
end

"""
    AnisotropicExponential(A, σ=1)

Create an anisotropic exponential covariance structure with anisotropy matrix A and (optional) marginal standard deviation `σ`.

# Examples
```jldoctest
julia> A = [1 0.5; 0.5 1]
2×2 Array{Float64,2}:
 1.0  0.5
 1.0  0.5

julia> a1 = AnisotropicExponential(A)
anisotropic exponential (A=[1.0 0.5; 0.5 1.0], σ=1.0)

```
"""
function AnisotropicExponential(A::Matrix{T} where {T<:Real}; σ=1.0::T where {T<:Real})
	isposdef(A) || throw(ArgumentError("anisotropy matrix A must be positive definite"))
    σ > 0 || throw(ArgumentError("marginal standard deviation σ of exponential covariance cannot be negative or zero"))
	T = promote_type(eltype(A),typeof(σ))
	AnisotropicExponential{T,typeof(A)}(A,convert(T,σ))
end

# evaluate exponential covariance
function apply(a::AnisotropicExponential,x::Vector{T}) where {T<:Real}
    exp(-x'*a.A*x)
end

show(io::IO, a::AnisotropicExponential) = print(io, "anisotropic exponential (A=$(a.A), σ=$(a.σ))")

ext: jl


text:
@testset "Find maximum time to nil triangle" begin
    t3 = (
        CausticsEngineering.Vertex3D(5.0, 5.0, 0.0, 0.0, 0.0),
        CausticsEngineering.Vertex3D(6.0, 5.0, 0.0, 0.0, 0.0),
        CausticsEngineering.Vertex3D(5.5, 5.5, 0.0, 0.0, -3.0),
    )
    @test CausticsEngineering.find_maximum_t(t3)[1] ≈ 0.5 / 3.0 atol = 0.01

    t3 = (
        CausticsEngineering.Vertex3D(5.0, 5.0, 0.0, 0.0, 0.0),
        CausticsEngineering.Vertex3D(6.0, 5.0, 0.0, 0.0, 0.0),
        CausticsEngineering.Vertex3D(5.5, 5.5, 0.0, 0.7, -3.0),
    )
    @test CausticsEngineering.find_maximum_t(t3)[1] ≈ 0.5 / 3.0 atol = 0.01

    t3 = (
        CausticsEngineering.Vertex3D(5.0, 5.0, 0.0, 0.0, 0.0),
        CausticsEngineering.Vertex3D(6.0, 5.0, 0.0, 0.0, 0.0),
        CausticsEngineering.Vertex3D(5.5, 5.5, 0.0, -10.0, -3.0),
    )
    @test CausticsEngineering.find_maximum_t(t3)[1] ≈ 0.5 / 3.0 atol = 0.01

    t3 = (
        CausticsEngineering.Vertex3D(5.0, 5.0, 0.01, 0.1, -2.0),
        CausticsEngineering.Vertex3D(6.0, 5.0, 0.01, 0.1, 2.0),
        CausticsEngineering.Vertex3D(5.5, 5.5, 0.01, 0.5, -3.0),
    )
    @test CausticsEngineering.find_maximum_t(t3)[1] ≈ 0.1540 atol = 0.01

    t3 = (
        CausticsEngineering.Vertex3D(5.0, 5.0, 0.01, 0.1, -2.0),
        CausticsEngineering.Vertex3D(6.0, 5.0, 0.01, 0.1, 2.0),
        CausticsEngineering.Vertex3D(5.5, 5.5, 0.01, 0.5, -3.0),
    )
    @test CausticsEngineering.find_maximum_t(t3)[1] ≈ 0.1540 atol = 0.01

end


text:
# FWI on Overthrust model using minConf library
# Author: Philipp Witte, pwitte@eoas.ubc.ca
# Date: December 2017
#

using Statistics, Random, LinearAlgebra
using JUDI, HDF5, SegyIO, PyPlot, IterativeSolvers

# Load starting model
n,d,o,m0 = read(h5open("$(JUDI.JUDI_DATA)/overthrust_model.h5","r"), "n", "d", "o", "m0")
model0 = Model((n[1],n[2]), (d[1],d[2]), (o[1],o[2]), m0)

# Bound constraints
v0 = sqrt.(1 ./ m0)
vmin = ones(Float32,model0.n) .* 1.3f0
vmax = ones(Float32,model0.n) .* 6.5f0
vmin[:,1:21] .= v0[:,1:21]   # keep water column fixed
vmax[:,1:21] .= v0[:,1:21]

# Slowness squared [s^2/km^2]
mmin = vec((1f0 ./ vmax).^2)
mmax = vec((1f0 ./ vmin).^2)

# Load data
block = segy_read("$(JUDI.JUDI_DATA)/overthrust_shot_records.segy")
d_obs = judiVector(block)

# Set up wavelet
src_geometry = Geometry(block; key="source")
wavelet = ricker_wavelet(src_geometry.t[1],src_geometry.dt[1],0.008f0)  # 8 Hz wavelet
q = judiVector(src_geometry,wavelet)

############################### FWI ###########################################
# Set up operators
F = judiModeling(model0, q.geometry, d_obs.geometry)
J = judiJacobian(F,q)

# Optimization parameters
maxiter = parse(Int, get(ENV, "NITER", "10"))
maxiter_GN = parse(Int, get(ENV, "NITER", "5"))
batch_size = 5 * parse(Int, get(ENV, "NITER", "$(q.nsrc ÷ 5)"))

fhistory_GN = zeros(Float32,maxiter)
proj(x) = reshape(median([vec(mmin) vec(x) vec(mmax)]; dims=2),model0.n)

# Gauss-Newton method
for j=1:maxiter
    println("Iteration: ",j)
    i = randperm(q.nsrc)[1:batch_size]
    # # Model predicted data for subset of sources
    d_pred = F[i]*q[i]
    fhistory_GN[j] = .5f0*norm(d_pred - d_obs[i])^2

    # GN update direction
    p = lsqr!(similar(model0.m), J[i], d_pred - d_obs[i]; maxiter=maxiter_GN, verbose=true)

    # update model and bound constraints
    model0.m .= proj(model0.m .- reshape(p, model0.n))  # alpha=1
end

figure(); imshow(sqrt.(1f0./model0.m)'); title("FWI with Gauss-Newton")


text:
workdir = dirname(dirname(pathof(FileManager)))

@testset "TXT" begin
    V = [0. 4. 4. 0. 2. 3. 3. 2;
    0. 0. 4. 4. 2. 2. 3. 3.]
    EV = [[1,2],[2,3],[3,4],[4,1],[5,6],[6,7],[7,8],[8,5]]

    file_V = joinpath(workdir,"test","Files/V.txt")
    file_EV = joinpath(workdir,"test","Files/EV.txt")
    FileManager.save_points_txt(file_V, V)
    FileManager.save_cells_txt(file_EV, EV)

    V_load = FileManager.load_points(file_V)
    EV_load = FileManager.load_cells(file_EV)
    @test V_load == V
    @test EV_load == EV

    file = joinpath(workdir,"Files/PC.txt")
    rgb = [1 1 1 1 1 1 1 1; 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0.]
    PC = FileManager.PointCloud(V,rgb)
    FileManager.save_points_rgbs_txt(file, PC)
    V_load = FileManager.load_points(file)
    @test V_load[1:2,:] == PC.coordinates
    @test V_load[3:5,:] == PC.rgbs*255
end


text:
module GeoDataFrames

    import ArchGDAL; const AG = ArchGDAL
    import DataFrames, DataStreams, GeoInterface, RecipesBase

    include("geodataframe.jl")
    include("plotrecipe.jl")
end


text:
using Graphene
using Test

export test_bonds

@test isequal(path2turn((10, 11, 12)), (10, 11) => (11, 12))

test_bonds, test_paths = collect_bonds_paths(test_atom_group_collection, test_indexed_atoms)
test_turn_dict = Dict(map(path2turn, vcat(test_paths...)))
initial_length = length(test_turn_dict)
test_patoms, test_pbonds = link_turns!(test_turn_dict)
@test length(test_patoms) == length(test_pbonds) == initial_length - length(test_turn_dict)

test_polygons = make_polygons(test_paths)
@test length(test_polygons) == 3
@test Set(test_polygons[1][1]) == Set([7, 4, 6, 8, 10, 9])
@test Set(test_polygons[2][1]) == Set([5, 7, 9, 10, 11, 12, 13, 12, 14, 12, 11, 10, 8, 6, 4, 2, 1, 3])
@test Set(test_polygons[3][1]) == Set([1, 2, 4, 7, 5, 3])


text:
using Cat
@category Z

# Next is a morphism in Z from Nothing~>Nothing
@morphism Z Next {} {Nothing, Nothing}
@morphism Z Prev {} {Nothing, Nothing}
@inverse Z Next Prev

println(Next(Prev()))


text:
const FULL_FNS = [:div, :mulinv, :log2, :exp2, :fma, :fms, :nfma, :nfms]#, :fas, :fcp, :fdp, :dpi]

const fmasig = Dict(:fma  => (n, es, a, b, c) -> "$(to_f(n,es,a)),  $(to_f(n,es,b)),  $(to_f(n,es,c))",
                    :fms  => (n, es, a, b, c) -> "$(to_f(n,es,a)),  $(to_f(n,es,b)), -$(to_f(n,es,c))",
                    :nfma => (n, es, a, b, c) -> "$(to_f(n,es,a)), -$(to_f(n,es,b)),  $(to_f(n,es,c))",
                    :nfms => (n, es, a, b, c) -> "$(to_f(n,es,a)), -$(to_f(n,es,b)), -$(to_f(n,es,c))")
doc"""
  z-counting functions for fused operations
"""
function zcounts()
  """
  static bool z_count_valid_float(float a, float b, float c){
    //convert a, b, and c to their respective integers
    uint32_t a_int = *((uint32_t *) &a);
    uint32_t b_int = *((uint32_t *) &b);
    uint32_t c_int = *((uint32_t *) &c);

    int64_t trailing_a = __builtin_ctz(a_int);
    int64_t trailing_b = __builtin_ctz(b_int);
    int64_t trailing_c = __builtin_ctz(c_int);

    return trailing_c == trailing_a + trailing_b - 23;
  }

  static bool z_count_valid_double(double a, double b, double c){
    //convert a, b, and c to their respective integers
    uint64_t a_int = *((uint64_t *) &a);
    uint64_t b_int = *((uint64_t *) &b);
    uint64_t c_int = *((uint64_t *) &c);

    int64_t trailing_a = __builtin_ctzl(a_int);
    int64_t trailing_b = __builtin_ctzl(b_int);
    int64_t trailing_c = __builtin_ctzl(c_int);

    return trailing_c == trailing_a + trailing_b - 52;
  }
  """
end

doc"""
  The skeleton of a unary operation, with adlibbable values
"""
function unop_fn(n::Integer ,es::Integer, op::Symbol, status::Bool)
  opfn = ops[op][status + 1]
  val = status ? "int" : p(n,es)
  err = status ? "if (POSIT_ENV.nanmode) { res->udata = P$(n)INF; return 0; } else { return EDOM; }" : "pres.udata = P$(n)INF; errno = (POSIT_ENV.nanmode) ? 0 : EDOM; return pres;"
  ret = status ? "res->udata = pres.udata; return 0" : "return pres"

"""
extern "C" $(opfn(n,es)) {
  $(p(n,es)) pres;
  int status = sanitize_$(op)\_$(n)(a.udata);
  switch (status){
   case 1: pres.udata = P$(n)ZER; $ret;
   case 2: pres.udata = P$(n)INF; $ret;
   case 3: $err
  }

  $(ftype[n]) fres = $(op)($(to_f(n,es,:a)));
  pres = $(to_p(n,es,:fres));
  $ret;
}
"""
end

doc"""
  The skeleton of a ternary operation, with adlibbable values
"""
function terop_fn(n::Integer, es::Integer, op::Symbol, status::Bool)
  opfn = ops[op][status + 1]
  quit = status ? "return EDOM" : "result.udata = P$(n)INF; errno = EDOM; return result"
  retval = status ? "*res = result; return 0" : "return result"
  """
extern "C" $(opfn(n,es)){
    $(p(n,es)) result;
    //two ways to fail: add/sub of infinity or infinity times zero.  Both
    //require at least one of a and b to be infinity.
    if ((a.udata == P$(n)INF) || (b.udata == P$(n)INF)){
      if (c.udata == P$(n)INF) { $quit; }
      result.udata = P$(n)INF;
      $retval;
    }
    if (c.udata == P$(n)INF) {
      result.udata = P$(n)INF;
      $retval;
    }  //or just be standard infinity if the adder is.

    //two ways to get zero:  one of the muliplicands is zero, add/sub is zero.
    if ((a.udata == P$(n)ZER) || (b.udata == P$(n)ZER)){
      if (c.udata == P$(n)ZER) { result.udata = P$(n)ZER; $retval;}
      //here we can quit early.
      result.udata = c.udata;
      $retval;
    }

    //the other way to get zero is when the two values match exactly except for
    //sign

    //if it passes all the other tests, do the fma.
    result = $(to_p(n,es,string("fma(",fmasig[op](n,es,:a,:b,:c),")")));

    $retval;
  }
  """
end

const fulls_sanitizers = Dict(#=:div => (n) -> """
  static int sanitize_div_$(n)(const uint$(n)_t lhs, const uint$(n)_t rhs){
    if (lhs == P$(n)INF) {
      if (rhs == P$(n)INF) { return 3; }
      return 2;
    }
    if (lhs == P$(n)ZER) {
      if (rhs == P$(n)ZER) { return 3; }
      return 1;
    }
    if (rhs == P$(n)INF) { return 1; }
    if (rhs == P$(n)ZER) { return 2; }
    return 0;
  }
  """,=#
  :log2 => (n) -> """
  static int sanitize_log2_$(n)(const uint$(n)_t arg){
    if (arg == P$(n)INF) { return 2; }
    if (arg == P$(n)ZER) { return 2; }
    if ((arg & P$(n)INF) != 0) { return 3; } //negative values are rejected
    return 0;
  }
  """,
  :exp2 => (n) -> """
  static int sanitize_exp2_$(n)(const uint$(n)_t arg){
    if (arg == P$(n)INF) { return 3; }
    return 0;
  }
  """,)

const fulls_code = Dict(
  :div => (n, es) -> """
  $(binop_fn(n,es,:div,true))
  $(binop_fn(n,es,:div,false))
  """,
  :mulinv => (n, es) -> """
  extern "C" $(ops[:mulinv][1](n,es)) {
    $(ftype[n]) fres = $(to_f(n,es,:a));
    return $(to_p(n,es,"1/fres"));
  }

  extern "C" $(ops[:mulinv][2](n,es)) {
    $(p(n,es)) pres;
    $(ftype[n]) fres = $(to_f(n,es,:a));
    pres = $(to_p(n,es,"1/fres"));
    res->udata = pres.udata;
    return 0;
  }
  """,
  :log2 => (n, es) -> """
  $(unop_fn(n,es,:log2,true))
  $(unop_fn(n,es,:log2,false))
  """,
  :exp2 => (n, es) -> """
  $(unop_fn(n,es,:exp2,true))
  $(unop_fn(n,es,:exp2,false))
  """,
  :fma => (n, es) -> """
  $(terop_fn(n,es,:fma,true))
  $(terop_fn(n,es,:fma,false))
  """,
  :fms => (n, es) -> """
  $(terop_fn(n,es,:fms,true))
  $(terop_fn(n,es,:fms,false))
  """,
  :nfma => (n, es) -> """
  $(terop_fn(n,es,:nfma,true))
  $(terop_fn(n,es,:nfma,false))
  """,
  :nfms => (n, es) -> """
  $(terop_fn(n,es,:nfms,true))
  $(terop_fn(n,es,:nfms,false))
  """)

function generate_posit_full_cpp(io, posit_defs)
  #generates "posit.h" based on the posit_definitions
  write(io,"""
  #include "include/posit.h"
  #include "include/posit_conv.h"
  #include <errno.h>
  """)
  #write(io, zcounts())
  write(io, "\n\n")

  for fn in FULL_FNS
    for n in sort(collect(keys(posit_defs)))

      sanitizer = haskey(fulls_sanitizers, fn) ? """
      ///////////////////////////////////////////////////////////////
      //  posit_$(n) section, $(fn) sanitizers
      ///////////////////////////////////////////////////////////////

      $(fulls_sanitizers[fn](n))
      """ : ""

      write(io, """
      $sanitizer

      ///////////////////////////////////////////////////////////////
      //  posit_$(n) section, variable ES adapters for $(fn)
      ///////////////////////////////////////////////////////////////
      """)

      for es in posit_defs[n]
        write(io, fulls_code[fn](n, es))
        write(io, "\n")
      end
    end
    write(io,"\n")
  end
end


text:
using SimpleSolvers
using Test
using GeometricIntegrators
using GeometricIntegrators.Integrators.VPRK
using GeometricIntegrators.Utils
using GeometricProblems.LotkaVolterra2d
using GeometricProblems.LotkaVolterra2d: Δt, nt, reference_solution

SimpleSolvers.set_config(:nls_atol, 8eps())
SimpleSolvers.set_config(:nls_rtol, 2eps())

@testset "$(rpad("Lotka-Volterra 2d",80))" begin

    ode  = lotka_volterra_2d_ode()
    hode = lotka_volterra_2d_hode()
    iode = lotka_volterra_2d_iode()
    pode = lotka_volterra_2d_pode()
    lode = lotka_volterra_2d_lode()
    dae  = lotka_volterra_2d_dae()
    hdae = lotka_volterra_2d_hdae()
    idae = lotka_volterra_2d_idae()
    pdae = lotka_volterra_2d_pdae()
    ldae = lotka_volterra_2d_ldae()

    ode_equs = get_functions(ode)
    ode_invs = get_invariants(ode)
    @test_nowarn ode_equs[:v](ode.t₀, ode.q₀[begin], zero(ode.q₀[begin]))
    @test_nowarn ode_invs[:h](ode.t₀, ode.q₀[begin])

    hode_equs = get_functions(hode)
    @test_nowarn hode_equs[:v](hode.t₀, hode.q₀[begin], hode.p₀[begin], zero(hode.q₀[begin]))
    @test_nowarn hode_equs[:f](hode.t₀, hode.q₀[begin], hode.p₀[begin], zero(hode.p₀[begin]))
    @test_nowarn hode_equs[:h](hode.t₀, hode.q₀[begin], hode.p₀[begin])

    iode_equs = get_functions(iode)
    iode_invs = get_invariants(iode)
    @test_nowarn iode_equs[:ϑ](iode.t₀, iode.q₀[begin], iode.p₀[begin], zero(iode.q₀[begin]))
    @test_nowarn iode_equs[:f](iode.t₀, iode.q₀[begin], iode.p₀[begin], zero(iode.p₀[begin]))
    @test_nowarn iode_equs[:v̄](iode.t₀, iode.q₀[begin], zero(iode.q₀[begin]))
    @test_nowarn iode_equs[:f̄](iode.t₀, iode.q₀[begin], iode.p₀[begin], zero(iode.p₀[begin]))
    @test_nowarn iode_invs[:h](iode.t₀, iode.q₀[begin], zero(iode.q₀[begin]))

    pode_equs = get_functions(pode)
    pode_invs = get_invariants(pode)
    @test_nowarn pode_equs[:v](pode.t₀, pode.q₀[begin], pode.p₀[begin], zero(pode.q₀[begin]))
    @test_nowarn pode_equs[:f](pode.t₀, pode.q₀[begin], pode.p₀[begin], zero(pode.p₀[begin]))
    @test_nowarn pode_invs[:h](pode.t₀, pode.q₀[begin], pode.p₀[begin])

    lode_equs = get_functions(lode)
    lode_invs = get_invariants(lode)
    @test_nowarn lode_equs[:ϑ](lode.t₀, lode.q₀[begin], lode.p₀[begin], zero(lode.q₀[begin]))
    @test_nowarn lode_equs[:f](lode.t₀, lode.q₀[begin], lode.p₀[begin], zero(lode.p₀[begin]))
    @test_nowarn lode_equs[:v̄](lode.t₀, lode.q₀[begin], zero(lode.q₀[begin]))
    @test_nowarn lode_equs[:f̄](lode.t₀, lode.q₀[begin], lode.p₀[begin], zero(lode.p₀[begin]))
    @test_nowarn lode_invs[:h](lode.t₀, lode.q₀[begin], zero(iode.q₀[begin]))

    dae_equs = get_functions(dae)
    dae_invs = get_invariants(dae)
    @test_nowarn dae_equs[:v](dae.t₀, dae.q₀[begin], zero(dae.q₀[begin]))
    @test_nowarn dae_equs[:u](dae.t₀, dae.q₀[begin], dae.λ₀[begin], zero(dae.q₀[begin]))
    @test_nowarn dae_equs[:ϕ](dae.t₀, dae.q₀[begin], zero(dae.λ₀[begin]))
    @test_nowarn dae_equs[:v̄](dae.t₀, dae.q₀[begin], zero(dae.q₀[begin]))
    @test_nowarn dae_invs[:h](dae.t₀, dae.q₀[begin])

    hdae_equs = get_functions(hdae)
    @test_nowarn hdae_equs[:v](hdae.t₀, hdae.q₀[begin], hdae.p₀[begin], zero(hdae.q₀[begin]))
    @test_nowarn hdae_equs[:f](hdae.t₀, hdae.q₀[begin], hdae.p₀[begin], zero(hdae.p₀[begin]))
    @test_nowarn hdae_equs[:u](hdae.t₀, hdae.q₀[begin], hdae.p₀[begin], hdae.λ₀[begin], zero(hdae.q₀[begin]))
    @test_nowarn hdae_equs[:g](hdae.t₀, hdae.q₀[begin], hdae.p₀[begin], hdae.λ₀[begin], zero(hdae.p₀[begin]))
    @test_nowarn hdae_equs[:ϕ](hdae.t₀, hdae.q₀[begin], hdae.p₀[begin], zero(hdae.λ₀[begin]))
    @test_nowarn hdae_equs[:v̄](hdae.t₀, hdae.q₀[begin], hdae.p₀[begin], zero(hdae.q₀[begin]))
    @test_nowarn hdae_equs[:f̄](hdae.t₀, hdae.q₀[begin], hdae.p₀[begin], zero(hdae.p₀[begin]))
    @test_nowarn hdae_equs[:h](hdae.t₀, hdae.q₀[begin], hdae.p₀[begin])

    idae_equs = get_functions(idae)
    idae_invs = get_invariants(idae)
    @test_nowarn idae_equs[:ϑ](idae.t₀, idae.q₀[begin], idae.p₀[begin], zero(idae.q₀[begin]))
    @test_nowarn idae_equs[:f](idae.t₀, idae.q₀[begin], idae.p₀[begin], zero(idae.p₀[begin]))
    @test_nowarn idae_equs[:u](idae.t₀, idae.q₀[begin], idae.p₀[begin], idae.λ₀[begin], zero(idae.q₀[begin]))
    @test_nowarn idae_equs[:g](idae.t₀, idae.q₀[begin], idae.p₀[begin], idae.λ₀[begin], zero(idae.p₀[begin]))
    @test_nowarn idae_equs[:ϕ](idae.t₀, idae.q₀[begin], idae.p₀[begin], zero(idae.λ₀[begin]))
    @test_nowarn idae_equs[:v̄](idae.t₀, idae.q₀[begin], zero(idae.q₀[begin]))
    @test_nowarn idae_equs[:f̄](idae.t₀, idae.q₀[begin], idae.p₀[begin], zero(idae.p₀[begin]))
    @test_nowarn idae_invs[:h](idae.t₀, idae.q₀[begin], zero(iode.q₀[begin]))

    pdae_equs = get_functions(pdae)
    pdae_invs = get_invariants(pdae)
    @test_nowarn pdae_equs[:v](pdae.t₀, pdae.q₀[begin], pdae.p₀[begin], zero(pdae.q₀[begin]))
    @test_nowarn pdae_equs[:f](pdae.t₀, pdae.q₀[begin], pdae.p₀[begin], zero(pdae.p₀[begin]))
    @test_nowarn pdae_equs[:u](pdae.t₀, pdae.q₀[begin], pdae.p₀[begin], pdae.λ₀[begin], zero(pdae.q₀[begin]))
    @test_nowarn pdae_equs[:g](pdae.t₀, pdae.q₀[begin], pdae.p₀[begin], pdae.λ₀[begin], zero(pdae.p₀[begin]))
    @test_nowarn pdae_equs[:ϕ](pdae.t₀, pdae.q₀[begin], pdae.p₀[begin], zero(pdae.λ₀[begin]))
    @test_nowarn pdae_equs[:v̄](pdae.t₀, pdae.q₀[begin], pdae.p₀[begin], zero(pdae.q₀[begin]))
    @test_nowarn pdae_equs[:f̄](pdae.t₀, pdae.q₀[begin], pdae.p₀[begin], zero(pdae.p₀[begin]))
    @test_nowarn pdae_invs[:h](pdae.t₀, pdae.q₀[begin], pdae.p₀[begin])

    ldae_equs = get_functions(ldae)
    ldae_invs = get_invariants(ldae)
    @test_nowarn ldae_equs[:ϑ](ldae.t₀, ldae.q₀[begin], ldae.λ₀[begin], zero(ldae.q₀[begin]))
    @test_nowarn ldae_equs[:f](ldae.t₀, ldae.q₀[begin], ldae.λ₀[begin], zero(ldae.p₀[begin]))
    @test_nowarn ldae_equs[:g](ldae.t₀, ldae.q₀[begin], ldae.λ₀[begin], zero(ldae.p₀[begin]))
    @test_nowarn ldae_equs[:ḡ](ldae.t₀, ldae.q₀[begin], ldae.λ₀[begin], zero(ldae.p₀[begin]))
    @test_nowarn ldae_equs[:ϕ](ldae.t₀, ldae.q₀[begin], ldae.p₀[begin], zero(ldae.λ₀[begin]))
    @test_nowarn ldae_equs[:ψ](ldae.t₀, ldae.q₀[begin], ldae.p₀[begin], zero(ldae.q₀[begin]), zero(ldae.p₀[begin]), zero(ldae.λ₀[begin]))
    @test_nowarn ldae_equs[:v̄](ldae.t₀, ldae.q₀[begin], zero(ldae.q₀[begin]))
    @test_nowarn ldae_equs[:f̄](ldae.t₀, ldae.q₀[begin], ldae.λ₀[begin], zero(ldae.p₀[begin]))
    @test_nowarn ldae_invs[:h](ldae.t₀, ldae.q₀[begin], zero(iode.q₀[begin]))

    int = Integrator(ode, TableauGauss(2), Δt)
    sol = integrate(ode, int, nt)
    @test relative_maximum_error(sol.q, reference_solution) < 5E-4

    int = IntegratorVPRKpMidpoint(iode, TableauVPGLRK(2), Δt)
    sol = integrate(iode, int, nt)
    @test relative_maximum_error(sol.q, reference_solution) < 5E-4

    int = IntegratorVPRKpSymmetric(iode, TableauVPGLRK(2), Δt)
    sol = integrate(iode, int, nt)
    @test relative_maximum_error(sol.q, reference_solution) < 5E-4

    int = Integrator(idae, TableauVSPARKGLRKpMidpoint(2), Δt)
    sol = integrate(idae, int, nt)
    @test relative_maximum_error(sol.q, reference_solution) < 5E-4

    int = Integrator(idae, TableauVSPARKGLRKpSymmetric(2), Δt)
    sol = integrate(idae, int, nt)
    @test relative_maximum_error(sol.q, reference_solution) < 5E-4
end


text:
using MathLink

mma_typemap = Dict{Type,Symbol}(
    Int => :Integers,
    Rational => :Rationals,
    AlgebraicNumber => :Algebraics
)

mutable struct MathematicaSolver <: NLSolver
    vars::Dict{Symbol,Type}
    cs::ClauseSet
    MathematicaSolver() = new(Dict(), ClauseSet())
end

function variables!(s::MathematicaSolver, d::Dict{Symbol,Type})
    push!(s.vars, d...)
end

_tostring(cl::Clause) = join([string(convert(Expr, c)) for c in cl], " || ")
_tostring(cs::ClauseSet) = join([string("(", _tostring(cl), ")") for cl in cs], " && ")

function solve(s::MathematicaSolver; timeout::Int=-1)
    formula = MathLink.parseexpr(_tostring(s.cs))
    vars = MathLink.parseexpr(string("{", join(collect(keys(s.vars)), ", "), "}"))
    result = if timeout <= 0
        W"FindInstance"(formula, vars, W"Algebraics")
    else
        W"TimeConstrained"(W"FindInstance"(formula, vars, W"Algebraics"), timeout, W"Timeout")
    end
    start = time_ns()
    result = weval(result)
    elapsed = Millisecond(round((time_ns()-start)/1e6))
    res = _to_julia(result)
    if res == :Timeout
        return NLSat.timeout, Second(timeout), nothing
    elseif res == :Aborted
        @warn("Mathematica aborted")
        return NLSat.unknown, elapsed, nothing
    elseif isempty(res)
        return NLSat.unsat, elapsed, nothing
    end
    NLSat.sat, elapsed, Dict(first(res))
end

_to_julia(w::MathLink.WSymbol) = Symbol(w.name)
_to_julia(w::Number) = w
function _to_julia(w::MathLink.WExpr)
    if w.head == W"List"
        return [_to_julia(x) for x in w.args]
    elseif w.head == W"Rule"
        return _to_julia(w.args[1]) => _to_julia(w.args[2])
    elseif w.head == W"Rational"
        return _to_julia(w.args[1]) // _to_julia(w.args[2])
    elseif w.head == W"Complex"
        return _to_julia(w.args[1]) + _to_julia(w.args[2]) * im
    end
    w
end


text:
function  compute()

	divisorsum=fill(0,10000)
	divisorsum[1]=1

	for i =1:length(divisorsum)
		for j=2*i:i:length(divisorsum)
			divisorsum[j]+=i
		end
	end
	ans=0

	for i=1:length(divisorsum)
		j=divisorsum[i]
		if j!=i && j<length(divisorsum) && divisorsum[j]==i
			ans+=i
		end
	end
	return ans
end

println(compute())


text:
using VlasiatorMakie, Vlasiator, LazyArtifacts
using Test

using GLMakie

@testset "VlasiatorMakie.jl" begin
   rootpath = artifact"testdata"
   files = joinpath.(rootpath, ("bulk.1d.vlsv", "bulk.2d.vlsv", "bulk.amr.vlsv"))

   meta1 = load(files[1])
   meta2 = load(files[2])
   meta3 = load(files[3])

   var = "proton/vg_rho"

   fig, ax, plt = lines(meta1, var)
   @test plt isa Lines

   fig = vlheatmap(meta2, var)
   @test fig isa Figure

   fig, ax, plt = heatmap(meta2, var)
   @test plt isa Heatmap

   fig, ax, plt = heatmap(meta2, var, EARTH, 0, :z)
   @test plt isa Heatmap

   fig = vlslice(meta3, var)
   @test fig isa Figure

   fig = vlslices(meta3, var)
   @test fig isa Figure

   fig = volume(meta3, "fg_b", EARTH, 3; algorithm=:iso, isovalue=0.0, isorange=1e-9)
   @test fig isa Makie.FigureAxisPlot

   location = [0.0, 0.0, 0.0]
   fig = vdfslice(meta1, location)
   @test fig isa Figure

   fig = vdfslices(meta1, location)
   @test fig isa Figure

   fig = vdfvolume(meta1, location)
   @test fig isa Figure
end


text:
const maxpowInt8 = Int8[0, 6, 4, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
const maxpowInt16 = Int8[0, 14, 9, 7, 6, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
const maxpowInt32 = Int8[0, 30, 19, 15, 13, 11, 11, 10, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]
const maxpowInt64 = Int8[0, 62, 39, 31, 27, 24, 22, 20, 19, 18, 18, 17, 17, 16, 16, 15, 15, 15, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8]
const maxpowInt128 = Int8[0, 126, 80, 63, 54, 49, 45, 42, 40, 38, 36, 35, 34, 33, 32, 31, 31, 30, 29, 29, 28, 28, 28, 27, 27, 27, 26, 26, 26, 25, 25, 25, 25, 24, 24, 24, 24, 24, 24, 23, 23, 23, 23, 23, 23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18]
const maxpowUInt128 = Int8[0, 127, 80, 63, 55, 49, 45, 42, 40, 38, 37, 35, 34, 33, 32, 31, 31, 30, 30, 29, 29, 28, 28, 27, 27, 27, 26, 26, 26, 26, 25, 25, 25, 25, 24, 24, 24, 24, 24, 24, 23, 23, 23, 23, 23, 23, 23, 22, 22, 22, 22, 22, 22, 22, 22, 22, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18]
const maxpowUInt64 = Int8[0, 63, 40, 31, 27, 24, 22, 21, 20, 19, 18, 17, 17, 16, 16, 15, 15, 15, 15, 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, 13, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]
const maxpowUInt32 = Int8[0, 31, 20, 15, 13, 12, 11, 10, 10, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]
const maxpowUInt16 = Int8[0, 15, 10, 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
const maxpowUInt8 = Int8[0, 7, 5, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

for (T,A,I) in ((:SafeInt128, :maxpowInt128, :Int128), (:SafeInt64, :maxpowInt64, :Int64),
                (:SafeInt32, :maxpowInt32, :Int32), (:SafeInt16, :maxpowInt16, :Int16),
                (:SafeInt8, :maxpowInt8, :Int8),
                (:SafeUInt128, :maxpowUInt128, :UInt128), (:SafeUInt64, :maxpowUInt64, :UInt64),
                (:SafeUInt32, :maxpowUInt32, :UInt32), (:SafeUInt16, :maxpowUInt16, :UInt16),
                (:SafeUInt8, :maxpowUInt8, :UInt8))
  @eval begin

    function Base.:(^)(x::$T, y::$T)
        if 1 < x < 129
            if y <= $A[x]
                $T($I(x)^$I(y))
            else
                throw(OverflowError(string(x,"^",y)))
            end
        else
            if !signbit(y)
                ipower(x, y)
            else
                throw(DomainError(string(x,"^(",y,")")))
            end
        end
    end

    function ipower(x::$T, y::$T)
        y === zero($T) && return one($T)
        (x === zero($T) || y === one($T)) && return x
        z = Float64($I(x))^Float64($I(y))
        if !isfinite(z) || z > typemax($T)
            throw(OverflowError(string(x,"^",y)))
        end
        return $T(floor($I,z+0.49999999999999994))
    end

  end
end

Base.:(^)(x::S1, y::S1) where {S1<:SafeInteger, S2<:SafeInteger} = (^)(promote(x,y)...,)
Base.:(^)(x::S, y::T) where {S<:SafeInteger, T<:Base.BitInteger} = (^)(promote(x,y)...,)
Base.:(^)(x::T, y::S) where {T<:Base.BitInteger, S<:SafeInteger} = baseint((^)(promote(safeint(x), y)...))


text:
# test not exported
@test_throws UndefVarError Pipeline
@test_throws UndefVarError AbstractPipeline
@test_throws UndefVarError ImmutablePipeline
@test Augmentor.AbstractPipeline <: Any
@test Augmentor.Pipeline <: Augmentor.AbstractPipeline
@test Augmentor.ImmutablePipeline <: Augmentor.Pipeline

@test typeof((FlipX(),FlipY())) <: Augmentor.AbstractPipeline
@test Augmentor.operations((FlipX(),FlipY())) === (FlipX(),FlipY())

@testset "ImmutablePipeline" begin
    @test_throws MethodError Augmentor.ImmutablePipeline()
    @test_throws MethodError Augmentor.ImmutablePipeline(())
    @test_throws MethodError Augmentor.ImmutablePipeline(1)
    @test_throws MethodError Augmentor.ImmutablePipeline((1,))
    @test_throws MethodError Augmentor.ImmutablePipeline{1}((1,))
    @test_throws MethodError Augmentor.ImmutablePipeline{2}((FlipX(),))
    @test_throws MethodError Augmentor.ImmutablePipeline{1}(FlipX())

    @test @inferred(Augmentor.ImmutablePipeline(FlipX())) === @inferred(Augmentor.ImmutablePipeline{1}((FlipX(),)))

    p = @inferred Augmentor.ImmutablePipeline(FlipX())
    @test p === @inferred(Augmentor.ImmutablePipeline((FlipX(),)))
    @test typeof(p) <: Augmentor.ImmutablePipeline{1}
    @test @inferred(length(p)) === 1
    @test @inferred(Augmentor.operations(p)) === (FlipX(),)

    p = @inferred Augmentor.ImmutablePipeline(FlipX(), FlipY())
    @test p === @inferred(Augmentor.ImmutablePipeline((FlipX(),FlipY())))
    @test typeof(p) <: Augmentor.ImmutablePipeline{2}
    @test @inferred(length(p)) === 2
    @test @inferred(Augmentor.operations(p)) === (FlipX(),FlipY())

    p = @inferred Augmentor.ImmutablePipeline(FlipX(), FlipY(), Rotate90())
    @test p === @inferred(Augmentor.ImmutablePipeline((FlipX(),FlipY(),Rotate90())))
    @test typeof(p) <: Augmentor.ImmutablePipeline{3}
    @test @inferred(length(p)) === 3
    @test @inferred(Augmentor.operations(p)) === (FlipX(),FlipY(),Rotate90())
end

@testset "ImmutablePipeline with |>" begin
    buf = rand(2,2)

    p = @inferred(FlipX() |> FlipY())
    @test p === Augmentor.ImmutablePipeline(FlipX(), FlipY())

    p = @inferred(FlipX() |> buf |> FlipY())
    @test p === Augmentor.ImmutablePipeline(FlipX(), CacheImage(buf), FlipY())

    p = @inferred(FlipX() |> CacheImage(buf) |> FlipY())
    @test p === Augmentor.ImmutablePipeline(FlipX(), CacheImage(buf), FlipY())

    p = @inferred(FlipX() |> CacheImage() |> FlipY())
    @test p === Augmentor.ImmutablePipeline(FlipX(), CacheImage(), FlipY())

    p = @inferred(FlipX() |> FlipY() |> buf)
    @test p === Augmentor.ImmutablePipeline(FlipX(), FlipY(), CacheImage(buf))

    p = @inferred(FlipX() |> NoOp() |> FlipY())
    @test p === Augmentor.ImmutablePipeline(FlipX(), NoOp(), FlipY())

    p = @inferred((FlipX() |> NoOp()) |> FlipY())
    @test p === Augmentor.ImmutablePipeline(FlipX(), NoOp(), FlipY())

    p = @inferred(FlipX() |> (NoOp() |> FlipY()))
    @test p === Augmentor.ImmutablePipeline(FlipX(), NoOp(), FlipY())

    p = @inferred(FlipX() |> NoOp() |> FlipY() |> Rotate90())
    @test p === Augmentor.ImmutablePipeline(FlipX(), NoOp(), FlipY(), Rotate90())

    p = @inferred((FlipX() |> NoOp()) |> (FlipY() |> Rotate90()))
    @test p === Augmentor.ImmutablePipeline(FlipX(), NoOp(), FlipY(), Rotate90())

    p = FlipX() * FlipY() |> Rotate90() * Rotate270()
    @test p == Augmentor.ImmutablePipeline(Either(FlipX(),FlipY()), Either(Rotate90(),Rotate270()))

    p = NoOp() * FlipX() * FlipY() |> Rotate90() * Rotate270()
    @test p == Augmentor.ImmutablePipeline(Either(NoOp(),FlipX(),FlipY()), Either(Rotate90(),Rotate270()))
end

@testset "Pipeline constructor" begin
    @test_throws MethodError Augmentor.Pipeline()
    @test_throws MethodError Augmentor.Pipeline(())
    @test_throws MethodError Augmentor.Pipeline(1)
    @test_throws MethodError Augmentor.Pipeline((1,))

    p = @inferred Augmentor.Pipeline(FlipX())
    @test typeof(p) <: Augmentor.ImmutablePipeline
    @test p == Augmentor.ImmutablePipeline(FlipX())

    p = @inferred Augmentor.Pipeline((FlipX(),))
    @test typeof(p) <: Augmentor.ImmutablePipeline
    @test p == Augmentor.ImmutablePipeline(FlipX())

    p = @inferred Augmentor.Pipeline(FlipX(), FlipY())
    @test typeof(p) <: Augmentor.ImmutablePipeline
    @test p == Augmentor.ImmutablePipeline(FlipX(),FlipY())

    p = @inferred Augmentor.Pipeline((FlipX(), FlipY()))
    @test typeof(p) <: Augmentor.ImmutablePipeline
    @test p == Augmentor.ImmutablePipeline(FlipX(),FlipY())
end

@test str_show(Augmentor.ImmutablePipeline(Rotate90(),Rotate270(),NoOp())) == """
3-step Augmentor.ImmutablePipeline:
 1.) Rotate 90 degree
 2.) Rotate 270 degree
 3.) No operation"""
 @test str_showcompact(Augmentor.ImmutablePipeline(Rotate90(.2),Rotate270(),NoOp())) == "(0.2=>Rotate90()) * (0.8=>NoOp()) |> Rotate270() |> NoOp()"
@test str_showcompact(Augmentor.ImmutablePipeline(Rotate90())) == "Rotate90()"


text:
module nMDS
using  Distances,  LoopVectorization,  DataStructures, Statistics

include("functions.jl")
include("main.jl")
export nmds
end


text:
using Documenter, Mapper2

makedocs(;
    modules = [Mapper2],
    sitename = "Mapper2.jl",
    format = :html,
    authors = "Mark Hildebrand, Arthur Hlaing",
    pages = [
        "Home" => "index.md",
        "Manual" => [
            "Architecture Modeling" => [
                "man/architecture/types.md",
                "man/architecture/components.md",
                "man/architecture/constructors.md",
            ],
            "man/taskgraph.md",
            "man/map.md",
            "man/extensions.md",
            "Simulated Annealing Placement" => [
                "man/SA/placement.md",
                "man/SA/sastruct.md",
                "man/SA/methods.md",
                "man/SA/types.md",
                "man/SA/distance.md",
                "man/SA/move_generators.md",
                "man/SA/map_tables.md",
            ],
            "Routing" => [
                "man/routing/routing.md",
                "man/routing/struct.md",
                "man/routing/links.md",
                "man/routing/channels.md",
                "man/routing/graph.md",
            ],
            "man/mappergraphs.md",
            "man/helper.md",
            "man/paths.md",
        ],
    ],
)

deploydocs(;
    repo = "github.com/hildebrandmw/Mapper2.jl.git",
    julia = "1.0",
    osname = "linux",
    target = "build",
    deps = nothing,
    make = nothing,
)


text:
module TestGraphvizWiringDiagrams

using Test
import JSON

using Catlab.Theories, Catlab.WiringDiagrams, Catlab.Graphics
import Catlab.Graphics: Graphviz
using Catlab.Graphics.WiringDiagramLayouts: position, normal

# Drawing
#########

function stmts(graph::Graphviz.Graph, type::Type)
  [ stmt for stmt in graph.stmts if stmt isa type ]
end
function stmts(graph::Graphviz.Graph, type::Type, attr::Symbol)
  [ stmt.attrs[attr] for stmt in graph.stmts
    if stmt isa type && haskey(stmt.attrs, attr) ]
end

f = singleton_diagram(Box(:f, [:A], [:B]))
g = singleton_diagram(Box(:g, [:B], [:A]))

# Simple wiring diagrams, with default settings.
graph = to_graphviz(f)
@test graph isa Graphviz.Graph && graph.directed
@test stmts(graph, Graphviz.Node, :comment) == ["f"]
@test stmts(graph, Graphviz.Edge, :comment) == ["A","B"]
@test stmts(graph, Graphviz.Edge, :label) == []
@test stmts(graph, Graphviz.Edge, :xlabel) == []
@test length(stmts(graph, Graphviz.Subgraph)) == 2

graph = to_graphviz(singleton_diagram(Box(:h, Symbol[], [:A])))
@test stmts(graph, Graphviz.Node, :comment) == ["h"]
@test length(stmts(graph, Graphviz.Subgraph)) == 1

graph = to_graphviz(singleton_diagram(Box(:h, Symbol[], Symbol[])))
@test stmts(graph, Graphviz.Node, :comment) == ["h"]
@test length(stmts(graph, Graphviz.Subgraph)) == 0

graph = to_graphviz(compose(f,g))
@test stmts(graph, Graphviz.Node, :comment) == ["f","g"]

# Layout orientation.
for orientation in instances(LayoutOrientation)
  graph = to_graphviz(compose(f,g); orientation=orientation)
  @test stmts(graph, Graphviz.Node, :comment) == ["f","g"]
end

# Junction nodes.
graph = to_graphviz(add_junctions!(compose(f, mcopy(Ports([:B])))))
@test stmts(graph, Graphviz.Node, :comment) == ["f","junction"]

# Edge labels.
graph = to_graphviz(f; labels=true)
@test stmts(graph, Graphviz.Edge, :label) == ["A","B"]
@test stmts(graph, Graphviz.Edge, :xlabel) == []

graph = to_graphviz(f; labels=true, label_attr=:xlabel)
@test stmts(graph, Graphviz.Edge, :label) == []
@test stmts(graph, Graphviz.Edge, :xlabel) == ["A","B"]

# Anchoring of outer ports.
graph = to_graphviz(otimes(f,g); anchor_outer_ports=true)
@test stmts(graph, Graphviz.Node, :comment) == ["f","g"]
graph = to_graphviz(otimes(f,g); anchor_outer_ports=false)
@test stmts(graph, Graphviz.Node, :comment) == ["f","g"]

# Layout
########

diagram = include(joinpath("data", "graphviz_wiring_diagram.jl"))
doc = open(JSON.parse,
  joinpath(@__DIR__, "data", "graphviz_wiring_diagram.json"), "r")
graph = Graphviz.parse_graphviz(doc)
layout = graphviz_layout(diagram, graph)

# Is original data preserved?
values(xs) = map(x -> x.value, xs)
@test WiringDiagrams.graph(layout) == WiringDiagrams.graph(diagram)
@test values(input_ports(layout)) == input_ports(diagram)
@test values(output_ports(layout)) == output_ports(diagram)
@test values(values(boxes(layout))) == values(boxes(diagram))

# Basic geometry.
positions = map(position, boxes(layout))
@test positions[1][1] < positions[2][1]
@test positions[1][2] < positions[3][2]

end