text:
<?php

class Mailchimp_Lists {
    public function __construct(Mailchimp $master) {
        $this->master = $master;
    }

    /**
     * Get all email addresses that complained about a campaign sent to a list
     * @param string $id
     * @param int $start
     * @param int $limit
     * @param string $since
     * @return associative_array the total of all reports and the specific reports reports this page
     *     - total int the total number of matching abuse reports
     *     - data array structs for the actual data for each reports, including:
     *         - date string date+time the abuse report was received and processed
     *         - email string the email address that reported abuse
     *         - campaign_id string the unique id for the campaign that report was made against
     *         - type string an internal type generally specifying the originating mail provider - may not be useful outside of filling report views
     */
    public function abuseReports($id, $start=0, $limit=500, $since=null) {
        $_params = array("id" => $id, "start" => $start, "limit" => $limit, "since" => $since);
        return $this->master->call('lists/abuse-reports', $_params);
    }

    /**
     * Access up to the previous 180 days of daily detailed aggregated activity stats for a given list. Does not include AutoResponder activity.
     * @param string $id
     * @return array of structs containing daily values, each containing:
     */
    public function activity($id) {
        $_params = array("id" => $id);
        return $this->master->call('lists/activity', $_params);
    }

    /**
     * Subscribe a batch of email addresses to a list at once. If you are using a serialized version of the API, we strongly suggest that you
only run this method as a POST request, and not a GET request. Maximum batch sizes vary based on the amount of data in each record,
though you should cap them at 5k - 10k records, depending on your experience. These calls are also long, so be sure you increase your timeout values.
     * @param string $id
     * @param array $batch
     *     - email associative_array a struct with one of the following keys - failing to provide anything will produce an error relating to the email address. Provide multiples and we'll use the first we see in this same order.
     *         - email string an email address
     *         - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
     *         - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
     *     - email_type string for the email type option (html or text)
     *     - merge_vars associative_array data for the various list specific and special merge vars documented in lists/subscribe
     * @param boolean $double_optin
     * @param boolean $update_existing
     * @param boolean $replace_interests
     * @return associative_array struct of result counts and associated data
     *     - add_count int Number of email addresses that were successfully added
     *     - adds array array of structs for each add
     *         - email string the email address added
     *         - euid string the email unique id
     *         - leid string the list member's truly unique id
     *     - update_count int Number of email addresses that were successfully updated
     *     - updates array array of structs for each update
     *         - email string the email address added
     *         - euid string the email unique id
     *         - leid string the list member's truly unique id
     *     - error_count int Number of email addresses that failed during addition/updating
     *     - errors array array of error structs including:
     *         - email string whatever was passed in the batch record's email parameter
     *             - email string the email address added
     *             - euid string the email unique id
     *             - leid string the list member's truly unique id
     *         - code int the error code
     *         - error string the full error message
     *         - row associative_array the row from the batch that caused the error
     */
    public function batchSubscribe($id, $batch, $double_optin=true, $update_existing=false, $replace_interests=true) {
        $_params = array("id" => $id, "batch" => $batch, "double_optin" => $double_optin, "update_existing" => $update_existing, "replace_interests" => $replace_interests);
        return $this->master->call('lists/batch-subscribe', $_params);
    }

    /**
     * Unsubscribe a batch of email addresses from a list
     * @param string $id
     * @param array $batch
     *     - email string an email address
     *     - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
     *     - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
     * @param boolean $delete_member
     * @param boolean $send_goodbye
     * @param boolean $send_notify
     * @return array Array of structs containing results and any errors that occurred
     *     - success_count int Number of email addresses that were successfully removed
     *     - error_count int Number of email addresses that failed during addition/updating
     *     - errors array array of error structs including:
     *         - email string whatever was passed in the batch record's email parameter
     *             - email string the email address added
     *             - euid string the email unique id
     *             - leid string the list member's truly unique id
     *         - code int the error code
     *         - error string the full error message
     */
    public function batchUnsubscribe($id, $batch, $delete_member=false, $send_goodbye=true, $send_notify=false) {
        $_params = array("id" => $id, "batch" => $batch, "delete_member" => $delete_member, "send_goodbye" => $send_goodbye, "send_notify" => $send_notify);
        return $this->master->call('lists/batch-unsubscribe', $_params);
    }

    /**
     * Retrieve the clients that the list's subscribers have been tagged as being used based on user agents seen. Made possible by user-agent-string.info
     * @param string $id
     * @return associative_array the desktop and mobile user agents in use on the list
     *     - desktop associative_array desktop user agents and percentages
     *         - penetration double the percent of desktop clients in use
     *         - clients array array of structs for each client including:
     *             - client string the common name for the client
     *             - icon string a url to an image representing this client
     *             - percent string percent of list using the client
     *             - members string total members using the client
     *     - mobile associative_array mobile user agents and percentages
     *         - penetration double the percent of mobile clients in use
     *         - clients array array of structs for each client including:
     *             - client string the common name for the client
     *             - icon string a url to an image representing this client
     *             - percent string percent of list using the client
     *             - members string total members using the client
     */
    public function clients($id) {
        $_params = array("id" => $id);
        return $this->master->call('lists/clients', $_params);
    }

    /**
     * Access the Growth History by Month in aggregate or for a given list.
     * @param string $id
     * @return array array of structs containing months and growth data
     *     - month string The Year and Month in question using YYYY-MM format
     *     - existing int number of existing subscribers to start the month
     *     - imports int number of subscribers imported during the month
     *     - optins int number of subscribers who opted-in during the month
     */
    public function growthHistory($id=null) {
        $_params = array("id" => $id);
        return $this->master->call('lists/growth-history', $_params);
    }

    /**
     * Get the list of interest groupings for a given list, including the label, form information, and included groups for each
     * @param string $id
     * @param bool $counts
     * @return array array of structs of the interest groupings for the list
     *     - id int The id for the Grouping
     *     - name string Name for the Interest groups
     *     - form_field string Gives the type of interest group: checkbox,radio,select
     *     - groups array Array structs of the grouping options (interest groups) including:
     *         - bit string the bit value - not really anything to be done with this
     *         - name string the name of the group
     *         - display_order string the display order of the group, if set
     *         - subscribers int total number of subscribers who have this group if "counts" is true. otherwise empty
     */
    public function interestGroupings($id, $counts=false) {
        $_params = array("id" => $id, "counts" => $counts);
        return $this->master->call('lists/interest-groupings', $_params);
    }

    /**
     * Add a single Interest Group - if interest groups for the List are not yet enabled, adding the first
group will automatically turn them on.
     * @param string $id
     * @param string $group_name
     * @param int $grouping_id
     * @return associative_array with a single entry:
     *     - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
     */
    public function interestGroupAdd($id, $group_name, $grouping_id=null) {
        $_params = array("id" => $id, "group_name" => $group_name, "grouping_id" => $grouping_id);
        return $this->master->call('lists/interest-group-add', $_params);
    }

    /**
     * Delete a single Interest Group - if the last group for a list is deleted, this will also turn groups for the list off.
     * @param string $id
     * @param string $group_name
     * @param int $grouping_id
     * @return associative_array with a single entry:
     *     - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
     */
    public function interestGroupDel($id, $group_name, $grouping_id=null) {
        $_params = array("id" => $id, "group_name" => $group_name, "grouping_id" => $grouping_id);
        return $this->master->call('lists/interest-group-del', $_params);
    }

    /**
     * Change the name of an Interest Group
     * @param string $id
     * @param string $old_name
     * @param string $new_name
     * @param int $grouping_id
     * @return associative_array with a single entry:
     *     - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
     */
    public function interestGroupUpdate($id, $old_name, $new_name, $grouping_id=null) {
        $_params = array("id" => $id, "old_name" => $old_name, "new_name" => $new_name, "grouping_id" => $grouping_id);
        return $this->master->call('lists/interest-group-update', $_params);
    }

    /**
     * Add a new Interest Grouping - if interest groups for the List are not yet enabled, adding the first
grouping will automatically turn them on.
     * @param string $id
     * @param string $name
     * @param string $type
     * @param array $groups
     * @return associative_array with a single entry:
     *     - id int the new grouping id if the request succeeds, otherwise an error will be thrown
     */
    public function interestGroupingAdd($id, $name, $type, $groups) {
        $_params = array("id" => $id, "name" => $name, "type" => $type, "groups" => $groups);
        return $this->master->call('lists/interest-grouping-add', $_params);
    }

    /**
     * Delete an existing Interest Grouping - this will permanently delete all contained interest groups and will remove those selections from all list members
     * @param int $grouping_id
     * @return associative_array with a single entry:
     *     - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
     */
    public function interestGroupingDel($grouping_id) {
        $_params = array("grouping_id" => $grouping_id);
        return $this->master->call('lists/interest-grouping-del', $_params);
    }

    /**
     * Update an existing Interest Grouping
     * @param int $grouping_id
     * @param string $name
     * @param string $value
     * @return associative_array with a single entry:
     *     - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
     */
    public function interestGroupingUpdate($grouping_id, $name, $value) {
        $_params = array("grouping_id" => $grouping_id, "name" => $name, "value" => $value);
        return $this->master->call('lists/interest-grouping-update', $_params);
    }

    /**
     * Retrieve the locations (countries) that the list's subscribers have been tagged to based on geocoding their IP address
     * @param string $id
     * @return array array of locations
     *     - country string the country name
     *     - cc string the ISO 3166 2 digit country code
     *     - percent double the percent of subscribers in the country
     *     - total double the total number of subscribers in the country
     */
    public function locations($id) {
        $_params = array("id" => $id);
        return $this->master->call('lists/locations', $_params);
    }

