<commit_before>package neustar

import (
	"encoding/json"
	"fmt"
	"net/http"
)

const (
	// MonitorURI is the endpoint for calls to the monitoring API
	ScriptURI = "alert/1.0"

	// PolicyURI is the endpoint for policy calls
	PolicyURI = "/policy"
)

// Script holds a representation of a script
type Script struct {
	ID      string `json:"id"`
	Version string `json:"version"`
	Name    string `json:"name"`
}

// ScriptingListResponse holds the response from the list endpoint
type ScriptingListResponse struct {
	// The name of the alert policy
	Name string `json:"name"`

	// The ID of the alert policy
	ID string `json:"id"`

	// The description of the alert policy
	Description string `json:"description"`

	// This flag will return true if the policy is an Advanced Alert Policy
	AdvancedEdit bool `json:"advancedEdit"`

	// The email addresses associated with the alert policy
	EmailAddress []string `json:"emailAddresses"`

	// The number of strikes before triggering an alert.
	Strikes int `json:"strikes"`

	ScriptInput          interface{} `json:"scriptInput"`
	EscalationPolicy     interface{} `json:"escalationPolicy"`
	FeedIDs              interface{} `json:"feedIds"`
	PagerDutyServiceKey  interface{} `json:"pagerDutyServiceKey"`
	PagerDutyConnectName interface{} `json:"pagerDutyConnectionName"`
	PagerDutyAccount     interface{} `json:"pagerDutyAccount"`
	SMS                  interface{} `json:"sms"`
	PolicyGroup          interface{} `json:"policyGroup"`
	History              interface{} `json:"history"`
	AccountID            string      `json:"accountId"`
	AlertType            interface{} `json:"alertType"`
	ScriptBody           string      `json:"scriptBody"`
	LastUser             string      `json:"lastUser"`
	Created              string      `json:"created"`
	InUse                bool        `json:"inUse"`
	Modified             string      `json:"modified"`
	LatestVersion        string      `json:"latestVersion"`
}

// ScriptCreateParameters holds the parameters passed in to
// create a new script
type ScriptCreateParameters struct {
	// The name of the alert policy
	Name string `json:"name"`

	// An array of comma-separated email addresses
	// associated with the alert policy e.g. ["<EMAIL>","<EMAIL>"].
	EmailAddresses []string `json:"emailAddresses"`

	// The number of strikes before triggering an alert.
	Strikes int `json:"strikes"`

	// A description for the alert policy
	Description string `json:"description"`
}

// Scripting holds scripting config
type Scripting struct {
	config *Configuration
}

// NewScript creates a new Scripting object
func NewScript(key, secret string) *Scripting {
	return &Scripting{
		config: LoadConfig(key, secret),
	}
}

// Create creates a new Alert policy
func (s *Scripting) Create() {}

// List retrieves a list of policies ordered by date in descending order.
func (s *Scripting) List() ([]Script, int, error) {
	var response *http.Response
	var data map[string]map[string][]ScriptingListRepsonse
	response, err := http.Get(fmt.Sprintf("%s%s?apikey=%s&sig=%s", BaseURL, ScriptURI, s.config.API.Key, s.config.DigitalSignature()))
	if err != nil {
		return nil, response.StatusCode, err
	}
	defer response.Body.Close()
	if err := json.NewDecoder(response.Body).Decode(&data); err != nil {
		return nil, response.StatusCode, err
	}
	return data["data"]["items"], response.StatusCode, nil
}<commit_msg>additinal work towards scripting functionality<commit_after>package neustar

import (
	"encoding/json"
	"fmt"
	"net/http"
)

const (
	// ScriptURI is the endpoint for calls to the scripting API
	ScriptURI = "alert/1.0"

	// PolicyURI is the endpoint for policy calls
	PolicyURI = "/policy"
)

// Strikes is a slice of valid strikes
var Strikes = []int{1, 2, 3}

