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

Associates a set of queues with a routing profile.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.
- `QueueConfigs`: The queues to associate with this routing profile.
- `RoutingProfileId`: The identifier of the routing profile.

"""

associate_routing_profile_queues(InstanceId, QueueConfigs, RoutingProfileId; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/routing-profiles/$(InstanceId)/$(RoutingProfileId)/associate-queues", Dict{String, Any}("QueueConfigs"=>QueueConfigs); aws_config=aws_config)
associate_routing_profile_queues(InstanceId, QueueConfigs, RoutingProfileId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/routing-profiles/$(InstanceId)/$(RoutingProfileId)/associate-queues", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("QueueConfigs"=>QueueConfigs), args)); aws_config=aws_config)

"""
    CreateContactFlow()

Creates a contact flow for the specified Amazon Connect instance. You can also create and update contact flows using the Amazon Connect Flow language.

# Required Parameters
- `Content`: The content of the contact flow.
- `InstanceId`: The identifier of the Amazon Connect instance.
- `Name`: The name of the contact flow.
- `Type`: The type of the contact flow. For descriptions of the available types, see Choose a Contact Flow Type in the Amazon Connect Administrator Guide.

# Optional Parameters
- `Description`: The description of the contact flow.
- `Tags`: One or more tags.
"""

create_contact_flow(Content, InstanceId, Name, Type; aws_config::AWSConfig=global_aws_config()) = connect("PUT", "/contact-flows/$(InstanceId)", Dict{String, Any}("Content"=>Content, "Name"=>Name, "Type"=>Type); aws_config=aws_config)
create_contact_flow(Content, InstanceId, Name, Type, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("PUT", "/contact-flows/$(InstanceId)", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("Content"=>Content, "Name"=>Name, "Type"=>Type), args)); aws_config=aws_config)

"""
    CreateRoutingProfile()

Creates a new routing profile.

# Required Parameters
- `DefaultOutboundQueueId`: The default outbound queue for the routing profile.
- `Description`: Description of the routing profile. Must not be more than 250 characters.
- `InstanceId`: The identifier of the Amazon Connect instance.
- `MediaConcurrencies`: The channels agents can handle in the Contact Control Panel (CCP) for this routing profile.
- `Name`: The name of the routing profile. Must not be more than 127 characters.

# Optional Parameters
- `QueueConfigs`: The inbound queues associated with the routing profile. If no queue is added, the agent can only make outbound calls.
- `Tags`: One or more tags.
"""

create_routing_profile(DefaultOutboundQueueId, Description, InstanceId, MediaConcurrencies, Name; aws_config::AWSConfig=global_aws_config()) = connect("PUT", "/routing-profiles/$(InstanceId)", Dict{String, Any}("DefaultOutboundQueueId"=>DefaultOutboundQueueId, "Description"=>Description, "MediaConcurrencies"=>MediaConcurrencies, "Name"=>Name); aws_config=aws_config)
create_routing_profile(DefaultOutboundQueueId, Description, InstanceId, MediaConcurrencies, Name, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("PUT", "/routing-profiles/$(InstanceId)", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("DefaultOutboundQueueId"=>DefaultOutboundQueueId, "Description"=>Description, "MediaConcurrencies"=>MediaConcurrencies, "Name"=>Name), args)); aws_config=aws_config)

"""
    CreateUser()

Creates a user account for the specified Amazon Connect instance. For information about how to create user accounts using the Amazon Connect console, see Add Users in the Amazon Connect Administrator Guide.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.
- `PhoneConfig`: The phone settings for the user.
- `RoutingProfileId`: The identifier of the routing profile for the user.
- `SecurityProfileIds`: The identifier of the security profile for the user.
- `Username`: The user name for the account. For instances not using SAML for identity management, the user name can include up to 20 characters. If you are using SAML for identity management, the user name can include up to 64 characters from [a-zA-Z0-9_-.@]+.

# Optional Parameters
- `DirectoryUserId`: The identifier of the user account in the directory used for identity management. If Amazon Connect cannot access the directory, you can specify this identifier to authenticate users. If you include the identifier, we assume that Amazon Connect cannot access the directory. Otherwise, the identity information is used to authenticate users from your directory. This parameter is required if you are using an existing directory for identity management in Amazon Connect when Amazon Connect cannot access your directory to authenticate users. If you are using SAML for identity management and include this parameter, an error is returned.
- `HierarchyGroupId`: The identifier of the hierarchy group for the user.
- `IdentityInfo`: The information about the identity of the user.
- `Password`: The password for the user account. A password is required if you are using Amazon Connect for identity management. Otherwise, it is an error to include a password.
- `Tags`: One or more tags.
"""

create_user(InstanceId, PhoneConfig, RoutingProfileId, SecurityProfileIds, Username; aws_config::AWSConfig=global_aws_config()) = connect("PUT", "/users/$(InstanceId)", Dict{String, Any}("PhoneConfig"=>PhoneConfig, "RoutingProfileId"=>RoutingProfileId, "SecurityProfileIds"=>SecurityProfileIds, "Username"=>Username); aws_config=aws_config)
create_user(InstanceId, PhoneConfig, RoutingProfileId, SecurityProfileIds, Username, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("PUT", "/users/$(InstanceId)", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("PhoneConfig"=>PhoneConfig, "RoutingProfileId"=>RoutingProfileId, "SecurityProfileIds"=>SecurityProfileIds, "Username"=>Username), args)); aws_config=aws_config)

"""
    DeleteUser()

Deletes a user account from the specified Amazon Connect instance. For information about what happens to a user's data when their account is deleted, see Delete Users from Your Amazon Connect Instance in the Amazon Connect Administrator Guide.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.
- `UserId`: The identifier of the user.

"""

delete_user(InstanceId, UserId; aws_config::AWSConfig=global_aws_config()) = connect("DELETE", "/users/$(InstanceId)/$(UserId)"; aws_config=aws_config)
delete_user(InstanceId, UserId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("DELETE", "/users/$(InstanceId)/$(UserId)", args; aws_config=aws_config)

"""
    DescribeContactFlow()

Describes the specified contact flow. You can also create and update contact flows using the Amazon Connect Flow language.

# Required Parameters
- `ContactFlowId`: The identifier of the contact flow.
- `InstanceId`: The identifier of the Amazon Connect instance.

"""

describe_contact_flow(ContactFlowId, InstanceId; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/contact-flows/$(InstanceId)/$(ContactFlowId)"; aws_config=aws_config)
describe_contact_flow(ContactFlowId, InstanceId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/contact-flows/$(InstanceId)/$(ContactFlowId)", args; aws_config=aws_config)

"""
    DescribeRoutingProfile()

Describes the specified routing profile.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.
- `RoutingProfileId`: The identifier of the routing profile.

"""

describe_routing_profile(InstanceId, RoutingProfileId; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/routing-profiles/$(InstanceId)/$(RoutingProfileId)"; aws_config=aws_config)
describe_routing_profile(InstanceId, RoutingProfileId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/routing-profiles/$(InstanceId)/$(RoutingProfileId)", args; aws_config=aws_config)

"""
    DescribeUser()

Describes the specified user account. You can find the instance ID in the console (it’s the final part of the ARN). The console does not display the user IDs. Instead, list the users and note the IDs provided in the output.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.
- `UserId`: The identifier of the user account.

"""

describe_user(InstanceId, UserId; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/users/$(InstanceId)/$(UserId)"; aws_config=aws_config)
describe_user(InstanceId, UserId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/users/$(InstanceId)/$(UserId)", args; aws_config=aws_config)

"""
    DescribeUserHierarchyGroup()

Describes the specified hierarchy group.

# Required Parameters
- `HierarchyGroupId`: The identifier of the hierarchy group.
- `InstanceId`: The identifier of the Amazon Connect instance.

"""

describe_user_hierarchy_group(HierarchyGroupId, InstanceId; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/user-hierarchy-groups/$(InstanceId)/$(HierarchyGroupId)"; aws_config=aws_config)
describe_user_hierarchy_group(HierarchyGroupId, InstanceId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/user-hierarchy-groups/$(InstanceId)/$(HierarchyGroupId)", args; aws_config=aws_config)

"""
    DescribeUserHierarchyStructure()

Describes the hierarchy structure of the specified Amazon Connect instance.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.

"""

describe_user_hierarchy_structure(InstanceId; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/user-hierarchy-structure/$(InstanceId)"; aws_config=aws_config)
describe_user_hierarchy_structure(InstanceId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/user-hierarchy-structure/$(InstanceId)", args; aws_config=aws_config)

"""
    DisassociateRoutingProfileQueues()

Disassociates a set of queues from a routing profile.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.
- `QueueReferences`: The queues to disassociate from this routing profile.
- `RoutingProfileId`: The identifier of the routing profile.

"""

disassociate_routing_profile_queues(InstanceId, QueueReferences, RoutingProfileId; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/routing-profiles/$(InstanceId)/$(RoutingProfileId)/disassociate-queues", Dict{String, Any}("QueueReferences"=>QueueReferences); aws_config=aws_config)
disassociate_routing_profile_queues(InstanceId, QueueReferences, RoutingProfileId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/routing-profiles/$(InstanceId)/$(RoutingProfileId)/disassociate-queues", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("QueueReferences"=>QueueReferences), args)); aws_config=aws_config)

"""
    GetContactAttributes()

Retrieves the contact attributes for the specified contact.

# Required Parameters
- `InitialContactId`: The identifier of the initial contact.
- `InstanceId`: The identifier of the Amazon Connect instance.

"""

get_contact_attributes(InitialContactId, InstanceId; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/contact/attributes/$(InstanceId)/$(InitialContactId)"; aws_config=aws_config)
get_contact_attributes(InitialContactId, InstanceId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/contact/attributes/$(InstanceId)/$(InitialContactId)", args; aws_config=aws_config)

"""
    GetCurrentMetricData()

Gets the real-time metric data from the specified Amazon Connect instance. For a description of each metric, see Real-time Metrics Definitions in the Amazon Connect Administrator Guide.