    /**
     * Get the most recent 100 activities for particular list members (open, click, bounce, unsub, abuse, sent to, etc.)
     * @param string $id
     * @param array $emails
     *     - email string an email address - for new subscribers obviously this should be used
     *     - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
     *     - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
     * @return associative_array of data and success/error counts
     *     - success_count int the number of subscribers successfully found on the list
     *     - error_count int the number of subscribers who were not found on the list
     *     - errors array array of error structs including:
     *         - email string whatever was passed in the email parameter
     *             - email string the email address added
     *             - euid string the email unique id
     *             - leid string the list member's truly unique id
     *         - error string the error message
     *         - code string the error code
     *     - data array an array of structs where each activity record has:
     *         - email string whatever was passed in the email parameter
     *             - email string the email address added
     *             - euid string the email unique id
     *             - leid string the list member's truly unique id
     *         - activity array an array of structs containing the activity, including:
     *             - action string The action name, one of: open, click, bounce, unsub, abuse, sent, queued, ecomm, mandrill_send, mandrill_hard_bounce, mandrill_soft_bounce, mandrill_open, mandrill_click, mandrill_spam, mandrill_unsub, mandrill_reject
     *             - timestamp string The date+time of the action (GMT)
     *             - url string For click actions, the url clicked, otherwise this is empty
     *             - type string If there's extra bounce, unsub, etc data it will show up here.
     *             - campaign_id string The campaign id the action was related to, if it exists - otherwise empty (ie, direct unsub from list)
     *             - campaign_data associative_array If not deleted, the campaigns/list data for the campaign
     */
    public function memberActivity($id, $emails) {
        $_params = array("id" => $id, "emails" => $emails);
        return $this->master->call('lists/member-activity', $_params);
    }

    /**
     * Get all the information for particular members of a list
     * @param string $id
     * @param array $emails
     *     - email string an email address - for new subscribers obviously this should be used
     *     - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
     *     - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
     * @return associative_array of data and success/error counts
     *     - success_count int the number of subscribers successfully found on the list
     *     - error_count int the number of subscribers who were not found on the list
     *     - errors array array of error structs including:
     *         - email associative_array whatever was passed in the email parameter
     *             - email string the email address added
     *             - euid string the email unique id
     *             - leid string the list member's truly unique id
     *         - error string the error message
     *     - data array array of structs for each valid list member
     *         - id string The unique id (euid) for this email address on an account
     *         - email string The email address associated with this record
     *         - email_type string The type of emails this customer asked to get: html or text
     *         - merges associative_array a struct containing a key for each merge tags and the data for those tags for this email address, plus:
     *             - GROUPINGS array if Interest groupings are enabled, this will exist with structs for each grouping:
     *                 - id int the grouping id
     *                 - name string the interest group name
     *                 - groups array structs for each group in the grouping
     *                     - name string the group name
     *                     - interested bool whether the member has this group selected
     *         - status string The subscription status for this email address, either pending, subscribed, unsubscribed, or cleaned
     *         - ip_signup string IP Address this address signed up from. This may be blank if single optin is used.
     *         - timestamp_signup string The date+time the double optin was initiated. This may be blank if single optin is used.
     *         - ip_opt string IP Address this address opted in from.
     *         - timestamp_opt string The date+time the optin completed
     *         - member_rating int the rating of the subscriber. This will be 1 - 5 as described here
     *         - campaign_id string If the user is unsubscribed and they unsubscribed from a specific campaign, that campaign_id will be listed, otherwise this is not returned.
     *         - lists array An array of structs for the other lists this member belongs to
     *             - id string the list id
     *             - status string the members status on that list
     *         - timestamp string The date+time this email address entered it's current status
     *         - info_changed string The last time this record was changed. If the record is old enough, this may be blank.
     *         - web_id int The Member id used in our web app, allows you to create a link directly to it
     *         - leid int The Member id used in our web app, allows you to create a link directly to it
     *         - list_id string The list id the for the member record being returned
     *         - list_name string The list name the for the member record being returned
     *         - language string if set/detected, a language code from here
     *         - is_gmonkey bool Whether the member is a Golden Monkey or not.
     *         - geo associative_array the geographic information if we have it. including:
     *             - latitude string the latitude
     *             - longitude string the longitude
     *             - gmtoff string GMT offset
     *             - dstoff string GMT offset during daylight savings (if DST not observered, will be same as gmtoff)
     *             - timezone string the timezone we've place them in
     *             - cc string 2 digit ISO-3166 country code
     *             - region string generally state, province, or similar
     *         - clients associative_array the client we've tracked the address as using with two keys:
     *             - name string the common name of the client
     *             - icon_url string a url representing a path to an icon representing this client
     *         - static_segments array structs for each static segments the member is a part of including:
     *             - id int the segment id
     *             - name string the name given to the segment
     *             - added string the date the member was added
     *         - notes array structs for each note entered for this member. For each note:
     *             - id int the note id
     *             - note string the text entered
     *             - created string the date the note was created
     *             - updated string the date the note was last updated
     *             - created_by_name string the name of the user who created the note. This can change as users update their profile.
     */
    public function memberInfo($id, $emails) {
        $_params = array("id" => $id, "emails" => $emails);
        return $this->master->call('lists/member-info', $_params);
    }

    /**
     * Get all of the list members for a list that are of a particular status and potentially matching a segment. This will cause locking, so don't run multiples at once. Are you trying to get a dump including lots of merge
data or specific members of a list? If so, checkout the List Export API
     * @param string $id
     * @param string $status
     * @param associative_array $opts
     *     - start int optional for large data sets, the page number to start at - defaults to 1st page of data  (page 0)
     *     - limit int optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
     *     - sort_field string optional the data field to sort by - mergeX (1-30), your custom merge tags, "email", "rating","last_update_time", or "optin_time" - invalid fields will be ignored
     *     - sort_dir string optional the direct - ASC or DESC. defaults to ASC (case insensitive)
     *     - segment associative_array a properly formatted segment that works with campaigns/segment-test
     * @return associative_array of the total records matched and limited list member data for this page
     *     - total int the total matching records
     *     - data array structs for each member as returned by member-info
     */
    public function members($id, $status='subscribed', $opts=array()) {
        $_params = array("id" => $id, "status" => $status, "opts" => $opts);
        return $this->master->call('lists/members', $_params);
    }

    /**
     * Add a new merge tag to a given list
     * @param string $id
     * @param string $tag
     * @param string $name
     * @param associative_array $options
     *     - field_type string optional one of: text, number, radio, dropdown, date, address, phone, url, imageurl, zip, birthday - defaults to text
     *     - req boolean optional indicates whether the field is required - defaults to false
     *     - public boolean optional indicates whether the field is displayed in public - defaults to true
     *     - show boolean optional indicates whether the field is displayed in the app's list member view - defaults to true
     *     - order int The order this merge tag should be displayed in - this will cause existing values to be reset so this fits
     *     - default_value string optional the default value for the field. See lists/subscribe() for formatting info. Defaults to blank - max 255 bytes
     *     - helptext string optional the help text to be used with some newer forms. Defaults to blank - max 255 bytes
     *     - choices array optional kind of - an array of strings to use as the choices for radio and dropdown type fields
     *     - dateformat string optional only valid for birthday and date fields. For birthday type, must be "MM/DD" (default) or "DD/MM". For date type, must be "MM/DD/YYYY" (default) or "DD/MM/YYYY". Any other values will be converted to the default.
     *     - phoneformat string optional "US" is the default - any other value will cause them to be unformatted (international)
     *     - defaultcountry string optional the ISO 3166 2 digit character code for the default country. Defaults to "US". Anything unrecognized will be converted to the default.
     * @return associative_array the full data for the new merge var, just like merge-vars returns
     *     - name string Name/description of the merge field
     *     - req bool Denotes whether the field is required (true) or not (false)
     *     - field_type string The "data type" of this merge var. One of: email, text, number, radio, dropdown, date, address, phone, url, imageurl
     *     - public bool Whether or not this field is visible to list subscribers
     *     - show bool Whether the field is displayed in thelist dashboard
     *     - order string The order this field displays in on forms
     *     - default string The default value for this field
     *     - helptext string The helptext for this field
     *     - size string The width of the field to be used
     *     - tag string The merge tag that's used for forms and lists/subscribe() and lists/update-member()
     *     - choices array the options available for radio and dropdown field types
     *     - id int an unchanging id for the merge var
     */
    public function mergeVarAdd($id, $tag, $name, $options=array()) {
        $_params = array("id" => $id, "tag" => $tag, "name" => $name, "options" => $options);
        return $this->master->call('lists/merge-var-add', $_params);
    }

    /**
     * Delete a merge tag from a given list and all its members. Seriously - the data is removed from all members as well!
Note that on large lists this method may seem a bit slower than calls you typically make.
     * @param string $id
     * @param string $tag
     * @return associative_array with a single entry:
     *     - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
     */
    public function mergeVarDel($id, $tag) {
        $_params = array("id" => $id, "tag" => $tag);
        return $this->master->call('lists/merge-var-del', $_params);
    }

    /**
     * Completely resets all data stored in a merge var on a list. All data is removed and this action can not be undone.
     * @param string $id
     * @param string $tag
     * @return associative_array with a single entry:
     *     - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
     */
    public function mergeVarReset($id, $tag) {
        $_params = array("id" => $id, "tag" => $tag);
        return $this->master->call('lists/merge-var-reset', $_params);
    }

