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

"""
    associate_customer_gateway(customer_gateway_arn, device_id, global_network_id)
    associate_customer_gateway(customer_gateway_arn, device_id, global_network_id, params::Dict{String,<:Any})

Associates a customer gateway with a device and optionally, with a link. If you specify a
link, it must be associated with the specified device.  You can only associate customer
gateways that are connected to a VPN attachment on a transit gateway. The transit gateway
must be registered in your global network. When you register a transit gateway, customer
gateways that are connected to the transit gateway are automatically included in the global
network. To list customer gateways that are connected to a transit gateway, use the
DescribeVpnConnections EC2 API and filter by transit-gateway-id. You cannot associate a
customer gateway with more than one device and link.

# Arguments
- `customer_gateway_arn`: The Amazon Resource Name (ARN) of the customer gateway.
- `device_id`: The ID of the device.
- `global_network_id`: The ID of the global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"LinkId"`: The ID of the link.
"""
function associate_customer_gateway(
    CustomerGatewayArn,
    DeviceId,
    globalNetworkId;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "POST",
        "/global-networks/$(globalNetworkId)/customer-gateway-associations",
        Dict{String,Any}(
            "CustomerGatewayArn" => CustomerGatewayArn, "DeviceId" => DeviceId
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function associate_customer_gateway(
    CustomerGatewayArn,
    DeviceId,
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "POST",
        "/global-networks/$(globalNetworkId)/customer-gateway-associations",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "CustomerGatewayArn" => CustomerGatewayArn, "DeviceId" => DeviceId
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    associate_link(device_id, link_id, global_network_id)
    associate_link(device_id, link_id, global_network_id, params::Dict{String,<:Any})

Associates a link to a device. A device can be associated to multiple links and a link can
be associated to multiple devices. The device and link must be in the same global network
and the same site.

# Arguments
- `device_id`: The ID of the device.
- `link_id`: The ID of the link.
- `global_network_id`: The ID of the global network.

"""
function associate_link(
    DeviceId, LinkId, globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "POST",
        "/global-networks/$(globalNetworkId)/link-associations",
        Dict{String,Any}("DeviceId" => DeviceId, "LinkId" => LinkId);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function associate_link(
    DeviceId,
    LinkId,
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "POST",
        "/global-networks/$(globalNetworkId)/link-associations",
        Dict{String,Any}(
            mergewith(
                _merge, Dict{String,Any}("DeviceId" => DeviceId, "LinkId" => LinkId), params
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    associate_transit_gateway_connect_peer(device_id, transit_gateway_connect_peer_arn, global_network_id)
    associate_transit_gateway_connect_peer(device_id, transit_gateway_connect_peer_arn, global_network_id, params::Dict{String,<:Any})

Associates a transit gateway Connect peer with a device, and optionally, with a link. If
you specify a link, it must be associated with the specified device.  You can only
associate transit gateway Connect peers that have been created on a transit gateway that's
registered in your global network. You cannot associate a transit gateway Connect peer with
more than one device and link.

# Arguments
- `device_id`: The ID of the device.
- `transit_gateway_connect_peer_arn`: The Amazon Resource Name (ARN) of the Connect peer.
- `global_network_id`: The ID of the global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"LinkId"`: The ID of the link.
"""
function associate_transit_gateway_connect_peer(
    DeviceId,
    TransitGatewayConnectPeerArn,
    globalNetworkId;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "POST",
        "/global-networks/$(globalNetworkId)/transit-gateway-connect-peer-associations",
        Dict{String,Any}(
            "DeviceId" => DeviceId,
            "TransitGatewayConnectPeerArn" => TransitGatewayConnectPeerArn,
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function associate_transit_gateway_connect_peer(
    DeviceId,
    TransitGatewayConnectPeerArn,
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "POST",
        "/global-networks/$(globalNetworkId)/transit-gateway-connect-peer-associations",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "DeviceId" => DeviceId,
                    "TransitGatewayConnectPeerArn" => TransitGatewayConnectPeerArn,
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    create_connection(connected_device_id, device_id, global_network_id)
    create_connection(connected_device_id, device_id, global_network_id, params::Dict{String,<:Any})

Creates a connection between two devices. The devices can be a physical or virtual
appliance that connects to a third-party appliance in a VPC, or a physical appliance that
connects to another physical appliance in an on-premises network.

# Arguments
- `connected_device_id`: The ID of the second device in the connection.
- `device_id`: The ID of the first device in the connection.
- `global_network_id`: The ID of the global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"ConnectedLinkId"`: The ID of the link for the second device.
- `"Description"`: A description of the connection. Length Constraints: Maximum length of
  256 characters.
- `"LinkId"`: The ID of the link for the first device.
- `"Tags"`: The tags to apply to the resource during creation.
"""
function create_connection(
    ConnectedDeviceId,
    DeviceId,
    globalNetworkId;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "POST",
        "/global-networks/$(globalNetworkId)/connections",
        Dict{String,Any}("ConnectedDeviceId" => ConnectedDeviceId, "DeviceId" => DeviceId);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function create_connection(
    ConnectedDeviceId,
    DeviceId,
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "POST",
        "/global-networks/$(globalNetworkId)/connections",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "ConnectedDeviceId" => ConnectedDeviceId, "DeviceId" => DeviceId
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Creates a new device in a global network. If you specify both a site ID and a location, the
location of the site is used for visualization in the Network Manager console.

# Arguments
- `global_network_id`: The ID of the global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"AWSLocation"`: The Amazon Web Services location of the device, if applicable. For an
  on-premises device, you can omit this parameter.
- `"Description"`: A description of the device. Constraints: Maximum length of 256
  characters.
- `"Location"`: The location of the device.
- `"Model"`: The model of the device. Constraints: Maximum length of 128 characters.
- `"SerialNumber"`: The serial number of the device. Constraints: Maximum length of 128
  characters.
- `"SiteId"`: The ID of the site.
- `"Tags"`: The tags to apply to the resource during creation.
- `"Type"`: The type of the device.
- `"Vendor"`: The vendor of the device. Constraints: Maximum length of 128 characters.
"""
function create_device(globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config())
    return networkmanager(
        "POST",
        "/global-networks/$(globalNetworkId)/devices";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function create_device(
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "POST",
        "/global-networks/$(globalNetworkId)/devices",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Creates a new, empty global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"Description"`: A description of the global network. Constraints: Maximum length of 256
  characters.
- `"Tags"`: The tags to apply to the resource during creation.
"""
function create_global_network(; aws_config::AbstractAWSConfig=global_aws_config())
    return networkmanager(
        "POST", "/global-networks"; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end
function create_global_network(
    params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "POST",
        "/global-networks",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    create_link(bandwidth, site_id, global_network_id)
    create_link(bandwidth, site_id, global_network_id, params::Dict{String,<:Any})

Creates a new link for a specified site.

# Arguments
- `bandwidth`:  The upload speed and download speed in Mbps.
- `site_id`: The ID of the site.
- `global_network_id`: The ID of the global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"Description"`: A description of the link. Constraints: Maximum length of 256 characters.
- `"Provider"`: The provider of the link. Constraints: Maximum length of 128 characters.
  Cannot include the following characters: |  ^
- `"Tags"`: The tags to apply to the resource during creation.
- `"Type"`: The type of the link. Constraints: Maximum length of 128 characters. Cannot
  include the following characters: |  ^
"""
function create_link(
    Bandwidth, SiteId, globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "POST",
        "/global-networks/$(globalNetworkId)/links",
        Dict{String,Any}("Bandwidth" => Bandwidth, "SiteId" => SiteId);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function create_link(
    Bandwidth,
    SiteId,
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "POST",
        "/global-networks/$(globalNetworkId)/links",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}("Bandwidth" => Bandwidth, "SiteId" => SiteId),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Creates a new site in a global network.

# Arguments
- `global_network_id`: The ID of the global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"Description"`: A description of your site. Constraints: Maximum length of 256
  characters.
- `"Location"`: The site location. This information is used for visualization in the
  Network Manager console. If you specify the address, the latitude and longitude are
  automatically calculated.    Address: The physical address of the site.    Latitude: The
  latitude of the site.     Longitude: The longitude of the site.
- `"Tags"`: The tags to apply to the resource during creation.
"""
function create_site(globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config())
    return networkmanager(
        "POST",
        "/global-networks/$(globalNetworkId)/sites";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function create_site(
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "POST",
        "/global-networks/$(globalNetworkId)/sites",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    delete_connection(connection_id, global_network_id)
    delete_connection(connection_id, global_network_id, params::Dict{String,<:Any})

Deletes the specified connection in your global network.

# Arguments
- `connection_id`: The ID of the connection.
- `global_network_id`: The ID of the global network.

"""
function delete_connection(
    connectionId, globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "DELETE",
        "/global-networks/$(globalNetworkId)/connections/$(connectionId)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function delete_connection(
    connectionId,
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "DELETE",
        "/global-networks/$(globalNetworkId)/connections/$(connectionId)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    delete_device(device_id, global_network_id)
    delete_device(device_id, global_network_id, params::Dict{String,<:Any})

Deletes an existing device. You must first disassociate the device from any links and
customer gateways.

# Arguments
- `device_id`: The ID of the device.
- `global_network_id`: The ID of the global network.

"""
function delete_device(
    deviceId, globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "DELETE",
        "/global-networks/$(globalNetworkId)/devices/$(deviceId)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function delete_device(
    deviceId,
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "DELETE",
        "/global-networks/$(globalNetworkId)/devices/$(deviceId)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Deletes an existing global network. You must first delete all global network objects
(devices, links, and sites) and deregister all transit gateways.

# Arguments
- `global_network_id`: The ID of the global network.

"""
function delete_global_network(
    globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "DELETE",
        "/global-networks/$(globalNetworkId)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function delete_global_network(
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "DELETE",
        "/global-networks/$(globalNetworkId)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    delete_link(global_network_id, link_id)
    delete_link(global_network_id, link_id, params::Dict{String,<:Any})

Deletes an existing link. You must first disassociate the link from any devices and
customer gateways.

# Arguments
- `global_network_id`: The ID of the global network.
- `link_id`: The ID of the link.

"""
function delete_link(
    globalNetworkId, linkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "DELETE",
        "/global-networks/$(globalNetworkId)/links/$(linkId)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function delete_link(
    globalNetworkId,
    linkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "DELETE",
        "/global-networks/$(globalNetworkId)/links/$(linkId)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    delete_site(global_network_id, site_id)
    delete_site(global_network_id, site_id, params::Dict{String,<:Any})

Deletes an existing site. The site cannot be associated with any device or link.

# Arguments
- `global_network_id`: The ID of the global network.
- `site_id`: The ID of the site.

"""
function delete_site(
    globalNetworkId, siteId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "DELETE",
        "/global-networks/$(globalNetworkId)/sites/$(siteId)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function delete_site(
    globalNetworkId,
    siteId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "DELETE",
        "/global-networks/$(globalNetworkId)/sites/$(siteId)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    deregister_transit_gateway(global_network_id, transit_gateway_arn)
    deregister_transit_gateway(global_network_id, transit_gateway_arn, params::Dict{String,<:Any})

Deregisters a transit gateway from your global network. This action does not delete your
transit gateway, or modify any of its attachments. This action removes any customer gateway
associations.

# Arguments
- `global_network_id`: The ID of the global network.
- `transit_gateway_arn`: The Amazon Resource Name (ARN) of the transit gateway.

"""
function deregister_transit_gateway(
    globalNetworkId, transitGatewayArn; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "DELETE",
        "/global-networks/$(globalNetworkId)/transit-gateway-registrations/$(transitGatewayArn)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function deregister_transit_gateway(
    globalNetworkId,
    transitGatewayArn,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "DELETE",
        "/global-networks/$(globalNetworkId)/transit-gateway-registrations/$(transitGatewayArn)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Describes one or more global networks. By default, all global networks are described. To
describe the objects in your global network, you must use the appropriate Get* action. For
example, to list the transit gateways in your global network, use
GetTransitGatewayRegistrations.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"globalNetworkIds"`: The IDs of one or more global networks. The maximum is 10.
- `"maxResults"`: The maximum number of results to return.
- `"nextToken"`: The token for the next page of results.
"""
function describe_global_networks(; aws_config::AbstractAWSConfig=global_aws_config())
    return networkmanager(
        "GET", "/global-networks"; aws_config=aws_config, feature_set=SERVICE_FEATURE_SET
    )
end
function describe_global_networks(
    params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "GET",
        "/global-networks",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    disassociate_customer_gateway(customer_gateway_arn, global_network_id)
    disassociate_customer_gateway(customer_gateway_arn, global_network_id, params::Dict{String,<:Any})

Disassociates a customer gateway from a device and a link.

# Arguments
- `customer_gateway_arn`: The Amazon Resource Name (ARN) of the customer gateway.
- `global_network_id`: The ID of the global network.

"""
function disassociate_customer_gateway(
    customerGatewayArn, globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "DELETE",
        "/global-networks/$(globalNetworkId)/customer-gateway-associations/$(customerGatewayArn)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function disassociate_customer_gateway(
    customerGatewayArn,
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "DELETE",
        "/global-networks/$(globalNetworkId)/customer-gateway-associations/$(customerGatewayArn)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    disassociate_link(device_id, global_network_id, link_id)
    disassociate_link(device_id, global_network_id, link_id, params::Dict{String,<:Any})

Disassociates an existing device from a link. You must first disassociate any customer
gateways that are associated with the link.

# Arguments
- `device_id`: The ID of the device.
- `global_network_id`: The ID of the global network.
- `link_id`: The ID of the link.

"""
function disassociate_link(
    deviceId, globalNetworkId, linkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "DELETE",
        "/global-networks/$(globalNetworkId)/link-associations",
        Dict{String,Any}("deviceId" => deviceId, "linkId" => linkId);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function disassociate_link(
    deviceId,
    globalNetworkId,
    linkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "DELETE",
        "/global-networks/$(globalNetworkId)/link-associations",
        Dict{String,Any}(
            mergewith(
                _merge, Dict{String,Any}("deviceId" => deviceId, "linkId" => linkId), params
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    disassociate_transit_gateway_connect_peer(global_network_id, transit_gateway_connect_peer_arn)
    disassociate_transit_gateway_connect_peer(global_network_id, transit_gateway_connect_peer_arn, params::Dict{String,<:Any})

Disassociates a transit gateway Connect peer from a device and link.

# Arguments
- `global_network_id`: The ID of the global network.
- `transit_gateway_connect_peer_arn`: The Amazon Resource Name (ARN) of the transit gateway
  Connect peer.

"""
function disassociate_transit_gateway_connect_peer(
    globalNetworkId,
    transitGatewayConnectPeerArn;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "DELETE",
        "/global-networks/$(globalNetworkId)/transit-gateway-connect-peer-associations/$(transitGatewayConnectPeerArn)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function disassociate_transit_gateway_connect_peer(
    globalNetworkId,
    transitGatewayConnectPeerArn,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "DELETE",
        "/global-networks/$(globalNetworkId)/transit-gateway-connect-peer-associations/$(transitGatewayConnectPeerArn)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Gets information about one or more of your connections in a global network.

# Arguments
- `global_network_id`: The ID of the global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"connectionIds"`: One or more connection IDs.
- `"deviceId"`: The ID of the device.
- `"maxResults"`: The maximum number of results to return.
- `"nextToken"`: The token for the next page of results.
"""
function get_connections(globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config())
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/connections";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_connections(
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/connections",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Gets the association information for customer gateways that are associated with devices and
links in your global network.

# Arguments
- `global_network_id`: The ID of the global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"customerGatewayArns"`: One or more customer gateway Amazon Resource Names (ARNs). The
  maximum is 10.
- `"maxResults"`: The maximum number of results to return.
- `"nextToken"`: The token for the next page of results.
"""
function get_customer_gateway_associations(
    globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/customer-gateway-associations";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_customer_gateway_associations(
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/customer-gateway-associations",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Gets information about one or more of your devices in a global network.

# Arguments
- `global_network_id`: The ID of the global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"deviceIds"`: One or more device IDs. The maximum is 10.
- `"maxResults"`: The maximum number of results to return.
- `"nextToken"`: The token for the next page of results.
- `"siteId"`: The ID of the site.
"""
function get_devices(globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config())
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/devices";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_devices(
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/devices",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Gets the link associations for a device or a link. Either the device ID or the link ID must
be specified.

# Arguments
- `global_network_id`: The ID of the global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"deviceId"`: The ID of the device.
- `"linkId"`: The ID of the link.
- `"maxResults"`: The maximum number of results to return.
- `"nextToken"`: The token for the next page of results.
"""
function get_link_associations(
    globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/link-associations";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_link_associations(
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/link-associations",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Gets information about one or more links in a specified global network. If you specify the
site ID, you cannot specify the type or provider in the same request. You can specify the
type and provider in the same request.

# Arguments
- `global_network_id`: The ID of the global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"linkIds"`: One or more link IDs. The maximum is 10.
- `"maxResults"`: The maximum number of results to return.
- `"nextToken"`: The token for the next page of results.
- `"provider"`: The link provider.
- `"siteId"`: The ID of the site.
- `"type"`: The link type.
"""
function get_links(globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config())
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/links";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_links(
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/links",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Gets the count of network resources, by resource type, for the specified global network.

# Arguments
- `global_network_id`: The ID of the global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"maxResults"`: The maximum number of results to return.
- `"nextToken"`: The token for the next page of results.
- `"resourceType"`: The resource type. The following are the supported resource types for
  Direct Connect:    dxcon     dx-gateway     dx-vif    The following are the supported
  resource types for Network Manager:    connection     device     link     site    The
  following are the supported resource types for Amazon VPC:    customer-gateway
  transit-gateway     transit-gateway-attachment     transit-gateway-connect-peer
  transit-gateway-route-table     vpn-connection
"""
function get_network_resource_counts(
    globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/network-resource-count";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_network_resource_counts(
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/network-resource-count",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Gets the network resource relationships for the specified global network.

# Arguments
- `global_network_id`: The ID of the global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"accountId"`: The Amazon Web Services account ID.
- `"awsRegion"`: The Amazon Web Services Region.
- `"maxResults"`: The maximum number of results to return.
- `"nextToken"`: The token for the next page of results.
- `"registeredGatewayArn"`: The ARN of the registered gateway.
- `"resourceArn"`: The ARN of the gateway.
- `"resourceType"`: The resource type. The following are the supported resource types for
  Direct Connect:    dxcon     dx-gateway     dx-vif    The following are the supported
  resource types for Network Manager:    connection     device     link     site    The
  following are the supported resource types for Amazon VPC:    customer-gateway
  transit-gateway     transit-gateway-attachment     transit-gateway-connect-peer
  transit-gateway-route-table     vpn-connection
"""
function get_network_resource_relationships(
    globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/network-resource-relationships";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_network_resource_relationships(
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/network-resource-relationships",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Describes the network resources for the specified global network. The results include
information from the corresponding Describe call for the resource, minus any sensitive
information such as pre-shared keys.

# Arguments
- `global_network_id`: The ID of the global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"accountId"`: The Amazon Web Services account ID.
- `"awsRegion"`: The Amazon Web Services Region.
- `"maxResults"`: The maximum number of results to return.
- `"nextToken"`: The token for the next page of results.
- `"registeredGatewayArn"`: The ARN of the gateway.
- `"resourceArn"`: The ARN of the resource.
- `"resourceType"`: The resource type. The following are the supported resource types for
  Direct Connect:    dxcon - The definition model is Connection.    dx-gateway - The
  definition model is DirectConnectGateway.    dx-vif - The definition model is
  VirtualInterface.   The following are the supported resource types for Network Manager:
  connection - The definition model is Connection.    device - The definition model is
  Device.    link - The definition model is Link.    site - The definition model is Site.
  The following are the supported resource types for Amazon VPC:    customer-gateway - The
  definition model is CustomerGateway.    transit-gateway - The definition model is
  TransitGateway.    transit-gateway-attachment - The definition model is
  TransitGatewayAttachment.    transit-gateway-connect-peer - The definition model is
  TransitGatewayConnectPeer.    transit-gateway-route-table - The definition model is
  TransitGatewayRouteTable.    vpn-connection - The definition model is VpnConnection.
"""
function get_network_resources(
    globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/network-resources";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_network_resources(
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/network-resources",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    get_network_routes(route_table_identifier, global_network_id)
    get_network_routes(route_table_identifier, global_network_id, params::Dict{String,<:Any})

Gets the network routes of the specified global network.

# Arguments
- `route_table_identifier`: The ID of the route table.
- `global_network_id`: The ID of the global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"DestinationFilters"`: Filter by route table destination. Possible Values:
  TRANSIT_GATEWAY_ATTACHMENT_ID, RESOURCE_ID, or RESOURCE_TYPE.
- `"ExactCidrMatches"`: An exact CIDR block.
- `"LongestPrefixMatches"`: The most specific route that matches the traffic (longest
  prefix match).
- `"PrefixListIds"`: The IDs of the prefix lists.
- `"States"`: The route states.
- `"SubnetOfMatches"`: The routes with a subnet that match the specified CIDR filter.
- `"SupernetOfMatches"`: The routes with a CIDR that encompasses the CIDR filter. Example:
  If you specify 10.0.1.0/30, then the result returns 10.0.1.0/29.
- `"Types"`: The route types.
"""
function get_network_routes(
    RouteTableIdentifier, globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "POST",
        "/global-networks/$(globalNetworkId)/network-routes",
        Dict{String,Any}("RouteTableIdentifier" => RouteTableIdentifier);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_network_routes(
    RouteTableIdentifier,
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "POST",
        "/global-networks/$(globalNetworkId)/network-routes",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}("RouteTableIdentifier" => RouteTableIdentifier),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Gets the network telemetry of the specified global network.

# Arguments
- `global_network_id`: The ID of the global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"accountId"`: The Amazon Web Services account ID.
- `"awsRegion"`: The Amazon Web Services Region.
- `"maxResults"`: The maximum number of results to return.
- `"nextToken"`: The token for the next page of results.
- `"registeredGatewayArn"`: The ARN of the gateway.
- `"resourceArn"`: The ARN of the resource.
- `"resourceType"`: The resource type. The following are the supported resource types for
  Direct Connect:    dxcon     dx-gateway     dx-vif    The following are the supported
  resource types for Network Manager:    connection     device     link     site    The
  following are the supported resource types for Amazon VPC:    customer-gateway
  transit-gateway     transit-gateway-attachment     transit-gateway-connect-peer
  transit-gateway-route-table     vpn-connection
"""
function get_network_telemetry(
    globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/network-telemetry";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_network_telemetry(
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/network-telemetry",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    get_route_analysis(global_network_id, route_analysis_id)
    get_route_analysis(global_network_id, route_analysis_id, params::Dict{String,<:Any})

Gets information about the specified route analysis.

# Arguments
- `global_network_id`: The ID of the global network.
- `route_analysis_id`: The ID of the route analysis.

"""
function get_route_analysis(
    globalNetworkId, routeAnalysisId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/route-analyses/$(routeAnalysisId)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_route_analysis(
    globalNetworkId,
    routeAnalysisId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/route-analyses/$(routeAnalysisId)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Gets information about one or more of your sites in a global network.

# Arguments
- `global_network_id`: The ID of the global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"maxResults"`: The maximum number of results to return.
- `"nextToken"`: The token for the next page of results.
- `"siteIds"`: One or more site IDs. The maximum is 10.
"""
function get_sites(globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config())
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/sites";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_sites(
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/sites",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Gets information about one or more of your transit gateway Connect peer associations in a
global network.

# Arguments
- `global_network_id`: The ID of the global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"maxResults"`: The maximum number of results to return.
- `"nextToken"`: The token for the next page of results.
- `"transitGatewayConnectPeerArns"`: One or more transit gateway Connect peer Amazon
  Resource Names (ARNs).
"""
function get_transit_gateway_connect_peer_associations(
    globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/transit-gateway-connect-peer-associations";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_transit_gateway_connect_peer_associations(
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/transit-gateway-connect-peer-associations",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Gets information about the transit gateway registrations in a specified global network.

# Arguments
- `global_network_id`: The ID of the global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"maxResults"`: The maximum number of results to return.
- `"nextToken"`: The token for the next page of results.
- `"transitGatewayArns"`: The Amazon Resource Names (ARNs) of one or more transit gateways.
  The maximum is 10.
"""
function get_transit_gateway_registrations(
    globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/transit-gateway-registrations";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_transit_gateway_registrations(
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "GET",
        "/global-networks/$(globalNetworkId)/transit-gateway-registrations",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Lists the tags for a specified resource.

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

"""
function list_tags_for_resource(
    resourceArn; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "GET",
        "/tags/$(resourceArn)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function list_tags_for_resource(
    resourceArn,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "GET",
        "/tags/$(resourceArn)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    register_transit_gateway(transit_gateway_arn, global_network_id)
    register_transit_gateway(transit_gateway_arn, global_network_id, params::Dict{String,<:Any})

Registers a transit gateway in your global network. The transit gateway can be in any
Amazon Web Services Region, but it must be owned by the same Amazon Web Services account
that owns the global network. You cannot register a transit gateway in more than one global
network.

# Arguments
- `transit_gateway_arn`: The Amazon Resource Name (ARN) of the transit gateway.
- `global_network_id`: The ID of the global network.

"""
function register_transit_gateway(
    TransitGatewayArn, globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "POST",
        "/global-networks/$(globalNetworkId)/transit-gateway-registrations",
        Dict{String,Any}("TransitGatewayArn" => TransitGatewayArn);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function register_transit_gateway(
    TransitGatewayArn,
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "POST",
        "/global-networks/$(globalNetworkId)/transit-gateway-registrations",
        Dict{String,Any}(
            mergewith(
                _merge, Dict{String,Any}("TransitGatewayArn" => TransitGatewayArn), params
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    start_route_analysis(destination, source, global_network_id)
    start_route_analysis(destination, source, global_network_id, params::Dict{String,<:Any})

Starts analyzing the routing path between the specified source and destination. For more
information, see Route Analyzer.

# Arguments
- `destination`: The destination.
- `source`: The source from which traffic originates.
- `global_network_id`: The ID of the global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"IncludeReturnPath"`: Indicates whether to analyze the return path. The default is false.
- `"UseMiddleboxes"`: Indicates whether to include the location of middlebox appliances in
  the route analysis. The default is false.
"""
function start_route_analysis(
    Destination, Source, globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "POST",
        "/global-networks/$(globalNetworkId)/route-analyses",
        Dict{String,Any}("Destination" => Destination, "Source" => Source);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function start_route_analysis(
    Destination,
    Source,
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "POST",
        "/global-networks/$(globalNetworkId)/route-analyses",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}("Destination" => Destination, "Source" => Source),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Tags a specified resource.

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

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

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

Removes tags from a specified resource.

# Arguments
- `resource_arn`: The Amazon Resource Name (ARN) of the resource.
- `tag_keys`: The tag keys to remove from the specified resource.

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

"""
    update_connection(connection_id, global_network_id)
    update_connection(connection_id, global_network_id, params::Dict{String,<:Any})

Updates the information for an existing connection. To remove information for any of the
parameters, specify an empty string.

# Arguments
- `connection_id`: The ID of the connection.
- `global_network_id`: The ID of the global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"ConnectedLinkId"`: The ID of the link for the second device in the connection.
- `"Description"`: A description of the connection. Length Constraints: Maximum length of
  256 characters.
- `"LinkId"`: The ID of the link for the first device in the connection.
"""
function update_connection(
    connectionId, globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "PATCH",
        "/global-networks/$(globalNetworkId)/connections/$(connectionId)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function update_connection(
    connectionId,
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "PATCH",
        "/global-networks/$(globalNetworkId)/connections/$(connectionId)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    update_device(device_id, global_network_id)
    update_device(device_id, global_network_id, params::Dict{String,<:Any})

Updates the details for an existing device. To remove information for any of the
parameters, specify an empty string.

# Arguments
- `device_id`: The ID of the device.
- `global_network_id`: The ID of the global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"AWSLocation"`: The Amazon Web Services location of the device, if applicable. For an
  on-premises device, you can omit this parameter.
- `"Description"`: A description of the device. Constraints: Maximum length of 256
  characters.
- `"Location"`:
- `"Model"`: The model of the device. Constraints: Maximum length of 128 characters.
- `"SerialNumber"`: The serial number of the device. Constraints: Maximum length of 128
  characters.
- `"SiteId"`: The ID of the site.
- `"Type"`: The type of the device.
- `"Vendor"`: The vendor of the device. Constraints: Maximum length of 128 characters.
"""
function update_device(
    deviceId, globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "PATCH",
        "/global-networks/$(globalNetworkId)/devices/$(deviceId)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function update_device(
    deviceId,
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "PATCH",
        "/global-networks/$(globalNetworkId)/devices/$(deviceId)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

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

Updates an existing global network. To remove information for any of the parameters,
specify an empty string.

# Arguments
- `global_network_id`: The ID of your global network.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"Description"`: A description of the global network. Constraints: Maximum length of 256
  characters.
"""
function update_global_network(
    globalNetworkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "PATCH",
        "/global-networks/$(globalNetworkId)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function update_global_network(
    globalNetworkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "PATCH",
        "/global-networks/$(globalNetworkId)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    update_link(global_network_id, link_id)
    update_link(global_network_id, link_id, params::Dict{String,<:Any})

Updates the details for an existing link. To remove information for any of the parameters,
specify an empty string.

# Arguments
- `global_network_id`: The ID of the global network.
- `link_id`: The ID of the link.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"Bandwidth"`: The upload and download speed in Mbps.
- `"Description"`: A description of the link. Constraints: Maximum length of 256 characters.
- `"Provider"`: The provider of the link. Constraints: Maximum length of 128 characters.
- `"Type"`: The type of the link. Constraints: Maximum length of 128 characters.
"""
function update_link(
    globalNetworkId, linkId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "PATCH",
        "/global-networks/$(globalNetworkId)/links/$(linkId)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function update_link(
    globalNetworkId,
    linkId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "PATCH",
        "/global-networks/$(globalNetworkId)/links/$(linkId)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    update_network_resource_metadata(metadata, global_network_id, resource_arn)
    update_network_resource_metadata(metadata, global_network_id, resource_arn, params::Dict{String,<:Any})

Updates the resource metadata for the specified global network.

# Arguments
- `metadata`: The resource metadata.
- `global_network_id`: The ID of the global network.
- `resource_arn`: The ARN of the resource.

"""
function update_network_resource_metadata(
    Metadata,
    globalNetworkId,
    resourceArn;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "PATCH",
        "/global-networks/$(globalNetworkId)/network-resources/$(resourceArn)/metadata",
        Dict{String,Any}("Metadata" => Metadata);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function update_network_resource_metadata(
    Metadata,
    globalNetworkId,
    resourceArn,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "PATCH",
        "/global-networks/$(globalNetworkId)/network-resources/$(resourceArn)/metadata",
        Dict{String,Any}(
            mergewith(_merge, Dict{String,Any}("Metadata" => Metadata), params)
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    update_site(global_network_id, site_id)
    update_site(global_network_id, site_id, params::Dict{String,<:Any})

Updates the information for an existing site. To remove information for any of the
parameters, specify an empty string.

# Arguments
- `global_network_id`: The ID of the global network.
- `site_id`: The ID of your site.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"Description"`: A description of your site. Constraints: Maximum length of 256
  characters.
- `"Location"`: The site location:    Address: The physical address of the site.
  Latitude: The latitude of the site.     Longitude: The longitude of the site.
"""
function update_site(
    globalNetworkId, siteId; aws_config::AbstractAWSConfig=global_aws_config()
)
    return networkmanager(
        "PATCH",
        "/global-networks/$(globalNetworkId)/sites/$(siteId)";
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function update_site(
    globalNetworkId,
    siteId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return networkmanager(
        "PATCH",
        "/global-networks/$(globalNetworkId)/sites/$(siteId)",
        params;
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end


text:
using PipeLayout.PipeDim
import PipeLayout: isapproxin, isSOS2
using JuMP
using GLPK

@testset "check dimensioning on single pipe" begin
    inst, topo = single_pipe()
    solver = PipeDim.LP(GLPK.Optimizer)

    result = optimize(inst, topo, solver)
    @test result.status == MOI.OPTIMAL

    πsol = result.sol.πsol
    psol = πsol.^0.5
    @test isapproxin(psol[1], 60.0, 80.0)
    @test isapproxin(psol[2], 60.0, 80.0)
    @test psol[1] > psol[2]

    lsol = result.sol.lsol
    @test size(lsol) == (1,3) # one pipe with 3 segments
    @test sum(lsol[1,:]) ≈ 1.0
    @test isapproxin(lsol[1,1], 0.0, 1.0)
    @test isapproxin(lsol[1,2], 0.0, 1.0)
    @test isapproxin(lsol[1,3], 0.0, 1.0)
    @test isSOS2(lsol[1,:])
end

ext: jl


text:
include("mountain_car_model_search_mlp.jl")
include("mountain_car_model_search_data.jl")
include("mountain_car_model_search_least_squares.jl")

struct MountainCarOptimizationParameters
    initial_step_size::Array{Float64}
    initial_params::Array{Float64}
    maximum_evaluations::Int64
    only_positive::Bool
end

function hill_climb(
    eval_fn::Function,
    optimization_params::MountainCarOptimizationParameters;
    least_squares_params::Array{Float64} = nothing,
    threshold::Float64 = 1e-6,
    debug::Bool = false,
)
    step = copy(optimization_params.initial_step_size)
    inputs = []
    outputs = []
    if debug
        println("Evaluating initial params ", optimization_params.initial_params)
    end
    push!(inputs, copy(optimization_params.initial_params))
    push!(outputs, eval_fn(inputs[1]))
    best_params = copy(optimization_params.initial_params)
    if !isnothing(least_squares_params)
        if debug
            println("Evaluating least squares params ", least_squares_params)
        end
        push!(inputs, least_squares_params)
        push!(outputs, eval_fn(inputs[2]))
        if outputs[2] < outputs[1]
            best_params = least_squares_params
        end
    end

    while length(outputs) < optimization_params.maximum_evaluations && maximum(step) > threshold
        new_inputs = []
        for i = 1:length(step)
            if optimization_params.only_positive
                push!(
                    new_inputs,
                    [
                        max.(best_params[i] - step[i], 1e-6),
                        max.(best_params[i], 1e-6),
                        max.(best_params[i] + step[i], 1e-6),
                    ],
                )
            else
                push!(
                    new_inputs,
                    [best_params[i] - step[i], best_params[i], best_params[i] + step[i]],
                )
            end
        end

        new_inputs = product(new_inputs[1], new_inputs[2])
        new_inputs = [[x for x in input] for input in new_inputs]
        new_outputs = pmap(eval_fn, new_inputs)
        for input in new_inputs
            push!(inputs, input)
        end
        for output in new_outputs
            push!(outputs, output)
        end

        new_best_params = inputs[argmin(outputs)]
        if new_best_params == best_params
            if debug
                println("Decreasing step size at params ", best_params)
            end
            step = step ./ 2
        else
            if debug
                println("Moving to params ", new_best_params)
            end
            best_params = new_best_params
        end
    end
    if length(outputs) >= optimization_params.maximum_evaluations && debug
        println("Exhausted maximum number of evaluations")
    end
    inputs[argmin(outputs)]
end

function mfmc_evaluation(
    mountaincar::MountainCar,
    policy::Array{Int64},
    values::Array{Float64},
    horizon::Int64,
    x_array::Array{Matrix{Float64}},
    xnext_array::Array{Array{Array{Float64}}},
    cost_array::Array{Array{Float64}},
    num_episodes_eval::Int64;
    hardcoded::Bool = false,
    max_inflation::Float64 = 2.0,
    scale::Float64 = 50.0,
    debug::Bool = false,
    eval_distance::Bool = false,
)
    x_array_copy = deepcopy(x_array)
    position_range = mountaincar.max_position - mountaincar.min_position
    speed_range = 2 * mountaincar.max_speed
    normalization = permutedims([position_range, speed_range])
    total_return = 0.0
    if hardcoded
        actual_return = 0.0
    end
    if eval_distance
        eval_distances = []
    end
    for i = 1:num_episodes_eval
        x = init(mountaincar; cont = true)
        c = 1.0
        actual_c = 1.0
        for t = 1:horizon
            a = policy[cont_state_to_idx(mountaincar, x)]
            total_return += c
            manual_data_index = -1
            if length(x_array_copy[a]) != 0
                distances = distance_fn(vec(x), x_array_copy[a], normalization)
                manual_data_index = argmin(distances)
            else
                distances = distance_fn(vec(x), x_array_copy[2-a], normalization)
                manual_data_index = argmin(distances)
            end
            distance = 0.0
            if hardcoded
                actual_return += actual_c
                distance = distances[manual_data_index]
                # x_approx = unvec(x_array_copy[a][manual_data_index, :]; cont = true)
                # distance = abs(
                #     values[cont_state_to_idx(mountaincar, x)] -
                #     values[cont_state_to_idx(mountaincar, x_approx)]
                # )
                actual_c = cost_array[a][manual_data_index]
            end
            inflation = min(1 + scale * distance, max_inflation)
            x_array_copy[a][manual_data_index, :] = [Inf, Inf]
            x = unvec(xnext_array[a][manual_data_index]; cont = true)
            c = inflation * cost_array[a][manual_data_index]
            if checkGoal(mountaincar, x)
                break
            end
            if eval_distance
                push!(eval_distances, distances[manual_data_index])
            end
        end
    end
    avg_return = total_return / num_episodes_eval
    if debug
        println("MFMC return computed as ", avg_return)
        if hardcoded
            println("Uninflated MFMC return computed as ", actual_return / num_episodes_eval)
        end
    end
    if eval_distance
        return avg_return, eval_distances
    end
    avg_return
end

function mfmc_optimistic_evaluation(
    mountaincar::MountainCar,
    policy::Array{Int64},
    params::Array{Float64},
    horizon::Int64,
    x_array::Array{Matrix{Float64}},
    xnext_array::Array{Array{Array{Float64}}},
    cost_array::Array{Array{Float64}},
    num_episodes_eval::Int64,
    distance_threshold::Float64;
    debug::Bool = false,
)
    x_array_copy = deepcopy(x_array)
    position_range = mountaincar.max_position - mountaincar.min_position
    speed_range = 2 * mountaincar.max_speed
    normalization = permutedims([position_range, speed_range])
    total_return = 0.0
    actions = getActions(mountaincar)
    for i=1:num_episodes_eval
        x = init(mountaincar; cont=true)
        c = 1.0
        for t = 1:horizon
            a = policy[cont_state_to_idx(mountaincar, x)]
            total_return += c
            closest_distance = Inf
            if length(x_array_copy[a]) != 0
                distances = distance_fn(vec(x), x_array_copy[a], normalization)
                manual_data_index = argmin(distances)
                closest_distance = distances[manual_data_index]
            end
            if closest_distance < distance_threshold
                # Use the data point
                x_array_copy[a][manual_data_index, :] = [Inf, Inf]
                x = unvec(xnext_array[a][manual_data_index]; cont = true)
                c = cost_array[a][manual_data_index]
            else
                # Use optimistic model
                x, c = step(mountaincar, x, actions[a], true_params)
            end
            if checkGoal(mountaincar, x)
                break
            end
        end
    end
    avg_return = total_return/num_episodes_eval
    if debug
        println("MFMC Optimistic return computed as ", avg_return)
    end
    avg_return
end

function mfmc_model_evaluation(
    mountaincar::MountainCar,
    policy::Array{Int64},
    params::Array{Float64},
    horizon::Int64,
    x_array::Array{Matrix{Float64}},
    xnext_array::Array{Array{Array{Float64}}},
    cost_array::Array{Array{Float64}},
    num_episodes_eval::Int64,
    distance_threshold::Float64;
    debug::Bool = false,
)
    x_array_copy = deepcopy(x_array)
    position_range = mountaincar.max_position - mountaincar.min_position
    speed_range = 2 * mountaincar.max_speed
    normalization = permutedims([position_range, speed_range])
    total_return = 0.0
    actions = getActions(mountaincar)
    for i=1:num_episodes_eval
        x = init(mountaincar; cont=true)
        c = 1.0
        for t = 1:horizon
            a = policy[cont_state_to_idx(mountaincar, x)]
            total_return += c
            closest_distance = Inf
            if length(x_array_copy[a]) != 0
                distances = distance_fn(vec(x), x_array_copy[a], normalization)
                manual_data_index = argmin(distances)
                closest_distance = distances[manual_data_index]
            end
            if closest_distance < distance_threshold
                # Use the data point
                x_array_copy[a][manual_data_index, :] = [Inf, Inf]
                x = unvec(xnext_array[a][manual_data_index]; cont = true)
                c = cost_array[a][manual_data_index]
            else
                # Use current model
                # x, c = step(mountaincar, x, actions[a], params)
                x, c = step(mountaincar, x, actions[a], [-0.002, 3.5])
            end
            if checkGoal(mountaincar, x)
                break
            end
        end
    end
    avg_return = total_return/num_episodes_eval
    if debug
        println("MFMC Model return computed as ", avg_return)
    end
    avg_return
end

function bellman_evaluation(
    mountaincar::MountainCar,
    params::Array{Float64},
    policy::Array{Int64},
    values::Array{Float64},
    horizon::Int64,
    x_array::Array{Matrix{Float64}},
    xnext_array::Array{Array{Array{Float64}}},
    num_episodes_eval::Int64;
    debug::Bool = false,
)
    # Evaluate return in the model
    model_return = 0.0
    x = init(mountaincar, cont = true)
    actions = getActions(mountaincar)
    for t = 1:horizon
        a = policy[cont_state_to_idx(mountaincar, x)]
        action = actions[a]
        x, c = step(mountaincar, x, action, params)
        model_return += c
        if checkGoal(mountaincar, x)
            break
        end
    end
    if debug
        println("Return in model is ", model_return)
    end
    # Evaluate bellman error
    bellman_error = 0.0
    x_array_copy = deepcopy(x_array)
    position_range = mountaincar.max_position - mountaincar.min_position
    speed_range = 2 * mountaincar.max_speed
    normalization = permutedims([position_range, speed_range])
    for i = 1:num_episodes_eval
        x = init(mountaincar, cont = true)
        for t = 1:horizon
            a = policy[cont_state_to_idx(mountaincar, x)]
            action = actions[a]
            manual_data_index =
                argmin(distance_fn(vec(x), x_array_copy[a], normalization))
            x_array_copy[a][manual_data_index, :] = [Inf, Inf]
            xnext = unvec(xnext_array[a][manual_data_index]; cont = true)
            xprednext, _ = step(mountaincar, x, action, params)
            # ABSOLUTE MODEL ADVANTAGE
            bellman_error += abs(
                values[cont_state_to_idx(mountaincar, xnext)] -
                values[cont_state_to_idx(mountaincar, xprednext)],
            )
            x = xnext
            if checkGoal(mountaincar, x)
                break
            end
        end
    end
    bellman_error = bellman_error / num_episodes_eval
    if debug
        println("Bellman error is ", bellman_error)
        println("Bellman evaluation computed as ", model_return + bellman_error)
    end
    model_return + bellman_error
end

function distance_fn(
    x::Array{Float64},
    xs::Matrix{Float64},
    normalization::Matrix{Float64}
)::Array{Float64}
    x_row = permutedims(x)
    # println(x_row, xs, normalization)
    sum(abs.((x_row .- xs) ./ normalization), dims=2)[:, 1]
end


text:
#=
ndgrid-range
ndgrid for a set of AbstractRange inputs.
=#

export ndgrid

"""
    GridAR{T,d,D} <: AbstractGrid{T,d,D}
The `d`th component of `D`-dimensional `ndgrid(x, y ...)`
where `1 ≤ d ≤ D` and `x, y, ...` are each an `AbstractRange`.
"""
struct GridAR{T,d,D} <: AbstractGrid{T,d,D}
    dims::Dims{D}
    first0::T # first - step
    step::T

    function GridAR(dims::Dims{D}, v::AbstractRange{T}, d::Int) where {D, T}
        1 ≤ d ≤ D || throw(ArgumentError("$d for $dims"))
        new{T,d,D}(dims, first(v) - step(v), step(v))
    end
end

Base.size(a::GridAR) = a.dims
Base.eltype(::GridAR{T}) where T = T

@inline Base.@propagate_inbounds function Base.getindex(
    a::GridAR{T,d,D},
    i::Vararg{Int,D},
) where {T,d,D}
     @boundscheck checkbounds(a, i...)
     return a.first0 + (@inbounds i[d]) * a.step
end

#=
"""
    (xg, yg, ...) = ndgrid(v1, v2,, ...)
Construct `ndgrid` tuple for `AbstractRange` inputs.

# Example

```jldoctest
julia> ndgrid(1:3, 5:2:7)
([1 1; 2 2; 3 3], [5 7; 5 7; 5 7])
```
"""
function ndgrid(vs::Vararg{AbstractRange})
    D = length(vs)
    dims = ntuple(i -> length(vs[i]), D)
    T = Tuple{ntuple(i -> GridAR{eltype(vs[i]), i, D}, D)...} # return type
    return ntuple(i -> GridAR(dims, vs[i], i), D)::T
end
=#


text:
using Base.CoreLogging:
    CoreLogging,
    AbstractLogger,
    LogLevel,
    handle_message,
    min_enabled_level,
    shouldlog,
    global_logger

struct BaseLogger <: AbstractLogger
    min_level::LogLevel
end

CoreLogging.min_enabled_level(logger::BaseLogger) = logger.min_level
CoreLogging.shouldlog(logger::BaseLogger, args...) = true
CoreLogging.catch_exceptions(logger::BaseLogger) = false

function CoreLogging.handle_message(
    ::BaseLogger,
    cl_level,
    msg,
    mod,
    group,
    id,
    filepath,
    line;
    kwargs...
)
    logger = getlogger(mod)
    level = lowercase(string(cl_level))
    log(logger, logger.record(logger.name, level, getlevels(logger)[level], msg))
end

function substitute!(level::LogLevel=min_enabled_level(global_logger()))
    global_logger(BaseLogger(level))
    notice(getlogger(@__MODULE__), "Substituting global logging with Memento")
end


text:
function partitionize(a::Vector{<:Integer})
    """
    For a given integer vector a, return the partition corresponding to that
    vector. Useful for both counting corrections when sampling and computing
    likelihoods, and when computing partition-based values of Ω.

    This is the fastest version I could come up with.
    """
    a = sort(a)
    k = length(a)
    v = zero(a)

    v[1] = 1
    current = 1

    for i = 2:k
        if a[i] == a[i-1]
            v[current] += 1
        else
            current += 1
            v[current] = 1
        end
    end
    # v = v[v.>0]
    # return sort(v, rev = true)
    sort!(v, rev = true)
    return sortedremovezeros(v)
end

function sortedremovezeros(p::Vector{<:Integer})
    for i = 2:length(p)
        if p[i] == 0
            return p[1:i-1]
        end
    end
    return p
end

function counting_coefficient(z::Array{T, 1}) where {T<:Integer}
    p = partitionize(z)
    return Combinatorics.multinomial(p...)
end

function poisson_pdf(x::Integer, λ::Float64)
    exp(-λ)*λ^x/factorial(big(x))
end

max_stars_repo_name: PhilChodrow/HypergraphModularity

max_issues_repo_name: PhilChodrow/HypergraphModularity

max_forks_repo_name: PhilChodrow/HypergraphModularity


text:
function parse_map(s)
    lines = readlines(IOBuffer(s))
    is_seat = falses((length(lines) + 2, length(lines[1]) + 2))
    for i in 1:length(lines)
        for j in 1:length(lines[1])
            is_seat[i + 1, j + 1] = lines[i][j] == 'L'
        end
    end
    return is_seat
end

function get_neighbor_seats(is_seat)
    n_seats = sum(is_seat)
    n_rows, n_cols = size(is_seat)
    neighbor_seats = zeros(Int, (n_seats, 8, 2))
    directions = [
        # north
        (-1, 0),
        # north-west
        (-1, 1),
        # west
        (0, 1),
        # south-west
        (1, 1),
        # south
        (1, 0),
        # south-east
        (1, -1),
        # east
        (0, -1),
        # north-east
        (-1, -1)
    ]
    k = 0
    for i in 2:n_rows - 1
        for j in 2:n_cols - 1
            if is_seat[i, j]
                k += 1
                for (d_idx, (d_i, d_j)) in enumerate(directions)
                    x, y = i + d_i, j + d_j
                    while !(is_seat[x, y]) && (1 < x < n_rows) && (1 < y < n_cols)
                        x += d_i
                        y += d_j
                    end
                    neighbor_seats[k, d_idx, :] = [x, y]
                end
            end
        end
    end
    return neighbor_seats
end

function count_neighbors(is_occupied::BitArray{2}, neighbor_seats::Array{Int,3}, k::Int)::Int
    count::Int = 0
    x::Int = 0
    y::Int = 0
    for d_idx in 1:8
        x = neighbor_seats[k, d_idx, 1]
        y = neighbor_seats[k, d_idx, 2]
        if is_occupied[x, y]
            count += 1
        end
    end
    return count
end

function run(s)
    # Your code here
    is_seat = parse_map(s)
    neighbor_seats = get_neighbor_seats(is_seat)
    is_occupied = copy(is_seat)
    old_is_occupied = copy(is_seat)
    n_rows, n_cols = size(is_seat)

    has_changed::Bool = true
    new_free::Bool = false
    new_occupied::Bool = false
    n_neighbors::Int = 0
    k::Int = 0
    while has_changed
        # is_seat .& .!is_occupied = not_occupied
        has_changed = false
        k = 0
        old_is_occupied .= is_occupied
        for i in 2:n_rows - 1
            for j in 2:n_cols - 1
                if is_seat[i, j]
                    k += 1
                    n_neighbors = count_neighbors(old_is_occupied, neighbor_seats, k)
                    new_occupied = is_seat[i, j] & !old_is_occupied[i, j] & (n_neighbors == 0)
                    new_free = old_is_occupied[i, j] & (n_neighbors >= 5)
                    if new_occupied
                        has_changed = true
                        is_occupied[i, j] = true
                    elseif new_free
                        has_changed = true
                        is_occupied[i, j] = false
                    end
                end
            end
        end
    end
    return sum(is_occupied)
end

#########################################

function main()
    res, time, memory = @timed run(ARGS[1])
    println("_duration:$(time * 1000)")
    println(res)
end

main()


text:
slurm_process_command(cmd) = strip.(reverse(readlines(cmd)))[1:end-2]
"""
    slurm_history_jobdir(stardate=yesterday())

Returns the unique job directories of the jobs that ran since the `startdate`.
Startdate should be printed in following format: yyyy-mm-dd.
"""
function slurm_history_jobdir(startdate = yesterday()) #format of startdate = yyyy-mm-dd
    history = slurm_process_command(`sacct --starttime $startdate --format=Workdir%100`)
    output = String[]
    for h in history
        if h ∉ output && ispath(h)
            push!(output, h)
        end
    end
    return output
end

function slurm_state(state)
    if state == "PENDING"
        return Jobs.Pending
    elseif state == "RUNNING"
        return Jobs.Running
    elseif state == "COMPLETED"
        return Jobs.Completed
    elseif state == "CANCELLED"
        return Jobs.Cancelled
    elseif state == "BOOT_FAIL"
        return Jobs.BootFail
    elseif state == "DEADLINE"
        return Jobs.Deadline
    elseif state == "FAILED"
        return Jobs.Failed
    elseif state == "NODE_FAIL"
        return Jobs.NodeFail
    elseif state == "OUT_OF_MEMORY"
        return Jobs.OutOfMemory
    elseif state == "PREEMTED"
        return Jobs.Preempted
    elseif state == "REQUEUED"
        return Jobs.Requeued
    elseif state == "RESIZING"
        return Jobs.Resizing
    elseif state == "REVOKED"
        return Jobs.Revoked
    elseif state == "SUSPENDED"
        return Jobs.Suspended
    elseif state == "TIMEOUT"
        return Jobs.Timeout
    end
end

function slurm_queue!(q, all=false)
    if all # Should only be done veeeery sporadically
        cmd = `sacct -u $(ENV["USER"]) --format=Workdir%100,JobID%20,State%30 -S 2000-01-01`
    else
        cmd = `sacct -u $(ENV["USER"]) --format=Workdir%100,JobID%20,State%30`
    end
    all = map(x -> strip.(filter(!isempty, split(x, "  "))), readlines(cmd)[3:end])
    lines = filter(x->length(x) == 3, all)
    return merge!(q, Dict([l[1] => (parse(Int, l[2]), slurm_state(occursin("by", l[3]) ? split(l[3])[1] : l[3])) for l in lines]))
end

"""
    slurm_jobid(job::Job)

Looks through the jobs since the `startdate` and returns the job ID if found.
Returns -1 if the jobID was not found in the list of jobs since `startdate`.
"""
function slurm_jobid(job::Job)
    if haskey(JOB_QUEUE[], job.dir)
        return JOB_QUEUE[][job.dir][1]
    else
        @info "Job in directory $(job.dir) was not found in the slurm jobs."
        return -1
    end
end

"""
    slurm_jobstate(job::Job)

Returns the current state of a job.
"""
function slurm_job_state(job::Job)
    if haskey(JOB_QUEUE[], job.dir)
        return JOB_QUEUE[][job.dir][2]
    else
        error("Job in directory $(job.dir) was not found in the slurm jobs.")
        return -1
    end
end

"""
    slurm_mostrecent(index=1, jobfile="job.tt", startdate=lastmonth(), args...; kwargs...)

Returns whether the `index`th most recent job with job script `jobfile`.
Extra args and kwargs will be passed to the `Job` constructor.
"""
function slurm_mostrecent(index = 1, jobfile = "job.tt", startdate = lastmonth(), args...;
                          kwargs...)
    dirs = slurm_history_jobdir(startdate)
    @assert length(dirs) >= index "There are less recent jobs since startdate $startdate than the index $index."
    jobpath = joinpath(dirs[index], jobfile)
    @assert ispath(jobpath) "The directory $(dirs[index]) does not have a job file with filename $jobfile."
    return Job(dirs[index], args...; job_fuzzy = jobfile, kwargs...)
end

function slurm_submit(j::String)
    cd(j)
    id = parse(Int, split(read(`sbatch job.tt`, String))[end])
    return (id, Jobs.Submitted)
end


text:
if VERSION ≥ v"1.3.0-"
   @testset "Coerce Col2" begin
      X = Tables.table(ones(1_000, 2))
      tmp = tempname()
      CSV.write(tmp, X)
      data = CSV.read(tmp, DataFrame)
      # data.Column1 and data.Column2 are Column2 (as of CSV 5.19)
      @test data.Column1 isa AbstractArray{<:AbstractFloat}
      dc = coerce(data, autotype(data, :discrete_to_continuous))
      @test scitype(dc) == Table{AbstractArray{Continuous,1}}
      rm(tmp)
   end
end

@testset "coerce!" begin
   df = DataFrame((x=ones(Int,5), y=ones(5)))
    @test scitype(df) == Table{Union{AbstractArray{Continuous,1},
                                     AbstractArray{Count,1}}}
   coerce!(df, :x=>Continuous)
   @test scitype(df) == Table{AbstractArray{Continuous,1}}

   df = DataFrame((
         x=ones(Int, 50),
         y=ones(50),
         z=collect("abbabaacbcabbabaacbbcccbccbbabaaacacbcabcbccaabaaa")
         ))
    @test scitype(df) == Table{Union{AbstractArray{Continuous,1},
                                     AbstractArray{Count,1},
                                     AbstractArray{Unknown,1}}}

   coerce!(df, autotype(df, :few_to_finite))
    @test scitype(df) == Table{Union{AbstractArray{Multiclass{3},1},
                                     AbstractArray{OrderedFactor{1},1}}}

   @test_throws ScientificTypes.CoercionError coerce!(randn(5, 5))
end


text:
# Some universal physical constant in
# https://en.wikipedia.org/wiki/Physical_constant

DATA["NIST"] = parse(NISTConst, DATAFILES["NIST"])

# Universal constants
export c, c0, G, g, ħ, h
"""
speed of light in vacuum
"""
const c = DATA["NIST"]["speed of light in vacuum"]
"""
speed of light in vacuum
"""
const c0 = DATA["NIST"]["speed of light in vacuum"]
"""
Newtonian constant of gravitation
"""
const G = DATA["NIST"]["Newtonian constant of gravitation"]
"""
standard acceleration of gravity
"""
const g = DATA["NIST"]["standard acceleration of gravity"]
"""
Planck constant
"""
const h = DATA["NIST"]["Planck constant"]
"""
Planck constant over 2 pi
"""
const ħ = DATA["NIST"]["Planck constant over 2 pi"]

# Electromagnetic constants
export e

"""
atomic unit of charge
"""
const e = DATA["NIST"]["atomic unit of charge"]

# Atomic and nuclear constants
export a0, α

"""
Bohr radius
"""
const a0 = DATA["NIST"]["Bohr radius"]

"""
fine-structure constant
"""
const α = DATA["NIST"]["fine-structure constant"]

# Physico-chemical constants
export k, NA, atm

"""
Boltzmann constant
"""
const k = DATA["NIST"]["Boltzmann constant"]

"""
Avogadro constant
"""
const NA = DATA["NIST"]["Avogadro constant"]

"""
standard atmosphere
"""
const atm = DATA["NIST"]["standard atmosphere"]

export μ0, ε0

"""
magnetic constant (vacuum permeability)
"""
const μ0 = DefConst("magnetic constant (vacuum permeability)", 4pi*1e-7, "N A^{-2}")

"""
electric constant (vacuum permittivity)
"""
const ε0 = DefConst("electric constant (vacuum permittivity)", 1/(value(μ0)*value(c)^2), "F m^{-1}")


text:
#=

  Seseman problem in Julia + ConstraintSolver.jl

  Description of the problem:

  n is the length of a border
  There are (n-2)^2 "holes", i.e.
  there are n^2 - (n-2)^2 variables to find out.

  The simplest problem, n = 3 (n x n matrix)
  which is represented by the following matrix:

   a b c
   d   e
   f g h

  Where the following constraints must hold:

    a + b + c = border_sum
    a + d + f = border_sum
    c + e + h = border_sum
    f + g + h = border_sum
    a + b + c + d + e + f = total_sum

  For a (Swedish) discussion of this problem, see
  "Sesemans matematiska klosterproblem samt lite Constraint Logic Programming"
  http://www.hakank.org/webblogg/archives/001084.html
  and
  Seseman's Convent Problem: http://www.hakank.org/seseman/seseman.cgi
  (using ECLiPSe CLP code)

  It was also is commented in the (Swedish) blog post
  "Constraint Programming: Minizinc, Gecode/flatzinc och ECLiPSe/minizinc"
  http://www.hakank.org/webblogg/archives/001209.html

  Model created by Hakan Kjellerstrand, hakank@gmail.com
  See also my Julia page: http://www.hakank.org/julia/

=#
using ConstraintSolver, JuMP
using Cbc, GLPK
const CS = ConstraintSolver

include("constraints_utils.jl")

#
# first_num = 1:
# * without symmetry breaking: 85 solutions
# * with symmetry breaking: 4 solutions
#
# first_num = 0:
# * without symmetry breaking: 231 solutions
# * with symmetry breaking: 7 solutions#
#
function seseman(row_sum=9,total=24,first_num=1;all_solutions=false,print_solutions=true,symmetry_breaking=false)

    cbc_optimizer = optimizer_with_attributes(Cbc.Optimizer, "logLevel" => 0)
    glpk_optimizer = optimizer_with_attributes(GLPK.Optimizer)

    model = Model(optimizer_with_attributes(CS.Optimizer,   "all_solutions"=> all_solutions,
                                                            # "all_optimal_solutions"=>true,
                                                            "logging"=>[],

                                                            # "traverse_strategy"=>:BFS,
                                                            "traverse_strategy"=>:DFS,
                                                            # "traverse_strategy"=>:DBFS,

                                                            # "branch_split"=>:Smallest,
                                                            # "branch_split"=>:Biggest,
                                                            "branch_split"=>:InHalf,

                                                            # "simplify"=>false,
                                                            "simplify"=>true,

                                                            "time_limit"=>14,
                                                            # "lp_optimizer" => cbc_optimizer,
                                                            # "lp_optimizer" => glpk_optimizer,
                                        ))

    println("row_sum:$row_sum total:$total first_num:$first_num symmetry_breaking:$symmetry_breaking")

    @variable(model, first_num <= x[1:8] <= 9, Int)
    a,b,c,d,e,f,g,h = x

    @constraint(model, sum(x) == total)

    segments = [[a,b,c],
                [a,d,f],
                [c,e,h],
                [f,g,h]]
    for segment in segments
        @constraint(model, sum(segment) == row_sum)
    end

    if symmetry_breaking
        syms = [[a,h],[b,d],[d,e],[e,g]]
        for s in syms
            @constraint(model, s[1] <= s[2])
        end
    end

    # Solve the problem
    # println("solve")
    optimize!(model)

    status = JuMP.termination_status(model)
    # println("status:$status")
    if status == MOI.OPTIMAL
        num_sols = MOI.get(model, MOI.ResultCount())
        println("num_sols:$num_sols\n")
        # num_sols2 = JuMP.result_count(model) # same result
        # println("num_sols2:$num_sols2\n")

        if print_solutions
            for sol in 1:num_sols
                println("solution #$sol")
                xx = convert.(Integer,JuMP.value.(x,result=sol))
                println("$(xx[1])  $(xx[2])  $(xx[3])")
                println("$(xx[4])     $(xx[5])")
                println("$(xx[6])  $(xx[7])  $(xx[8])")
            end
        end
    end
end

# First num: 1
seseman(9,24,1;all_solutions=true,print_solutions=true,symmetry_breaking=true)

# First num: 0
# seseman(9,24,0;all_solutions=true,symmetry_breaking=false)

println("\nChecking different configurations")
for first_num in [0,1], symmetry_breaking in [true,false]
    seseman(9,24,first_num;all_solutions=true,print_solutions=false,symmetry_breaking=symmetry_breaking)
end

max_stars_repo_name: Wikunia/hakank

max_issues_repo_name: Wikunia/hakank

max_forks_repo_name: Wikunia/hakank


text:
# Tools for dealing with setting the affinity of
const libaffinity = joinpath(DEPSDIR, "libaffinity.so")
dlopen(libaffinity)

# When we get the current affinity from the `C` code, we're receiving a `C` allocated object
# which needs to be freed at some point.
#
# We wrap the returned pointer in this `PtrWrap` mutable struct and attach a finalizer
# which calls `free` on the pointer.
mutable struct PtrWrap
    ptr::Ptr{Cvoid}
end

free(W::PtrWrap) = ccall((:jl_free, libaffinity), Cvoid, (Ptr{Cvoid},), W.ptr)

function getaffinity()
    affinity = ccall((:jl_get_affinity, libaffinity), Ptr{Cvoid}, (Int64,), getpid())

    # Stop the memory leak!
    wrap = PtrWrap(affinity)
    finalizer(free, wrap)
    return wrap
end

function setaffinity(pid, cpu::IndexZero)
    return ccall((:jl_set_affinity, libaffinity), Cvoid, (Int64, Int64,), pid, value(cpu))
end

setaffinity(pid, cpu::Integer) = setaffinity(pid, indexzero(cpu))
setaffinity(cpu) = setaffinity(getpid(), cpu)

function setaffinity(pid, wrap::PtrWrap)
    ccall((:jl_reset_affinity, libaffinity), Cvoid, (Int64, Ptr{Cvoid},), pid, wrap.ptr)
    return nothing
end
setaffinity(wrap::PtrWrap) = setaffinity(getpid(), wrap)


text:
Lattices.sites(lattice::Square) = SitesIterator(lattice)

struct SitesIterator{Shape}
    SitesIterator(ltc::Square{S}) where S = new{S}()
end

function Base.iterate(it::SitesIterator{Tuple{height, width}}, state = (1, 1, 1)) where {height, width}
    i, j, count = state

    if count == length(it) + 1
        return nothing
    elseif i > height
        return (1, j+1), (2, j+1, count+1)
    else
        return (i, j), (i+1, j, count+1)
    end
end

Base.size(::SitesIterator{Tuple{H, W}}) where {H, W} = (H, W)
Base.length(::SitesIterator{Tuple{height, width}}) where {height, width} = width * height
Base.eltype(::SitesIterator) = SiteType


text:
using Documenter
using TopoChains

makedocs(
    sitename = "TopoChains",
    format = Documenter.HTML(
        prettyurls = get(ENV, "CI", nothing) == "true"
    ),
    modules = [TopoChains]
)

deploydocs(
    repo = "https://github.com/irhum/TopoChains.jl"
)


text:
module MultipeakFunctions
	import ..PeakshapeFunctions
	import ..MasslistFunctions
	import ..TOFFunctions
	import ..InterpolationFunctions

	export calculateCrossTalkMatrix, reconstructSpectrum, sumBins

	function createPeakPattern(mass, composition, massScaleMode, massScaleParameters, peakShapesCenterMass, peakShapesY)
	    safetyMarginMasses = 10
	    peakShapeSize = size(peakShapesY,1)
	    # Get isotopes
	    if sum(composition) > 0
	      isotopeMasses, isotopeMasslistElements, isotopeCompositions, isotopeAbundances = MasslistFunctions.isotopesFromCompositionArray(composition)
	    else
	      #println("Unidentified Peak at mass $(mass)")
	      isotopeMasses = [mass]
	      isotopeAbundances = [1]
	    end
	    isotopeMassesIdx = TOFFunctions.mass2timebin(isotopeMasses, massScaleMode, massScaleParameters)
	    # Create Peak Pattern
	    # how many points minimum are needed?
	    nLocalPeakPatternPoints = Int(ceil(TOFFunctions.mass2timebin(maximum(isotopeMasses) + safetyMarginMasses, massScaleMode, massScaleParameters) - TOFFunctions.mass2timebin(minimum(isotopeMasses) - safetyMarginMasses, massScaleMode, massScaleParameters)))
	    localPeakPattern = zeros(nLocalPeakPatternPoints)

	    # where will be zero index? isotope could have lower mass!
	    startIndex = TOFFunctions.mass2timebin(minimum(isotopeMasses) - safetyMarginMasses, massScaleMode, massScaleParameters)
	    for isotope = 1:length(isotopeMasses)
	      localPeakshape = PeakshapeFunctions.getLocalPeakshape(isotopeMasses[isotope], peakShapesCenterMass, peakShapesY)
	      localPeakshape = localPeakshape * isotopeAbundances[isotope]
	      indexRelativeToStartIdx = isotopeMassesIdx[isotope] - startIndex
	      indexRelativeToPeakshapeStart = indexRelativeToStartIdx - (peakShapeSize-1)/2
	      InterpolationFunctions.addArraysShiftedInterpolated(localPeakPattern, localPeakshape, indexRelativeToPeakshapeStart-1)
	    end
	    return startIndex, localPeakPattern
	end

	function calculateCrossTalkMatrix(masses, centerindices, lowindices, highindices, massScaleMode, massScaleParameters, compositions, peakShapesCenterMass, peakShapesY)
	    mtrx = Array{Float64}(undef,length(masses), length(masses))
	    fill(mtrx,0)
	    for i = 1:length(masses)
		startIndex, localPeakPattern = createPeakPattern(masses[i], compositions[:,i], massScaleMode, massScaleParameters, peakShapesCenterMass, peakShapesY)
		for j = 1:length(masses)
		    if ((masses[j] > masses[i]-1) && (masses[j] < masses[i]+3.5))
		        overlap = InterpolationFunctions.interpolatedSum(lowindices[j]-startIndex-1, highindices[j]-startIndex-1, localPeakPattern)
		        mtrx[j,i] = overlap
		    else
		        mtrx[j,i] = 0
		    end
		end
	    end
	    return mtrx
	end

	function sumBins(massAxis, binWidth, spectrum, masses)
	  stickRaw = Array{Float64}(undef,length(masses))
	  fill(stickRaw,0)
	  for i=1:length(masses)
	    midx = searchsortedfirst(massAxis, masses[i])-1
	    stickRaw[i] = sum(spectrum[midx-binWidth:midx+binWidth])
	  end
	  return stickRaw
	end

	function reconstructSpectrum(massAxis, massScaleMode, massScaleParameters, masses, compositions, counts, peakShapesCenterMass, peakShapesY)

	  reconstructedSpectrum = zeros(length(massAxis))
	  fill(reconstructedSpectrum, 0)
	  for i=1:length(masses)
	      startIndex, localPeakPattern = createPeakPattern(masses[i], compositions[:,i], massScaleMode, massScaleParameters, peakShapesCenterMass, peakShapesY)
	      InterpolationFunctions.addArraysShiftedInterpolated(reconstructedSpectrum, counts[i]*localPeakPattern, startIndex)
	  end
	  return reconstructedSpectrum
	end

end