<commit_before>define(function (require) {
  "use strict";

  var globals = require('globals'),
    stores = require('stores'),
    $ = require('jquery'),
    Utils = require('../Utils');

  return {

    requestImage: function(params){
      if(!params.instance) throw new Error("Missing instance");
      if(!params.name) throw new Error("Missing name");
      if(!params.description) throw new Error("Missing description");
      if(!params.tags) throw new Error("Missing tags");
      if(params.versionFork == undefined) throw new Error("Missing create/update flag(fork)");
      if(!params.versionName) throw new Error("Missing name");
      if(!params.versionChanges) throw new Error("Missing description");
      if(!params.providerId) throw new Error("Missing providerId");
      //if(!params.software) throw new Error("Missing software");
      //if(!params.filesToExclude) throw new Error("Missing filesToExclude");
      //if(!params.systemFiles) throw new Error("Missing systemFiles");
      if(!params.scripts) throw new Error("Missing scripts");
      if(!params.licenses) throw new Error("Missing licenses");
      if(!params.visibility) throw new Error("Missing visibility");
      if(!params.imageUsers) throw new Error("Missing imageUsers");


      var instance = params.instance,
          name = params.name,
          description = params.description,
          providerId = params.providerId,
          software = params.software,
          filesToExclude = params.filesToExclude,
          fork = params.versionFork,
          versionName = params.versionName,
          versionChanges = params.versionChanges,
          systemFiles = params.systemFiles || "[no files specified]",
          visibility = params.visibility,
          scripts = params.scripts,
          licenses = params.licenses,
          imageUsers = params.imageUsers,
          userNames = imageUsers.map(function(user){
            return user.get('username');
          }),
          tags = params.tags,
          tagNames = tags.map(function(tag){
            return tag.get('name');
          }),
          provider = stores.ProviderStore.get(providerId);

      var requestData = {
        fork: fork,
        name: name,
        description: description,
        tags: tagNames,
        instance: instance.get('uuid'),
        ip_address: instance.get("ip_address"),
        provider: provider.get('uuid'),
        version_name: versionName,
        version_changes: versionChanges,
        vis: visibility,
        shared_with: userNames,
        exclude: filesToExclude || "[no files specified]",
        software: software || "[no software specified]",
        sys: systemFiles || "[no files specified]",
        licenses: licenses,
        scripts: scripts
      };

      var requestUrl = (
        globals.API_ROOT +
        "/provider/" + instance.get('provider').uuid +
        "/identity/" + instance.get('identity').uuid +
        "/request_image"
      );

      $.ajax({
        url: requestUrl,
        type: 'POST',
        data: JSON.stringify(requestData),
        dataType: 'json',<commit_msg>finish fixing merge conflicts. send proper fields in POST request<commit_after>define(function (require) {
  "use strict";

  var globals = require('globals'),
    stores = require('stores'),
    $ = require('jquery'),
    Utils = require('../Utils');

  return {

    requestImage: function(params){
      if(!params.instance) throw new Error("Missing instance");
      if(!params.name) throw new Error("Missing name");
      if(!params.description) throw new Error("Missing description");
      if(!params.tags) throw new Error("Missing tags");
      if(params.versionFork == undefined) throw new Error("Missing create/update flag(fork)");
      if(!params.versionName) throw new Error("Missing name");
      if(!params.versionChanges) throw new Error("Missing description");
      if(!params.providerId) throw new Error("Missing providerId");
      //if(!params.software) throw new Error("Missing software");
      //if(!params.filesToExclude) throw new Error("Missing filesToExclude");
      //if(!params.systemFiles) throw new Error("Missing systemFiles");
      if(!params.scripts) throw new Error("Missing scripts");
      if(!params.licenses) throw new Error("Missing licenses");
      if(!params.visibility) throw new Error("Missing visibility");
      if(!params.imageUsers) throw new Error("Missing imageUsers");


      var instance = params.instance.get('id'),
          name = params.name,
          description = params.description,
          minMem = params.minMem,
          minStorage = params.minStorage,
          providerId = params.providerId,
          identity = params.identity,
          software = params.software || "[no files specified]",
          filesToExclude = params.filesToExclude || "[no files specified]",
          fork = params.versionFork,
          versionName = params.versionName,
          newMachineOwner = params.newMachineOwner,
          versionChanges = params.versionChanges,
          systemFiles = params.systemFiles || "[no files specified]",
          visibility = params.visibility,
          scripts = params.scripts,
          licenses = params.licenses,
          imageUsers = params.imageUsers,
          userNames = imageUsers.map(function(user){
            return user.get('username');
          }),
          tags = params.tags,
          tagNames = tags.map(function(tag){
            return tag.get('name');
          }),
          provider = stores.ProviderStore.get(providerId);


      var requestData = {
        access_list: userNames,
        exclude_files: filesToExclude,
        installed_software: software,
        instance: instance,
        identity: identity,
        iplant_sys_files: systemFiles,
        new_application_description: description,
        new_application_name: name,
        new_version_memory_min: minMem,
        new_version_storage_min: minStorage,
        new_application_visibility: visibility,
        new_machine_owner: newMachineOwner,
        new_machine_provider: providerId,
        new_version_allow_imaging: true,
        new_version_change_log: versionChanges,
        new_version_forked: fork,
        new_version_name: versionName,
        tags: tagNames
      };

      var requestUrl = (
        globals.API_V2_ROOT + "/machine_requests" 
      );

      $.ajax({
        url: requestUrl,
        type: 'POST',
        data: JSON.stringify(requestData),
        dataType: 'json',
{'fraction_non_alphanumeric': 0.11789117737473102, 'fraction_numerical': 0.0001537042729787888, 'mean_word_length': 2.686685552407932, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3015146', 'n_tokens_mistral': 1663, 'n_tokens_neox': 1631, 'n_words': 405}