    /**
     * Sets a particular merge var to the specified value for every list member. Only merge var ids 1 - 30 may be modified this way. This is generally a dirty method
unless you're fixing data since you should probably be using default_values and/or conditional content. as with lists/merge-var-reset(), this can not be undone.
     * @param string $id
     * @param string $tag
     * @param string $value
     * @return associative_array with a single entry:
     *     - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
     */
    public function mergeVarSet($id, $tag, $value) {
        $_params = array("id" => $id, "tag" => $tag, "value" => $value);
        return $this->master->call('lists/merge-var-set', $_params);
    }

    /**
     * Update most parameters for a merge tag on a given list. You cannot currently change the merge type
     * @param string $id
     * @param string $tag
     * @param associative_array $options
     * @return associative_array the full data for the new merge var, just like merge-vars returns
     *     - name string Name/description of the merge field
     *     - req bool Denotes whether the field is required (true) or not (false)
     *     - field_type string The "data type" of this merge var. One of: email, text, number, radio, dropdown, date, address, phone, url, imageurl
     *     - public bool Whether or not this field is visible to list subscribers
     *     - show bool Whether the field is displayed in thelist dashboard
     *     - order string The order this field to displays in on forms
     *     - default string The default value for this field
     *     - helptext string The helptext for this field
     *     - size string The width of the field to be used
     *     - tag string The merge tag that's used for forms and lists/subscribe() and lists/update-member()
     *     - choices array the options available for radio and dropdown field types
     *     - id int an unchanging id for the merge var
     */
    public function mergeVarUpdate($id, $tag, $options) {
        $_params = array("id" => $id, "tag" => $tag, "options" => $options);
        return $this->master->call('lists/merge-var-update', $_params);
    }

    /**
     * Get the list of merge tags for a given list, including their name, tag, and required setting
     * @param array $id
     * @return associative_array of data and success/error counts
     *     - success_count int the number of subscribers successfully found on the list
     *     - error_count int the number of subscribers who were not found on the list
     *     - data array of structs for the merge tags on each list
     *         - id string the list id
     *         - name string the list name
     *         - merge_vars array of structs for each merge var
     *             - name string Name of the merge field
     *             - req bool Denotes whether the field is required (true) or not (false)
     *             - field_type string The "data type" of this merge var. One of the options accepted by field_type in lists/merge-var-add
     *             - public bool Whether or not this field is visible to list subscribers
     *             - show bool Whether the list owner has this field displayed on their list dashboard
     *             - order string The order the list owner has set this field to display in
     *             - default string The default value the list owner has set for this field
     *             - helptext string The helptext for this field
     *             - size string The width of the field to be used
     *             - tag string The merge tag that's used for forms and lists/subscribe() and listUpdateMember()
     *             - choices array For radio and dropdown field types, an array of the options available
     *             - id int an unchanging id for the merge var
     *     - errors array of error structs
     *         - id string the passed list id that failed
     *         - code int the resulting error code
     *         - msg string the resulting error message
     */
    public function mergeVars($id) {
        $_params = array("id" => $id);
        return $this->master->call('lists/merge-vars', $_params);
    }

    /**
     * Retrieve all of Segments for a list.
     * @param string $id
     * @param string $type
     * @return associative_array with 2 keys:
     *     - static array of structs with data for each segment
     *         - id int the id of the segment
     *         - name string the name for the segment
     *         - created_date string the date+time the segment was created
     *         - last_update string the date+time the segment was last updated (add or del)
     *         - last_reset string the date+time the segment was last reset (ie had all members cleared from it)
     *     - saved array of structs with data for each segment
     *         - id int the id of the segment
     *         - name string the name for the segment
     *         - segment_opts string same match+conditions struct typically used
     *         - segment_text string a textual description of the segment match/conditions
     *     - created_date string the date+time the segment was created
     *     - last_update string the date+time the segment was last updated (add or del)
     */
    public function segments($id, $type=null) {
        $_params = array("id" => $id, "type" => $type);
        return $this->master->call('lists/segments', $_params);
    }

    /**
     * Save a segment against a list for later use. There is no limit to the number of segments which can be saved. Static Segments are not tied
to any merge data, interest groups, etc. They essentially allow you to configure an unlimited number of custom segments which will have standard performance.
When using proper segments, Static Segments are one of the available options for segmentation just as if you used a merge var (and they can be used with other segmentation
options), though performance may degrade at that point. Saved Segments (called "auto-updating" in the app) are essentially just the match+conditions typically
used.
     * @param string $id
     * @param associative_array $opts
     *     - type string either "static" or "saved"
     *     - name string a unique name per list for the segment - 100 byte maximum length, anything longer will throw an error
     *     - segment_opts associative_array for "saved" only, the standard segment match+conditions, just like campaigns/segment-test
     *         - match string "any" or "all"
     *         - conditions array structs for each condition, just like campaigns/segment-test
     * @return associative_array with a single entry:
     *     - id int the id of the new segment, otherwise an error will be thrown.
     */
    public function segmentAdd($id, $opts) {
        $_params = array("id" => $id, "opts" => $opts);
        return $this->master->call('lists/segment-add', $_params);
    }

    /**
     * Delete a segment. Note that this will, of course, remove any member affiliations with any static segments deleted
     * @param string $id
     * @param int $seg_id
     * @return associative_array with a single entry:
     *     - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
     */
    public function segmentDel($id, $seg_id) {
        $_params = array("id" => $id, "seg_id" => $seg_id);
        return $this->master->call('lists/segment-del', $_params);
    }

    /**
     * Allows one to test their segmentation rules before creating a campaign using them - this is no different from campaigns/segment-test() and will eventually replace it.
For the time being, the crazy segmenting condition documentation will continue to live over there.
     * @param string $list_id
     * @param associative_array $options
     * @return associative_array with a single entry:
     *     - total int The total number of subscribers matching your segmentation options
     */
    public function segmentTest($list_id, $options) {
        $_params = array("list_id" => $list_id, "options" => $options);
        return $this->master->call('lists/segment-test', $_params);
    }

    /**
     * Update an existing segment. The list and type can not be changed.
     * @param string $id
     * @param int $seg_id
     * @param associative_array $opts
     *     - name string a unique name per list for the segment - 100 byte maximum length, anything longer will throw an error
     *     - segment_opts associative_array for "saved" only, the standard segment match+conditions, just like campaigns/segment-test
     *         - match string "any" or "all"
     *         - conditions array structs for each condition, just like campaigns/segment-test
     * @return associative_array with a single entry:
     *     - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
     */
    public function segmentUpdate($id, $seg_id, $opts) {
        $_params = array("id" => $id, "seg_id" => $seg_id, "opts" => $opts);
        return $this->master->call('lists/segment-update', $_params);
    }

    /**
     * Save a segment against a list for later use. There is no limit to the number of segments which can be saved. Static Segments are not tied
to any merge data, interest groups, etc. They essentially allow you to configure an unlimited number of custom segments which will have standard performance.
When using proper segments, Static Segments are one of the available options for segmentation just as if you used a merge var (and they can be used with other segmentation
options), though performance may degrade at that point.
     * @param string $id
     * @param string $name
     * @return associative_array with a single entry:
     *     - id int the id of the new segment, otherwise an error will be thrown.
     */
    public function staticSegmentAdd($id, $name) {
        $_params = array("id" => $id, "name" => $name);
        return $this->master->call('lists/static-segment-add', $_params);
    }

    /**
     * Delete a static segment. Note that this will, of course, remove any member affiliations with the segment
     * @param string $id
     * @param int $seg_id
     * @return associative_array with a single entry:
     *     - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
     */
    public function staticSegmentDel($id, $seg_id) {
        $_params = array("id" => $id, "seg_id" => $seg_id);
        return $this->master->call('lists/static-segment-del', $_params);
    }

    /**
     * Add list members to a static segment. It is suggested that you limit batch size to no more than 10,000 addresses per call. Email addresses must exist on the list
in order to be included - this will not subscribe them to the list!
     * @param string $id
     * @param int $seg_id
     * @param array $batch
     *     - email string an email address
     *     - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
     *     - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
     * @return associative_array an array with the results of the operation
     *     - success_count int the total number of successful updates (will include members already in the segment)
     *     - errors array structs for each error including:
     *         - email string whatever was passed in the email parameter
     *             - email string the email address added
     *             - euid string the email unique id
     *             - leid string the list member's truly unique id
     *         - code string the error code
     *         - error string the full error message
     */
    public function staticSegmentMembersAdd($id, $seg_id, $batch) {
        $_params = array("id" => $id, "seg_id" => $seg_id, "batch" => $batch);
        return $this->master->call('lists/static-segment-members-add', $_params);
    }

    /**
     * Remove list members from a static segment. It is suggested that you limit batch size to no more than 10,000 addresses per call. Email addresses must exist on the list
in order to be removed - this will not unsubscribe them from the list!
     * @param string $id
     * @param int $seg_id
     * @param array $batch
     *     - email string an email address
     *     - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
     *     - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
     * @return associative_array an array with the results of the operation
     *     - success_count int the total number of successful removals
     *     - error_count int the total number of unsuccessful removals
     *     - errors array structs for each error including:
     *         - email string whatever was passed in the email parameter
     *             - email string the email address added
     *             - euid string the email unique id
     *             - leid string the list member's truly unique id
     *         - code string the error code
     *         - error string the full error message
     */
    public function staticSegmentMembersDel($id, $seg_id, $batch) {
        $_params = array("id" => $id, "seg_id" => $seg_id, "batch" => $batch);
        return $this->master->call('lists/static-segment-members-del', $_params);
    }

