<commit_before>#Common class with methods used for interaction with dtk server

require 'rubygems'
require 'rest_client'
require 'pp'
require 'json'
require 'awesome_print'

STDOUT.sync = true

class DtkCommon

	$success == true
	attr_accessor :assembly_name, :assembly_template, :SERVER, :PORT, :ENDPOINT, :USERNAME, :PASSWORD, :success, :error_message
	attr_accessor :component_module_id_list

	$opts = {
		:timeout => 100,
		:open_timeout => 50,
		:cookies => {}
	}

	def initialize(assembly_name, assembly_template)
		@assembly_name = assembly_name
		@assembly_template = assembly_template
		@SERVER = 'dev10.r8network.com'
		@PORT = 7000
		@ENDPOINT = "http://dev10.r8network.com:7000"
		@USERNAME = 'dtk10'
		@PASSWORD = '<PASSWORD>'

		#used as placeholder for component ids for specific module that are accumulated
		@component_module_id_list = Array.new()

		#Login to dtk application
		response_login = RestClient.post(@ENDPOINT + '/rest/user/process_login', 'username' => @USERNAME, 'password' => @PASSWORD, 'server_host' => @SERVER, 'server_port' => @PORT)

		$cookies = response_login.cookies
		$opts[:cookies] = response_login.cookies
	end

	def send_request(path, body)
		resource = RestClient::Resource.new(@ENDPOINT + path, $opts)
		response = resource.post(body)
		response_JSON = JSON.parse(response)

		#If response contains errors, accumulate all errors to error_message
		unless response_JSON["errors"].nil? 
			@error_message = ""<commit_msg>Config change - no_build<commit_after>#Common class with methods used for interaction with dtk server

require 'rubygems'
require 'rest_client'
require 'pp'
require 'json'
require 'awesome_print'

STDOUT.sync = true

class DtkCommon

	$success == true
	attr_accessor :assembly_name, :assembly_template, :SERVER, :PORT, :ENDPOINT, :USERNAME, :PASSWORD, :success, :error_message
	attr_accessor :component_module_id_list

	$opts = {
		:timeout => 100,
		:open_timeout => 50,
		:cookies => {}
	}

	def initialize(assembly_name, assembly_template)
		@assembly_name = assembly_name
		@assembly_template = assembly_template
		#@SERVER = 'dev10.r8network.com'
		#@PORT = 7000
		#@ENDPOINT = "http://dev10.r8network.com:7000"
		#@USERNAME = 'dtk10'
		#@PASSWORD = '<PASSWORD>'

		#Tenant9
		@SERVER = 'dev9.r8network.com'
		@PORT = 3001
		@ENDPOINT = "http://dev9.r8network.com:3001"
		@USERNAME = 'dtk9'
		@PASSWORD = '<PASSWORD>'

		#used as placeholder for component ids for specific module that are accumulated
		@component_module_id_list = Array.new()

		#Login to dtk application
		response_login = RestClient.post(@ENDPOINT + '/rest/user/process_login', 'username' => @USERNAME, 'password' => @PASSWORD, 'server_host' => @SERVER, 'server_port' => @PORT)

		$cookies = response_login.cookies
		$opts[:cookies] = response_login.cookies
	end

	def send_request(path, body)
		resource = RestClient::Resource.new(@ENDPOINT + path, $opts)
		response = resource.post(body)
		response_JSON = JSON.parse(response)

		#If response contains errors, accumulate all errors to error_message
		unless response_JSON["errors"].nil? 
			@error_message = ""
{'fraction_non_alphanumeric': 0.12286359238955176, 'fraction_numerical': 0.01805869074492099, 'mean_word_length': 5.179282868525896, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 20, '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': '1321895', 'n_tokens_mistral': 1127, 'n_tokens_neox': 1018, 'n_words': 249}