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

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

Create a configuration set. Configuration sets are groups of rules that you can apply to
the emails you send using Amazon Pinpoint. You apply a configuration set to an email by
including a reference to the configuration set in the headers of the email. When you apply
a configuration set to an email, all of the rules in that configuration set are applied to
the email.

# Arguments
- `configuration_set_name`: The name of the configuration set.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"DeliveryOptions"`: An object that defines the dedicated IP pool that is used to send
  emails that you send using the configuration set.
- `"ReputationOptions"`: An object that defines whether or not Amazon Pinpoint collects
  reputation metrics for the emails that you send that use the configuration set.
- `"SendingOptions"`: An object that defines whether or not Amazon Pinpoint can send email
  that you send using the configuration set.
- `"Tags"`: An array of objects that define the tags (keys and values) that you want to
  associate with the configuration set.
- `"TrackingOptions"`: An object that defines the open and click tracking options for
  emails that you send using the configuration set.
"""
create_configuration_set(ConfigurationSetName; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("POST", "/v1/email/configuration-sets", Dict{String, Any}("ConfigurationSetName"=>ConfigurationSetName); aws_config=aws_config)
create_configuration_set(ConfigurationSetName, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("POST", "/v1/email/configuration-sets", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ConfigurationSetName"=>ConfigurationSetName), params)); aws_config=aws_config)

"""
    create_configuration_set_event_destination(configuration_set_name, event_destination, event_destination_name)
    create_configuration_set_event_destination(configuration_set_name, event_destination, event_destination_name, params::Dict{String,<:Any})

Create an event destination. In Amazon Pinpoint, events include message sends, deliveries,
opens, clicks, bounces, and complaints. Event destinations are places that you can send
information about these events to. For example, you can send event data to Amazon SNS to
receive notifications when you receive bounces or complaints, or you can use Amazon Kinesis
Data Firehose to stream data to Amazon S3 for long-term storage. A single configuration set
can include more than one event destination.

# Arguments
- `configuration_set_name`: The name of the configuration set that you want to add an event
  destination to.
- `event_destination`: An object that defines the event destination.
- `event_destination_name`: A name that identifies the event destination within the
  configuration set.

"""
create_configuration_set_event_destination(ConfigurationSetName, EventDestination, EventDestinationName; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("POST", "/v1/email/configuration-sets/$(ConfigurationSetName)/event-destinations", Dict{String, Any}("EventDestination"=>EventDestination, "EventDestinationName"=>EventDestinationName); aws_config=aws_config)
create_configuration_set_event_destination(ConfigurationSetName, EventDestination, EventDestinationName, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("POST", "/v1/email/configuration-sets/$(ConfigurationSetName)/event-destinations", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("EventDestination"=>EventDestination, "EventDestinationName"=>EventDestinationName), params)); aws_config=aws_config)

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

Create a new pool of dedicated IP addresses. A pool can include one or more dedicated IP
addresses that are associated with your Amazon Pinpoint account. You can associate a pool
with a configuration set. When you send an email that uses that configuration set, Amazon
Pinpoint sends it using only the IP addresses in the associated pool.

# Arguments
- `pool_name`: The name of the dedicated IP pool.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"Tags"`: An object that defines the tags (keys and values) that you want to associate
  with the pool.
"""
create_dedicated_ip_pool(PoolName; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("POST", "/v1/email/dedicated-ip-pools", Dict{String, Any}("PoolName"=>PoolName); aws_config=aws_config)
create_dedicated_ip_pool(PoolName, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("POST", "/v1/email/dedicated-ip-pools", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("PoolName"=>PoolName), params)); aws_config=aws_config)

"""
    create_deliverability_test_report(content, from_email_address)
    create_deliverability_test_report(content, from_email_address, params::Dict{String,<:Any})

Create a new predictive inbox placement test. Predictive inbox placement tests can help you
predict how your messages will be handled by various email providers around the world. When
you perform a predictive inbox placement test, you provide a sample message that contains
the content that you plan to send to your customers. Amazon Pinpoint then sends that
message to special email addresses spread across several major email providers. After about
24 hours, the test is complete, and you can use the GetDeliverabilityTestReport operation
to view the results of the test.

# Arguments
- `content`: The HTML body of the message that you sent when you performed the predictive
  inbox placement test.
- `from_email_address`: The email address that the predictive inbox placement test email
  was sent from.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"ReportName"`: A unique name that helps you to identify the predictive inbox placement
  test when you retrieve the results.
- `"Tags"`: An array of objects that define the tags (keys and values) that you want to
  associate with the predictive inbox placement test.
"""
create_deliverability_test_report(Content, FromEmailAddress; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("POST", "/v1/email/deliverability-dashboard/test", Dict{String, Any}("Content"=>Content, "FromEmailAddress"=>FromEmailAddress); aws_config=aws_config)
create_deliverability_test_report(Content, FromEmailAddress, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("POST", "/v1/email/deliverability-dashboard/test", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("Content"=>Content, "FromEmailAddress"=>FromEmailAddress), params)); aws_config=aws_config)

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

Verifies an email identity for use with Amazon Pinpoint. In Amazon Pinpoint, an identity is
an email address or domain that you use when you send email. Before you can use an identity
to send email with Amazon Pinpoint, you first have to verify it. By verifying an address,
you demonstrate that you're the owner of the address, and that you've given Amazon Pinpoint
permission to send email from the address. When you verify an email address, Amazon
Pinpoint sends an email to the address. Your email address is verified as soon as you
follow the link in the verification email.  When you verify a domain, this operation
provides a set of DKIM tokens, which you can convert into CNAME tokens. You add these CNAME
tokens to the DNS configuration for your domain. Your domain is verified when Amazon
Pinpoint detects these records in the DNS configuration for your domain. It usually takes
around 72 hours to complete the domain verification process.

# Arguments
- `email_identity`: The email address or domain that you want to verify.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"Tags"`: An array of objects that define the tags (keys and values) that you want to
  associate with the email identity.