    /**
     * Resets a static segment - removes all members from the static segment. Note: does not actually affect list member data
     * @param string $id
     * @param int $seg_id
     * @return associative_array with a single entry:
     *     - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
     */
    public function staticSegmentReset($id, $seg_id) {
        $_params = array("id" => $id, "seg_id" => $seg_id);
        return $this->master->call('lists/static-segment-reset', $_params);
    }

    /**
     * Retrieve all of the Static Segments for a list.
     * @param string $id
     * @param boolean $get_counts
     * @param int $start
     * @param int $limit
     * @return array an of structs with data for each static segment
     *     - id int the id of the segment
     *     - name string the name for the segment
     *     - member_count int the total number of subscribed members currently in a segment
     *     - created_date string the date+time the segment was created
     *     - last_update string the date+time the segment was last updated (add or del)
     *     - last_reset string the date+time the segment was last reset (ie had all members cleared from it)
     */
    public function staticSegments($id, $get_counts=true, $start=0, $limit=null) {
        $_params = array("id" => $id, "get_counts" => $get_counts, "start" => $start, "limit" => $limit);
        return $this->master->call('lists/static-segments', $_params);
    }

    /**
     * Subscribe the provided email to a list. By default this sends a confirmation email - you will not see new members until the link contained in it is clicked!
     * @param string $id
     * @param array $email
     *     - email string an email address - for new subscribers obviously this should be used
     *     - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
     *     - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
     * @param array $merge_vars
     *     - new-email string set this to change the email address. This is only respected on calls using update_existing or when passed to lists/update.
     *     - groupings array of Interest Grouping structs. Each should contain:
     *         - id int Grouping "id" from lists/interest-groupings (either this or name must be present) - this id takes precedence and can't change (unlike the name)
     *         - name string Grouping "name" from lists/interest-groupings (either this or id must be present)
     *         - groups array an array of valid group names for this grouping.
     *     - optin_ip string Set the Opt-in IP field. Abusing this may cause your account to be suspended. We do validate this and it must not be a private IP address.
     *     - optin_time string Set the Opt-in Time field. Abusing this may cause your account to be suspended. We do validate this and it must be a valid date. Use  - 24 hour format in GMT, eg "2013-12-30 20:30:00" to be safe. Generally, though, anything strtotime() understands we'll understand - http://us2.php.net/strtotime
     *     - mc_location associative_array Set the member's geographic location either by optin_ip or geo data.
     *         - latitude string use the specified latitude (longitude must exist for this to work)
     *         - longitude string use the specified longitude (latitude must exist for this to work)
     *         - anything string if this (or any other key exists here) we'll try to use the optin ip. NOTE - this will slow down each subscribe call a bit, especially for lat/lng pairs in sparsely populated areas. Currently our automated background processes can and will overwrite this based on opens and clicks.
     *     - mc_language string Set the member's language preference. Supported codes are fully case-sensitive and can be found here.
     *     - mc_notes array of structs for managing notes - it may contain:
     *         - note string the note to set. this is required unless you're deleting a note
     *         - id int the note id to operate on. not including this (or using an invalid id) causes a new note to be added
     *         - action string if the "id" key exists and is valid, an "update" key may be set to "append" (default), "prepend", "replace", or "delete" to handle how we should update existing notes. "delete", obviously, will only work with a valid "id" - passing that along with "note" and an invalid "id" is wrong and will be ignored.
     * @param string $email_type
     * @param bool $double_optin
     * @param bool $update_existing
     * @param bool $replace_interests
     * @param bool $send_welcome
     * @return array the ids for this subscriber
     *     - email string the email address added
     *     - euid string the email unique id
     *     - leid string the list member's truly unique id
     */
    public function subscribe($id, $email, $merge_vars=null, $email_type='html', $double_optin=true, $update_existing=false, $replace_interests=true, $send_welcome=false) {
        $_params = array("id" => $id, "email" => $email, "merge_vars" => $merge_vars, "email_type" => $email_type, "double_optin" => $double_optin, "update_existing" => $update_existing, "replace_interests" => $replace_interests, "send_welcome" => $send_welcome);
        return $this->master->call('lists/subscribe', $_params);
    }

    /**
     * Unsubscribe the given email address from the list
     * @param string $id
     * @param array $email
     *     - email string an email address
     *     - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
     *     - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
     * @param boolean $delete_member
     * @param boolean $send_goodbye
     * @param boolean $send_notify
     * @return array with a single entry:
     *     - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
     */
    public function unsubscribe($id, $email, $delete_member=false, $send_goodbye=true, $send_notify=true) {
        $_params = array("id" => $id, "email" => $email, "delete_member" => $delete_member, "send_goodbye" => $send_goodbye, "send_notify" => $send_notify);
        return $this->master->call('lists/unsubscribe', $_params);
    }

    /**
     * Edit the email address, merge fields, and interest groups for a list member. If you are doing a batch update on lots of users,
consider using lists/batch-subscribe() with the update_existing and possible replace_interests parameter.
     * @param string $id
     * @param associative_array $email
     *     - email string an email address
     *     - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
     *     - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
     * @param array $merge_vars
     * @param string $email_type
     * @param boolean $replace_interests
     * @return associative_array the ids for this subscriber
     *     - email string the email address added
     *     - euid string the email unique id
     *     - leid string the list member's truly unique id
     */
    public function updateMember($id, $email, $merge_vars, $email_type='', $replace_interests=true) {
        $_params = array("id" => $id, "email" => $email, "merge_vars" => $merge_vars, "email_type" => $email_type, "replace_interests" => $replace_interests);
        return $this->master->call('lists/update-member', $_params);
    }

    /**
     * Add a new Webhook URL for the given list
     * @param string $id
     * @param string $url
     * @param associative_array $actions
     *     - subscribe bool optional as subscribes occur, defaults to true
     *     - unsubscribe bool optional as subscribes occur, defaults to true
     *     - profile bool optional as profile updates occur, defaults to true
     *     - cleaned bool optional as emails are cleaned from the list, defaults to true
     *     - upemail bool optional when  subscribers change their email address, defaults to true
     *     - campaign bool option when a campaign is sent or canceled, defaults to true
     * @param associative_array $sources
     *     - user bool optional user/subscriber initiated actions, defaults to true
     *     - admin bool optional admin actions in our web app, defaults to true
     *     - api bool optional actions that happen via API calls, defaults to false
     * @return associative_array with a single entry:
     *     - id int the id of the new webhook, otherwise an error will be thrown.
     */
    public function webhookAdd($id, $url, $actions=array(), $sources=array()) {
        $_params = array("id" => $id, "url" => $url, "actions" => $actions, "sources" => $sources);
        return $this->master->call('lists/webhook-add', $_params);
    }

    /**
     * Delete an existing Webhook URL from a given list
     * @param string $id
     * @param string $url
     * @return associative_array with a single entry:
     *     - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
     */
    public function webhookDel($id, $url) {
        $_params = array("id" => $id, "url" => $url);
        return $this->master->call('lists/webhook-del', $_params);
    }

    /**
     * Return the Webhooks configured for the given list
     * @param string $id
     * @return array of structs for each webhook
     *     - url string the URL for this Webhook
     *     - actions associative_array the possible actions and whether they are enabled
     *         - subscribe bool triggered when subscribes happen
     *         - unsubscribe bool triggered when unsubscribes happen
     *         - profile bool triggered when profile updates happen
     *         - cleaned bool triggered when a subscriber is cleaned (bounced) from a list
     *         - upemail bool triggered when a subscriber's email address is changed
     *         - campaign bool triggered when a campaign is sent or canceled
     *     - sources associative_array the possible sources and whether they are enabled
     *         - user bool whether user/subscriber triggered actions are returned
     *         - admin bool whether admin (manual, in-app) triggered actions are returned
     *         - api bool whether api triggered actions are returned
     */
    public function webhooks($id) {
        $_params = array("id" => $id);
        return $this->master->call('lists/webhooks', $_params);
    }

