<commit_before>//  Copyright 2014 Rackspace, Inc.
//
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing,
//  software distributed under the License is distributed on an "AS
//  IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
//  express or implied. See the License for the specific language
//  governing permissions and limitations under the License.

/*
 *  ZeroVM on Swift (Zwift) client.
 */
function ZwiftClient(authUrl, username, password, tenant) {
    this._authUrl = authUrl;
    this._username = username;
    this._password = password;
    this._tenant = tenant;

    this._token = null;
    this._swiftUrl = null;
}

/*
 * Authenticate to Keystone. This will login to Keystone and obtain an
 * authentication token. Call this before calling other methods that
 * talk with Swift.
 *
 * If Keystone and Swift are served from differnet domains, you must
 * install a CORS (Cross-Origin Resource Sharing) middleware in Swift.
 * Otherwise the authentication requests made by this function wont be
 * allowed by the browser.
 */
ZwiftClient.prototype.auth = function (success) {
    var headers = {'Content-Type': 'application/json',
                   'Accept': 'application/json'};
    var payload = {'auth':
                   {'tenantName': this._tenant,
                    'passwordCredentials':
                    {'username': this._username,<commit_msg>templates/zebra: refactor auth into a _auth2 method<commit_after>//  Copyright 2014 Rackspace, Inc.
//
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing,
//  software distributed under the License is distributed on an "AS
//  IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
//  express or implied. See the License for the specific language
//  governing permissions and limitations under the License.

/*
 *  ZeroVM on Swift (Zwift) client.
 */
function ZwiftClient(authUrl, username, password, tenant) {
    this._authUrl = authUrl;
    this._username = username;
    this._password = password;
    this._tenant = tenant;

    this._token = null;
    this._swiftUrl = null;
}

/*
 * Authenticate to Keystone. Call this before calling other methods
 * that talk with Swift.
 *
 * If Keystone and Swift are served from differnet domains, you must
 * install a CORS (Cross-Origin Resource Sharing) middleware in Swift.
 * Otherwise the authentication requests made by this function wont be
 * allowed by the browser.
 */
ZwiftClient.prototype.auth = function (success) {
    this._auth2(success);
}

/*
 * Swift v2 authentication. This will login to Keystone and obtain an
 * authentication token.
 */
ZwiftClient.prototype._auth2 = function (success) {
    var headers = {'Content-Type': 'application/json',
                   'Accept': 'application/json'};
    var payload = {'auth':
                   {'tenantName': this._tenant,
                    'passwordCredentials':
                    {'username': this._username,
{'fraction_non_alphanumeric': 0.09491822429906542, 'fraction_numerical': 0.005841121495327103, 'mean_word_length': 2.945852534562212, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, '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': '1329100', 'n_tokens_mistral': 925, 'n_tokens_neox': 900, 'n_words': 370}