<commit_before>package implementation

import (
	"net/http"
	runtime "github.com/go-openapi/runtime"
	middleware "github.com/go-openapi/runtime/middleware"

	"../restapi/operations/subscribers"
	"../models"
	"fmt"
	"math/rand"
	"strconv"
	"os"
    "regexp"
    "strings"
    "os/exec"
)

type LocalESEndpoint models.ESEndpoint
type LocalRMQEndpoint models.RMQEndpoint

type IEndpoint interface {
	getInjectableString(subId string) string
}

type SubscribeOk struct {

    // In: body
	subscriptionId string
}


type UnSubscribeOk struct {
}

type SubscribeManyOk struct {

    // In: body
	subscriptionIds []string
}

// WriteResponse to the client
func (o SubscribeOk) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {

    rw.WriteHeader(200)
	if err := producer.Produce(rw, o.subscriptionId); err != nil {
		panic(err) // let the recovery middleware deal with this
    }
}

func (o UnSubscribeOk) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {

    rw.WriteHeader(200)
	if err := producer.Produce(rw, "ok"); err != nil {
		panic(err) // let the recovery middleware deal with this
    }
}

func (o SubscribeManyOk) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {

    rw.WriteHeader(200)
	if err := producer.Produce(rw, o.subscriptionIds); err != nil {
		panic(err) // let the recovery middleware deal with this
    }
}

func (endpoint LocalESEndpoint) getInjectableString(subId string) string {
	template := `
# SUBID %s
  elasticsearch {
    hosts => ["%s:%v"]
    user => %s
    password => %s
  }
# ENDOF %s
}`
  return fmt.Sprintf(template, subId, endpoint.IP, endpoint.Port, endpoint.User, endpoint.Password, subId)
}

func (endpoint LocalRMQEndpoint) getInjectableString(subId string) string {
	template := `
# SUBID %s
  rabbitmq {
    key => "%s"<commit_msg>Added channel to elasticsearch (#173)<commit_after>package implementation

import (
	"net/http"
	runtime "github.com/go-openapi/runtime"
	middleware "github.com/go-openapi/runtime/middleware"

	"../restapi/operations/subscribers"
	"../models"
	"fmt"
	"math/rand"
	"strconv"
	"os"
    "regexp"
    "strings"
    "os/exec"
)

type LocalESEndpoint models.ESEndpoint
type LocalRMQEndpoint models.RMQEndpoint

type IEndpoint interface {
	getInjectableString(subId string) string
}

type SubscribeOk struct {

    // In: body
	subscriptionId string
}


type UnSubscribeOk struct {
}

type SubscribeManyOk struct {

    // In: body
	subscriptionIds []string
}

// WriteResponse to the client
func (o SubscribeOk) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {

    rw.WriteHeader(200)
	if err := producer.Produce(rw, o.subscriptionId); err != nil {
		panic(err) // let the recovery middleware deal with this
    }
}

func (o UnSubscribeOk) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {

    rw.WriteHeader(200)
	if err := producer.Produce(rw, "ok"); err != nil {
		panic(err) // let the recovery middleware deal with this
    }
}

func (o SubscribeManyOk) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {

    rw.WriteHeader(200)
	if err := producer.Produce(rw, o.subscriptionIds); err != nil {
		panic(err) // let the recovery middleware deal with this
    }
}

func (endpoint LocalESEndpoint) getInjectableString(subId string) string {
	template := `
# SUBID %s
  if "%s" in [channels] {
    elasticsearch {
      hosts => ["%s:%v"]
      user => %s
      password => %s
    }
  }
# ENDOF %s
}`
  return fmt.Sprintf(template, subId, endpoint.Channel, endpoint.IP, endpoint.Port, endpoint.User, endpoint.Password, subId)
}

func (endpoint LocalRMQEndpoint) getInjectableString(subId string) string {
	template := `
# SUBID %s
  rabbitmq {
    key => "%s"
{'fraction_non_alphanumeric': 0.1195069667738478, 'fraction_numerical': 0.005627009646302251, 'mean_word_length': 3.9053876478318004, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '6191690', 'n_tokens_mistral': 1267, 'n_tokens_neox': 1226, 'n_words': 316}