    /**
     * Retrieve all of the lists defined for your user account
     * @param associative_array $filters
     *     - list_id string optional - return a single list using a known list_id. Accepts multiples separated by commas when not using exact matching
     *     - list_name string optional - only lists that match this name
     *     - from_name string optional - only lists that have a default from name matching this
     *     - from_email string optional - only lists that have a default from email matching this
     *     - from_subject string optional - only lists that have a default from email matching this
     *     - created_before string optional - only show lists that were created before this date+time  - 24 hour format in GMT, eg "2013-12-30 20:30:00"
     *     - created_after string optional - only show lists that were created since this date+time  - 24 hour format in GMT, eg "2013-12-30 20:30:00"
     *     - exact boolean optional - flag for whether to filter on exact values when filtering, or search within content for filter values - defaults to true
     * @param int $start
     * @param int $limit
     * @param string $sort_field
     * @param string $sort_dir
     * @return associative_array result of the operation including valid data and any errors
     *     - total int the total number of lists which matched the provided filters
     *     - data array structs for the lists which matched the provided filters, including the following
     *         - id string The list id for this list. This will be used for all other list management functions.
     *         - web_id int The list id used in our web app, allows you to create a link directly to it
     *         - name string The name of the list.
     *         - date_created string The date that this list was created.
     *         - email_type_option boolean Whether or not the List supports multiple formats for emails or just HTML
     *         - use_awesomebar boolean Whether or not campaigns for this list use the Awesome Bar in archives by default
     *         - default_from_name string Default From Name for campaigns using this list
     *         - default_from_email string Default From Email for campaigns using this list
     *         - default_subject string Default Subject Line for campaigns using this list
     *         - default_language string Default Language for this list's forms
     *         - list_rating double An auto-generated activity score for the list (0 - 5)
     *         - subscribe_url_short string Our eepurl shortened version of this list's subscribe form (will not change)
     *         - subscribe_url_long string The full version of this list's subscribe form (host will vary)
     *         - beamer_address string The email address to use for this list's Email Beamer
     *         - visibility string Whether this list is Public (pub) or Private (prv). Used internally for projects like Wavelength
     *         - stats associative_array various stats and counts for the list - many of these are cached for at least 5 minutes
     *             - member_count double The number of active members in the given list.
     *             - unsubscribe_count double The number of members who have unsubscribed from the given list.
     *             - cleaned_count double The number of members cleaned from the given list.
     *             - member_count_since_send double The number of active members in the given list since the last campaign was sent
     *             - unsubscribe_count_since_send double The number of members who have unsubscribed from the given list since the last campaign was sent
     *             - cleaned_count_since_send double The number of members cleaned from the given list since the last campaign was sent
     *             - campaign_count double The number of campaigns in any status that use this list
     *             - grouping_count double The number of Interest Groupings for this list
     *             - group_count double The number of Interest Groups (regardless of grouping) for this list
     *             - merge_var_count double The number of merge vars for this list (not including the required EMAIL one)
     *             - avg_sub_rate double the average number of subscribe per month for the list (empty value if we haven't calculated this yet)
     *             - avg_unsub_rate double the average number of unsubscribe per month for the list (empty value if we haven't calculated this yet)
     *             - target_sub_rate double the target subscription rate for the list to keep it growing (empty value if we haven't calculated this yet)
     *             - open_rate double the average open rate per campaign for the list  (empty value if we haven't calculated this yet)
     *             - click_rate double the average click rate per campaign for the list  (empty value if we haven't calculated this yet)
     *         - modules array Any list specific modules installed for this list (example is SocialPro)
     *     - errors array structs of any errors found while loading lists - usually just from providing invalid list ids
     *         - param string the data that caused the failure
     *         - code int the error code
     *         - error string the error message
     */
    public function getList($filters=array(), $start=0, $limit=25, $sort_field='created', $sort_dir='DESC') {
        $_params = array("filters" => $filters, "start" => $start, "limit" => $limit, "sort_field" => $sort_field, "sort_dir" => $sort_dir);
        return $this->master->call('lists/list', $_params);
    }

}


text:
<ion-modal-view ng-controller="glideraTxDetailsController">
  <ion-header-bar class="bar-royal">
    <button class="button button-back button-clear"
            ng-click="cancel()">
      Close
    </button>

Details

  </ion-header-bar>

  <ion-content>

        Bought
        Sold
        {{tx.qty}} BTC

          {{tx.subtotal|currency:'':2}} {{tx.currency}}

          Status

            Completed
            Processing
            Error

          Date
          {{tx.transactionDate | amCalendar}}

          Exchange rate
          {{tx.price|currency:'':2}} {{tx.currency}}/BTC

          Subtotal
          {{tx.subtotal|currency:'':2}} {{tx.currency}}

          Fees
          {{tx.fees|currency:'':2}} {{tx.currency}}

          Total
          {{tx.total|currency:'':2}} {{tx.currency}}

  </ion-content>
</ion-modal-view>

redpajama_set_name: RedPajamaGithub


text:
package model

import (
	"fmt"

	networking "istio.io/api/networking/v1alpha3"
	"istio.io/istio/pkg/log"
)

// MergedGateway describes a set of gateways for a workload merged into a single logical gateway.
//
// TODO: do we need a `func (m *MergedGateway) MergeInto(gateway *networking.Gateway)`?
type MergedGateway struct {
	Names map[string]bool

	// maps from physical port to virtual servers
	Servers map[uint32][]*networking.Server

	// maps from port names to virtual hosts
	// Used for RDS. No two port names share same port except for HTTPS
	// The typical length of the value is always 1, except for HTTP (not HTTPS),
	RDSRouteConfigNames map[string][]*networking.Server
}

// MergeGateways combines multiple gateways targeting the same workload into a single logical Gateway.
// Note that today any Servers in the combined gateways listening on the same port must have the same protocol.
// If servers with different protocols attempt to listen on the same port, one of the protocols will be chosen at random.
func MergeGateways(gateways ...Config) *MergedGateway {
	names := make(map[string]bool, len(gateways))
	gatewayPorts := make(map[uint32]bool)
	servers := make(map[uint32][]*networking.Server)
	tlsServers := make(map[uint32][]*networking.Server)
	plaintextServers := make(map[uint32][]*networking.Server)
	rdsRouteConfigNames := make(map[string][]*networking.Server)

	log.Debugf("MergeGateways: merging %d gateways", len(gateways))
	for _, spec := range gateways {
		name := ResolveShortnameToFQDN(spec.Name, spec.ConfigMeta)
		names[name.String()] = true

		gateway := spec.Spec.(*networking.Gateway)
		log.Debugf("MergeGateways: merging gateway %q into %v:\n%v", name, names, gateway)
		for _, s := range gateway.Servers {
			log.Debugf("MergeGateways: gateway %q processing server %v", name, s.Hosts)
			protocol := ParseProtocol(s.Port.Protocol)
			if gatewayPorts[s.Port.Number] {
				// We have two servers on the same port. Should we merge?
				// 1. Yes if both servers are plain text and HTTP
				// 2. Yes if both servers are using TLS
				//    if using HTTPS ensure that port name is distinct so that we can setup separate RDS
				//    for each server (as each server ends up as a separate http connection manager due to filter chain match
				// 3. No for everything else.

				if p, exists := plaintextServers[s.Port.Number]; exists {
					currentProto := ParseProtocol(p[0].Port.Protocol)
					if currentProto != protocol || !protocol.IsHTTP() {
						log.Debugf("skipping server on gateway %s port %s.%d.%s: conflict with existing server %s.%d.%s",
							spec.Name, s.Port.Name, s.Port.Number, s.Port.Protocol, p[0].Port.Name, p[0].Port.Number, p[0].Port.Protocol)
						continue
					}
					rdsName := GatewayRDSRouteName(s)
					if rdsName == "" {
						log.Debugf("skipping server on gateway %s port %s.%d.%s: could not build RDS name from server",
							spec.Name, s.Port.Name, s.Port.Number, s.Port.Protocol)
						continue
					}
					rdsRouteConfigNames[rdsName] = append(rdsRouteConfigNames[rdsName], s)
				} else {
					// We have duplicate port. Its not in plaintext servers. So, this has to be in TLS servers
					// Check if this is also a HTTP server and if so, ensure uniqueness of port name
					if isHTTPServer(s) {
						rdsName := GatewayRDSRouteName(s)
						if rdsName == "" {
							log.Debugf("skipping server on gateway %s port %s.%d.%s: could not build RDS name from server",
								spec.Name, s.Port.Name, s.Port.Number, s.Port.Protocol)
							continue
						}

						// both servers are HTTPS servers. Make sure the port names are different so that RDS can pick out individual servers
						// WE cannot have two servers with same port name because we need the port name to distinguish one HTTPS server from another
						// WE cannot merge two HTTPS servers even if their TLS settings have same path to the keys, because we don't know if the contents
						// of the keys are same. So we treat them as effectively different TLS settings.
						if _, exists := rdsRouteConfigNames[rdsName]; exists {
							log.Debugf("skipping server on gateway %s port %s.%d.%s: non unique port name for HTTPS port",
								spec.Name, s.Port.Name, s.Port.Number, s.Port.Protocol)
							continue
						}
						rdsRouteConfigNames[rdsName] = []*networking.Server{s}
					}

					// We have another TLS server on the same port. Can differentiate servers using SNI
					tlsServers[s.Port.Number] = append(tlsServers[s.Port.Number], s)
				}
			} else {
				gatewayPorts[s.Port.Number] = true
				if isTLSServer(s) {
					tlsServers[s.Port.Number] = []*networking.Server{s}
				} else {
					plaintextServers[s.Port.Number] = []*networking.Server{s}
				}

				if isHTTPServer(s) {
					rdsRouteConfigNames[GatewayRDSRouteName(s)] = []*networking.Server{s}
				}
			}
			log.Debugf("MergeGateways: gateway %q merged server %v", name, s.Hosts)
		}
	}

	// Concatenate both sets of servers
	for p, v := range tlsServers {
		servers[p] = v
	}
	for p, v := range plaintextServers {
		servers[p] = v
	}

	return &MergedGateway{
		Names:               names,
		Servers:             servers,
		RDSRouteConfigNames: rdsRouteConfigNames,
	}
}

func isTLSServer(server *networking.Server) bool {
	if server.Tls != nil && !ParseProtocol(server.Port.Protocol).IsHTTP() {
		return true
	}
	return false
}

func isHTTPServer(server *networking.Server) bool {
	protocol := ParseProtocol(server.Port.Protocol)
	if protocol.IsHTTP() {
		return true
	}

	if protocol == ProtocolHTTPS && server.Tls != nil && server.Tls.Mode != networking.Server_TLSOptions_PASSTHROUGH {
		return true
	}

	return false
}

