<commit_before>import Foundation
import SWXMLHash

public struct PlatformApplications {
    public let nextToken: String?
    public let applicationArns: [String]
    
    init?(xml: XMLIndexer) {
        let responseXml = xml["ListPlatformApplicationsResponse"]["ListPlatformApplicationsResult"]
        let optionalArns = responseXml["PlatformApplications"]["member"].all.map { $0["PlatformApplicationArn"].element?.text }
        
        guard let applicationArns = optionalArns as? [String] else { return nil }
        self.applicationArns = applicationArns
        nextToken = responseXml["NextToken"].element?.text
    }
}

public struct PlatformApplicationEnpoints {
    public let nextToken: String?
    public let endpoints: [Endpoint]
    
    init?(xml: XMLIndexer) {
        let responseXml = xml["ListEndpointsByPlatformApplicationResponse"]["ListEndpointsByPlatformApplicationResult"]
        let optionalEndpoints = responseXml["Endpoints"]["member"].all.map { endpointXml in
            return Endpoint(xml: endpointXml)
        }
        
        guard let endpoints = optionalEndpoints as? [Endpoint] else { return nil }
        self.endpoints = endpoints
        nextToken = responseXml["NextToken"].element?.text
    }
}

public struct Endpoint {
    public let arn: String
    public let enabled: Bool
    
    init?(xml: XMLIndexer) {
        let enabledXml = xml["Attributes"]["entry"].all.filter { $0["key"].element?.text == "Enabled" }
        guard let arn = xml["EndpointArn"].element?.text,
            let enabled = enabledXml.first?["value"].element?.text else { return nil }
        
        self.arn = arn
        self.enabled = enabled == "true"
    }
}

public struct EndpointAttributes {
    public let attributes: [String : String]
    
    init?(xml: XMLIndexer) {
        let attributesXml = xml["GetEndpointAttributesResponse"]["GetEndpointAttributesResult"]["Attributes"]
        var attributes = [String : String]()
        attributesXml["entry"].all.forEach {
            guard let key = $0["key"].element?.text,
                let value = $0["value"].element?.text else { return }
            attributes[key] = value
        }<commit_msg>Add token to endpoint model<commit_after>import Foundation
import SWXMLHash

public struct PlatformApplications {
    public let nextToken: String?
    public let applicationArns: [String]
    
    init?(xml: XMLIndexer) {
        let responseXml = xml["ListPlatformApplicationsResponse"]["ListPlatformApplicationsResult"]
        let optionalArns = responseXml["PlatformApplications"]["member"].all.map { $0["PlatformApplicationArn"].element?.text }
        
        guard let applicationArns = optionalArns as? [String] else { return nil }
        self.applicationArns = applicationArns
        nextToken = responseXml["NextToken"].element?.text
    }
}

public struct PlatformApplicationEnpoints {
    public let nextToken: String?
    public let endpoints: [Endpoint]
    
    init?(xml: XMLIndexer) {
        let responseXml = xml["ListEndpointsByPlatformApplicationResponse"]["ListEndpointsByPlatformApplicationResult"]
        let optionalEndpoints = responseXml["Endpoints"]["member"].all.map { endpointXml in
            return Endpoint(xml: endpointXml)
        }
        
        guard let endpoints = optionalEndpoints as? [Endpoint] else { return nil }
        self.endpoints = endpoints
        nextToken = responseXml["NextToken"].element?.text
    }
}

public struct Endpoint {
    public let arn: String
    public let enabled: Bool
    public let token: String
    
    init?(xml: XMLIndexer) {
        let enabledXml = xml["Attributes"]["entry"].all.filter { $0["key"].element?.text == "Enabled" }
        let tokenXml = xml["Attributes"]["entry"].all.filter { $0["key"].element?.text == "Token" }
        guard let arn = xml["EndpointArn"].element?.text,
            let enabled = enabledXml.first?["value"].element?.text,
            let token = tokenXml.first?["value"].element?.text else { return nil }
        
        self.arn = arn
        self.enabled = enabled == "true"
        self.token = token
    }
}

public struct EndpointAttributes {
    public let attributes: [String : String]
    
    init?(xml: XMLIndexer) {
        let attributesXml = xml["GetEndpointAttributesResponse"]["GetEndpointAttributesResult"]["Attributes"]
        var attributes = [String : String]()
        attributesXml["entry"].all.forEach {
            guard let key = $0["key"].element?.text,
                let value = $0["value"].element?.text else { return }
            attributes[key] = value
        }
{'fraction_non_alphanumeric': 0.11326086956521739, 'fraction_numerical': 0.001956521739130435, 'mean_word_length': 3.011333914559721, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 21}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5754631', 'n_tokens_mistral': 1183, 'n_tokens_neox': 1197, 'n_words': 290}