# Required Parameters
- `CurrentMetrics`: The metrics to retrieve. Specify the name and unit for each metric. The following metrics are available. For a description of all the metrics, see Real-time Metrics Definitions in the Amazon Connect Administrator Guide.  AGENTS_AFTER_CONTACT_WORK  Unit: COUNT Name in real-time metrics report: ACW   AGENTS_AVAILABLE  Unit: COUNT Name in real-time metrics report: Available   AGENTS_ERROR  Unit: COUNT Name in real-time metrics report: Error   AGENTS_NON_PRODUCTIVE  Unit: COUNT Name in real-time metrics report: NPT (Non-Productive Time)   AGENTS_ON_CALL  Unit: COUNT Name in real-time metrics report: On contact   AGENTS_ON_CONTACT  Unit: COUNT Name in real-time metrics report: On contact   AGENTS_ONLINE  Unit: COUNT Name in real-time metrics report: Online   AGENTS_STAFFED  Unit: COUNT Name in real-time metrics report: Staffed   CONTACTS_IN_QUEUE  Unit: COUNT Name in real-time metrics report: In queue   CONTACTS_SCHEDULED  Unit: COUNT Name in real-time metrics report: Scheduled   OLDEST_CONTACT_AGE  Unit: SECONDS When you use groupings, Unit says SECONDS but the Value is returned in MILLISECONDS. For example, if you get a response like this:  { \"Metric\": { \"Name\": \"OLDEST_CONTACT_AGE\", \"Unit\": \"SECONDS\" }, \"Value\": 24113.0 } The actual OLDEST_CONTACT_AGE is 24 seconds. Name in real-time metrics report: Oldest   SLOTS_ACTIVE  Unit: COUNT Name in real-time metrics report: Active   SLOTS_AVAILABLE  Unit: COUNT Name in real-time metrics report: Availability
- `Filters`: The queues, up to 100, or channels, to use to filter the metrics returned. Metric data is retrieved only for the resources associated with the queues or channels included in the filter. You can include both queue IDs and queue ARNs in the same request. Both VOICE and CHAT channels are supported.
- `InstanceId`: The identifier of the Amazon Connect instance.

# Optional Parameters
- `Groupings`: The grouping applied to the metrics returned. For example, when grouped by QUEUE, the metrics returned apply to each queue rather than aggregated for all queues. If you group by CHANNEL, you should include a Channels filter. Both VOICE and CHAT channels are supported. If no Grouping is included in the request, a summary of metrics is returned.
- `MaxResults`: The maximimum number of results to return per page.
- `NextToken`: The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results. The token expires after 5 minutes from the time it is created. Subsequent requests that use the token must use the same request parameters as the request that generated the token.
"""

get_current_metric_data(CurrentMetrics, Filters, InstanceId; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/metrics/current/$(InstanceId)", Dict{String, Any}("CurrentMetrics"=>CurrentMetrics, "Filters"=>Filters); aws_config=aws_config)
get_current_metric_data(CurrentMetrics, Filters, InstanceId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/metrics/current/$(InstanceId)", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("CurrentMetrics"=>CurrentMetrics, "Filters"=>Filters), args)); aws_config=aws_config)

"""
    GetFederationToken()

Retrieves a token for federation.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.

"""

get_federation_token(InstanceId; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/user/federate/$(InstanceId)"; aws_config=aws_config)
get_federation_token(InstanceId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/user/federate/$(InstanceId)", args; aws_config=aws_config)

"""
    GetMetricData()

Gets historical metric data from the specified Amazon Connect instance. For a description of each historical metric, see Historical Metrics Definitions in the Amazon Connect Administrator Guide.

# Required Parameters
- `EndTime`: The timestamp, in UNIX Epoch time format, at which to end the reporting interval for the retrieval of historical metrics data. The time must be specified using an interval of 5 minutes, such as 11:00, 11:05, 11:10, and must be later than the start time timestamp. The time range between the start and end time must be less than 24 hours.
- `Filters`: The queues, up to 100, or channels, to use to filter the metrics returned. Metric data is retrieved only for the resources associated with the queues or channels included in the filter. You can include both queue IDs and queue ARNs in the same request. Both VOICE and CHAT channels are supported.
- `HistoricalMetrics`: The metrics to retrieve. Specify the name, unit, and statistic for each metric. The following historical metrics are available. For a description of each metric, see Historical Metrics Definitions in the Amazon Connect Administrator Guide.  ABANDON_TIME  Unit: SECONDS Statistic: AVG  AFTER_CONTACT_WORK_TIME  Unit: SECONDS Statistic: AVG  API_CONTACTS_HANDLED  Unit: COUNT Statistic: SUM  CALLBACK_CONTACTS_HANDLED  Unit: COUNT Statistic: SUM  CONTACTS_ABANDONED  Unit: COUNT Statistic: SUM  CONTACTS_AGENT_HUNG_UP_FIRST  Unit: COUNT Statistic: SUM  CONTACTS_CONSULTED  Unit: COUNT Statistic: SUM  CONTACTS_HANDLED  Unit: COUNT Statistic: SUM  CONTACTS_HANDLED_INCOMING  Unit: COUNT Statistic: SUM  CONTACTS_HANDLED_OUTBOUND  Unit: COUNT Statistic: SUM  CONTACTS_HOLD_ABANDONS  Unit: COUNT Statistic: SUM  CONTACTS_MISSED  Unit: COUNT Statistic: SUM  CONTACTS_QUEUED  Unit: COUNT Statistic: SUM  CONTACTS_TRANSFERRED_IN  Unit: COUNT Statistic: SUM  CONTACTS_TRANSFERRED_IN_FROM_QUEUE  Unit: COUNT Statistic: SUM  CONTACTS_TRANSFERRED_OUT  Unit: COUNT Statistic: SUM  CONTACTS_TRANSFERRED_OUT_FROM_QUEUE  Unit: COUNT Statistic: SUM  HANDLE_TIME  Unit: SECONDS Statistic: AVG  HOLD_TIME  Unit: SECONDS Statistic: AVG  INTERACTION_AND_HOLD_TIME  Unit: SECONDS Statistic: AVG  INTERACTION_TIME  Unit: SECONDS Statistic: AVG  OCCUPANCY  Unit: PERCENT Statistic: AVG  QUEUE_ANSWER_TIME  Unit: SECONDS Statistic: AVG  QUEUED_TIME  Unit: SECONDS Statistic: MAX  SERVICE_LEVEL  Unit: PERCENT Statistic: AVG Threshold: Only \"Less than\" comparisons are supported, with the following service level thresholds: 15, 20, 25, 30, 45, 60, 90, 120, 180, 240, 300, 600
- `InstanceId`: The identifier of the Amazon Connect instance.
- `StartTime`: The timestamp, in UNIX Epoch time format, at which to start the reporting interval for the retrieval of historical metrics data. The time must be specified using a multiple of 5 minutes, such as 10:05, 10:10, 10:15. The start time cannot be earlier than 24 hours before the time of the request. Historical metrics are available only for 24 hours.

# Optional Parameters
- `Groupings`: The grouping applied to the metrics returned. For example, when results are grouped by queue, the metrics returned are grouped by queue. The values returned apply to the metrics for each queue rather than aggregated for all queues. The only supported grouping is QUEUE. If no grouping is specified, a summary of metrics for all queues is returned.
- `MaxResults`: The maximimum number of results to return per page.
- `NextToken`: The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.
"""

get_metric_data(EndTime, Filters, HistoricalMetrics, InstanceId, StartTime; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/metrics/historical/$(InstanceId)", Dict{String, Any}("EndTime"=>EndTime, "Filters"=>Filters, "HistoricalMetrics"=>HistoricalMetrics, "StartTime"=>StartTime); aws_config=aws_config)
get_metric_data(EndTime, Filters, HistoricalMetrics, InstanceId, StartTime, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/metrics/historical/$(InstanceId)", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("EndTime"=>EndTime, "Filters"=>Filters, "HistoricalMetrics"=>HistoricalMetrics, "StartTime"=>StartTime), args)); aws_config=aws_config)

"""
    ListContactFlows()

Provides information about the contact flows for the specified Amazon Connect instance. You can also create and update contact flows using the Amazon Connect Flow language. For more information about contact flows, see Contact Flows in the Amazon Connect Administrator Guide.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.

# Optional Parameters
- `contactFlowTypes`: The type of contact flow.
- `maxResults`: The maximimum number of results to return per page.
- `nextToken`: The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.
"""

list_contact_flows(InstanceId; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/contact-flows-summary/$(InstanceId)"; aws_config=aws_config)
list_contact_flows(InstanceId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/contact-flows-summary/$(InstanceId)", args; aws_config=aws_config)

"""
    ListHoursOfOperations()

Provides information about the hours of operation for the specified Amazon Connect instance. For more information about hours of operation, see Set the Hours of Operation for a Queue in the Amazon Connect Administrator Guide.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.

# Optional Parameters
- `maxResults`: The maximimum number of results to return per page.
- `nextToken`: The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.
"""

list_hours_of_operations(InstanceId; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/hours-of-operations-summary/$(InstanceId)"; aws_config=aws_config)
list_hours_of_operations(InstanceId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/hours-of-operations-summary/$(InstanceId)", args; aws_config=aws_config)

"""
    ListPhoneNumbers()

Provides information about the phone numbers for the specified Amazon Connect instance.  For more information about phone numbers, see Set Up Phone Numbers for Your Contact Center in the Amazon Connect Administrator Guide.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.

# Optional Parameters
- `maxResults`: The maximimum number of results to return per page.
- `nextToken`: The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.
- `phoneNumberCountryCodes`: The ISO country code.
- `phoneNumberTypes`: The type of phone number.
"""

list_phone_numbers(InstanceId; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/phone-numbers-summary/$(InstanceId)"; aws_config=aws_config)
list_phone_numbers(InstanceId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/phone-numbers-summary/$(InstanceId)", args; aws_config=aws_config)

"""
    ListPrompts()

Provides information about the prompts for the specified Amazon Connect instance.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.

# Optional Parameters
- `maxResults`: The maximum number of results to return per page.
- `nextToken`: The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.
"""

list_prompts(InstanceId; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/prompts-summary/$(InstanceId)"; aws_config=aws_config)
list_prompts(InstanceId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/prompts-summary/$(InstanceId)", args; aws_config=aws_config)

"""
    ListQueues()

Provides information about the queues for the specified Amazon Connect instance. For more information about queues, see Queues: Standard and Agent in the Amazon Connect Administrator Guide.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.

# Optional Parameters
- `maxResults`: The maximimum number of results to return per page.
- `nextToken`: The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.
- `queueTypes`: The type of queue.
"""

list_queues(InstanceId; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/queues-summary/$(InstanceId)"; aws_config=aws_config)
list_queues(InstanceId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/queues-summary/$(InstanceId)", args; aws_config=aws_config)

"""
    ListRoutingProfileQueues()

List the queues associated with a routing profile.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.
- `RoutingProfileId`: The identifier of the routing profile.

# Optional Parameters
- `maxResults`: The maximimum number of results to return per page.
- `nextToken`: The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.
"""

list_routing_profile_queues(InstanceId, RoutingProfileId; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/routing-profiles/$(InstanceId)/$(RoutingProfileId)/queues"; aws_config=aws_config)
list_routing_profile_queues(InstanceId, RoutingProfileId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/routing-profiles/$(InstanceId)/$(RoutingProfileId)/queues", args; aws_config=aws_config)

"""
    ListRoutingProfiles()

Provides summary information about the routing profiles for the specified Amazon Connect instance. For more information about routing profiles, see Routing Profiles and Create a Routing Profile in the Amazon Connect Administrator Guide.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.

# Optional Parameters
- `maxResults`: The maximimum number of results to return per page.
- `nextToken`: The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.
"""

list_routing_profiles(InstanceId; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/routing-profiles-summary/$(InstanceId)"; aws_config=aws_config)
list_routing_profiles(InstanceId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/routing-profiles-summary/$(InstanceId)", args; aws_config=aws_config)

"""
    ListSecurityProfiles()

Provides summary information about the security profiles for the specified Amazon Connect instance. For more information about security profiles, see Security Profiles in the Amazon Connect Administrator Guide.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.

# Optional Parameters
- `maxResults`: The maximimum number of results to return per page.
- `nextToken`: The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.
"""

list_security_profiles(InstanceId; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/security-profiles-summary/$(InstanceId)"; aws_config=aws_config)
list_security_profiles(InstanceId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/security-profiles-summary/$(InstanceId)", args; aws_config=aws_config)

"""
    ListTagsForResource()

Lists the tags for the specified resource. For sample policies that use tags, see Amazon Connect Identity-Based Policy Examples in the Amazon Connect Administrator Guide.

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

"""

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

"""
    ListUserHierarchyGroups()

Provides summary information about the hierarchy groups for the specified Amazon Connect instance. For more information about agent hierarchies, see Set Up Agent Hierarchies in the Amazon Connect Administrator Guide.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.

# Optional Parameters
- `maxResults`: The maximimum number of results to return per page.
- `nextToken`: The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.
"""

list_user_hierarchy_groups(InstanceId; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/user-hierarchy-groups-summary/$(InstanceId)"; aws_config=aws_config)
list_user_hierarchy_groups(InstanceId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/user-hierarchy-groups-summary/$(InstanceId)", args; aws_config=aws_config)

"""
    ListUsers()

Provides summary information about the users for the specified Amazon Connect instance.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.

# Optional Parameters
- `maxResults`: The maximimum number of results to return per page.
- `nextToken`: The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.
"""

list_users(InstanceId; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/users-summary/$(InstanceId)"; aws_config=aws_config)
list_users(InstanceId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("GET", "/users-summary/$(InstanceId)", args; aws_config=aws_config)

"""
    ResumeContactRecording()

When a contact is being recorded, and the recording has been suspended using SuspendContactRecording, this API resumes recording the call. Only voice recordings are supported at this time.

# Required Parameters
- `ContactId`: The identifier of the contact.
- `InitialContactId`: The identifier of the contact. This is the identifier of the contact associated with the first interaction with the contact center.
- `InstanceId`: The identifier of the Amazon Connect instance.

"""

resume_contact_recording(ContactId, InitialContactId, InstanceId; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/contact/resume-recording", Dict{String, Any}("ContactId"=>ContactId, "InitialContactId"=>InitialContactId, "InstanceId"=>InstanceId); aws_config=aws_config)
resume_contact_recording(ContactId, InitialContactId, InstanceId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/contact/resume-recording", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ContactId"=>ContactId, "InitialContactId"=>InitialContactId, "InstanceId"=>InstanceId), args)); aws_config=aws_config)

"""
    StartChatContact()

Initiates a contact flow to start a new chat for the customer. Response of this API provides a token required to obtain credentials from the CreateParticipantConnection API in the Amazon Connect Participant Service. When a new chat contact is successfully created, clients need to subscribe to the participant’s connection for the created chat within 5 minutes. This is achieved by invoking CreateParticipantConnection with WEBSOCKET and CONNECTION_CREDENTIALS.  A 429 error occurs in two situations:   API rate limit is exceeded. API TPS throttling returns a TooManyRequests exception from the API Gateway.   The quota for concurrent active chats is exceeded. Active chat throttling returns a LimitExceededException.   For more information about how chat works, see Chat in the Amazon Connect Administrator Guide.

# Required Parameters
- `ContactFlowId`: The identifier of the contact flow for initiating the chat. To see the ContactFlowId in the Amazon Connect console user interface, on the navigation menu go to Routing, Contact Flows. Choose the contact flow. On the contact flow page, under the name of the contact flow, choose Show additional flow information. The ContactFlowId is the last part of the ARN, shown here in bold:  arn:aws:connect:us-west-2:xxxxxxxxxxxx:instance/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/contact-flow/846ec553-a005-41c0-8341-xxxxxxxxxxxx
- `InstanceId`: The identifier of the Amazon Connect instance.
- `ParticipantDetails`: Information identifying the participant.

# Optional Parameters
- `Attributes`: A custom key-value pair using an attribute map. The attributes are standard Amazon Connect attributes, and can be accessed in contact flows just like any other contact attributes.  There can be up to 32,768 UTF-8 bytes across all key-value pairs per contact. Attribute keys can include only alphanumeric, dash, and underscore characters.
- `ClientToken`: A unique, case-sensitive identifier that you provide to ensure the idempotency of the request.
- `InitialMessage`: The initial message to be sent to the newly created chat.
"""

start_chat_contact(ContactFlowId, InstanceId, ParticipantDetails; aws_config::AWSConfig=global_aws_config()) = connect("PUT", "/contact/chat", Dict{String, Any}("ContactFlowId"=>ContactFlowId, "InstanceId"=>InstanceId, "ParticipantDetails"=>ParticipantDetails, "ClientToken"=>string(uuid4())); aws_config=aws_config)
start_chat_contact(ContactFlowId, InstanceId, ParticipantDetails, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("PUT", "/contact/chat", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ContactFlowId"=>ContactFlowId, "InstanceId"=>InstanceId, "ParticipantDetails"=>ParticipantDetails, "ClientToken"=>string(uuid4())), args)); aws_config=aws_config)

"""
    StartContactRecording()

This API starts recording the contact when the agent joins the call. StartContactRecording is a one-time action. For example, if you use StopContactRecording to stop recording an ongoing call, you can't use StartContactRecording to restart it. For scenarios where the recording has started and you want to suspend and resume it, such as when collecting sensitive information (for example, a credit card number), use SuspendContactRecording and ResumeContactRecording. You can use this API to override the recording behavior configured in the Set recording behavior block. Only voice recordings are supported at this time.

# Required Parameters
- `ContactId`: The identifier of the contact.
- `InitialContactId`: The identifier of the contact. This is the identifier of the contact associated with the first interaction with the contact center.
- `InstanceId`: The identifier of the Amazon Connect instance.
- `VoiceRecordingConfiguration`: Who is being recorded.

"""

start_contact_recording(ContactId, InitialContactId, InstanceId, VoiceRecordingConfiguration; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/contact/start-recording", Dict{String, Any}("ContactId"=>ContactId, "InitialContactId"=>InitialContactId, "InstanceId"=>InstanceId, "VoiceRecordingConfiguration"=>VoiceRecordingConfiguration); aws_config=aws_config)
start_contact_recording(ContactId, InitialContactId, InstanceId, VoiceRecordingConfiguration, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/contact/start-recording", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ContactId"=>ContactId, "InitialContactId"=>InitialContactId, "InstanceId"=>InstanceId, "VoiceRecordingConfiguration"=>VoiceRecordingConfiguration), args)); aws_config=aws_config)

"""
    StartOutboundVoiceContact()

This API places an outbound call to a contact, and then initiates the contact flow. It performs the actions in the contact flow that's specified (in ContactFlowId). Agents are not involved in initiating the outbound API (that is, dialing the contact). If the contact flow places an outbound call to a contact, and then puts the contact in queue, that's when the call is routed to the agent, like any other inbound case. There is a 60 second dialing timeout for this operation. If the call is not connected after 60 seconds, it fails.  UK numbers with a 447 prefix are not allowed by default. Before you can dial these UK mobile numbers, you must submit a service quota increase request. For more information, see Amazon Connect Service Quotas in the Amazon Connect Administrator Guide.

# Required Parameters
- `ContactFlowId`: The identifier of the contact flow for the outbound call. To see the ContactFlowId in the Amazon Connect console user interface, on the navigation menu go to Routing, Contact Flows. Choose the contact flow. On the contact flow page, under the name of the contact flow, choose Show additional flow information. The ContactFlowId is the last part of the ARN, shown here in bold:  arn:aws:connect:us-west-2:xxxxxxxxxxxx:instance/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/contact-flow/846ec553-a005-41c0-8341-xxxxxxxxxxxx
- `DestinationPhoneNumber`: The phone number of the customer, in E.164 format.
- `InstanceId`: The identifier of the Amazon Connect instance.

# Optional Parameters
- `Attributes`: A custom key-value pair using an attribute map. The attributes are standard Amazon Connect attributes, and can be accessed in contact flows just like any other contact attributes. There can be up to 32,768 UTF-8 bytes across all key-value pairs per contact. Attribute keys can include only alphanumeric, dash, and underscore characters.
- `ClientToken`: A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. The token is valid for 7 days after creation. If a contact is already started, the contact ID is returned. If the contact is disconnected, a new contact is started.
- `QueueId`: The queue for the call. If you specify a queue, the phone displayed for caller ID is the phone number specified in the queue. If you do not specify a queue, the queue defined in the contact flow is used. If you do not specify a queue, you must specify a source phone number.
- `SourcePhoneNumber`: The phone number associated with the Amazon Connect instance, in E.164 format. If you do not specify a source phone number, you must specify a queue.
"""

start_outbound_voice_contact(ContactFlowId, DestinationPhoneNumber, InstanceId; aws_config::AWSConfig=global_aws_config()) = connect("PUT", "/contact/outbound-voice", Dict{String, Any}("ContactFlowId"=>ContactFlowId, "DestinationPhoneNumber"=>DestinationPhoneNumber, "InstanceId"=>InstanceId, "ClientToken"=>string(uuid4())); aws_config=aws_config)
start_outbound_voice_contact(ContactFlowId, DestinationPhoneNumber, InstanceId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("PUT", "/contact/outbound-voice", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ContactFlowId"=>ContactFlowId, "DestinationPhoneNumber"=>DestinationPhoneNumber, "InstanceId"=>InstanceId, "ClientToken"=>string(uuid4())), args)); aws_config=aws_config)

"""
    StopContact()

Ends the specified contact.

# Required Parameters
- `ContactId`: The ID of the contact.
- `InstanceId`: The identifier of the Amazon Connect instance.

"""

stop_contact(ContactId, InstanceId; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/contact/stop", Dict{String, Any}("ContactId"=>ContactId, "InstanceId"=>InstanceId); aws_config=aws_config)
stop_contact(ContactId, InstanceId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/contact/stop", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ContactId"=>ContactId, "InstanceId"=>InstanceId), args)); aws_config=aws_config)

"""
    StopContactRecording()

When a contact is being recorded, this API stops recording the call. StopContactRecording is a one-time action. If you use StopContactRecording to stop recording an ongoing call, you can't use StartContactRecording to restart it. For scenarios where the recording has started and you want to suspend it for sensitive information (for example, to collect a credit card number), and then restart it, use SuspendContactRecording and ResumeContactRecording. Only voice recordings are supported at this time.

# Required Parameters
- `ContactId`: The identifier of the contact.
- `InitialContactId`: The identifier of the contact. This is the identifier of the contact associated with the first interaction with the contact center.
- `InstanceId`: The identifier of the Amazon Connect instance.

"""

stop_contact_recording(ContactId, InitialContactId, InstanceId; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/contact/stop-recording", Dict{String, Any}("ContactId"=>ContactId, "InitialContactId"=>InitialContactId, "InstanceId"=>InstanceId); aws_config=aws_config)
stop_contact_recording(ContactId, InitialContactId, InstanceId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/contact/stop-recording", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ContactId"=>ContactId, "InitialContactId"=>InitialContactId, "InstanceId"=>InstanceId), args)); aws_config=aws_config)

"""
    SuspendContactRecording()

When a contact is being recorded, this API suspends recording the call. For example, you might suspend the call recording while collecting sensitive information, such as a credit card number. Then use ResumeContactRecording to restart recording.  The period of time that the recording is suspended is filled with silence in the final recording.  Only voice recordings are supported at this time.

# Required Parameters
- `ContactId`: The identifier of the contact.
- `InitialContactId`: The identifier of the contact. This is the identifier of the contact associated with the first interaction with the contact center.
- `InstanceId`: The identifier of the Amazon Connect instance.

"""

suspend_contact_recording(ContactId, InitialContactId, InstanceId; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/contact/suspend-recording", Dict{String, Any}("ContactId"=>ContactId, "InitialContactId"=>InitialContactId, "InstanceId"=>InstanceId); aws_config=aws_config)
suspend_contact_recording(ContactId, InitialContactId, InstanceId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/contact/suspend-recording", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ContactId"=>ContactId, "InitialContactId"=>InitialContactId, "InstanceId"=>InstanceId), args)); aws_config=aws_config)

"""
    TagResource()

Adds the specified tags to the specified resource. The supported resource types are users, routing profiles, and contact flows. For sample policies that use tags, see Amazon Connect Identity-Based Policy Examples in the Amazon Connect Administrator Guide.

# Required Parameters
- `resourceArn`: The Amazon Resource Name (ARN) of the resource.
- `tags`: One or more tags. For example, { \"tags\": {\"key1\":\"value1\", \"key2\":\"value2\"} }.

"""

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

"""
    UntagResource()

Removes the specified tags from the specified resource.

# Required Parameters
- `resourceArn`: The Amazon Resource Name (ARN) of the resource.
- `tagKeys`: The tag keys.

"""

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

"""
    UpdateContactAttributes()

Creates or updates the contact attributes associated with the specified contact. You can add or update attributes for both ongoing and completed contacts. For example, you can update the customer's name or the reason the customer called while the call is active, or add notes about steps that the agent took during the call that are displayed to the next agent that takes the call. You can also update attributes for a contact using data from your CRM application and save the data with the contact in Amazon Connect. You could also flag calls for additional analysis, such as legal review or identifying abusive callers. Contact attributes are available in Amazon Connect for 24 months, and are then deleted. This operation is also available in the Amazon Connect Flow language. See UpdateContactAttributes.  Important: You cannot use the operation to update attributes for contacts that occurred prior to the release of the API, September 12, 2018. You can update attributes only for contacts that started after the release of the API. If you attempt to update attributes for a contact that occurred prior to the release of the API, a 400 error is returned. This applies also to queued callbacks that were initiated prior to the release of the API but are still active in your instance.

# Required Parameters
- `Attributes`: The Amazon Connect attributes. These attributes can be accessed in contact flows just like any other contact attributes. You can have up to 32,768 UTF-8 bytes across all attributes for a contact. Attribute keys can include only alphanumeric, dash, and underscore characters.
- `InitialContactId`: The identifier of the contact. This is the identifier of the contact associated with the first interaction with the contact center.
- `InstanceId`: The identifier of the Amazon Connect instance.

"""

update_contact_attributes(Attributes, InitialContactId, InstanceId; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/contact/attributes", Dict{String, Any}("Attributes"=>Attributes, "InitialContactId"=>InitialContactId, "InstanceId"=>InstanceId); aws_config=aws_config)
update_contact_attributes(Attributes, InitialContactId, InstanceId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/contact/attributes", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("Attributes"=>Attributes, "InitialContactId"=>InitialContactId, "InstanceId"=>InstanceId), args)); aws_config=aws_config)

"""
    UpdateContactFlowContent()

Updates the specified contact flow. You can also create and update contact flows using the Amazon Connect Flow language.

# Required Parameters
- `ContactFlowId`: The identifier of the contact flow.
- `Content`: The JSON string that represents contact flow’s content. For an example, see Example contact flow in Amazon Connect Flow language in the Amazon Connect Administrator Guide.
- `InstanceId`: The identifier of the Amazon Connect instance.

"""

update_contact_flow_content(ContactFlowId, Content, InstanceId; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/contact-flows/$(InstanceId)/$(ContactFlowId)/content", Dict{String, Any}("Content"=>Content); aws_config=aws_config)
update_contact_flow_content(ContactFlowId, Content, InstanceId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/contact-flows/$(InstanceId)/$(ContactFlowId)/content", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("Content"=>Content), args)); aws_config=aws_config)

"""
    UpdateContactFlowName()

The name of the contact flow.

# Required Parameters
- `ContactFlowId`: The identifier of the contact flow.
- `InstanceId`: The identifier of the Amazon Connect instance.

# Optional Parameters
- `Description`: The description of the contact flow.
- `Name`: The name of the contact flow.
"""

update_contact_flow_name(ContactFlowId, InstanceId; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/contact-flows/$(InstanceId)/$(ContactFlowId)/name"; aws_config=aws_config)
update_contact_flow_name(ContactFlowId, InstanceId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/contact-flows/$(InstanceId)/$(ContactFlowId)/name", args; aws_config=aws_config)

"""
    UpdateRoutingProfileConcurrency()

Updates the channels that agents can handle in the Contact Control Panel (CCP) for a routing profile.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.
- `MediaConcurrencies`: The channels agents can handle in the Contact Control Panel (CCP).
- `RoutingProfileId`: The identifier of the routing profile.

"""

update_routing_profile_concurrency(InstanceId, MediaConcurrencies, RoutingProfileId; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/routing-profiles/$(InstanceId)/$(RoutingProfileId)/concurrency", Dict{String, Any}("MediaConcurrencies"=>MediaConcurrencies); aws_config=aws_config)
update_routing_profile_concurrency(InstanceId, MediaConcurrencies, RoutingProfileId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/routing-profiles/$(InstanceId)/$(RoutingProfileId)/concurrency", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("MediaConcurrencies"=>MediaConcurrencies), args)); aws_config=aws_config)

"""
    UpdateRoutingProfileDefaultOutboundQueue()

Updates the default outbound queue of a routing profile.

# Required Parameters
- `DefaultOutboundQueueId`: The identifier for the default outbound queue.
- `InstanceId`: The identifier of the Amazon Connect instance.
- `RoutingProfileId`: The identifier of the routing profile.

"""

update_routing_profile_default_outbound_queue(DefaultOutboundQueueId, InstanceId, RoutingProfileId; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/routing-profiles/$(InstanceId)/$(RoutingProfileId)/default-outbound-queue", Dict{String, Any}("DefaultOutboundQueueId"=>DefaultOutboundQueueId); aws_config=aws_config)
update_routing_profile_default_outbound_queue(DefaultOutboundQueueId, InstanceId, RoutingProfileId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/routing-profiles/$(InstanceId)/$(RoutingProfileId)/default-outbound-queue", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("DefaultOutboundQueueId"=>DefaultOutboundQueueId), args)); aws_config=aws_config)

"""
    UpdateRoutingProfileName()

Updates the name and description of a routing profile. The request accepts the following data in JSON format. At least Name or Description must be provided.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.
- `RoutingProfileId`: The identifier of the routing profile.

# Optional Parameters
- `Description`: The description of the routing profile. Must not be more than 250 characters.
- `Name`: The name of the routing profile. Must not be more than 127 characters.
"""

update_routing_profile_name(InstanceId, RoutingProfileId; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/routing-profiles/$(InstanceId)/$(RoutingProfileId)/name"; aws_config=aws_config)
update_routing_profile_name(InstanceId, RoutingProfileId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/routing-profiles/$(InstanceId)/$(RoutingProfileId)/name", args; aws_config=aws_config)

"""
    UpdateRoutingProfileQueues()

Updates the properties associated with a set of queues for a routing profile.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.
- `QueueConfigs`: The queues to be updated for this routing profile.
- `RoutingProfileId`: The identifier of the routing profile.

"""

update_routing_profile_queues(InstanceId, QueueConfigs, RoutingProfileId; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/routing-profiles/$(InstanceId)/$(RoutingProfileId)/queues", Dict{String, Any}("QueueConfigs"=>QueueConfigs); aws_config=aws_config)
update_routing_profile_queues(InstanceId, QueueConfigs, RoutingProfileId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/routing-profiles/$(InstanceId)/$(RoutingProfileId)/queues", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("QueueConfigs"=>QueueConfigs), args)); aws_config=aws_config)

"""
    UpdateUserHierarchy()

Assigns the specified hierarchy group to the specified user.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.
- `UserId`: The identifier of the user account.

# Optional Parameters
- `HierarchyGroupId`: The identifier of the hierarchy group.
"""

update_user_hierarchy(InstanceId, UserId; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/users/$(InstanceId)/$(UserId)/hierarchy"; aws_config=aws_config)
update_user_hierarchy(InstanceId, UserId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/users/$(InstanceId)/$(UserId)/hierarchy", args; aws_config=aws_config)

"""
    UpdateUserIdentityInfo()

Updates the identity information for the specified user.  Someone with the ability to invoke UpdateUserIndentityInfo can change the login credentials of other users by changing their email address. This poses a security risk to your organization. They can change the email address of a user to the attacker's email address, and then reset the password through email. We strongly recommend limiting who has the ability to invoke UpdateUserIndentityInfo. For more information, see Best Practices for Security Profiles in the Amazon Connect Administrator Guide.

# Required Parameters
- `IdentityInfo`: The identity information for the user.
- `InstanceId`: The identifier of the Amazon Connect instance.
- `UserId`: The identifier of the user account.

"""

update_user_identity_info(IdentityInfo, InstanceId, UserId; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/users/$(InstanceId)/$(UserId)/identity-info", Dict{String, Any}("IdentityInfo"=>IdentityInfo); aws_config=aws_config)
update_user_identity_info(IdentityInfo, InstanceId, UserId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/users/$(InstanceId)/$(UserId)/identity-info", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("IdentityInfo"=>IdentityInfo), args)); aws_config=aws_config)

"""
    UpdateUserPhoneConfig()

Updates the phone configuration settings for the specified user.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.
- `PhoneConfig`: Information about phone configuration settings for the user.
- `UserId`: The identifier of the user account.

"""

update_user_phone_config(InstanceId, PhoneConfig, UserId; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/users/$(InstanceId)/$(UserId)/phone-config", Dict{String, Any}("PhoneConfig"=>PhoneConfig); aws_config=aws_config)
update_user_phone_config(InstanceId, PhoneConfig, UserId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/users/$(InstanceId)/$(UserId)/phone-config", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("PhoneConfig"=>PhoneConfig), args)); aws_config=aws_config)

"""
    UpdateUserRoutingProfile()

Assigns the specified routing profile to the specified user.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.
- `RoutingProfileId`: The identifier of the routing profile for the user.
- `UserId`: The identifier of the user account.

"""

update_user_routing_profile(InstanceId, RoutingProfileId, UserId; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/users/$(InstanceId)/$(UserId)/routing-profile", Dict{String, Any}("RoutingProfileId"=>RoutingProfileId); aws_config=aws_config)
update_user_routing_profile(InstanceId, RoutingProfileId, UserId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/users/$(InstanceId)/$(UserId)/routing-profile", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("RoutingProfileId"=>RoutingProfileId), args)); aws_config=aws_config)

"""
    UpdateUserSecurityProfiles()

Assigns the specified security profiles to the specified user.

# Required Parameters
- `InstanceId`: The identifier of the Amazon Connect instance.
- `SecurityProfileIds`: The identifiers of the security profiles for the user.
- `UserId`: The identifier of the user account.

"""

update_user_security_profiles(InstanceId, SecurityProfileIds, UserId; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/users/$(InstanceId)/$(UserId)/security-profiles", Dict{String, Any}("SecurityProfileIds"=>SecurityProfileIds); aws_config=aws_config)
update_user_security_profiles(InstanceId, SecurityProfileIds, UserId, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = connect("POST", "/users/$(InstanceId)/$(UserId)/security-profiles", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("SecurityProfileIds"=>SecurityProfileIds), args)); aws_config=aws_config)


text:
"""
  Software License Agreement (BSD License)

  Point Cloud Library (PCL) - www.pointclouds.org
  Copyright (c) 2010, Willow Garage, Inc.
  Copyright (c) 2012-, Open Perception, Inc.

  All rights reserved.

  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions
  are met:

  * Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.
  * Redistributions in binary form must reproduce the above
    copyright notice, this list of conditions and the following
    disclaimer in the documentation and/or other materials provided
    with the distribution.
  * Neither the name of the copyright holder(s) nor the names of its
    contributors may be used to endorse or promote products derived
    from this software without specific prior written permission.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  POSSIBILITY OF SUCH DAMAGE.
"""

@info "Caesar.jl is loading (but not exporting) tools requiring Colors.jl; e.g. Caesar._PCL"

module _PCL

using DocStringExtensions
using StaticArrays
using ..Colors

## hold off on exports, users can in the mean-time use/import via e.g. _PCL.PointXYZ
# export PointT, PointXYZ, PointXYZRGB, PointXYZRGBA
# export PCLHeader, PointCloud

abstract type PointT end

"""
    $TYPEDEF

See https://pointclouds.org/documentation/point__types_8hpp_source.html
"""
Base.@kwdef struct PointXYZ{C <: Colorant, T <: Number} <: PointT
  color::C           = RGBA(1,1,1,1)
  data::SVector{4,T} = SVector(0,0,0,Float32(1))
end

# Construct helpers nearest to PCL
PointXYZRGBA( x::Real=0, y::Real=0, z::Real=Float32(1);
              r::Real=1,g::Real=1,b::Real=1, alpha::Real=1,
              color::Colorant=RGBA(r,g,b,alpha),
              pos=SA[x,y,z], data=SA[pos...,1] ) = PointXYZ(;color,data)
#
PointXYZRGB(  x::Real=0, y::Real=0, z::Real=Float32(1);
              r::Real=1,g::Real=1,b::Real=1,
              color::Colorant=RGB(r,g,b),
              pos=SA[x,y,z], data=SA[pos...,1] ) = PointXYZ(;color,data)
#

function Base.getproperty(p::PointXYZ, f::Symbol)
  if f == :x
    return getfield(p, :data)[1]
  elseif f == :y
    return getfield(p, :data)[2]
  elseif f == :z
    return getfield(p, :data)[3]
  elseif f == :r
    return getfield(p, :color).r
  elseif f == :g
    return getfield(p, :color).g
  elseif f == :b
    return getfield(p, :color).b
  elseif f == :alpha
    return getfield(p, :color).alpha
  elseif f == :data || f == :pos
    return getfield(p, :data)
  elseif f == :color || f == :rgb
    return getfield(p, :color)
  end
  error("PointXYZ has no field $f")
end

"""
    $TYPEDEF

See https://pointclouds.org/documentation/structpcl_1_1_p_c_l_header.html
"""
Base.@kwdef struct PCLHeader
  seq::UInt32      = UInt32(0)
  stamp::UInt64    = UInt64(0)
  frame_id::String = ""
end

Base.@kwdef struct PointCloud
  header::PCLHeader        = PCLHeader()
  """ vector of points representing the point cloud """
  points::Vector{<:PointT} = Vector{PointXYZ{RGBA{Colors.FixedPointNumbers.N0f8}, Float32}}()
end

end

ext: jl


text:
module PedigreeBase

using SparseArrays
using OffsetArrays
using SparseMatrixDicts

export read_ped, check_ped, set_upg
export find_ped_order, permute_ped!, extract_ped, get_upg_range, subset_ped, mgs_ped
export get_inb, get_inbupg_code
export get_nrm, get_nrminv, get_mgsnrminv, get_qm, get_pm

include("io.jl")
include("permutation.jl")
include("inbreeding.jl")
include("relationship.jl")

end


text:
"""
    fixed(val)

Represents a parameter whose value is required to stay constant. The `value` of a `Fixed` is
simply `val`. Constantness of the parameter is enforced by returning an empty
vector from `flatten`.
"""
fixed(val) = Fixed(val)

struct Fixed{T} <: AbstractParameter
    value::T
end

value(x::Fixed) = value(x.value)

function flatten(::Type{T}, x::Fixed) where {T<:Real}
    unflatten_Fixed(v_new::Vector{T}) = x
    return T[], unflatten_Fixed
end

"""
    deferred(f, args...)

The `value` of a `deferred` is `f(value(args)...)`. This makes it possible to make the value
of the `args` e.g. `AbstractParameter`s and, therefore, enforce constraints on them even if
`f` knows nothing about `AbstractParameters`.

It can be helpful to use `deferred` recursively when constructing complicated objects.
"""
deferred(f, args...) = Deferred(f, args)

struct Deferred{Tf,Targs} <: AbstractParameter
    f::Tf
    args::Targs
end

Base.:(==)(a::Deferred, b::Deferred) = (a.f == b.f) && (a.args == b.args)

value(x::Deferred) = x.f(value(x.args)...)

function flatten(::Type{T}, x::Deferred) where {T<:Real}
    v, unflatten = flatten(T, x.args)
    unflatten_Deferred(v_new::Vector{T}) = Deferred(x.f, unflatten(v_new))
    return v, unflatten_Deferred
end


text:
##################
# Landmarks code #
##################

struct Landmark
    what::Vector{Int}
    value::Float64
end

# priority queue implementation to avoid DataStructures.jl dependency

function landmark_put!(pq::Vector{Landmark}, what::Vector{Int}, value::Float64)
    p = Landmark(what, value)
    push!(pq, p)
    i = length(pq)
    @inbounds while (j = div(i, 2)) >= 1
        if value < pq[j].value
            pq[i] = pq[j]
            i = j
        else
            break
        end
    end
    pq[i] = p
end

function landmark_pop!(pq::Vector{Landmark})
    x = pq[1]
    y = pop!(pq)
    if !isempty(pq)
        i = 1
        len = length(pq)
        @inbounds while (l = 2i) <= len
            r = 2i + 1
            j = r > len || pq[l].value < pq[r].value ? l : r
            if pq[j].value < y.value
                pq[i] = pq[j]
                i = j
            else
                break
            end
        end
        pq[i] = y
    end
    return x.what, x.value
end

# On-line SSE calculation, to OnlineStats.jl dependency

struct WSSE
    ss::Float64 # weighted sum of squared values
    s::Float64  # weighted sum of values
    ws::Float64 # sum of weights
end

WSSE(x::AbstractVector{<:Real}, w::AbstractVector{<:Real}) =
    if isempty(x)
        WSSE(0.0, 0.0, 0.0)
    else
        WSSE(sum(v->v[2]*v[1]^2, zip(x, w)), dot(w, x), sum(w))
    end
WSSE(x::Real, w::Real) = WSSE(w*x^2, w*x, w)

# this is numerically unstable but we are OK even if we have some inaccuracy
wsse(x::WSSE) = x.ss - x.s^2 / x.ws
Base.:+(x1::WSSE, x2::WSSE) = WSSE(x1.ss + x2.ss, x1.s + x2.s, x1.ws + x2.ws)
Base.:-(x1::WSSE, x2::WSSE) = WSSE(x1.ss - x2.ss, x1.s - x2.s, x1.ws - x2.ws)

# weighted mean to avoid StatsBase.jl dependency

function matrix_w_mean(m, w)
    sw = sum(w)
    res = zeros(1, size(m, 2))
    for i in axes(m, 2)
        for j in axes(m, 1)
            @inbounds res[1, i] += m[j, i] * w[j]
        end
        res[1, i] /= sw
    end
    return res
end

"""
    split_cluster_rss2(m, w)

Splits cluster `m` with weights `w` into two clusters along its first principal
component so as to minimize maximum RSS of one of the resulting clusters.

This is a second slower version of the algorithm using sorting.
Retained for testing purposes.
"""
function split_cluster_rss2(m, w)
    @assert size(m, 1) > 1
    if size(m, 1) == 2
        return [1], [2]
    end
    y = (m .- matrix_w_mean(m, w)) .* sqrt.(w)
    yᵀwy = transpose(y) * y
    z = y * (@view eigvecs(yᵀwy)[:, end])
    p = sortperm(z)
    low = 1
    high = length(p)
    rss_low = [WSSE(m[p[1], i], w[p[1]]) for i in axes(m, 2)]
    rss_high = [WSSE(m[p[end], i], w[p[end]]) for i in axes(m, 2)]
    while low + 1 < high
        if sum(wsse, rss_low) < sum(wsse, rss_high)
            low += 1
            for (i, v) in enumerate(rss_low)
                rss_low[i] = v + WSSE(m[p[low], i], w[p[low]])
            end
        else
            high -= 1
            for (i, v) in enumerate(rss_high)
                rss_high[i] = v + WSSE(m[p[high], i], w[p[high]])
            end
        end
    end
    moved_low = false
    while low > 1
        rss_low_tmp = [rss_low[i] - WSSE(m[p[low], i], w[p[low]]) for i in axes(rss_low, 1)]
        rss_high_tmp = [rss_high[i] + WSSE(m[p[low], i], w[p[low]]) for i in axes(rss_high, 1)]
        if max(sum(wsse, rss_low_tmp), sum(wsse, rss_high_tmp)) < max(sum(wsse, rss_low), sum(wsse, rss_high))
            moved_low = true
            low -= 1
            high -= 1
            rss_low = rss_low_tmp
            rss_high = rss_high_tmp
        else
            break
        end
    end
    if !moved_low
        while high < length(p)
            rss_low_tmp = [rss_low[i] + WSSE(m[p[high], i], w[p[high]]) for i in axes(rss_low, 1)]
            rss_high_tmp = [rss_high[i] - WSSE(m[p[high], i], w[p[high]]) for i in axes(rss_high, 1)]
            if max(sum(wsse, rss_low_tmp), sum(wsse, rss_high_tmp)) < max(sum(wsse, rss_low), sum(wsse, rss_high))
                low += 1
                high += 1
                rss_low = rss_low_tmp
                rss_high = rss_high_tmp
            else
                break
            end
        end
    end
    return view(p, 1:low), view(p, high:length(p))
end

"""
    split_cluster_rss(m, w)

Splits cluster `m` with weights `w` into two clusters along its first principal
component so as to minimize maximum RSS of one of the resulting clusters.
"""
function split_cluster_rss(m, w)
    @assert size(m, 1) > 1
    if size(m, 1) == 2
        return [1], [2]
    end
    y = (m .- matrix_w_mean(m, w)) .* sqrt.(w)
    yᵀwy = transpose(y) * y
    z = y * (@view eigvecs(yᵀwy)[:, end])
    l1 = Int[argmin(z)]
    l2 = Int[argmax(z)]
    if l1 == l2
        throw(ErrorException("Trying to split homogenous cluster"))
    end
    gray = setdiff(axes(z, 1), l1, l2)
    rss_low = [WSSE(m[l1[1],i]^2*w[l1[1]], m[l1[1],i]*w[l1[1]], w[l1[1]]) for i in axes(m, 2)]
    rss_high = [WSSE(m[l2[1],i]^2*w[l2[1]], m[l2[1],i]*w[l2[1]], w[l2[1]]) for i in axes(m, 2)]
    med = median(z)
    t1 = Int[]
    t2 = Int[]
    while true
        empty!(t1)
        empty!(t2)
        for i in gray
            if z[i] < med
                push!(t1, i)
            else
                push!(t2, i)
            end
        end
        rss_low_tmp = [wssei + WSSE(view(m, t1, i), view(w, t1)) for (i, wssei) in enumerate(rss_low)]
        rss_high_tmp = [wssei + WSSE(view(m, t2, i), view(w, t2)) for (i, wssei) in enumerate(rss_high)]
        if sum(wsse, rss_low_tmp) < sum(wsse, rss_high_tmp)
            length(t1) == 0 && break
            rss_low = rss_low_tmp
            append!(l1, t1)
            gray = copy(t2)
        else
            length(t2) == 0 && break
            rss_high = rss_high_tmp
            append!(l2, t2)
            gray = copy(t1)
        end
        isempty(gray) && break
        med = median(view(z, gray))
    end
    if length(gray) > 0
        rss_low_tmp = [wssei + WSSE(view(m, gray, i), view(w, gray)) for (i, wssei) in enumerate(rss_low)]
        rss_high_tmp = [wssei + WSSE(view(m, gray, i), view(w, gray)) for (i, wssei) in enumerate(rss_high)]
        if max(sum(wsse, rss_low_tmp), sum(wsse, rss_high)) < max(sum(wsse, rss_low), sum(wsse, rss_high_tmp))
            append!(l1, gray)
        else
            append!(l2, gray)
        end
    end
    return l1, l2
end

"""
    split_cluster_size(m, w)

Splits cluster `m` with weights `w` into two clusters along its first principal
component so as to make the clusters have equal size (number of edges).
"""
function split_cluster_size(m, w)
    @assert size(m, 1) > 1
    if size(m, 1) == 2
        return [1], [2]
    end
    y = (m .- matrix_w_mean(m, w)) .* sqrt.(w)
    yᵀwy = transpose(y) * y
    z = y * (@view eigvecs(yᵀwy)[:, end])
    med = median(z)

    low = Int[]
    high = Int[]
    for (i, c) in enumerate(z)
        if c == med
            push!(length(low) < length(high) ? low : high, i)
        else
            push!(c < med ? low : high, i)
        end
    end
    return low, high
end

"""
    split_cluster_diameter(m, w)

Splits cluster `m` with weights `w` into two clusters along its first principal
component so as to make both clusters have approximately the same diameter along
the first principal component.
"""
function split_cluster_diameter(m, w)
    @assert size(m, 2) > 1
    if size(m, 1) == 2
        return [1], [2]
    end
    y = (m .- matrix_w_mean(m, w)) .* sqrt.(w)
    yᵀwy = transpose(y) * y
    z = y * (@view eigvecs(yᵀwy)[:, end])
    avg = mean(extrema(z))

    low = Int[]
    high = Int[]
    for (i, c) in enumerate(z)
        if c == avg
            push!(length(low) < length(high) ? low : high, i)
        else
            push!(c < avg ? low : high, i)
        end
    end
    return low, high
end

total_rss(m::AbstractMatrix, w) = sum(x -> wsse(WSSE(x, w)), eachcol(m))

"""
    runsplit(embedding, w, initial_clusters, n, s, rule)

Take `embedding` with weights `w` where each column is a single observation and
`initial_clusters` is a vector of vectors indicating an initial 1-based cluster
assignment of vertices. Return a vector of 0-based assignments of vertices to `n` groups.
Each cluster is guaranteed to be split to at most `s` landmarks (may be less if its size is less than `s`).
"""
function runsplit(embedding, w, initial_clusters, n, s, rule)
    landmarks = Vector{Landmark}()
    for cluster in sort(initial_clusters)
        if length(cluster) <= s
            for j in cluster
                landmark_put!(landmarks, [j], eps())
            end
        else
            locallandmarks = Vector{Landmark}()
            landmark_put!(locallandmarks, cluster, -total_rss(view(embedding, cluster, :), view(w, cluster)))
            while length(locallandmarks) < s
                idxs, sse = landmark_pop!(locallandmarks)
                low, high = rule(view(embedding, idxs, :), view(w, idxs))
                idxs_low = idxs[low]
                if length(idxs_low) > 1
                    landmark_put!(locallandmarks, idxs_low, -total_rss(view(embedding, idxs_low, :), view(w, idxs_low)))
                elseif length(idxs_low) == 1
                    landmark_put!(locallandmarks, idxs_low, eps()) # make sure 1-length cluster is in tail of the queue
                else
                    throw(ErrorException("Unexpected empty cluster generated"))
                end
                idxs_high = idxs[high]
                if length(idxs_high) > 1
                    landmark_put!(locallandmarks, idxs_high, -total_rss(view(embedding, idxs_high, :), view(w, idxs_high)))
                elseif length(idxs_high) == 1
                    landmark_put!(locallandmarks, idxs_high, eps()) # make sure 1-length cluster is in tail of the queue
                else
                    throw(ErrorException("Unexpected empty cluster generated"))
                end
            end
            while !isempty(locallandmarks)
                idxs, sse = landmark_pop!(locallandmarks)
                landmark_put!(landmarks, idxs, sse)
            end
        end
    end

    while length(landmarks) < n
        idxs, sse = landmark_pop!(landmarks)
        low, high = rule(view(embedding, idxs, :), view(w, idxs))
        idxs_low = idxs[low]
        if length(idxs_low) > 1
            landmark_put!(landmarks, idxs_low, -total_rss(view(embedding, idxs_low, :), view(w, idxs_low)))
        elseif length(idxs_low) == 1
            landmark_put!(landmarks, idxs_low, eps()) # make sure 1-length cluster is in tail of the queue
        else
            throw(ErrorException("Unexpected empty cluster generated"))
        end
        idxs_high = idxs[high]
        if length(idxs_high) > 1
            landmark_put!(landmarks, idxs_high, -total_rss(view(embedding, idxs_high, :), view(w, idxs_high)))
        elseif length(idxs_high) == 1
            landmark_put!(landmarks, idxs_high, eps()) # make sure 1-length cluster is in tail of the queue
        else
            throw(ErrorException("Unexpected empty cluster generated"))
        end
    end

    group_ids = fill(-1, size(embedding, 1))
    i = 0
    for vs in landmarks
        group_ids[vs.what] .= i
        i += 1
    end
    @assert all(>=(0), group_ids)
    return group_ids
end

"""
    landmarks(edges::Array{Int,2},vweights::Vector{Float64}, clusters::Vector{Vector{Int}},
        embedding::Array{Float64,2}, verbose::Bool, land::Int, forced::Int, method::Function)

**Arguments**
* `edges::Array{Int,2}` array with edges definition (two whitespace separated vertices ids)
* `weights::Vector{Float64}` edges weights
* `vweights::Vector{Float64}` vertices weights
* `clusters::Vector{Vector{Int}}` vector of vectors indicating an initial 1-based cluster
assignment of vertices.
* `embedding::Array{Float64,2}` array with vertices embeddings
* `comm::Array{Int,2}` assignment of vertices to communities
* `verbose::Bool` verbose switch, if true prints additional processing information
* `land::Int` number of landmarks to generate
* `forced::Int` required maximum number of forced splits of a cluster
* `method::Function` method used to generate landmarks
* `directed::Bool` flag for directed version of landmark-based graph creation
"""
function landmarks(edges::Array{Int,2}, weights::Vector{Float64}, vweights::Vector{Float64},
                    clusters::Vector{Vector{Int}}, comm::Array{Int,2},embedding::Array{Float64,2},
                    verbose::Bool, land::Int, forced::Int, method::Function, directed::Bool)

    verbose && println("Starts landmark generation")
    rows_embed, dim = size(embedding)
    unique_rows = size(unique(embedding, dims=1), 1) #performance 0.5 sec for 100k vertices

    if land > unique_rows
        @warn "Requested number of clusters larger than unique no. embeddings. Truncating to $unique_rows landmarks."
        land = unique_rows
    end

    landmarks = runsplit(embedding, vweights, clusters, land, forced, method)
    landmarks .+=1

    verbose && println("Landmarks generated")

    # Count no. landmarks
    N = Int(maximum(landmarks))
    verbose && println("Using $N landmarks")

    embed = zeros(N,dim)
    lweight = zeros(N)

    # read from 0-based embedding file
    for i in 1:rows_embed
        what = landmarks[i]
        lweight[what] += vweights[i]
        for j in 1:dim
            embed[what,j] += vweights[i]*embedding[i,j]
        end
    end

    # normalize landmark based embedding
    for i in 1:N
        for j in 1:dim
            embed[i,j] /= lweight[i]
        end
    end

    # compute landmark internal distances d_ii
    dii = zeros(N)
    for i in 1:rows_embed
        what = landmarks[i]
        dist = 0
        for j in 1:dim
            dist += (embed[what,j]-embedding[i,j])^2
        end
        dii[what] += dist
    end

    # normalize
    for i in 1:N
        if lweight[i]>0
            dii[i] /= lweight[i]
            dii[i] = sqrt(dii[i])
        end
    end

    # re-write clusters for the landmarks
    cluster = zeros(Int,N)
    for i in 1:rows_embed
        cluster[landmarks[i]]=comm[i]
    end
    cluster = reshape(cluster,:,1)

    # Output weighted landmark_edgelist
    wedges = zeros(Float64,N,N)
    if directed
        for i in 1:size(edges,1)
            a,b = [landmarks[edges[i,1]],landmarks[edges[i,2]]]
            wedges[a,b] += weights[i]
        end

        # re-write
        landmark_edges = Array{Float64}(undef, Int(N*N), 3)
        for i in 1:N
            for j in 1:N
                landmark_edges[N*(i-1)+j,:] = [i j wedges[i,j]]
            end
        end
    else
        for i in 1:size(edges,1)
            a,b = extrema([landmarks[edges[i,1]],landmarks[edges[i,2]]])
            wedges[a,b] += weights[i]
        end

        # re-write
        landmark_edges = Array{Float64}(undef, Int(N*(N+1)/2), 3)
        for i in 1:N
            for j in i:N
                landmark_edges[idx(N,i,j),:] = [i j wedges[i,j]]
            end
        end
    end
    landmark_edges = landmark_edges[landmark_edges[:,3] .>0,:]
    weights = landmark_edges[:,3]
    landmark_edges = Int.(landmark_edges[:,1:2])

    return dii, embed, cluster, landmark_edges, weights, lweight, landmarks
end


text:
using PyPlot
using JLD
function plot_errorbar()
	X = load("../data/sens/lorenz/dJds_vs_params.jld")
	rho_arr = X["s"]
	dJds_arr = X["dJds"]
	err_arr = sqrt.(X["var_dJds"])/4
	@show err_arr
	sel = err_arr .<= 0.2
	rho_arr = rho_arr[sel]
	err_arr = err_arr[sel]
	dJds_arr = dJds_arr[sel]

	fig, ax = subplots(1,1)
	ax.plot(rho_arr, dJds_arr, "X", ms=10.0)
	ax.errorbar(rho_arr, dJds_arr, yerr=err_arr, linewidth=3.0, color="blue",fmt="none")
    ax.xaxis.set_tick_params(labelsize=28)
    ax.yaxis.set_tick_params(labelsize=28)
    ax.set_xlabel(L"$s$",fontsize=28)
	ax.set_ylabel(L"$d_{s}\langle J\rangle$",fontsize=28)
	ax.grid(true)

end
function plot_lines()
	X = load("../data/sens/lorenz/dvarz_ds2_800.jld")
	rho = X["rho"]
	dJds = X["dJds"]
	err = sqrt.(X["var_dJds"])/4

	@show err
	X = load("../data/obj_erg_avg/lorenz/zm28sq.jld")
    s2 = X["s2"]
    J = X["J"]
    fig, ax = subplots(1,1)
    ax.plot(s2, J, ".", ms=25.0)
    ax.xaxis.set_tick_params(labelsize=28)
    ax.yaxis.set_tick_params(labelsize=28)
    ax.set_xlabel(L"$s$",fontsize=28)
    ax.set_ylabel(L"$\langle J\rangle$",fontsize=28)
    ax.grid(true)

    eps = 2e-1

	X = load("../data/obj_erg_avg/lorenz/zm28sq_dJds.jld")
	J = X["J"]
	s2 = X["s2"]

	sel = rho .<= 30.5

	dJds = dJds[sel]
	err = err[sel]

	J = J[sel]
	s2 = s2[sel]
	rho = rho[sel]
	s2 = s2[err .<= 1.8]
	J = J[err .<= 1.8]
    dJds = dJds[err .<= 1.8]
	n = size(dJds)[1]
	J_pts = reshape([J .- eps*dJds J .+ eps*dJds], n,
                    2)'
    s_pts = reshape([s2 .- eps s2 .+ eps], n,
                    2)'

    ax.plot(s_pts[:,1:n-1], J_pts[:,1:n-1], "k",lw=3.0)
    ax.plot(s_pts[:,n], J_pts[:,n], "k",lw=4.0,label=L"$d_s\langle J\rangle$ from S3")

    ax.legend(fontsize=28)

	X = load("../data/sens/lorenz/dvarz_ds2_1500.jld")
	rho = X["rho"]
	dJds = X["dJds"]
	err = sqrt.(X["var_dJds"])/4
	@show err
	X = load("../data/obj_erg_avg/lorenz/zm28sq_dJds.jld")
	J = X["J"]
	s2 = X["s2"]

	sel = .!(30 .>= rho .>= 29)
	dJds = dJds[sel]
	err = err[sel]
	s2 = s2[sel]
	J = J[sel]

	s2 = s2[err .<= 1.8]
	J = J[err .<= 1.8]
    dJds = dJds[err .<= 1.8]
	n = size(dJds)[1]
	J_pts = reshape([J .- eps*dJds J .+ eps*dJds], n,
                    2)'
    s_pts = reshape([s2 .- eps s2 .+ eps], n,
                    2)'

    ax.plot(s_pts[:,1:n-1], J_pts[:,1:n-1], "k",lw=3.0)
    ax.plot(s_pts[:,n], J_pts[:,n], "k",lw=4.0,label=L"$d_s\langle J\rangle$ from S3")

end

max_stars_repo_name: nishaChandramoorthy/linearResponse

max_issues_repo_name: nishaChandramoorthy/linearResponse

max_forks_repo_name: nishaChandramoorthy/linearResponse


text:
import Base.length
import Base.isempty
import Base.getindex
import Base.setindex!
import Base.firstindex
import Base.lastindex
import Base.sum

# Use a binary tree to describe a categorical distribution
# This allows for O(1) read, O(log n) write and O(log n) generation of a random index
# Optimized for categorical distributions with a large number of possible outcomes

# Should this be a subtype of AbstractVector?
struct CategoricalTree{T<:Real}
    ns::Vector{<:Integer} # number of nodes at each layer of the tree (`ns[end]` should be 1, i.e. the root of the tree
    as::Vector{Vector{T}} # store each layer into a separate array. Each parent node contains the sum of its children
end

function CategoricalTree(a::Vector{T}) where T<:Real
    n = length(a)
    ns::Vector{Int64} = [n]
    while n > 1
        if isodd(n)
            n = Int((n+1)/2)
            push!(ns,n)
        else
            n = Int(n/2)
            push!(ns,n)
        end
    end
    as = [zeros(T,k) for k in ns]
    as[1] = a
    for i in 1:(length(ns)-1)
        for j in 2:2:ns[i]
            as[i+1][Int(j/2)] = as[i][j-1] + as[i][j]
        end
        if isodd(ns[i])
            as[i+1][ns[i+1]] = as[i][ns[i]]
        end
    end
    return CategoricalTree{T}(ns,as)
end

isempty(ct::CategoricalTree{<:Real}) = isempty(ct.as[1])
length(ct::CategoricalTree{<:Real}) = length(ct.as[1])

firstindex(::CategoricalTree) = 1
lastindex(ct::CategoricalTree) = length(ct)

getindex(ct::CategoricalTree{<:Real}, i) = ct.as[1][i]

function setindex!(ct::CategoricalTree{<:Real}, x, i)
    ct.as[1][i] = x
    j = i
    for k in 2:length(ct.ns)
        j = isodd(j) ? Int((j+1)/2) : Int(j/2)
        if isodd(ct.ns[k-1]) && j == ct.ns[k]
                ct.as[k][j] = ct.as[k-1][2*j-1]
        else
            ct.as[k][j] = ct.as[k-1][2*j-1] + ct.as[k-1][2*j]
        end
    end
end

# since we already computed the sum, we might as well make use of it
sum(ct::CategoricalTree{<:Real}) = ct.as[end][1]

"""
    rand_categorical(ct::CategoricalTree{<:Real}, a0)

Pick one index according to a categorical distribution described by `ct`.
"""
function rand_categorical(ct::CategoricalTree{<:Real}, a0 = sum(ct))
    r = rand()*sum(ct)
    i = length(ct.ns) - 1
    j = 1
    while i > 1
        if r <= ct.as[i][j]
            j = 2*j - 1
        else
            r -= ct.as[i][j]
            j = 2*j + 1
        end
        i -= 1
    end
    if r <= ct.as[i][j]
        return j
    else
        return j+1
    end
end

max_stars_repo_name: csimal/metaplex-networks

max_issues_repo_name: csimal/metaplex-networks

max_forks_repo_name: csimal/metaplex-networks


text: abstract type AbstractObject  <: AbstractThing end;

max_stars_repo_name: daviddoret/julia-cybersecurity

max_issues_repo_name: daviddoret/julia-cybersecurity

max_forks_repo_name: daviddoret/julia-cybersecurity


text:
using GeometricIntegrators

set_config(:tab_compensated_summation, false)

const out_dir = "../../docs/src/integrators/runge_kutta/guiding_center_4d/"
const run_id  = "fast_barely_trapped_firk"

include("guiding_center_4d_fast_barely_trapped.jl")
include("../guiding_center_4d_firk.jl")


text:
using LinearAlgebra

struct ValueOne; end
ValueOne()

# Compute X <- a X + b I.
function matfun_axpby!(X,a,b,Y::UniformScaling)
    m,n=size(X)
    if ~(a isa ValueOne)
        rmul!(X,a)
    end
    @inbounds for i=1:n
        X[i,i]+=(b isa ValueOne) ? 1 : b
    end
end

@inline function exp_mono_m5_opt_rho1_68(A)
    T=promote_type(eltype(A),Float64)
    A_copy=similar(A,T); A_copy .= A;
    return exp_mono_m5_opt_rho1_68!(A_copy)
end

@inline function exp_mono_m5_opt_rho1_68!(A)
    T=promote_type(eltype(A),Float64) # Make it work for many 'bigger' types (matrices and scalars)
    # max_memslots=8
    n=size(A,1)
    # The first slots are precomputed nodes [:A]
    memslots2 = similar(A,T)
    memslots3 = similar(A,T)
    memslots4 = similar(A,T)
    memslots5 = similar(A,T)
    memslots6 = similar(A,T)
    memslots7 = similar(A,T)
    memslots8 = similar(A,T)
    # Assign precomputed nodes memslots
    memslots1=A # overwrite A
    # Uniform scaling is exploited.
    # No matrix I explicitly allocated.
    # Computation order: Bb2 Ba2 B2 Ba3 Bb3 B3 Ba4 Bb4 B4 Ba5 Bb5 B5 Ba6 Bb6 B6 T2k8
    # Computing Bb2 = x*I+x*A
    coeff1=0.0010904030413732757
    coeff2=1.0008760081747117
    memslots2 .= coeff2.*memslots1
    mul!(memslots2,true,I*coeff1,true,true)
    # Computing Ba2 = x*I+x*A
    coeff1=0.0010904030413732757
    coeff2=1.0008760081747117
    memslots3 .= coeff2.*memslots1
    mul!(memslots3,true,I*coeff1,true,true)
    # Computing B2 with operation: mult
    mul!(memslots4,memslots3,memslots2)
    # Deallocating Ba2 in slot 3
    # Deallocating Bb2 in slot 2
    # Computing Ba3 = x*I+x*A+x*B2
    coeff1=-4.6346414362462995e-5
    coeff2=0.0015183205977868746
    coeff3=0.9996379335010811
    memslots2 .= coeff2.*memslots1 .+ coeff3.*memslots4
    mul!(memslots2,true,I*coeff1,true,true)
    # Computing Bb3 = x*I+x*A+x*B2
    coeff1=0.001530127478825033
    coeff2=0.9994108881899734
    coeff3=0.030492786462992225
    memslots3 .= coeff2.*memslots1 .+ coeff3.*memslots4
    mul!(memslots3,true,I*coeff1,true,true)
    # Computing B3 with operation: mult
    mul!(memslots5,memslots2,memslots3)
    # Deallocating Ba3 in slot 2
    # Deallocating Bb3 in slot 3
    # Computing Ba4 = x*I+x*A+x*B2+x*B3
    coeff1=-5.439593588786742e-5
    coeff2=8.642508638357873e-5
    coeff3=0.0011897338053029579
    coeff4=0.9997653650686295
    memslots2 .= coeff2.*memslots1 .+ coeff3.*memslots4 .+ coeff4.*memslots5
    mul!(memslots2,true,I*coeff1,true,true)
    # Computing Bb4 = x*I+x*A+x*B2+x*B3
    coeff1=0.0010337804923906489
    coeff2=0.9970317188215052
    coeff3=0.08229676673753394
    coeff4=0.0031469743629754005
    memslots3 .= coeff2.*memslots1 .+ coeff3.*memslots4 .+ coeff4.*memslots5
    mul!(memslots3,true,I*coeff1,true,true)
    # Computing B4 with operation: mult
    mul!(memslots6,memslots2,memslots3)
    # Deallocating Ba4 in slot 2
    # Deallocating Bb4 in slot 3
    # Computing Ba5 = x*I+x*A+x*B2+x*B3+x*B4
    coeff1=-8.30025660582309e-6
    coeff2=-1.614854194638885e-5
    coeff3=-1.2536139794669188e-5
    coeff4=0.0010411131935665154
    coeff5=0.9999723778369385
    memslots2 .= coeff2.*memslots1 .+ coeff3.*memslots4 .+ coeff4.*memslots5 .+ coeff5.*memslots6
    mul!(memslots2,true,I*coeff1,true,true)
    # Computing Bb5 = x*I+x*A+x*B2+x*B3+x*B4
    coeff1=0.0007031814361206821
    coeff2=1.0010882362282207
    coeff3=0.05182299699949662
    coeff4=0.007748443487686225
    coeff5=0.0002736987094186782
    memslots3 .= coeff2.*memslots1 .+ coeff3.*memslots4 .+ coeff4.*memslots5 .+ coeff5.*memslots6
    mul!(memslots3,true,I*coeff1,true,true)
    # Computing B5 with operation: mult
    mul!(memslots7,memslots2,memslots3)
    # Deallocating Ba5 in slot 2
    # Deallocating Bb5 in slot 3
    # Computing Ba6 = x*I+x*A+x*B2+x*B3+x*B4+x*B5
    coeff1=-1.2408057646229667e-6
    coeff2=-3.1395014660350098e-6
    coeff3=-1.8699534803824349e-6
    coeff4=2.3223775362920453e-6
    coeff5=0.0007434150049329373
    coeff6=0.999999459268548
    memslots2 .= coeff2.*memslots1 .+ coeff3.*memslots4 .+ coeff4.*memslots5 .+ coeff5.*memslots6 .+ coeff6.*memslots7
    mul!(memslots2,true,I*coeff1,true,true)
    # Computing Bb6 = x*I+x*A+x*B2+x*B3+x*B4+x*B5
    coeff1=-2.7188726824232142e-6
    coeff2=0.9998021510172249
    coeff3=0.06065097803531471
    coeff4=0.005091212395247093
    coeff5=0.00034385565143820764
    coeff6=2.2549509122548797e-6
    memslots3 .= coeff2.*memslots1 .+ coeff3.*memslots4 .+ coeff4.*memslots5 .+ coeff5.*memslots6 .+ coeff6.*memslots7
    mul!(memslots3,true,I*coeff1,true,true)
    # Computing B6 with operation: mult
    mul!(memslots8,memslots2,memslots3)
    # Deallocating Ba6 in slot 2
    # Deallocating Bb6 in slot 3
    # Computing T2k8 = x*I+x*A+x*B2+x*B3+x*B4+x*B5+x*B6
    coeff1=0.9999994211561953
    coeff2=0.9989210320213427
    coeff3=0.49825582022614506
    coeff4=0.16623132434744778
    coeff5=0.036597641936229344
    coeff6=0.004190644602100282
    coeff7=0.0004888481055895867
    # Smart lincomb recycle A
    memslots1 .= coeff2.*memslots1 .+ coeff3.*memslots4 .+ coeff4.*memslots5 .+ coeff5.*memslots6 .+ coeff6.*memslots7 .+ coeff7.*memslots8
    mul!(memslots1,true,I*coeff1,true,true)
    # Deallocating B2 in slot 4
    # Deallocating B3 in slot 5
    # Deallocating B4 in slot 6
    # Deallocating B5 in slot 7
    # Deallocating B6 in slot 8
    return memslots1 # Returning T2k8
end

max_stars_repo_name: matrixfunctions/GraphMatFunData

max_issues_repo_name: matrixfunctions/GraphMatFunData

max_forks_repo_name: matrixfunctions/GraphMatFunData