// GatewayRDSRouteName generates the RDS route config name for gateway's servers.
// Unlike sidecars where the RDS route name is the listener port number, gateways have a different
// structure for RDS.
// HTTP servers have route name set to http.<portNumber>.
//   Multiple HTTP servers can exist on the same port and the code will combine all of them into
//   one single RDS payload for http.<portNumber>
// HTTPS servers with TLS termination (i.e. envoy decoding the content, and making outbound http calls to backends)
// will use route name https.<portnumber>.<portName>. HTTPS servers using SNI passthrough or
// non-HTTPS servers (e.g., TCP+TLS) with SNI passthrough will be setup as opaque TCP proxies without terminating
// the SSL connection. They would inspect the SNI header and forward to the appropriate upstream as opaque TCP.
//
// Within HTTPS servers terminating TLS, user could setup multiple servers in the gateway. each server could have
// one or more hosts but have different TLS certificates. In this case, we end up having separate filter chain
// for each server, with the filter chain match matching on the server specific TLS certs and SNI headers.
// We have two options here: either have all filter chains use the same RDS route name (e.g. "443") and expose
// all virtual hosts on that port to every filter chain uniformly or expose only the set of virtual hosts
// configured under the server for those certificates. We adopt the latter approach. In other words, each
// filter chain in the multi-filter-chain listener will have a distinct RDS route name (https.<portnumber>.portname)
// so that when a RDS request comes in, we serve the virtual hosts and associated routes for that server.
//
// Note that the common case is one where multiple servers are exposed under a single multi-SAN cert on a single port.
// In this case, we have a single https.<portnumber>.portname RDS for the HTTPS server.
// While we can use the same RDS route name for two servers (say HTTP and HTTPS) exposing the same set of hosts on
// different ports, the optimization (one RDS instead of two) could quickly become useless the moment the set of
// hosts on the two servers start differing -- necessitating the need for two different RDS routes.
func GatewayRDSRouteName(server *networking.Server) string {
	protocol := ParseProtocol(server.Port.Protocol)
	if protocol.IsHTTP() {
		return fmt.Sprintf("http.%d", server.Port.Number)
	}

	if protocol == ProtocolHTTPS && server.Tls != nil && server.Tls.Mode != networking.Server_TLSOptions_PASSTHROUGH {
		return fmt.Sprintf("https.%d.%s", server.Port.Number, server.Port.Name)
	}

	return ""
}


text:
import { useMemo, useState } from 'react';

import { c, msgid } from 'ttag';

import { orderContactGroups } from '@proton/shared/lib/helpers/contactGroups';
import { normalize } from '@proton/shared/lib/helpers/string';
import { Recipient } from '@proton/shared/lib/interfaces';
import { ContactEmail } from '@proton/shared/lib/interfaces/contacts';

import { CircleLoader, SearchInput } from '../../../components';
import { useContactEmails, useContactGroups, useNotifications, useUser, useUserSettings } from '../../../hooks';
import { useItemsSelection } from '../../items';
import { ContactGroupDeleteProps } from '../group/ContactGroupDeleteModal';
import { ContactGroupEditProps } from '../group/ContactGroupEditModal';
import ContactsGroupsList from '../lists/ContactsGroupsList';
import ContactsWidgetGroupsToolbar from './ContactsWidgetGroupsToolbar';
import ContactsWidgetPlaceholder, { EmptyType } from './ContactsWidgetPlaceholder';
import { CustomAction } from './types';

interface Props {
    onClose: () => void;
    onCompose?: (recipients: Recipient[], attachments: File[]) => void;
    onImport: () => void;
    customActions: CustomAction[];
    onDetails: (contactGroupID: string) => void;
    onDelete: (props: ContactGroupDeleteProps) => void;
    onEdit: (props: ContactGroupEditProps) => void;
    onUpgrade: () => void;
}

const ContactsWidgetGroupsContainer = ({
    onClose,
    onCompose,
    onImport,
    customActions,
    onDetails,
    onDelete,
    onEdit,
    onUpgrade,
}: Props) => {
    const [userSettings, loadingUserSettings] = useUserSettings();
    const { createNotification } = useNotifications();
    const [user] = useUser();

    const [search, setSearch] = useState('');

    const [groups = [], loadingGroups] = useContactGroups();
    const orderedGroups = orderContactGroups(groups);
    const [contactEmails = [], loadingContactEmails] = useContactEmails() as [ContactEmail[], boolean, any];

    const normalizedSearch = normalize(search);

    const filteredGroups = useMemo(
        () => orderedGroups.filter(({ Name }) => normalize(Name).includes(normalizedSearch)),
        [orderedGroups, normalizedSearch]
    );

    const groupIDs = filteredGroups.map((group) => group.ID);

    const { checkedIDs, selectedIDs, handleCheckAll, handleCheckOne } = useItemsSelection(undefined, groupIDs, []);

    const allChecked = checkedIDs.length > 0 && checkedIDs.length === filteredGroups.length;

    const groupsEmailsMap = useMemo(
        () =>
            contactEmails.reduce<{ [groupID: string]: ContactEmail[] }>((acc, contactEmail) => {
                contactEmail.LabelIDs.forEach((labelID) => {
                    if (!acc[labelID]) {
                        acc[labelID] = [];
                    }
                    acc[labelID].push(contactEmail);
                });
                return acc;
            }, {}),
        [groups, contactEmails]
    );

    const recipients = selectedIDs
        .map((selectedID) => {
            const group = groups.find((group) => group.ID === selectedID);
            if (groupsEmailsMap[selectedID]) {
                return groupsEmailsMap[selectedID].map((email) => ({
                    Name: email.Name,
                    Address: email.Email,
                    Group: group?.Path,
                }));
            }
            return [];
        })
        .flat();

    const handleClearSearch = () => {
        // If done synchronously, button is removed from the dom and the dropdown considers a click outside
        setTimeout(() => setSearch(''));
    };

    const handleCompose = () => {
        if (recipients.length > 100) {
            createNotification({
                type: 'error',
                text: c('Error').t`You can't send a mail to more than 100 recipients`,
            });
            return;
        }

        const noContactGroupIDs = selectedIDs.filter((groupID) => !groupsEmailsMap[groupID]?.length);

        if (noContactGroupIDs.length) {
            const noContactsGroupNames = noContactGroupIDs.map(
                // Looping in all groups is no really performant but should happen rarely
                (groupID) => groups.find((group) => group.ID === groupID)?.Name
            );

            const noContactGroupCount = noContactsGroupNames.length;
            const noContactGroupList = noContactsGroupNames.join(', ');

            const text = c('Error').ngettext(
                msgid`One of the groups has no contacts: ${noContactGroupList}`,
                `Some groups have no contacts: ${noContactGroupList} `,
                noContactGroupCount
            );

            createNotification({ type: 'warning', text });
        }

        onCompose?.(recipients, []);
        onClose();
    };

    const handleDetails = (groupID: string) => {
        onDetails(groupID);
        onClose();
    };

    const handleDelete = () => {
        onDelete({
            groupIDs: selectedIDs,
            onDelete: () => {
                if (selectedIDs.length === filteredGroups.length) {
                    setSearch('');
                }
                handleCheckAll(false);
            },
        });
        onClose();
    };

    const handleCreate = () => {
        if (!user.hasPaidMail) {
            onUpgrade();
            onClose();
            return;
        }

        onEdit({});
        onClose();
    };

    const handleImport = () => {
        onImport();
        onClose();
    };

    const groupCounts = filteredGroups.length;

    const loading = loadingGroups || loadingContactEmails || loadingUserSettings;
    const showPlaceholder = !loading && !groupCounts;
    const showList = !showPlaceholder;

    return (

                {c('Placeholder')
                    .t`Search for group name`}
                <SearchInput
                    autoFocus
                    value={search}
                    onChange={setSearch}
                    id="id_contact-widget-group-search"
                    placeholder={c('Placeholder').t`Search for group name`}
                />

                    {c('Info').ngettext(msgid`${groupCounts} group found`, `${groupCounts} groups found`, groupCounts)}

                <ContactsWidgetGroupsToolbar
                    allChecked={allChecked}
                    selected={selectedIDs}
                    numberOfRecipients={recipients.length}
                    onCheckAll={handleCheckAll}
                    onCompose={onCompose ? handleCompose : undefined}
                    groupsEmailsMap={groupsEmailsMap}
                    recipients={recipients}
                    onClose={onClose}
                    customActions={customActions}
                    onCreate={handleCreate}
                    onDelete={handleDelete}
                />

                {loading ? (

                        <CircleLoader className="mauto color-primary" size="large" />

                ) : null}
                {showPlaceholder ? (
                    <ContactsWidgetPlaceholder
                        type={groups.length ? EmptyType.Search : EmptyType.AllGroups}
                        onClearSearch={handleClearSearch}
                        onCreate={handleCreate}
                        onImport={handleImport}
                    />
                ) : null}
                {showList ? (
                    <ContactsGroupsList
                        groups={filteredGroups}
                        groupsEmailsMap={groupsEmailsMap}
                        userSettings={userSettings}
                        onCheckOne={handleCheckOne}
                        isDesktop={false}
                        checkedIDs={checkedIDs}
                        onClick={handleDetails}
                    />
                ) : null}

    );
};

export default ContactsWidgetGroupsContainer;