// Script holds a representation of a script
type Script struct {
	ID      string `json:"id"`
	Version string `json:"version"`
	Name    string `json:"name"`
}

// ScriptingListResponse holds the response from the list endpoint
type ScriptingListResponse struct {
	// The name of the alert policy
	Name string `json:"name"`

	// The ID of the alert policy
	ID string `json:"id"`

	// The description of the alert policy
	Description string `json:"description"`

	// This flag will return true if the policy is an Advanced Alert Policy
	AdvancedEdit bool `json:"advancedEdit"`

	// The email addresses associated with the alert policy
	EmailAddress []string `json:"emailAddresses"`

	// The number of strikes before triggering an alert.
	Strikes int `json:"strikes"`

	ScriptInput          interface{} `json:"scriptInput"`
	EscalationPolicy     interface{} `json:"escalationPolicy"`
	FeedIDs              interface{} `json:"feedIds"`
	PagerDutyServiceKey  interface{} `json:"pagerDutyServiceKey"`
	PagerDutyConnectName interface{} `json:"pagerDutyConnectionName"`
	PagerDutyAccount     interface{} `json:"pagerDutyAccount"`
	SMS                  interface{} `json:"sms"`
	PolicyGroup          interface{} `json:"policyGroup"`
	History              interface{} `json:"history"`
	AccountID            string      `json:"accountId"`
	AlertType            interface{} `json:"alertType"`
	ScriptBody           string      `json:"scriptBody"`
	LastUser             string      `json:"lastUser"`
	Created              string      `json:"created"`
	InUse                bool        `json:"inUse"`
	Modified             string      `json:"modified"`
	LatestVersion        string      `json:"latestVersion"`
}

// ScriptCreateParameters holds the parameters passed in to
// create a new script
type ScriptCreateParameters struct {
	// The name of the alert policy
	Name string `json:"name"`

	// An array of comma-separated email addresses
	// associated with the alert policy e.g. ["<EMAIL>","<EMAIL>"].
	EmailAddresses []string `json:"emailAddresses"`

	// The number of strikes before triggering an alert.
	Strikes int `json:"strikes"`

	// A description for the alert policy
	Description string `json:"description"`
}

// Scripting holds scripting config
type Scripting struct {
	config *Configuration
}

// NewScript creates a new Scripting object
func NewScript(key, secret string) *Scripting {
	return &Scripting{
		config: LoadConfig(key, secret),
	}
}

// ScriptDataResponse holds the return from the API list call
type ScriptDataResponse struct {
	Data struct {
		Total  int                     `json:"total"`
		Offset int                     `json:"offset"`
		More   bool                    `json:"more"`
		Items  []ScriptingListResponse `json:"items"`
	} `json:"data"`
}

// Create creates a new Alert policy
func (s *Scripting) Create() {}

// List retrieves a list of policies ordered by date in descending order.
func (s *Scripting) List() ([]ScriptingListResponse, int, error) {
	var response *http.Response
	var data ScriptDataResponse
	response, err := http.Get(fmt.Sprintf("%s%s?apikey=%s&sig=%s", BaseURL, ScriptURI, s.config.API.Key, s.config.DigitalSignature()))
	if err != nil {
		return nil, response.StatusCode, err
	}
	defer response.Body.Close()
	if err := json.NewDecoder(response.Body).Decode(&data); err != nil {
		return nil, response.StatusCode, err
	}
	return data.Data.Items, response.StatusCode, nil
}

// ValidStrikes makes sure that the given strike is valid
func ValidStrikes(strike int) bool {
	for _, i := range Strikes {
		if i == strike {
			return true
		}
	}
	return false
}
{'fraction_non_alphanumeric': 0.10925170068027211, 'fraction_numerical': 0.0009523809523809524, 'mean_word_length': 3.4795856185252894, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3982242', 'n_tokens_mistral': 2126, 'n_tokens_neox': 2062, 'n_words': 711}