"""
create_email_identity(EmailIdentity; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("POST", "/v1/email/identities", Dict{String, Any}("EmailIdentity"=>EmailIdentity); aws_config=aws_config)
create_email_identity(EmailIdentity, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("POST", "/v1/email/identities", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("EmailIdentity"=>EmailIdentity), params)); aws_config=aws_config)

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

Delete an existing configuration set. In Amazon Pinpoint, configuration sets are groups of
rules that you can apply to the emails you send. You apply a configuration set to an email
by including a reference to the configuration set in the headers of the email. When you
apply a configuration set to an email, all of the rules in that configuration set are
applied to the email.

# Arguments
- `configuration_set_name`: The name of the configuration set that you want to delete.

"""
delete_configuration_set(ConfigurationSetName; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("DELETE", "/v1/email/configuration-sets/$(ConfigurationSetName)"; aws_config=aws_config)
delete_configuration_set(ConfigurationSetName, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("DELETE", "/v1/email/configuration-sets/$(ConfigurationSetName)", params; aws_config=aws_config)

"""
    delete_configuration_set_event_destination(configuration_set_name, event_destination_name)
    delete_configuration_set_event_destination(configuration_set_name, event_destination_name, params::Dict{String,<:Any})

Delete an event destination. In Amazon Pinpoint, events include message sends, deliveries,
opens, clicks, bounces, and complaints. Event destinations are places that you can send
information about these events to. For example, you can send event data to Amazon SNS to
receive notifications when you receive bounces or complaints, or you can use Amazon Kinesis
Data Firehose to stream data to Amazon S3 for long-term storage.

# Arguments
- `configuration_set_name`: The name of the configuration set that contains the event
  destination that you want to delete.
- `event_destination_name`: The name of the event destination that you want to delete.

"""
delete_configuration_set_event_destination(ConfigurationSetName, EventDestinationName; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("DELETE", "/v1/email/configuration-sets/$(ConfigurationSetName)/event-destinations/$(EventDestinationName)"; aws_config=aws_config)
delete_configuration_set_event_destination(ConfigurationSetName, EventDestinationName, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("DELETE", "/v1/email/configuration-sets/$(ConfigurationSetName)/event-destinations/$(EventDestinationName)", params; aws_config=aws_config)

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

Delete a dedicated IP pool.

# Arguments
- `pool_name`: The name of the dedicated IP pool that you want to delete.

"""
delete_dedicated_ip_pool(PoolName; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("DELETE", "/v1/email/dedicated-ip-pools/$(PoolName)"; aws_config=aws_config)
delete_dedicated_ip_pool(PoolName, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("DELETE", "/v1/email/dedicated-ip-pools/$(PoolName)", params; aws_config=aws_config)

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

Deletes an email identity that you previously verified for use with Amazon Pinpoint. An
identity can be either an email address or a domain name.

# Arguments
- `email_identity`: The identity (that is, the email address or domain) that you want to
  delete from your Amazon Pinpoint account.

"""
delete_email_identity(EmailIdentity; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("DELETE", "/v1/email/identities/$(EmailIdentity)"; aws_config=aws_config)
delete_email_identity(EmailIdentity, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("DELETE", "/v1/email/identities/$(EmailIdentity)", params; aws_config=aws_config)

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

Obtain information about the email-sending status and capabilities of your Amazon Pinpoint
account in the current AWS Region.

"""
get_account(; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/account"; aws_config=aws_config)
get_account(params::AbstractDict{String, Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/account", params; aws_config=aws_config)

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

Retrieve a list of the blacklists that your dedicated IP addresses appear on.

# Arguments
- `blacklist_item_names`: A list of IP addresses that you want to retrieve blacklist
  information about. You can only specify the dedicated IP addresses that you use to send
  email using Amazon Pinpoint or Amazon SES.

"""
get_blacklist_reports(BlacklistItemNames; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/deliverability-dashboard/blacklist-report", Dict{String, Any}("BlacklistItemNames"=>BlacklistItemNames); aws_config=aws_config)
get_blacklist_reports(BlacklistItemNames, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/deliverability-dashboard/blacklist-report", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("BlacklistItemNames"=>BlacklistItemNames), params)); aws_config=aws_config)

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

Get information about an existing configuration set, including the dedicated IP pool that
it's associated with, whether or not it's enabled for sending email, and more. In Amazon
Pinpoint, configuration sets are groups of rules that you can apply to the emails you send.
You apply a configuration set to an email by including a reference to the configuration set
in the headers of the email. When you apply a configuration set to an email, all of the
rules in that configuration set are applied to the email.

# Arguments
- `configuration_set_name`: The name of the configuration set that you want to obtain more
  information about.

"""
get_configuration_set(ConfigurationSetName; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/configuration-sets/$(ConfigurationSetName)"; aws_config=aws_config)
get_configuration_set(ConfigurationSetName, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/configuration-sets/$(ConfigurationSetName)", params; aws_config=aws_config)

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

Retrieve a list of event destinations that are associated with a configuration set. In
Amazon Pinpoint, events include message sends, deliveries, opens, clicks, bounces, and
complaints. Event destinations are places that you can send information about these events
to. For example, you can send event data to Amazon SNS to receive notifications when you
receive bounces or complaints, or you can use Amazon Kinesis Data Firehose to stream data
to Amazon S3 for long-term storage.

# Arguments
- `configuration_set_name`: The name of the configuration set that contains the event
  destination.

"""
get_configuration_set_event_destinations(ConfigurationSetName; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/configuration-sets/$(ConfigurationSetName)/event-destinations"; aws_config=aws_config)
get_configuration_set_event_destinations(ConfigurationSetName, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/configuration-sets/$(ConfigurationSetName)/event-destinations", params; aws_config=aws_config)

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

Get information about a dedicated IP address, including the name of the dedicated IP pool
that it's associated with, as well information about the automatic warm-up process for the
address.

# Arguments
- `ip`: The IP address that you want to obtain more information about. The value you
  specify has to be a dedicated IP address that's assocaited with your Amazon Pinpoint
  account.

"""
get_dedicated_ip(IP; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/dedicated-ips/$(IP)"; aws_config=aws_config)
get_dedicated_ip(IP, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/dedicated-ips/$(IP)", params; aws_config=aws_config)

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

List the dedicated IP addresses that are associated with your Amazon Pinpoint account.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"NextToken"`: A token returned from a previous call to GetDedicatedIps to indicate the
  position of the dedicated IP pool in the list of IP pools.
- `"PageSize"`: The number of results to show in a single call to GetDedicatedIpsRequest.
  If the number of results is larger than the number you specified in this parameter, then
  the response includes a NextToken element, which you can use to obtain additional results.
- `"PoolName"`: The name of the IP pool that the dedicated IP address is associated with.
"""
get_dedicated_ips(; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/dedicated-ips"; aws_config=aws_config)
get_dedicated_ips(params::AbstractDict{String, Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/dedicated-ips", params; aws_config=aws_config)

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

Retrieve information about the status of the Deliverability dashboard for your Amazon
Pinpoint account. When the Deliverability dashboard is enabled, you gain access to
reputation, deliverability, and other metrics for the domains that you use to send email
using Amazon Pinpoint. You also gain the ability to perform predictive inbox placement
tests. When you use the Deliverability dashboard, you pay a monthly subscription charge, in
addition to any other fees that you accrue by using Amazon Pinpoint. For more information
about the features and cost of a Deliverability dashboard subscription, see Amazon Pinpoint
Pricing.

"""
get_deliverability_dashboard_options(; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/deliverability-dashboard"; aws_config=aws_config)
get_deliverability_dashboard_options(params::AbstractDict{String, Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/deliverability-dashboard", params; aws_config=aws_config)

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

Retrieve the results of a predictive inbox placement test.

# Arguments
- `report_id`: A unique string that identifies the predictive inbox placement test.

"""
get_deliverability_test_report(ReportId; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/deliverability-dashboard/test-reports/$(ReportId)"; aws_config=aws_config)
get_deliverability_test_report(ReportId, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/deliverability-dashboard/test-reports/$(ReportId)", params; aws_config=aws_config)

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

Retrieve all the deliverability data for a specific campaign. This data is available for a
campaign only if the campaign sent email by using a domain that the Deliverability
dashboard is enabled for (PutDeliverabilityDashboardOption operation).

# Arguments
- `campaign_id`: The unique identifier for the campaign. Amazon Pinpoint automatically
  generates and assigns this identifier to a campaign. This value is not the same as the
  campaign identifier that Amazon Pinpoint assigns to campaigns that you create and manage by
  using the Amazon Pinpoint API or the Amazon Pinpoint console.

"""
get_domain_deliverability_campaign(CampaignId; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/deliverability-dashboard/campaigns/$(CampaignId)"; aws_config=aws_config)
get_domain_deliverability_campaign(CampaignId, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/deliverability-dashboard/campaigns/$(CampaignId)", params; aws_config=aws_config)

"""
    get_domain_statistics_report(domain, end_date, start_date)
    get_domain_statistics_report(domain, end_date, start_date, params::Dict{String,<:Any})

Retrieve inbox placement and engagement rates for the domains that you use to send email.

# Arguments
- `domain`: The domain that you want to obtain deliverability metrics for.
- `end_date`: The last day (in Unix time) that you want to obtain domain deliverability
  metrics for. The EndDate that you specify has to be less than or equal to 30 days after the
  StartDate.
- `start_date`: The first day (in Unix time) that you want to obtain domain deliverability
  metrics for.

"""
get_domain_statistics_report(Domain, EndDate, StartDate; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/deliverability-dashboard/statistics-report/$(Domain)", Dict{String, Any}("EndDate"=>EndDate, "StartDate"=>StartDate); aws_config=aws_config)
get_domain_statistics_report(Domain, EndDate, StartDate, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/deliverability-dashboard/statistics-report/$(Domain)", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("EndDate"=>EndDate, "StartDate"=>StartDate), params)); aws_config=aws_config)

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

Provides information about a specific identity associated with your Amazon Pinpoint
account, including the identity's verification status, its DKIM authentication status, and
its custom Mail-From settings.

# Arguments
- `email_identity`: The email identity that you want to retrieve details for.

"""
get_email_identity(EmailIdentity; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/identities/$(EmailIdentity)"; aws_config=aws_config)
get_email_identity(EmailIdentity, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/identities/$(EmailIdentity)", params; aws_config=aws_config)

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

List all of the configuration sets associated with your Amazon Pinpoint account in the
current region. In Amazon Pinpoint, configuration sets are groups of rules that you can
apply to the emails you send. You apply a configuration set to an email by including a
reference to the configuration set in the headers of the email. When you apply a
configuration set to an email, all of the rules in that configuration set are applied to
the email.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"NextToken"`: A token returned from a previous call to ListConfigurationSets to indicate
  the position in the list of configuration sets.
- `"PageSize"`: The number of results to show in a single call to ListConfigurationSets. If
  the number of results is larger than the number you specified in this parameter, then the
  response includes a NextToken element, which you can use to obtain additional results.
"""
list_configuration_sets(; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/configuration-sets"; aws_config=aws_config)
list_configuration_sets(params::AbstractDict{String, Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/configuration-sets", params; aws_config=aws_config)

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

List all of the dedicated IP pools that exist in your Amazon Pinpoint account in the
current AWS Region.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"NextToken"`: A token returned from a previous call to ListDedicatedIpPools to indicate
  the position in the list of dedicated IP pools.
- `"PageSize"`: The number of results to show in a single call to ListDedicatedIpPools. If
  the number of results is larger than the number you specified in this parameter, then the
  response includes a NextToken element, which you can use to obtain additional results.
"""
list_dedicated_ip_pools(; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/dedicated-ip-pools"; aws_config=aws_config)
list_dedicated_ip_pools(params::AbstractDict{String, Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/dedicated-ip-pools", params; aws_config=aws_config)

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

Show a list of the predictive inbox placement tests that you've performed, regardless of
their statuses. For predictive inbox placement tests that are complete, you can use the
GetDeliverabilityTestReport operation to view the results.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"NextToken"`: A token returned from a previous call to ListDeliverabilityTestReports to
  indicate the position in the list of predictive inbox placement tests.
- `"PageSize"`: The number of results to show in a single call to
  ListDeliverabilityTestReports. If the number of results is larger than the number you
  specified in this parameter, then the response includes a NextToken element, which you can
  use to obtain additional results. The value you specify has to be at least 0, and can be no
  more than 1000.
"""
list_deliverability_test_reports(; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/deliverability-dashboard/test-reports"; aws_config=aws_config)
list_deliverability_test_reports(params::AbstractDict{String, Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/deliverability-dashboard/test-reports", params; aws_config=aws_config)

"""
    list_domain_deliverability_campaigns(end_date, start_date, subscribed_domain)
    list_domain_deliverability_campaigns(end_date, start_date, subscribed_domain, params::Dict{String,<:Any})

Retrieve deliverability data for all the campaigns that used a specific domain to send
email during a specified time range. This data is available for a domain only if you
enabled the Deliverability dashboard (PutDeliverabilityDashboardOption operation) for the
domain.

# Arguments
- `end_date`: The last day, in Unix time format, that you want to obtain deliverability
  data for. This value has to be less than or equal to 30 days after the value of the
  StartDate parameter.
- `start_date`: The first day, in Unix time format, that you want to obtain deliverability
  data for.
- `subscribed_domain`: The domain to obtain deliverability data for.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"NextToken"`: A token that’s returned from a previous call to the
  ListDomainDeliverabilityCampaigns operation. This token indicates the position of a
  campaign in the list of campaigns.
- `"PageSize"`: The maximum number of results to include in response to a single call to
  the ListDomainDeliverabilityCampaigns operation. If the number of results is larger than
  the number that you specify in this parameter, the response includes a NextToken element,
  which you can use to obtain additional results.
"""
list_domain_deliverability_campaigns(EndDate, StartDate, SubscribedDomain; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/deliverability-dashboard/domains/$(SubscribedDomain)/campaigns", Dict{String, Any}("EndDate"=>EndDate, "StartDate"=>StartDate); aws_config=aws_config)
list_domain_deliverability_campaigns(EndDate, StartDate, SubscribedDomain, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/deliverability-dashboard/domains/$(SubscribedDomain)/campaigns", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("EndDate"=>EndDate, "StartDate"=>StartDate), params)); aws_config=aws_config)

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

Returns a list of all of the email identities that are associated with your Amazon Pinpoint
account. An identity can be either an email address or a domain. This operation returns
identities that are verified as well as those that aren't.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"NextToken"`: A token returned from a previous call to ListEmailIdentities to indicate
  the position in the list of identities.
- `"PageSize"`: The number of results to show in a single call to ListEmailIdentities. If
  the number of results is larger than the number you specified in this parameter, then the
  response includes a NextToken element, which you can use to obtain additional results. The
  value you specify has to be at least 0, and can be no more than 1000.
"""
list_email_identities(; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/identities"; aws_config=aws_config)
list_email_identities(params::AbstractDict{String, Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/identities", params; aws_config=aws_config)

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

Retrieve a list of the tags (keys and values) that are associated with a specified
resource. A tag is a label that you optionally define and associate with a resource in
Amazon Pinpoint. Each tag consists of a required tag key and an optional associated tag
value. A tag key is a general label that acts as a category for more specific tag values. A
tag value acts as a descriptor within a tag key.

# Arguments
- `resource_arn`: The Amazon Resource Name (ARN) of the resource that you want to retrieve
  tag information for.

"""
list_tags_for_resource(ResourceArn; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/tags", Dict{String, Any}("ResourceArn"=>ResourceArn); aws_config=aws_config)
list_tags_for_resource(ResourceArn, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("GET", "/v1/email/tags", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ResourceArn"=>ResourceArn), params)); aws_config=aws_config)

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

Enable or disable the automatic warm-up feature for dedicated IP addresses.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"AutoWarmupEnabled"`: Enables or disables the automatic warm-up feature for dedicated IP
  addresses that are associated with your Amazon Pinpoint account in the current AWS Region.
  Set to true to enable the automatic warm-up feature, or set to false to disable it.
"""
put_account_dedicated_ip_warmup_attributes(; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/account/dedicated-ips/warmup"; aws_config=aws_config)
put_account_dedicated_ip_warmup_attributes(params::AbstractDict{String, Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/account/dedicated-ips/warmup", params; aws_config=aws_config)

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

Enable or disable the ability of your account to send email.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"SendingEnabled"`: Enables or disables your account's ability to send email. Set to true
  to enable email sending, or set to false to disable email sending.  If AWS paused your
  account's ability to send email, you can't use this operation to resume your account's
  ability to send email.
"""
put_account_sending_attributes(; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/account/sending"; aws_config=aws_config)
put_account_sending_attributes(params::AbstractDict{String, Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/account/sending", params; aws_config=aws_config)

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

Associate a configuration set with a dedicated IP pool. You can use dedicated IP pools to
create groups of dedicated IP addresses for sending specific types of email.

# Arguments
- `configuration_set_name`: The name of the configuration set that you want to associate
  with a dedicated IP pool.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"SendingPoolName"`: The name of the dedicated IP pool that you want to associate with
  the configuration set.
- `"TlsPolicy"`: Specifies whether messages that use the configuration set are required to
  use Transport Layer Security (TLS). If the value is Require, messages are only delivered if
  a TLS connection can be established. If the value is Optional, messages can be delivered in
  plain text if a TLS connection can't be established.
"""
put_configuration_set_delivery_options(ConfigurationSetName; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/configuration-sets/$(ConfigurationSetName)/delivery-options"; aws_config=aws_config)
put_configuration_set_delivery_options(ConfigurationSetName, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/configuration-sets/$(ConfigurationSetName)/delivery-options", params; aws_config=aws_config)

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

Enable or disable collection of reputation metrics for emails that you send using a
particular configuration set in a specific AWS Region.

# Arguments
- `configuration_set_name`: The name of the configuration set that you want to enable or
  disable reputation metric tracking for.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"ReputationMetricsEnabled"`: If true, tracking of reputation metrics is enabled for the
  configuration set. If false, tracking of reputation metrics is disabled for the
  configuration set.
"""
put_configuration_set_reputation_options(ConfigurationSetName; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/configuration-sets/$(ConfigurationSetName)/reputation-options"; aws_config=aws_config)
put_configuration_set_reputation_options(ConfigurationSetName, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/configuration-sets/$(ConfigurationSetName)/reputation-options", params; aws_config=aws_config)

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

Enable or disable email sending for messages that use a particular configuration set in a
specific AWS Region.

# Arguments
- `configuration_set_name`: The name of the configuration set that you want to enable or
  disable email sending for.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"SendingEnabled"`: If true, email sending is enabled for the configuration set. If
  false, email sending is disabled for the configuration set.
"""
put_configuration_set_sending_options(ConfigurationSetName; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/configuration-sets/$(ConfigurationSetName)/sending"; aws_config=aws_config)
put_configuration_set_sending_options(ConfigurationSetName, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/configuration-sets/$(ConfigurationSetName)/sending", params; aws_config=aws_config)

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

Specify a custom domain to use for open and click tracking elements in email that you send
using Amazon Pinpoint.

# Arguments
- `configuration_set_name`: The name of the configuration set that you want to add a custom
  tracking domain to.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"CustomRedirectDomain"`: The domain that you want to use to track open and click events.
"""
put_configuration_set_tracking_options(ConfigurationSetName; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/configuration-sets/$(ConfigurationSetName)/tracking-options"; aws_config=aws_config)
put_configuration_set_tracking_options(ConfigurationSetName, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/configuration-sets/$(ConfigurationSetName)/tracking-options", params; aws_config=aws_config)

"""
    put_dedicated_ip_in_pool(destination_pool_name, ip)
    put_dedicated_ip_in_pool(destination_pool_name, ip, params::Dict{String,<:Any})

Move a dedicated IP address to an existing dedicated IP pool.  The dedicated IP address
that you specify must already exist, and must be associated with your Amazon Pinpoint
account.  The dedicated IP pool you specify must already exist. You can create a new pool
by using the CreateDedicatedIpPool operation.

# Arguments
- `destination_pool_name`: The name of the IP pool that you want to add the dedicated IP
  address to. You have to specify an IP pool that already exists.
- `ip`: The IP address that you want to move to the dedicated IP pool. The value you
  specify has to be a dedicated IP address that's associated with your Amazon Pinpoint
  account.

"""
put_dedicated_ip_in_pool(DestinationPoolName, IP; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/dedicated-ips/$(IP)/pool", Dict{String, Any}("DestinationPoolName"=>DestinationPoolName); aws_config=aws_config)
put_dedicated_ip_in_pool(DestinationPoolName, IP, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/dedicated-ips/$(IP)/pool", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("DestinationPoolName"=>DestinationPoolName), params)); aws_config=aws_config)

"""
    put_dedicated_ip_warmup_attributes(ip, warmup_percentage)
    put_dedicated_ip_warmup_attributes(ip, warmup_percentage, params::Dict{String,<:Any})

# Arguments
- `ip`: The dedicated IP address that you want to update the warm-up attributes for.
- `warmup_percentage`: The warm-up percentage that you want to associate with the dedicated
  IP address.

"""
put_dedicated_ip_warmup_attributes(IP, WarmupPercentage; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/dedicated-ips/$(IP)/warmup", Dict{String, Any}("WarmupPercentage"=>WarmupPercentage); aws_config=aws_config)
put_dedicated_ip_warmup_attributes(IP, WarmupPercentage, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/dedicated-ips/$(IP)/warmup", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("WarmupPercentage"=>WarmupPercentage), params)); aws_config=aws_config)

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

Enable or disable the Deliverability dashboard for your Amazon Pinpoint account. When you
enable the Deliverability dashboard, you gain access to reputation, deliverability, and
other metrics for the domains that you use to send email using Amazon Pinpoint. You also
gain the ability to perform predictive inbox placement tests. When you use the
Deliverability dashboard, you pay a monthly subscription charge, in addition to any other
fees that you accrue by using Amazon Pinpoint. For more information about the features and
cost of a Deliverability dashboard subscription, see Amazon Pinpoint Pricing.

# Arguments
- `dashboard_enabled`: Specifies whether to enable the Deliverability dashboard for your
  Amazon Pinpoint account. To enable the dashboard, set this value to true.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"SubscribedDomains"`: An array of objects, one for each verified domain that you use to
  send email and enabled the Deliverability dashboard for.
"""
put_deliverability_dashboard_option(DashboardEnabled; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/deliverability-dashboard", Dict{String, Any}("DashboardEnabled"=>DashboardEnabled); aws_config=aws_config)
put_deliverability_dashboard_option(DashboardEnabled, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/deliverability-dashboard", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("DashboardEnabled"=>DashboardEnabled), params)); aws_config=aws_config)

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

Used to enable or disable DKIM authentication for an email identity.

# Arguments
- `email_identity`: The email identity that you want to change the DKIM settings for.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"SigningEnabled"`: Sets the DKIM signing configuration for the identity. When you set
  this value true, then the messages that Amazon Pinpoint sends from the identity are
  DKIM-signed. When you set this value to false, then the messages that Amazon Pinpoint sends
  from the identity aren't DKIM-signed.
"""
put_email_identity_dkim_attributes(EmailIdentity; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/identities/$(EmailIdentity)/dkim"; aws_config=aws_config)
put_email_identity_dkim_attributes(EmailIdentity, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/identities/$(EmailIdentity)/dkim", params; aws_config=aws_config)

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

Used to enable or disable feedback forwarding for an identity. This setting determines what
happens when an identity is used to send an email that results in a bounce or complaint
event. When you enable feedback forwarding, Amazon Pinpoint sends you email notifications
when bounce or complaint events occur. Amazon Pinpoint sends this notification to the
address that you specified in the Return-Path header of the original email. When you
disable feedback forwarding, Amazon Pinpoint sends notifications through other mechanisms,
such as by notifying an Amazon SNS topic. You're required to have a method of tracking
bounces and complaints. If you haven't set up another mechanism for receiving bounce or
complaint notifications, Amazon Pinpoint sends an email notification when these events
occur (even if this setting is disabled).

# Arguments
- `email_identity`: The email identity that you want to configure bounce and complaint
  feedback forwarding for.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"EmailForwardingEnabled"`: Sets the feedback forwarding configuration for the identity.
  If the value is true, Amazon Pinpoint sends you email notifications when bounce or
  complaint events occur. Amazon Pinpoint sends this notification to the address that you
  specified in the Return-Path header of the original email. When you set this value to
  false, Amazon Pinpoint sends notifications through other mechanisms, such as by notifying
  an Amazon SNS topic or another event destination. You're required to have a method of
  tracking bounces and complaints. If you haven't set up another mechanism for receiving
  bounce or complaint notifications, Amazon Pinpoint sends an email notification when these
  events occur (even if this setting is disabled).
"""
put_email_identity_feedback_attributes(EmailIdentity; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/identities/$(EmailIdentity)/feedback"; aws_config=aws_config)
put_email_identity_feedback_attributes(EmailIdentity, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/identities/$(EmailIdentity)/feedback", params; aws_config=aws_config)

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

Used to enable or disable the custom Mail-From domain configuration for an email identity.

# Arguments
- `email_identity`: The verified email identity that you want to set up the custom MAIL
  FROM domain for.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"BehaviorOnMxFailure"`: The action that you want Amazon Pinpoint to take if it can't
  read the required MX record when you send an email. When you set this value to
  UseDefaultValue, Amazon Pinpoint uses amazonses.com as the MAIL FROM domain. When you set
  this value to RejectMessage, Amazon Pinpoint returns a MailFromDomainNotVerified error, and
  doesn't attempt to deliver the email. These behaviors are taken when the custom MAIL FROM
  domain configuration is in the Pending, Failed, and TemporaryFailure states.
- `"MailFromDomain"`:  The custom MAIL FROM domain that you want the verified identity to
  use. The MAIL FROM domain must meet the following criteria:   It has to be a subdomain of
  the verified identity.   It can't be used to receive email.   It can't be used in a
  \"From\" address if the MAIL FROM domain is a destination for feedback forwarding emails.
"""
put_email_identity_mail_from_attributes(EmailIdentity; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/identities/$(EmailIdentity)/mail-from"; aws_config=aws_config)
put_email_identity_mail_from_attributes(EmailIdentity, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/identities/$(EmailIdentity)/mail-from", params; aws_config=aws_config)

"""
    send_email(content, destination)
    send_email(content, destination, params::Dict{String,<:Any})

Sends an email message. You can use the Amazon Pinpoint Email API to send two types of
messages:    Simple – A standard email message. When you create this type of message, you
specify the sender, the recipient, and the message body, and Amazon Pinpoint assembles the
message for you.    Raw – A raw, MIME-formatted email message. When you send this type of
email, you have to specify all of the message headers, as well as the message body. You can
use this message type to send messages that contain attachments. The message that you
specify has to be a valid MIME message.

# Arguments
- `content`: An object that contains the body of the message. You can send either a Simple
  message or a Raw message.
- `destination`: An object that contains the recipients of the email message.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"ConfigurationSetName"`: The name of the configuration set that you want to use when
  sending the email.
- `"EmailTags"`: A list of tags, in the form of name/value pairs, to apply to an email that
  you send using the SendEmail operation. Tags correspond to characteristics of the email
  that you define, so that you can publish email sending events.
- `"FeedbackForwardingEmailAddress"`: The address that Amazon Pinpoint should send bounce
  and complaint notifications to.
- `"FromEmailAddress"`: The email address that you want to use as the \"From\" address for
  the email. The address that you specify has to be verified.
- `"ReplyToAddresses"`: The \"Reply-to\" email addresses for the message. When the
  recipient replies to the message, each Reply-to address receives the reply.
"""
send_email(Content, Destination; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("POST", "/v1/email/outbound-emails", Dict{String, Any}("Content"=>Content, "Destination"=>Destination); aws_config=aws_config)
send_email(Content, Destination, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("POST", "/v1/email/outbound-emails", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("Content"=>Content, "Destination"=>Destination), params)); aws_config=aws_config)

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

Add one or more tags (keys and values) to a specified resource. A tag is a label that you
optionally define and associate with a resource in Amazon Pinpoint. Tags can help you
categorize and manage resources in different ways, such as by purpose, owner, environment,
or other criteria. A resource can have as many as 50 tags. Each tag consists of a
required tag key and an associated tag value, both of which you define. A tag key is a
general label that acts as a category for more specific tag values. A tag value acts as a
descriptor within a tag key.

# Arguments
- `resource_arn`: The Amazon Resource Name (ARN) of the resource that you want to add one
  or more tags to.
- `tags`: A list of the tags that you want to add to the resource. A tag consists of a
  required tag key (Key) and an associated tag value (Value). The maximum length of a tag key
  is 128 characters. The maximum length of a tag value is 256 characters.

"""
tag_resource(ResourceArn, Tags; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("POST", "/v1/email/tags", Dict{String, Any}("ResourceArn"=>ResourceArn, "Tags"=>Tags); aws_config=aws_config)
tag_resource(ResourceArn, Tags, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("POST", "/v1/email/tags", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ResourceArn"=>ResourceArn, "Tags"=>Tags), params)); aws_config=aws_config)

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

Remove one or more tags (keys and values) from a specified resource.

# Arguments
- `resource_arn`: The Amazon Resource Name (ARN) of the resource that you want to remove
  one or more tags from.
- `tag_keys`: The tags (tag keys) that you want to remove from the resource. When you
  specify a tag key, the action removes both that key and its associated tag value. To remove
  more than one tag from the resource, append the TagKeys parameter and argument for each
  additional tag to remove, separated by an ampersand. For example:
  /v1/email/tags?ResourceArn=ResourceArn&TagKeys=Key1&TagKeys=Key2

"""
untag_resource(ResourceArn, TagKeys; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("DELETE", "/v1/email/tags", Dict{String, Any}("ResourceArn"=>ResourceArn, "TagKeys"=>TagKeys); aws_config=aws_config)
untag_resource(ResourceArn, TagKeys, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("DELETE", "/v1/email/tags", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ResourceArn"=>ResourceArn, "TagKeys"=>TagKeys), params)); aws_config=aws_config)

"""
    update_configuration_set_event_destination(configuration_set_name, event_destination, event_destination_name)
    update_configuration_set_event_destination(configuration_set_name, event_destination, event_destination_name, params::Dict{String,<:Any})

Update the configuration of an event destination for a configuration set. In Amazon
Pinpoint, events include message sends, deliveries, opens, clicks, bounces, and complaints.
Event destinations are places that you can send information about these events to. For
example, you can send event data to Amazon SNS to receive notifications when you receive
bounces or complaints, or you can use Amazon Kinesis Data Firehose to stream data to Amazon
S3 for long-term storage.

# Arguments
- `configuration_set_name`: The name of the configuration set that contains the event
  destination that you want to modify.
- `event_destination`: An object that defines the event destination.
- `event_destination_name`: The name of the event destination that you want to modify.

"""
update_configuration_set_event_destination(ConfigurationSetName, EventDestination, EventDestinationName; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/configuration-sets/$(ConfigurationSetName)/event-destinations/$(EventDestinationName)", Dict{String, Any}("EventDestination"=>EventDestination); aws_config=aws_config)
update_configuration_set_event_destination(ConfigurationSetName, EventDestination, EventDestinationName, params::AbstractDict{String, <:Any}; aws_config::AbstractAWSConfig=global_aws_config()) = pinpoint_email("PUT", "/v1/email/configuration-sets/$(ConfigurationSetName)/event-destinations/$(EventDestinationName)", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("EventDestination"=>EventDestination), params)); aws_config=aws_config)


text:
using WaveSim
using StaticArrays

# Define simulation parameters (use many default values, see WaveSimParameters).
const fov = @SVector [0.8 * 15e-2, 15e-2]  # [m]
sim_params = WaveSimParameters(
    tx_frequency = 2.75e6,
    pulse_cycles = 5,
    steer_angle = 0.0,  # [deg]
    fov = fov,
    end_simulation_time = 2 * 56.0e-6,  # [s] starts at 0 s
    aperture_size = 0.019968,
    # focus_depth = 0.11,  # [m]
    focus_depth = Inf,  # [m]
    temporal_res = 0.05e-6 ,  # [s]
    spatial_res = [256, 256],  # [pixels]
    dbrange = 30,
    orientation = :vertical
);

# Compute focusing delays for the elements of the phased array.
trans_delays = WaveSim.delays_from_focus_and_steer(sim_params);

# Run the simulation.
images = WaveSim.wavesim(trans_delays, sim_params);
beam_energy_map, transmit_time_map = WaveSim.beam_energy_map_and_transmit_time_map(images, sim_params);

# Display results.
include("src/view.jl")
imshowall(images, beam_energy_map, transmit_time_map, sim_params);

# Save results.
include("src/save.jl")
saveall(images, beam_energy_map, transmit_time_map, sim_params);

ext: jl


text:
#
println("Cd) Test of the FormFactor module with ASF from an internally generated multiplet.")
#
setDefaults("print summary: open", "zzz-FormFactor.sum")
wa = Atomic.Computation("xx",  Nuclear.Model(26.); properties=[JAC.FormF],
                        configs=[Configuration("[Ne] 3s^2 3p^5"), Configuration("[Ne] 3s 3p^6")],
                        formSettings=FormFactor.Settings([0., 0.1, 1.0, 10., 100., 1000.], true, false, Int64[]) )

wb = perform(wa)
setDefaults("print summary: close", "")


text:
# ---
# title: 89. Gray Code
# id: problem89
# author: Indigo
# date: 2021-06-02
# difficulty: Medium
# categories: Backtracking
# link: <https://leetcode.com/problems/gray-code/description/>
# hidden: true
# ---
#
# The gray code is a binary numeral system where two successive values differ in
# only one bit.
#
# Given a non-negative integer _n_ representing the total number of bits in the
# code, print the sequence of gray code. A gray code sequence must begin with 0.
#
# **Example 1:**
#
#
#
#     Input:  2
#     Output:  [0,1,3,2]
#     Explanation:
#     00 - 0
#     01 - 1
#     11 - 3
#     10 - 2
#
#     For a given  _n_ , a gray code sequence may not be uniquely defined.
#     For example, [0,2,3,1] is also a valid gray code sequence.
#
#     00 - 0
#     10 - 2
#     11 - 3
#     01 - 1
#
#
# **Example 2:**
#
#
#
#     Input:  0
#     Output:  [0]
#     Explanation: We define the gray code sequence to begin with 0.
#                  A gray code sequence of _n_ has size = 2n, which for _n_ = 0 the size is 20 = 1.
#                  Therefore, for _n_ = 0 the gray code sequence is [0].
#
#
#
## @lc code=start
using LeetCode

function gray_code(N::Int)
    powN = 1 << N
    res = Array{Int}(undef, powN)
    for i in 0:powN-1
        res[i + 1] = i ⊻ (i >> 1);
    end
    res
end
## @lc code=end


text:
module TestUtils

using Test
using ThreadedScans.Internal: partitionto

function test_partitionto()
    @testset for len in 1:100, nchunks in 1:len
        chunks = collect(partitionto(1:len, nchunks))
        @test length(chunks) == nchunks
        @test reduce(vcat, chunks) == 1:len
    end
end

end  # module


text:
using AbstractPlotting: extrema_nan

notch_width(q2, q4, N) = 1.58 * (q4-q2)/sqrt(N)

pair_up(dict, key) = (key => dict[key])

#=
Taken from https://github.com/JuliaPlots/StatPlots.jl/blob/master/src/boxplot.jl#L7
The StatPlots.jl package is licensed under the MIT "Expat" License:
    Copyright (c) 2016: Thomas Breloff.
=#
@recipe(BoxPlot, x, y) do scene
    t = Theme(
        color = theme(scene, :color),
        notch = false,
        range = 1.5,
        outliers = true,
        whisker_width = :match,
        width = 0.8,
        markershape = :circle,
        strokecolor = :black,
        strokewidth = 1.0,
        mediancolor = :white,
        show_median = true,
        markersize = automatic,
        orientation = :vertical,
    )
    t[:outliercolor] = t[:color]
    t
end

_cycle(v::AbstractVector, idx::Integer) = v[mod1(idx, length(v))]
_cycle(v, idx::Integer) = v

_flip_xy(p::Point2f0) = reverse(p)
_flip_xy(r::Rect{2, T}) where T = Rect{2, T}(reverse(r.origin), reverse(r.widths))

function AbstractPlotting.plot!(plot::BoxPlot)
    args = @extract plot (width, range, outliers, whisker_width, notch, orientation)

    signals = lift(plot[1], plot[2], args...) do x, y, bw, range, outliers, whisker_width, notch, orientation
        glabels = sort(collect(unique(x)))
        warning = false
        outlier_points = Point2f0[]
        if !(whisker_width == :match || whisker_width >= 0)
            error("whisker_width must be :match or a positive number. Found: $whisker_width")
        end
        ww = whisker_width == :match ? bw : whisker_width
        boxes = FRect2D[]
        notched_boxes = Vector{Point2f0}[]
        t_segments = Point2f0[]
        medians = Point2f0[]
        for (i, glabel) in enumerate(glabels)
            # filter y
            values = y[filter(i -> _cycle(x, i) == glabel, 1:length(y))]
            # compute quantiles
            q1, q2, q3, q4, q5 = quantile(values, LinRange(0, 1, 5))
            # notch
            n = notch_width(q2, q4, length(values))
            # warn on inverted notches?
            if notch && !warning && ( (q2>(q3-n)) || (q4<(q3+n)) )
                @warn("Boxplot's notch went outside hinges. Set notch to false.")
                warning = true # Show the warning only one time
            end

            # make the shape
            center = glabel
            hw = 0.5 * _cycle(bw, i) # Box width
            HW = 0.5 * _cycle(ww, i) # Whisker width
            l, m, r = center - hw, center, center + hw
            lw, rw = center - HW, center + HW

            # internal nodes for notches
            L, R = center - 0.5 * hw, center + 0.5 * hw

            # outliers
            if Float64(range) != 0.0  # if the range is 0.0, the whiskers will extend to the data
                limit = range*(q4-q2)
                inside = Float64[]
                for value in values
                    if (value < (q2 - limit)) || (value > (q4 + limit))
                        if outliers
                            push!(outlier_points, (center, value))
                        end
                    else
                        push!(inside, value)
                    end
                end
                # change q1 and q5 to show outliers
                # using maximum and minimum values inside the limits
                q1, q5 = extrema_nan(inside)
            end
            push!(t_segments, (m, q2), (m, q1), (l, q1), (r, q1))# lower T
            push!(t_segments, (m, q4), (m, q5), (r, q5), (l, q5))# upper T
            # Box
            if notch
                push!(notched_boxes, map(Point2f0, [(l,q2),(r,q2),(r, q2 + n/2),(R, q3), (r, q4-n/2) , (r, q4), (l, q4), (l, q4-n/2), (L, q3), (l, q2+n/2), (l,q2)]))
                # push!(boxes, FRect(l, q4, hw, n)) # lower box
                push!(medians, (L, q3), (R, q3))
            else
                push!(boxes, FRect(l, q2, 2hw, (q4 - q2)))
                push!(medians, (l, q3), (r, q3))
            end
        end

        final_boxes = notch ? notched_boxes : boxes

        # for horizontal boxplots just flip all components
        if orientation == :horizontal
            final_boxes = _flip_xy.(final_boxes)
            outlier_points = _flip_xy.(outlier_points)
            medians = _flip_xy.(medians)
            t_segments = _flip_xy.(t_segments)
        elseif orientation != :vertical
            error("Invalid orientation $orientation. Valid options: :horizontal or :vertical.")
        end

        return final_boxes, outlier_points, medians, t_segments
    end

    boxes = @lift($signals[1])
    outliers = @lift($signals[2])
    medians = @lift($signals[3])
    t_segments = @lift($signals[4])

    scatter!(
        plot,
        color = plot[:outliercolor],
        strokecolor = plot[:strokecolor],
        markersize = lift((w, ms)-> ms === automatic ? w * 0.1 : ms, width, plot.markersize),
        strokewidth = plot[:strokewidth],
        outliers,
    )
    linesegments!(
        plot,
        color = plot[:strokecolor],
        linewidth = plot[:strokewidth],
        t_segments,
    )
    poly!(
        plot,
        color = plot[:color],
        boxes,
    )
    linesegments!(
        plot,
        color = plot[:mediancolor],
        visible = plot[:show_median],
        medians,
    )
end


text:
using CDSAPI
using NCDatasets
using Test

# list of tests

@testset "CDSAPI.jl" begin

    ddir = joinpath(@__DIR__,"data")

    @testset "ERA5 Single Level" begin

        fnc = joinpath(ddir,"era5test.nc")
        lsm = Dict(
            "product_type" => "reanalysis",
            "variable"     => "land_sea_mask",
            "year"         => 2019,
            "month"        => 1,
            "day"          => 1,
            "time"         => "00:00",
            "format"       => "netcdf"
        )
        retrieve("reanalysis-era5-single-levels",lsm,fnc)

        ds = NCDataset(fnc)
        @test ds["longitude"] == collect(0:0.25:359.75)
        @test ds["latitude"]  == collect(90:-0.25:-90)
        @test ds["time"]      == DateTime(2019,1,1)
        close(ds)

        rm(fnc)

    end

    @testset "ERA5 Arrays in Dict" begin

        fnc = joinpath(ddir,"era5test.nc")
        lsm = Dict(
            "product_type" => "reanalysis",
            "variable"     => "land_sea_mask",
            "year"         => [2019,2020],
            "month"        => 1,
            "day"          => 1,
            "grid"         => [20,90,-15,165]
            "time"         => "00:00",
            "format"       => "netcdf"
        )
        retrieve("reanalysis-era5-single-levels",lsm,fnc)

        ds = NCDataset(fnc)
        @test ds["longitude"] == collect(90:0.25:165)
        @test ds["latitude"]  == collect(20:-0.25:-15)
        @test ds["time"]      == DateTime.([2019,2020],1,1)
        close(ds)

        rm(fnc)

    end

end


text:
struct TextureParameters{NDim}
    minfilter::Symbol
    magfilter::Symbol # magnification
    repeat   ::NTuple{NDim, Symbol}
    anisotropic::Float32
    swizzle_mask::Vector{GLenum}
end

abstract type OpenglTexture{T, NDIM} <: GPUArray{T, NDIM} end

mutable struct Texture{T <: GLArrayEltypes, NDIM} <: OpenglTexture{T, NDIM}
    id              ::GLuint
    texturetype     ::GLenum
    pixeltype       ::GLenum
    internalformat  ::GLenum
    format          ::GLenum
    parameters      ::TextureParameters{NDIM}
    size            ::NTuple{NDIM, Int}
    context         ::GLContext
    function Texture{T, NDIM}(
            id              ::GLuint,
            texturetype     ::GLenum,
            pixeltype       ::GLenum,
            internalformat  ::GLenum,
            format          ::GLenum,
            parameters      ::TextureParameters{NDIM},
            size            ::NTuple{NDIM, Int}
        )  where {T, NDIM}
        tex = new(
            id,
            texturetype,
            pixeltype,
            internalformat,
            format,
            parameters,
            size,
            current_context()
        )
        finalizer(free, tex)
        tex
    end
end

# for bufferSampler, aka Texture Buffer
mutable struct TextureBuffer{T <: GLArrayEltypes} <: OpenglTexture{T, 1}
    texture::Texture{T, 1}
    buffer::GLBuffer{T}
end
Base.size(t::TextureBuffer) = size(t.buffer)
Base.size(t::TextureBuffer, i::Integer) = size(t.buffer, i)
Base.length(t::TextureBuffer) = length(t.buffer)
bind(t::Texture) = glBindTexture(t.texturetype, t.id)
bind(t::Texture, id) = glBindTexture(t.texturetype, id)

is_texturearray(t::Texture) = t.texturetype == GL_TEXTURE_2D_ARRAY
is_texturebuffer(t::Texture) = t.texturetype == GL_TEXTURE_BUFFER

colordim(::Type{T}) where {T} = cardinality(T)
colordim(::Type{T}) where {T <: Real} = 1

function set_packing_alignment(a) # at some point we should specialize to array/ptr a
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
    glPixelStorei(GL_UNPACK_ROW_LENGTH, 0)
    glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0)
    glPixelStorei(GL_UNPACK_SKIP_ROWS, 0)
end

function Texture(
        data::Ptr{T}, dims::NTuple{NDim, Int};
        internalformat::GLenum = default_internalcolorformat(T),
        texturetype   ::GLenum = default_texturetype(NDim),
        format        ::GLenum = default_colorformat(T),
        mipmap = false,
        parameters... # rest should be texture parameters
    ) where {T, NDim}
    texparams = TextureParameters(T, NDim; parameters...)
    id = glGenTextures()
    glBindTexture(texturetype, id)
    set_packing_alignment(data)
    numbertype = julia2glenum(eltype(T))
    glTexImage(texturetype, 0, internalformat, dims..., 0, format, numbertype, data)
    mipmap && glGenerateMipmap(texturetype)
    texture = Texture{T, NDim}(
        id, texturetype, numbertype, internalformat, format,
        texparams,
        dims
    )
    set_parameters(texture)
    texture::Texture{T, NDim}
end
export resize_nocopy!
function resize_nocopy!(t::Texture{T, ND}, newdims::NTuple{ND, Int}) where {T, ND}
    bind(t)
    glTexImage(t.texturetype, 0, t.internalformat, newdims..., 0, t.format, t.pixeltype, C_NULL)
    t.size = newdims
    bind(t, 0)
    t
end

"""
Constructor for empty initialization with NULL pointer instead of an array with data.
You just need to pass the wanted color/vector type and the dimensions.
To which values the texture gets initialized is driver dependent
"""
Texture(::Type{T}, dims::NTuple{N, Int}; kw_args...) where {T <: GLArrayEltypes, N} =
    Texture(convert(Ptr{T}, C_NULL), dims; kw_args...)::Texture{T, N}

"""
Constructor for a normal array, with color or Abstract Arrays as elements.
So Array{Real, 2} == Texture2D with 1D Colorant dimension
Array{Vec1/2/3/4, 2} == Texture2D with 1/2/3/4D Colorant dimension
Colors from Colors.jl should mostly work as well
"""
Texture(image::Array{T, NDim}; kw_args...) where {T <: GLArrayEltypes, NDim} =
    Texture(pointer(image), size(image); kw_args...)::Texture{T, NDim}

"""
Constructor for Array Texture
"""
function Texture(
        data::Vector{Array{T, 2}};
        internalformat::GLenum = default_internalcolorformat(T),
        texturetype::GLenum    = GL_TEXTURE_2D_ARRAY,
        format::GLenum         = default_colorformat(T),
        parameters...
    ) where T <: GLArrayEltypes
    texparams = TextureParameters(T, 2; parameters...)
    id = glGenTextures()

    glBindTexture(texturetype, id)

    numbertype = julia2glenum(eltype(T))

    layers  = length(data)
    dims    = map(size, data)
    maxdims = foldl(dims, init = (0,0)) do v0, x
        a = max(v0[1], x[1])
        b = max(v0[2], x[2])
        (a,b)
    end
    set_packing_alignment(data)
    glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, internalformat, maxdims..., layers)
    for (layer, texel) in enumerate(data)
        width, height = size(texel)
        glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, layer-1, width, height, 1, format, numbertype, texel)
    end

    texture = Texture{T, 2}(
        id, texturetype, numbertype,
        internalformat, format, texparams,
        tuple(maxdims...)
    )
    set_parameters(texture)
    texture
end

function TextureBuffer(buffer::GLBuffer{T}) where T <: GLArrayEltypes
    texture_type = GL_TEXTURE_BUFFER
    id = glGenTextures()
    glBindTexture(texture_type, id)
    internalformat = default_internalcolorformat(T)
    glTexBuffer(texture_type, internalformat, buffer.id)
    tex = Texture{T, 1}(
        id, texture_type, julia2glenum(T), internalformat,
        default_colorformat(T), TextureParameters(T, 1),
        size(buffer)
    )
    TextureBuffer(tex, buffer)
end
function TextureBuffer(buffer::Vector{T}) where T <: GLArrayEltypes
    buff = GLBuffer(buffer, buffertype = GL_TEXTURE_BUFFER, usage = GL_DYNAMIC_DRAW)
    TextureBuffer(buff)
end

#=
Some special treatmend for types, with alpha in the First place

function Texture{T <: Real, NDim}(image::Array{ARGB{T}, NDim}, texture_properties::Vector{(Symbol, Any)})
    data = map(image) do colorvalue
        AlphaColorValue(colorvalue.c, colorvalue.alpha)
    end
    Texture(pointer(data), [size(data)...], texture_properties)
end
=#

#=
Creates a texture from an Image
=#
##function Texture(image::Image, texture_properties::Vector{(Symbol, Any)})
#    data = image.data
#    Texture(mapslices(reverse, data, ndims(data)), texture_properties)
#end

GeometryBasics.width(t::Texture)  = size(t, 1)
GeometryBasics.height(t::Texture) = size(t, 2)
depth(t::Texture)  = size(t, 3)

# AbstractArrays default show assumes `getindex`. Try to catch all calls
# https://discourse.julialang.org/t/overload-show-for-array-of-custom-types/9589

Base.show(io::IO, t::Texture) = show(IOContext(io), MIME"text/plain"(), t)

function Base.show(io::IOContext, mime::MIME"text/plain", t::Texture{T,D}) where {T,D}
    if get(io, :compact, false)
        println(io, "Texture$(D)D, ID: $(t.id), Size: $(size(t))")
    else
        show(io.io, mime, t)
    end
end

function Base.show(io::IO, ::MIME"text/plain", t::Texture{T,D}) where {T,D}
    println(io, "Texture$(D)D: ")
    println(io, "                  ID: ", t.id)
    println(io, "                Size: ", reduce(size(t), init = "Dimensions: ") do v0, v1
        v0*"x"*string(v1)
    end)
    println(io, "    Julia pixel type: ", T)
    println(io, "   OpenGL pixel type: ", GLENUM(t.pixeltype).name)
    println(io, "              Format: ", GLENUM(t.format).name)
    println(io, "     Internal format: ", GLENUM(t.internalformat).name)
    println(io, "          Parameters: ", t.parameters)
end

# GPUArray interface:
function unsafe_copy!(a::Vector{T}, readoffset::Int, b::TextureBuffer{T}, writeoffset::Int, len::Int) where T
    copy!(a, readoffset, b.buffer, writeoffset, len)
    glBindTexture(b.texture.texturetype, b.texture.id)
    glTexBuffer(b.texture.texturetype, b.texture.internalformat, b.buffer.id) # update texture
end

function unsafe_copy!(a::TextureBuffer{T}, readoffset::Int, b::Vector{T}, writeoffset::Int, len::Int) where T
    copy!(a.buffer, readoffset, b, writeoffset, len)
    glBindTexture(a.texture.texturetype, a.texture.id)
    glTexBuffer(a.texture.texturetype, a.texture.internalformat, a.buffer.id) # update texture
end

function unsafe_copy!(a::TextureBuffer{T}, readoffset::Int, b::TextureBuffer{T}, writeoffset::Int, len::Int) where T
    unsafe_copy!(a.buffer, readoffset, b.buffer, writeoffset, len)

    glBindTexture(a.texture.texturetype, a.texture.id)
    glTexBuffer(a.texture.texturetype, a.texture.internalformat, a.buffer.id) # update texture

    glBindTexture(b.texture.texturetype, btexture..id)
    glTexBuffer(b.texture.texturetype, b.texture.internalformat, b.buffer.id) # update texture
    glBindTexture(t.texture.texturetype, 0)
end
function gpu_setindex!(t::TextureBuffer{T}, newvalue::Vector{T}, indexes::UnitRange{I}) where {T, I <: Integer}
    glBindTexture(t.texture.texturetype, t.texture.id)
    t.buffer[indexes] = newvalue # set buffer indexes
    glTexBuffer(t.texture.texturetype, t.texture.internalformat, t.buffer.id) # update texture
    glBindTexture(t.texture.texturetype, 0)
end
function gpu_setindex!(t::Texture{T, 1}, newvalue::Array{T, 1}, indexes::UnitRange{I}) where {T, I <: Integer}
    glBindTexture(t.texturetype, t.id)
    texsubimage(t, newvalue, indexes)
    glBindTexture(t.texturetype, 0)
end
function gpu_setindex!(t::Texture{T, N}, newvalue::Array{T, N}, indexes::Union{UnitRange,Integer}...) where {T, N}
    glBindTexture(t.texturetype, t.id)
    texsubimage(t, newvalue, indexes...)
    glBindTexture(t.texturetype, 0)
end

function gpu_setindex!(target::Texture{T, 2}, source::Texture{T, 2}, fbo=glGenFramebuffers()) where T
    glBindFramebuffer(GL_FRAMEBUFFER, fbo)
    glFramebufferTexture2D(
        GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
        GL_TEXTURE_2D, source.id, 0
    )
    glFramebufferTexture2D(
        GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT1,
        GL_TEXTURE_2D, target.id, 0
    )
    glDrawBuffer(GL_COLOR_ATTACHMENT1);
    w, h = map(minimum, zip(size(target), size(source)))
    glBlitFramebuffer(
        0, 0, w, h, 0, 0, w, h,
        GL_COLOR_BUFFER_BIT, GL_NEAREST
    )
end

#=
function gpu_setindex!{T}(target::Texture{T, 2}, source::Texture{T, 2}, fbo=glGenFramebuffers())
    w, h = map(minimum, zip(size(target), size(source)))
    glCopyImageSubData( source.id, source.texturetype,
    0,0,0,0,
    target.id, target.texturetype,
    0,0,0,0, w,h,0);
end
=#
# Implementing the GPUArray interface
function gpu_data(t::Texture{T, ND}) where {T, ND}
    result = Array{T, ND}(undef, size(t))
    unsafe_copy!(result, t)
    return result
end

function unsafe_copy!(dest::Array{T, N}, source::Texture{T, N}) where {T,N}
    bind(source)
    glGetTexImage(source.texturetype, 0, source.format, source.pixeltype, dest)
    bind(source, 0)
    nothing
end

gpu_data(t::TextureBuffer{T}) where {T} = gpu_data(t.buffer)
gpu_getindex(t::TextureBuffer{T}, i::UnitRange{Int64}) where {T} = t.buffer[i]

similar(t::Texture{T, NDim}, newdims::Int...) where {T, NDim} = similar(t, newdims)
function similar(t::TextureBuffer{T}, newdims::NTuple{1, Int}) where T
    buff = similar(t.buffer, newdims...)
    return TextureBuffer(buff)
end
function similar(t::Texture{T, NDim}, newdims::NTuple{NDim, Int}) where {T, NDim}
    Texture(
        Ptr{T}(C_NULL),
        newdims, t.texturetype,
        t.pixeltype,
        t.internalformat,
        t.format,
        t.parameters
    )
end
# Resize Texture
function gpu_resize!(t::TextureBuffer{T}, newdims::NTuple{1, Int}) where T
    resize!(t.buffer, newdims)
    glBindTexture(t.texture.texturetype, t.texture.id)
    glTexBuffer(t.texture.texturetype, t.texture.internalformat, t.buffer.id) #update data in texture
    t.texture.size  = newdims
    glBindTexture(t.texture.texturetype, 0)
    t
end
# Resize Texture
function gpu_resize!(t::Texture{T, ND}, newdims::NTuple{ND, Int}) where {T, ND}
    # dangerous code right here...Better write a few tests for this
    newtex = similar(t, newdims)
    old_size = size(t)
    gpu_setindex!(newtex, t)
    t.size = newdims
    free(t)
    t.id = newtex.id
    return t
end

texsubimage(t::Texture{T, 1}, newvalue::Array{T, 1}, xrange::UnitRange, level=0) where {T} = glTexSubImage1D(
    t.texturetype, level, first(xrange)-1, length(xrange), t.format, t.pixeltype, newvalue
)
function texsubimage(t::Texture{T, 2}, newvalue::Array{T, 2}, xrange::UnitRange, yrange::UnitRange, level=0) where T
    glTexSubImage2D(
        t.texturetype, level,
        first(xrange)-1, first(yrange)-1, length(xrange), length(yrange),
        t.format, t.pixeltype, newvalue
    )
end
texsubimage(t::Texture{T, 3}, newvalue::Array{T, 3}, xrange::UnitRange, yrange::UnitRange, zrange::UnitRange, level=0) where {T} = glTexSubImage3D(
    t.texturetype, level,
    first(xrange)-1, first(yrange)-1, first(zrange)-1, length(xrange), length(yrange), length(zrange),
    t.format, t.pixeltype, newvalue
)

Base.iterate(t::TextureBuffer{T}) where {T} = iterate(t.buffer)
function Base.iterate(t::TextureBuffer{T}, state::Tuple{Ptr{T}, Int}) where T
    v_idx = iterate(t.buffer, state)
    if v_idx === nothing
        glBindTexture(t.texturetype, t.id)
        glTexBuffer(t.texturetype, t.internalformat, t.buffer.id)
        glBindTexture(t.texturetype, 0)
    end
    v_idx
end
function default_colorformat_sym(colordim::Integer, isinteger::Bool, colororder::AbstractString)
    colordim > 4 && error("no colors with dimension > 4 allowed. Dimension given: ", colordim)
    sym = "GL_"
    # Handle that colordim == 1 => RED instead of R
    color = colordim == 1 ? "RED" : colororder[1:colordim]
    # Handle gray value
    integer = isinteger ? "_INTEGER" : ""
    sym *= color * integer
    return Symbol(sym)
end

default_colorformat_sym(::Type{T}) where {T <: Real} = default_colorformat_sym(1, T <: Integer, "RED")
default_colorformat_sym(::Type{T}) where {T <: AbstractArray} = default_colorformat_sym(cardinality(T), eltype(T) <: Integer, "RGBA")
default_colorformat_sym(::Type{T}) where {T <: StaticVector} = default_colorformat_sym(cardinality(T), eltype(T) <: Integer, "RGBA")
default_colorformat_sym(::Type{T}) where {T <: Colorant} = default_colorformat_sym(cardinality(T), eltype(T) <: Integer, string(Base.typename(T).name))

@generated function default_colorformat(::Type{T}) where T
    sym = default_colorformat_sym(T)
    if !isdefined(ModernGL, sym)
        error("$T doesn't have a propper mapping to an OpenGL format")
    end
    :($sym)
end

function default_internalcolorformat_sym(::Type{T}) where T
    cdim = colordim(T)
    if cdim > 4 || cdim < 1
        error("$(cdim)-dimensional colors not supported")
    end
    eltyp = eltype(T)
    sym = "GL_"
    sym *= "RGBA"[1:cdim]
    bits = sizeof(eltyp) * 8
    sym *= bits <= 32 ? string(bits) : error("$(T) has too many bits")
    if eltyp <: AbstractFloat
        sym *= "F"
    elseif eltyp <: FixedPoint
        sym *= eltyp <: Normed ? "" : "_SNORM"
    elseif eltyp <: Signed
        sym *= "I"
    elseif eltyp <: Unsigned
        sym *= "UI"
    end
    Symbol(sym)
end

# for I = 1:4
#     for
@generated function default_internalcolorformat(::Type{T}) where T
    sym = default_internalcolorformat_sym(T)
    if !isdefined(ModernGL, sym)
        error("$T doesn't have a propper mapping to an OpenGL format")
    end
    :($sym)
end

#Supported texture modes/dimensions
function default_texturetype(ndim::Integer)
    ndim == 1 && return GL_TEXTURE_1D
    ndim == 2 && return GL_TEXTURE_2D
    ndim == 3 && return GL_TEXTURE_3D
    error("Dimensionality: $(ndim), not supported for OpenGL texture")
end

map_texture_paramers(s::NTuple{N, Symbol}) where {N} = map(map_texture_paramers, s)

function map_texture_paramers(s::Symbol)

    s == :clamp_to_edge && return GL_CLAMP_TO_EDGE
    s == :mirrored_repeat && return GL_MIRRORED_REPEAT
    s == :repeat && return GL_REPEAT

    s == :linear && return GL_LINEAR
    s == :nearest && return GL_NEAREST
    s == :nearest_mipmap_nearest && return GL_NEAREST_MIPMAP_NEAREST
    s == :linear_mipmap_nearest && return GL_LINEAR_MIPMAP_NEAREST
    s == :nearest_mipmap_linear && return GL_NEAREST_MIPMAP_LINEAR
    s == :linear_mipmap_linear && return GL_LINEAR_MIPMAP_LINEAR

    error("$s is not a valid texture parameter")
end

function TextureParameters(T, NDim;
        minfilter = T <: Integer ? :nearest : :linear,
        magfilter = minfilter, # magnification
        x_repeat  = :clamp_to_edge, #wrap_s
        y_repeat  = x_repeat, #wrap_t
        z_repeat  = x_repeat, #wrap_r
        anisotropic = 1f0
    )
    T <: Integer && (minfilter == :linear || magfilter == :linear) && error("Wrong Texture Parameter: Integer texture can't interpolate. Try :nearest")
    repeat = (x_repeat, y_repeat, z_repeat)
    swizzle_mask = if T <: Gray
        GLenum[GL_RED, GL_RED, GL_RED, GL_ONE]
    elseif T <: GrayA
        GLenum[GL_RED, GL_RED, GL_RED, GL_ALPHA]
    else
        GLenum[]
    end
    TextureParameters(
        minfilter, magfilter, ntuple(i->repeat[i], NDim),
        anisotropic, swizzle_mask
    )
end
function TextureParameters(t::Texture{T, NDim}; kw_args...) where {T, NDim}
    TextureParameters(T, NDim; kw_args...)
end

const GL_TEXTURE_MAX_ANISOTROPY_EXT = GLenum(0x84FE)

function set_parameters(t::Texture{T, N}, params::TextureParameters=t.parameters) where {T, N}
    fnames = (:minfilter, :magfilter, :repeat)
    data = Dict([(name, map_texture_paramers(getfield(params, name))) for name in fnames])
    result = Tuple{GLenum, Any}[]
    push!(result, (GL_TEXTURE_MIN_FILTER, data[:minfilter]))
    push!(result, (GL_TEXTURE_MAG_FILTER, data[:magfilter]))
    push!(result, (GL_TEXTURE_WRAP_S, data[:repeat][1]))
    if !isempty(params.swizzle_mask)
        push!(result, (GL_TEXTURE_SWIZZLE_RGBA, params.swizzle_mask))
    end
    N >= 2 && push!(result, (GL_TEXTURE_WRAP_T, data[:repeat][2]))
    if N >= 3 && !is_texturearray(t) # for texture arrays, third dimension can not be set
        push!(result, (GL_TEXTURE_WRAP_R, data[:repeat][3]))
    end
    push!(result, (GL_TEXTURE_MAX_ANISOTROPY_EXT, params.anisotropic))
    t.parameters = params
    set_parameters(t, result)
end
function texparameter(t::Texture, key::GLenum, val::GLenum)
    glTexParameteri(t.texturetype, key, val)
end
function texparameter(t::Texture, key::GLenum, val::Vector)
    glTexParameteriv(t.texturetype, key, val)
end
function texparameter(t::Texture, key::GLenum, val::Float32)
    glTexParameterf(t.texturetype, key, val)
end
function set_parameters(t::Texture, parameters::Vector{Tuple{GLenum, Any}})
    bind(t)
    for elem in parameters
        texparameter(t, elem...)
    end
    bind(t, 0)
end


text:
### Time Handler ###
"""
`Clock` type contains information related to time

# Fields
- `tspan`::Tuple{Float64,Float64} : simulation time interval
- `current_time`::Float64 : current simulation time
- `iter`::Int : iteration number
- `Δt_max`::Float64 : maximum timestep
- `Δt`::Float64 : timestep
- `time_vec`::Vector{Float64} : vector containing times for each iteration
- `variable_Δt`::Bool : controls the ability to adapt the timestep
- `Δt_fact_up`::Float64 : timestep increase factor
- `Δt_fact_down`::Float64 : timestep decrease factor
"""
mutable struct Clock
    tspan::Tuple{Float64,Float64}
    current_time::Float64
    iter::Int
    Δt_max::Float64
    Δt::Float64
    time_vec::Vector{Float64}
    variable_Δt::Bool
    Δt_fact_up::Float64 # timestep increase factor
    Δt_fact_down::Float64 # timestep decrease factor
    function Clock(tspan,Δt_max,Δt,variable_Δt,Δt_fact_up,Δt_fact_down)
        current_time = float(tspan[1])
        iter = 0
        time_vec = Float64[tspan[1]]
        (Δt_max < Δt) && (Δt_max = Δt)
        if variable_Δt == false
            Δt_fact_up = 1.0
            Δt_fact_down = 1.0
        end
        new(convert(Tuple{Float64,Float64},tspan),current_time,iter,float(Δt_max),float(Δt),time_vec,variable_Δt,float(Δt_fact_up),float(Δt_fact_down))
    end
end

"""
    Clock(tspan::Tuple, Δt ; <keyword arguments>)

Clock constructor with time span `tspan` and timestep `Δt`.

# Keyword arguments
- `Δt_max` = 1.0 : maximum Δt
- `variable_Δt` = true : is the timestep allowed to change
- `Δt_fact_up` = 1.5 : timestep increase multiplier
- `Δt_fact_down` = 0.5 : timestep decrease multiplier
"""
Clock(tspan, Δt; Δt_max = 1.0, variable_Δt = true, Δt_fact_up = 1.5, Δt_fact_down = 0.5) = Clock(tspan,Δt_max,Δt,variable_Δt,Δt_fact_up,Δt_fact_down)

"""
    Clock(<keyword arguments>)

Clock constructor.

# Keyword arguments
- `tspan::Tuple` (mandatory) : time span
- `Δt` (mandatory) : timestep
- `Δt_max` = 1.0 : maximum Δt
- `variable_Δt` = true : is the timestep allowed to change
- `Δt_fact_up` = 1.5 : timestep increase multiplier
- `Δt_fact_down` = 0.5 : timestep decrease multiplier
"""
Clock(;tspan, Δt_max = 1.0, Δt, variable_Δt = true, Δt_fact_up = 1.5, Δt_fact_down = 0.5) = Clock(tspan,Δt_max,Δt,variable_Δt,Δt_fact_up,Δt_fact_down)

function Base.show(io::IO, ::MIME"text/plain", c::Clock)
        print(io, "⌗  Clock instance\n",
        "├── tspan        : $(c.tspan)\n",
        "├── current_time : $(c.current_time)\n",
        "├── iter         : $(c.iter)\n",
        "├── Δt_max       : $(c.Δt_max)\n",
        "├── Δt           : $(c.Δt)\n",
        "├── time_vec     : $(c.time_vec)\n",
        "├── variable_Δt  : $(c.variable_Δt)\n",
        "├── Δt_fact_up     : $(c.Δt_fact_up)\n",
        "└── Δt_fact_down  : $(c.Δt_fact_down)")
end

function timestep!(c::Clock)
    c.Δt = min(c.Δt, c.Δt_max)
    # handle the case when timestepping overshoots the maximum simulation time
    if (c.current_time + c.Δt) > c.tspan[2]
        c.Δt = c.tspan[2] - c.current_time
        c.current_time = c.tspan[2]
    else
        # don't update first iteration time to start at tspan[1]
        (c.iter != 0) && (c.current_time += c.Δt)
    end
    c.iter += 1
    (c.iter != 0) && push!(c.time_vec,c.current_time)
    return nothing
end

function timestep!(c::Clock,Δt)
    c.Δt = min(Δt, c.Δt_max, c.Δt)
    # handle the case when timestepping overshoots the maximum simulation time
    if (c.current_time + c.Δt) > c.tspan[2]
        c.Δt = c.tspan[2] - c.current_time
        c.current_time = c.tspan[2]
    else
        # don't update first iteration time to start at tspan[1]
        (c.iter != 0) && (c.current_time += c.Δt)
    end
    c.iter += 1
    (c.iter != 0) && push!(c.time_vec,c.current_time)
    return nothing
end

function undo_timestep!(c::Clock)
    (c.iter > 1) && (c.current_time -= c.Δt)
    c.iter -= 1
    pop!(c.time_vec)
    return nothing
end

function JuAFEM.reinit!(c::Clock)
    c.iter = 0
    length(c.time_vec)>=2 && (c.Δt = c.time_vec[2] - c.time_vec[1])
    c.current_time = c.tspan[1]
    c.time_vec = Float64[c.tspan[1]]
    return nothing
end


text:
function part1(input)
    weights = reverse(parse.(Int, eachline(input)))
    best = [length(weights) + 1, 0]
    find_best_partition(weights, best, sum(weights) ÷ 3)
    return last(best)
end

function part2(input)
    weights = reverse(parse.(Int, eachline(input)))
    best = [length(weights) + 1, 0]
    find_best_partition(weights, best, sum(weights) ÷ 4)
    return last(best)
end

function find_best_partition(weights, best, missing_weight, next = 1,
                             placed = zeros(Int, length(weights)))
    for i = next:length(weights)
        placed[i] != 0 && continue
        if weights[i] == missing_weight
            n = sum(placed) + 1
            qe = prod(weights[placed .== 1]) * weights[i]
            if [n, qe] < best
                best .= [n, qe]
            end
            return
        end
        weights[i] > missing_weight && continue
        weights[i] * (first(best) - sum(placed)) < missing_weight && continue
        placed[i] = 1
        find_best_partition(weights, best, missing_weight - weights[i],
                            i + 1, placed)
        placed[i] = 0
    end
end


text:
function addkey!(membernames, nam)
    if !haskey(membernames, nam)
        membernames[nam] = gensym()
    end
    membernames[nam]
end

onearg(e::Expr, f) = e.head == :call && length(e.args) == 2 && e.args[1] == f
onearg(e, f) = false

mapexpr(f, e) = Expr(e.head, map(f, e.args)...)

replace_syms!(x, membernames) = x
replace_syms!(q::QuoteNode, membernames) =
    replace_syms!(Meta.quot(q.value), membernames)
replace_syms!(e::Expr, membernames) =
    if onearg(e, :^)
        e.args[2]
    elseif onearg(e, :_I_)
        @warn "_I_() for escaping variables is deprecated, use cols() instead"
        addkey!(membernames, :($(e.args[2])))
    elseif onearg(e, :cols)
        addkey!(membernames, :($(e.args[2])))
    elseif e.head == :quote
        addkey!(membernames, Meta.quot(e.args[1]) )
    elseif e.head == :.
        replace_dotted!(e, membernames)
    else
        mapexpr(x -> replace_syms!(x, membernames), e)
    end

is_simple_non_broadcast_call(x) = false
function is_simple_non_broadcast_call(expr::Expr)
    expr.head == :call &&
        length(expr.args) >= 2 &&
        expr.args[1] isa Symbol &&
        all(x -> x isa QuoteNode || onearg(x, :cols), expr.args[2:end])
end

is_simple_broadcast_call(x) = false
function is_simple_broadcast_call(expr::Expr)
    expr.head == :. &&
        length(expr.args) == 2 &&
        expr.args[1] isa Symbol &&
        expr.args[2] isa Expr &&
        expr.args[2].head == :tuple &&
        all(x -> x isa QuoteNode || onearg(x, :cols), expr.args[2].args)
end

function args_to_selectors(v)
    t = map(v) do arg
        if arg isa QuoteNode
            arg
        elseif onearg(arg, :cols)
            arg.args[2]
        else
            throw(ArgumentError("This path should not be reached, arg: $(arg)"))
        end
    end

    :(DataFramesMeta.make_source_concrete($(Expr(:vect, t...))))
end

"""
    get_source_fun(function_expr)

Given an expression that may contain `QuoteNode`s (`:x`)
and items wrapped in `cols`, return a function
that is equivalent to that expression where the
`QuoteNode`s and `cols` items are the inputs
to the function.

For fast compilation `get_source_fun` returns
the name of a called function where possible.

* `f(:x, :y)` will return `f`
* `f.(:x, :y)` will return `ByRow(f)`
* `:x .+ :y` will return `.+`

`get_source_fun` also returns an expression
representing the vector of inputs that will be
used as the `src` in the `src => fun => dest`
call later on.

### Examples

julia> using MacroTools

julia> ex = :(:x + :y)

julia> DataFramesMeta.get_source_fun(ex)
(:(DataFramesMeta.make_source_concrete([:x, :y])), :+)

julia> ex = quote
           :x .+ 1 .* :y
       end |> MacroTools.prettify

julia> src, fun = DataFramesMeta.get_source_fun(ex);

julia> MacroTools.prettify(fun)
:((mammoth, goat)->mammoth .+ 1 .* goat)

"""
function get_source_fun(function_expr)
    # recursive step for begin :a + :b end
    if function_expr isa Expr &&
        function_expr.head == :block &&
        length(function_expr.args) == 1

        return get_source_fun(function_expr.args[1])
    elseif is_simple_non_broadcast_call(function_expr)
        source = args_to_selectors(function_expr.args[2:end])
        fun_t = function_expr.args[1]

        # .+ to +
        if startswith(string(fun_t), '.')
            f_sym_without_dot = Symbol(chop(string(fun_t), head = 1, tail = 0))
            fun = :(DataFrames.ByRow($f_sym_without_dot))
        else
            fun = fun_t
        end

        return source, fun
    elseif is_simple_broadcast_call(function_expr)
        # extract source symbols from quotenodes
        source = args_to_selectors(function_expr.args[2].args)
        fun_t = function_expr.args[1]
        fun = :(DataFrames.ByRow($fun_t))

        return source, fun
    else
        membernames = Dict{Any, Symbol}()

        body = replace_syms!(function_expr, membernames)

        source = :(DataFramesMeta.make_source_concrete($(Expr(:vect, keys(membernames)...))))
        inputargs = Expr(:tuple, values(membernames)...)

        fun = quote
            $inputargs -> begin
                $body
            end
        end
        return source, fun
    end
end

# `nolhs` needs to be `true` when we have syntax of the form
# `@combine(gd, fun(:x, :y))` where `fun` returns a `table` object.
# We don't create the "new name" pair because new names are
# given by the table.
function fun_to_vec(ex::Expr; nolhs::Bool = false, gensym_names::Bool = false)
    # classify the type of expression
    # :x # handled via dispatch
    # cols(:x) # handled as though above
    # f(:x) # nohls == true, re-write as simple call
    # (; a = :x, ) # nolhs == true, complicated call
    # y = :x # :x is a QuoteNode
    # y = cols(:x) # use cols on RHS
    # cols(:y) = :x # RHS in :block
    # cols(:y) = cols(:x) #
    # y = f(:x) # re-write as simple call
    # y = f(cols(:x)) # re-write as simple call, use cols
    # y = :x + 1 # re-write as complicated call
    # y = cols(:x) + 1 # re-write as complicated call, with cols
    # cols(:y) = f(:x) # re-write as simple call, but RHS is :block
    # cols(:y) = f(cols(:x)) # re-write as simple call, RHS is block, use cols
    # cols(y) = :x + 1 # re-write as complicated col, but RHS is :block
    # cols(:y) = cols(:x) + 1 # re-write as complicated call, RHS is block, use cols

    if gensym_names
        ex = Expr(:kw, gensym(), ex)
    end

    nokw = (ex.head !== :(=)) && (ex.head !== :kw) && nolhs

    # :x
    # handled below via dispatch on ::QuoteNode

    # cols(:x)
    if onearg(ex, :cols)
        return ex.args[2]
    end

    # The above cases are the only ones allowed
    # if you don't have nolhs explicitely stated
    # or are just `:x` or `cols(x)`
    if !(ex.head === :(=) || ex.head === :kw || nolhs)
        throw(ArgumentError("Expressions not of the form `y = f(:x)` are currently disallowed."))
    end

    # f(:x) # it's assumed this returns a Table
    # (; a = :x, ) # something more explicit we might see
    if nokw
        source, fun = get_source_fun(ex)

        return quote
            $source => $fun => AsTable
        end
    end

    if !nokw
        lhs = ex.args[1]
        rhs_t = ex.args[2]
        # if lhs is a cols(y) then the rhs gets parsed as a block
        if onearg(lhs, :cols) && rhs_t.head === :block && length(rhs_t.args) == 1
            rhs = rhs_t.args[1]
        else
            rhs = rhs_t
        end
    else
        throw(ArgumentError("This path should not be reached"))
    end

    # y = :x
    if lhs isa Symbol && rhs isa QuoteNode
        source = rhs
        dest = QuoteNode(lhs)

        return quote
            $source => $dest
        end
    end

    # y = cols(:x)
    if lhs isa Symbol && onearg(rhs, :cols)
        source = rhs.args[2]
        dest = QuoteNode(lhs)

        return quote
            $source => $dest
        end
    end

    # cols(:y) = :x
    if onearg(lhs, :cols) && rhs isa QuoteNode
        source = rhs
        dest = lhs.args[2]

        return quote
            $source => $dest
        end
    end

    # cols(:y) = cols(:x)
    if onearg(lhs, :cols) && onearg(rhs, :cols)
        source = rhs.args[2]
        dest = lhs.args[2]

        return quote
            $source => $dest
        end
    end

    # y = f(:x)
    # y = f(cols(:x))
    # y = :x + 1
    # y = cols(:x) + 1
    if lhs isa Symbol
        source, fun = get_source_fun(rhs)
        dest = QuoteNode(lhs)

        return quote
            $source => $fun => $dest
        end
    end

    # cols(:y) = f(:x)
    if onearg(lhs, :cols)
        source, fun = get_source_fun(rhs)
        dest = lhs.args[2]

        return quote
            $source => $fun => $dest
        end
    end

    throw(ArgumentError("This path should not be reached"))
end
fun_to_vec(ex::QuoteNode; nolhs::Bool = false, gensym_names::Bool = false) = ex

function make_source_concrete(x::AbstractVector)
    if isempty(x) || isconcretetype(eltype(x))
        return x
    elseif all(t -> t isa Union{AbstractString, Symbol}, x)
        return Symbol.(x)
    else
        throw(ArgumentError("Column references must be either all the same " *
                            "type or a a combination of `Symbol`s and strings"))
    end
end

protect_replace_syms!(e, membernames) = e
function protect_replace_syms!(e::Expr, membernames)
    if e.head == :quote
        e
    else
        replace_syms!(e, membernames)
    end
end

function replace_dotted!(e, membernames)
    x_new = replace_syms!(e.args[1], membernames)
    y_new = protect_replace_syms!(e.args[2], membernames)
    Expr(:., x_new, y_new)
end

"""
    create_args_vector(args...)

Given multiple arguments which can be any type
of expression-like object (`Expr`, `QuoteNode`, etc.),
puts them into a single array, removing line numbers.
"""
function create_args_vector(args...)
    Any[Base.remove_linenums!(arg) for arg in args]
end

"""
   create_args_vector(arg)

Normalize a single input to a vector of expressions.
If `arg` is a single `:block`, it is unnested.
Otherwise, return a single-element array.
Also removes line numbers.
"""
function create_args_vector(arg)
    if arg isa Expr && arg.head == :block
        x = Base.remove_linenums!(arg).args
    else
        x = Any[Base.remove_linenums!(arg)]
    end
    return x
end