text:
[![Build Status](https://travis-ci.org/cansik/pg4nosql.svg)](https://travis-ci.org/cansik/pg4nosql)
[![Code Climate](https://codeclimate.com/github/cansik/pg4nosql/badges/gpa.svg)](https://codeclimate.com/github/cansik/pg4nosql)
[![Latest Version](https://img.shields.io/pypi/v/pg4nosql.svg)](https://pypi.python.org/pypi/pg4nosql)
[![Development Status](https://img.shields.io/pypi/status/pg4nosql.svg)](https://pypi.python.org/pypi/pg4nosql)
[![Python Versions](https://img.shields.io/pypi/pyversions/pg4nosql.svg)](https://pypi.python.org/pypi/pg4nosql)
[![License](https://img.shields.io/pypi/l/pg4nosql.svg)](https://github.com/cansik/pg4nosql/blob/master/LICENSE.txt)

A simple psycopg2 based wrapper for nosql like database interaction with python.

### Why another wrapper?
The wrapper was developed to work with JSON postgres storage like a real NoSQL DB (e.g. MongoDB). After a long research with google there was no library found which helps to work with JSON and PostgreSQL so I decided to develop one.

The strength of the wrapper is that you still can have multiple relational colums in your table.

### Installation

##### Using [Python Package Index](https://pypi.python.org/pypi/pg4nosql) (PIP)
Just run the command:
`pip install pg4nosql`

*During alpha stage the api will change with each build. So try to stay with one version if you want to use it.*

##### The hacky way
1. [download](https://github.com/cansik/pg4nosql/tarball/0.4.2) or clone this repository
2. run the command `python setup.py install`

### Changelog
* Version `0.4.2`
  * fixed python 3.3 iterator return
* Version `0.4.1`
  * Query from view
  * fixed some bugs
* Version `0.4.0`
  * adds join query statements
  * adds update method
  * adds save method on result item
* Version `0.3.7`
  * adds the support for non-json database tables
* Version `0.3.6`
  * id datatype can be set on table creation
* Version `0.3.3`
  * project cleanup
* Version `0.3.1`
  * auto-commit for very operation as default
  * save does not affect saving object anymore
  * bug fixes
* Version `0.2.4`
  * a lot of bug fixes
* Version `0.2.0`
  * added port argument
  * replaced dictionary argument with **keyword syntax
  * switched result.relational with result.json
  * add bracket syntax to get database or table
  * renamed table.get\_or\_create to match codestyle

### Example
These examples show the funcionality of the wrapper. There are some functions which are not covered by the examples (like removing of a table) but the importent ones are explained.

##### Dataschema Creation
To create the dataschema you can use normal database tools if you want. A document table has two fields:

* `id` with data type **serial**
* `json` with data type **JSON** which represents the document

But pg4nosql also provides methods to create your database schema on the fly. This is useful to create tables and databases software controlled.

This example shows how to create a database and their tables. The cities table is special because it also contains relational data like a normal table would:

```python
# create pg4nosql client
pg4nosql = PostgresNoSQLClient(host='localhost')

# create demo database
demo_db = pg4nosql['demo']

# create document only table
users = demo_db['users']

# create document & relational table
cities = demo_db.get_or_create_table('cities', size='real NOT NULL')
```

###### Row Identifier Type
By default the `id` row type is `SERIAL` but in some cases it is necessary to define the type yourself. This is possible with the `row_identifier_type` argument.

```python
# create document table with bigserial
big_users = demo_db.create_table('big_users',
								  row_identifier_type='BIGSERIAL')
```

##### Insert Data
To insert data into the table you just hand over a dictionary or an object which is json serializable. If there are relational columns defined you can set those by the table name as keyword and the value:

```python
# store data into users table
users.put({'name': 'Florian', 'age': 24})
users.put({'name': 'Markus', 'age': 24})
users.put({'name': 'Sara', 'age': 22})
users.put({'name': 'Thomas', 'age': 25})

# store data into cities table
cities.put({'name': 'Zurich'}, size=87.88)
cities.put({'name': 'Berlin'}, size=891.8)
cities.put({'name': 'Bern'}, size=51.6)
cities.put({'name': 'London'}, size=1572)
```

If you work **without json documents**, there is just a normal `insert` method to store new records into a table.

```python
# store data into cities table
users.insert(age=25, name="Florian")
```

###### Lazy Commit
If you want to store or save multiple entries you can set the `auto_commit` argument to `False` and commit it yourself.

```python
# store data with lazy commit
for i in range(0, 255):
    users.put({'name': 'Test', 'age': i}, auto_commit=False)

# lazy commit data
users.commit()
```

##### Query Data
To get your data back you can run a query over it. This works like normal SQL WHERE queries. For **JSON** data you have to use the `json` column:

```python
# query all users which are 24 years old
users_24 = users.query("json->>'age'='24'")
```
And here the result of the user query:

```json
[
   "{'json': {u'age': 24, u'name': u'Florian'}, 'id': 1}",
   "{'json': {u'age': 24, u'name': u'Markus'}, 'id': 2}"
]
```
You can also combine relational and JSON queries together like this:

```python
# query all cities which start with be and are bigger than 100 km
big_ber_cities = cities.query("json->>'name' LIKE 'Ber%'"
                              "AND size > 100")
```
Here the result of this query:

```json
[
   "{'json': {u'name': u'Berlin'}, 'id': 2, 'size': 891.8}"
]
```

##### Query with Join
It is also possible to create simple *joined* queries with the function `query_join`. Consider a datamodel with an `user` table and an `address` table. This two tables are connected through a *foreign key* `fk_user`.

The called table get's the identifier `a` and the joined table the identifier `b`.

```python
# get all users with their address
users = user.query_join('address', 'a.id = b.fk_user')
```

##### Query from View
To query data from a view you have to get the view from the database and then it has the same query method like a table.

```python
# get view
self.user_view = self.database.get_view('user_view')

# query data
records = self.user_view.query()
```

##### Query Data Access
To **access** the **JSON** fields of the result there is an attribute called `json`:

```python
# get first city of the result array
first_city = big_ber_cities[0]

# read JSON attribute
city_name = first_city.json['name']
```
To **access** the **relational** fields of the result you have to use **square brackets** (`[]`) on the result:

```python
# read relational attribute
city_size = first_city['size']
```
There is also a default field called `id` which contains the default row identifier for easy access:

```python
# get id of row
city_id = first_city.id
```

##### Update Data
With those access methods you can also write into the result and change the values of the fields. To save it just call `save(obj)` on the table object.

```python
# change florian's age
florian = users_24[0]
florian.json['age'] = 25

users.save(florian)
```
The same works also with the `relational` fields:

```python
# make zurich a bit bigger
zurich = cities.query_one("data->>'name'='Zurich'")
zurich['size'] = 90

cities.save(zurich)
```

With the release `0.4.0` it is also possible to save the database object directly:
```python
# make zurich a bit bigger
zurich = cities.query_one("data->>'name'='Zurich'")
zurich['size'] = 90

zurich.save()
```

**Without json documents**, there is just a normal `update` method to update new records into a table.

```python
# store data into cities table
florian = users_24[0]
florian['name'] = 'Markus'
users.update(florian)
```

##### Direct Execution
It is also possible to directly execute sql statements as you are used to. The execute function is declared on the database object and on the table object.

```python
# run simple sql query
my_data = demo_db.execute('SELECT * FROM cities')
```

##### Close Connection
Finally don't forget to close the connection to the database.

```python
# close db
demo_db.close()
```

### About
The wrapper has been written for a science project and is still an early beta version!
Idea and implementation by Florian (cansik)

MIT License
Copyright (c) 2015


text:
package com.github.jweixin.jwx.message.request;

public abstract class InPlainMessage extends InMessage {
	// 消息 id,64 位整型
	protected long msgId;

	public long getMsgId() {
		return msgId;
	}

	public void setMsgId(long msgId) {
		this.msgId = msgId;
	}

}


text:
package net.sf.mmm.util.path.impl;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Path;

import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;

import net.sf.mmm.util.path.api.PathFactory;
import net.sf.mmm.util.path.api.PathUri;
import net.sf.mmm.util.resource.base.ClasspathResource;

/**
 * This is the test-case for {@link PathFactory}.
 *
 * @author Joerg Hohwiller (hohwille at users.sourceforge.net)
 */
@SuppressWarnings("all")
public class PathFactoryTest extends Assert {

  /**
   * This method gets the {@link PathFactory} instance to test.
   *
   * @return the {@link PathFactory}.
   */
  public PathFactory getPathFactory() {

    PathFactoryImpl impl = new PathFactoryImpl();
    impl.initialize();
    return impl;
  }

  @Test
  public void testFileResource() throws Exception {

    String filename = "non-existent-file";
    String path = "/" + filename;
    String resourceUri = "file://" + path;
    Path resource = getPathFactory().createPath(resourceUri);
    assertEquals(filename, resource.getFileName().toString());
    // will not work on windows by intention - see javadoc...
    // assertEquals(path, resource.getPath());
    // assertEquals(resourceUri, resource.getUri());
    assertFalse(Files.exists(resource));
    assertFalse(Files.isDirectory(resource));
    // assertNull(Files.getLastModifiedTime(resource));
    try {
      Files.size(resource);
      fail("Exception expected");
    } catch (IOException e) {
      // OK
      assertTrue(e.getMessage().contains(filename));
    }
  }

  @Test
  @Ignore
  public void testUrlResource() throws Exception {

    String filename = "page.html";
    String path = "/folder/subfolder/" + filename;
    String host = "foo.bar.xyz";
    String resourceUri = "http://" + host + path;
    Path resource = getPathFactory().createPath(resourceUri);
    assertEquals(filename, resource.getFileName());
    assertEquals(path, resource.getParent().toString());
    assertEquals(resourceUri, resource.toString());
    assertFalse(Files.exists(resource));
    // try {
    // resource.getSize();
    // Assert.fail("Exception expected");
    // } catch (ResourceNotAvailableException e) {
    // // OK
    // assertTrue(e.getMessage().contains(filename));
    // }
  }

  @Test
  @Ignore
  public void testClasspathResource() throws Exception {

    PathFactory pathFactory = getPathFactory();
    String resourceUri = PathUri.SCHEME_PREFIX_CLASSPATH + ClasspathResource.class.getName().replace('.', '/')
        + ".txt";
    Path resource = pathFactory.createPath(resourceUri);
    verifyResource(resource);

    resource = pathFactory.createPath("file:///test");
    resource = pathFactory.createPath(resource, "foo/bar.txt");
    resource = pathFactory.createPath(resource, resourceUri);
    verifyResource(resource);

    resource = pathFactory.createPath("classpath:META-INF/maven/org.slf4j/slf4j-api/pom.properties");
    assertTrue(Files.exists(resource));
    assertEquals(104, Files.size(resource));
  }

  public static void verifyResource(Path resource) throws Exception {

    assertTrue(Files.exists(resource));
    assertEquals(41, Files.size(resource));

    try (InputStream in = Files.newInputStream(resource)) {
      BufferedReader reader = new BufferedReader(new InputStreamReader(in));
      String line = reader.readLine();
      assertEquals("This is a resource loaded from classpath.", line);
      line = reader.readLine();
      assertNull(line);
    }
  }

}


text:
package linkedin

import (
	"github.com/pebble/github-digest/Godeps/_workspace/src/golang.org/x/oauth2"
)

// Endpoint is LinkedIn's OAuth 2.0 endpoint.
var Endpoint = oauth2.Endpoint{
	AuthURL:  "https://www.linkedin.com/uas/oauth2/authorization",
	TokenURL: "https://www.linkedin.com/uas/oauth2/accessToken",
}


text:
This directory contains both the server and client of ZetaSQL Helper. Its server imports ZetaSQL as
dependency and implements helper functions on top of it. The server and client communicate through RPC
service (gRPC). The server can be put into a Docker image, so it is OS independent.

This project is a prerequisite of the `auto_query_fixer` in the parent directory. Please make sure you have
installed this ZetaSQL Helper Docker image or downloaded from a Docker repository before using the query fixer.

## Prerequisite
This project requires `bazel` and `docker` on your machine. The version of `bazel` is 1.0.0. The `c++` standard
is c++1z.

If you haven't installed them, please refer to their documentations: [Bazel](https://docs.bazel.build/versions/master/install.html)
 and [Docker](https://docs.docker.com/get-docker/).

## Build the C++ server and its image.

If you hope to start the ZetaSQL Helper server locally, run this command:
```bash
bazel run //zetasql_helper/local_service:run_server
```

If you hope to build the server docker image, use the following command.

```bash
docker build . -t <docker-image-name>:<version>
```

For example, the current image stored in `gcr` is built as:

```bash
docker build . -t gcr.io/sql-gravity-internship/zetasql-helper:1.0
```

## Build java client

To build a light-weighted client jar
```bash
bazel build //java/com/google/bigquery/utils/zetasqlhelper:zetasql_helper_client
```

The built jar exists in `./bazel-bin/java/com/google/bigquery/utils/zetasqlhelper/zetasql_helper_client.jar`.

Copy the jar to your project. The client jar needs to be used with external dependencies.
Here is how to use it in Gradle:

```groovy
// Import the jar locally
implementation name: 'zetasql_helper_client'

// gRPC dependency used to set up RPC service
def JAVA_GRPC_VERSION = "1.18.0"
implementation "io.grpc:grpc-netty-shaded:" + JAVA_GRPC_VERSION
implementation "io.grpc:grpc-protobuf:" + JAVA_GRPC_VERSION
implementation "io.grpc:grpc-stub:" + JAVA_GRPC_VERSION

//docker-java used by the ZetaSQL Helper client
compile group: 'com.github.docker-java', name: 'docker-java-core', version: '3.2.5'
compile group: 'com.github.docker-java', name: 'docker-java-transport-httpclient5', version: '3.2.5'
```

Since `1.18.0` is a relatively old version, it may be overridden by a newer version when other dependencies
use the newer version of `gRPC` component in Gradle. Therefore, please try to increase `JAVA_GRPC_VERSION`
if an error pops out. `1.30.0` has been verified to be compatible with the client.

### Sample Usage

When you import the jar inside your project, you could call the RPC functions like this:
```java
QueryFunctionRange range =
        ZetaSqlHelper.extractFunctionRange(query, row, column);
```

You don't have to set up any connections to a server because the client will automatically check if a docker image
has started. If not, the client will pull the image, run it, and expose the port 50051.

Of course you could manually specify the docker image and the connection port like this:

```java
LocalServiceDockerProvider.setImage("your own ZetaSQL Helper Image");
int yourPort = 50052;
Client.setPort(yourPort);

// call the ZetaSQL Helper RPC functions
```

### Caution with Docker
Please make sure your program has enough permission to use docker. Before you start your program
with the ZetaSQL Helper client, try `docker ps` and see if the current user has the permission to use docker.
If not, please switch to a user or a group with enough permission.

## What functions does it provide and how do I add my own?
Please go to `zetasql_helper/local_service/local_service_rgrpc.h` to check all the RPC functions. Also you
could check their client caller in `java/com/google/bigquery/utils/zetasqlhelper/ZetaSqlHelper.java`.

If you would like to develop your own RPC functions inside, please first add your RPC definition inside
`local_service.proto` at `zetasql_helper/local_service`. Then implement these methods in both the server
and client mentioned above.


text:
package org.jboss.resteasy.test.resource.basic;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.test.resource.basic.resource.CovariantReturnSubresourceLocatorsRootProxy;
import org.jboss.resteasy.test.resource.basic.resource.CovariantReturnSubresourceLocatorsSubProxy;
import org.jboss.resteasy.test.resource.basic.resource.CovariantReturnSubresourceLocatorsSubProxyRootImpl;
import org.jboss.resteasy.test.resource.basic.resource.CovariantReturnSubresourceLocatorsSubProxySubImpl;
import org.jboss.resteasy.util.HttpResponseCodes;
import org.jboss.resteasy.utils.PortProviderUtil;
import org.jboss.resteasy.utils.TestUtil;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

import javax.ws.rs.core.Response;

/**
 * @tpSubChapter Resources
 * @tpChapter Integration tests
 * @tpTestCaseDetails Test return value of covariant with locators.
 * @tpSince RESTEasy 3.0.16
 */
@RunWith(Arquillian.class)
@RunAsClient
public class CovariantReturnSubresourceLocatorsTest {

    @Deployment
    public static Archive<?> deployUriInfoSimpleResource() {
        WebArchive war = TestUtil.prepareArchive(CovariantReturnSubresourceLocatorsTest.class.getSimpleName());
        war.addClasses(CovariantReturnSubresourceLocatorsRootProxy.class, CovariantReturnSubresourceLocatorsSubProxy.class);
        return TestUtil.finishContainerPrepare(war, null, CovariantReturnSubresourceLocatorsSubProxyRootImpl.class,
                CovariantReturnSubresourceLocatorsSubProxySubImpl.class);
    }

    /**
     * @tpTestDetails Test basic path
     * @tpSince RESTEasy 3.0.16
     */
    @Test
    public void basicTest() {
        ResteasyClient client = new ResteasyClientBuilder().build();
        Response response = client.target(PortProviderUtil.generateURL("/path/sub/xyz",
                CovariantReturnSubresourceLocatorsTest.class.getSimpleName())).request().get();
        Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
        Assert.assertEquals("Wrong content of response", "Boo! - xyz", response.readEntity(String.class));
        response.close();
        client.close();
    }
}


text:
package sampleclean.clean

import org.apache.spark.{SparkContext, SparkConf}
import sampleclean.api.SampleCleanContext
import sys.process._

trait RemoteSCContext extends Serializable {

  def withSampleCleanContext[T](f: SampleCleanContext => T): T = {
    val master = ("cat /root/ephemeral-hdfs/conf/masters" !!).trim()
    val conf = new SparkConf()
      .setMaster("spark://" + master + ":7077")
      .setAppName("test")
      //.set("spark.driver.allowMultipleContexts","true")
    val sc = new SparkContext(conf)
    val scc = new SampleCleanContext(sc)
    try {
      f(scc)
    } finally {
      sc.stop()
    }
  }

  def withFullRecords[T](sample:Int, f: SampleCleanContext => T): T = {
    val master = ("cat /root/ephemeral-hdfs/conf/masters" !!).trim()
    val conf = new SparkConf()
      .setMaster("spark://" + master + ":7077")
      .setAppName("test")
      //.set("spark.driver.allowMultipleContexts","true")
    val sc = new SparkContext(conf)
    val scc = new SampleCleanContext(sc)
    val context = List("id") ++ (0 until 20).toList.map("col" + _.toString)

    val contextString = context.mkString(" String,") + " String"
    val hiveContext = scc.getHiveContext()
    scc.closeHiveSession()
    scc.hql("DROP TABLE IF EXISTS test")
    scc.hql("CREATE TABLE IF NOT EXISTS test(%s) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' LINES TERMINATED BY '\\n'".format(contextString))
    scc.hql("LOAD DATA INPATH 'hdfs://%s:9000/csvJaccard100000dups' OVERWRITE INTO TABLE test".format(master))
    scc.initializeConsistent("test", "test_sample", "id", sample)

    try {
      f(scc)
    } finally {
      sc.stop()
    }
  }
}