<commit_before>package api

import (
	"encoding/json"
	"fmt"
	"strings"

	"github.com/boltdb/bolt"
	uuid "github.com/satori/go.uuid"

	"github.com/TykTechnologies/tyk-cli/db"
	"github.com/TykTechnologies/tyk/apidef"
)

type APIDef struct {
	id            string
	name          string
	item          db.Item
	APIModel      APIModel
	APIDefinition apidef.APIDefinition
}

type APIModel struct {
	schemaPath string
}

func (api *APIDef) setAPIDefinition() {
	api.APIDefinition.APIID = api.Id()
	api.APIDefinition.Name = api.Name()
}

func New(name string) *APIDef {
	api := APIDef{}
	api.id = strings.Replace(uuid.NewV4().String(), "-", "", -1)
	api.name = name
	return &api
}

func (api *APIDef) Id() string {
	return api.id
}

func (api *APIDef) Name() string {
	return api.name
}

func (api *APIDef) BucketName() string {
	return "apis"
}

func (api *APIDef) Group() string {
	return "API"
}

func (api *APIDef) RecordData() interface{} {
	api.setAPIDefinition()
	type rec struct {
		APIModel      APIModel             `json:"api_model"`
		APIDefinition apidef.APIDefinition `json:"api_definition"`
	}
	return rec{api.APIModel, api.APIDefinition}
}

// Create is a public function for creating staged APIs<commit_msg>Fix go.uuid usage<commit_after>package api

import (
	"encoding/json"
	"fmt"
	"strings"

	"github.com/boltdb/bolt"
	uuid "github.com/satori/go.uuid"

	"github.com/TykTechnologies/tyk-cli/db"
	"github.com/TykTechnologies/tyk/apidef"
)

type APIDef struct {
	id            string
	name          string
	item          db.Item
	APIModel      APIModel
	APIDefinition apidef.APIDefinition
}

type APIModel struct {
	schemaPath string
}

func (api *APIDef) setAPIDefinition() {
	api.APIDefinition.APIID = api.Id()
	api.APIDefinition.Name = api.Name()
}

func New(name string) *APIDef {
	api := APIDef{}
	id, _ := uuid.NewV4()
	api.id = strings.Replace(id.String(), "-", "", -1)
	api.name = name
	return &api
}

func (api *APIDef) Id() string {
	return api.id
}

func (api *APIDef) Name() string {
	return api.name
}

func (api *APIDef) BucketName() string {
	return "apis"
}

func (api *APIDef) Group() string {
	return "API"
}

func (api *APIDef) RecordData() interface{} {
	api.setAPIDefinition()
	type rec struct {
		APIModel      APIModel             `json:"api_model"`
		APIDefinition apidef.APIDefinition `json:"api_definition"`
	}
	return rec{api.APIModel, api.APIDefinition}
}

// Create is a public function for creating staged APIs
{'fraction_non_alphanumeric': 0.131374949000408, 'fraction_numerical': 0.0016319869441044472, 'mean_word_length': 3.482632541133455, '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': '5790368', 'n_tokens_mistral': 955, 'n_tokens_neox': 951, 'n_words': 213}