<commit_before>package protocol

import (
	"koding/kites/kloud/eventer"
	"koding/kites/kloud/machinestate"
)

// Provider manages a machine, it's start/stop/destroy/restart a machine.
type Provider interface {
	// Build the machine and creates an artifact that can be pass to other
	// methods
	Build(*Machine) (*Artifact, error)

	// Start starts the machine
	Start(*Machine) (*Artifact, error)

	// Stop stops the machine
	Stop(*Machine) error

	// Restart restarts the machine
	Restart(*Machine) error

	// Reinit destroys and builds the machine, basically re initializes
	// the machine to a new and clean state.
	Reinit(*Machine) (*Artifact, error)

	// Destroy destroys the machine
	Destroy(*Machine) error

	// Resize the machine and creates an artifact that can be pass to other
	// methods
	Resize(*Machine) (*Artifact, error)

	// Info returns full information about a single machine
	Info(*Machine) (*InfoArtifact, error)
}

// Domainer is responsible of managing DNS records
type Domainer interface {
	// Create creates a new domain record with the given name to the new IP
	Create(name, newIP string) error

	// Delete deletes the given domain name which was associated to the old IP
	Delete(name, oldIP string) error

	// Update updates the given domain name which was associated to the old IP
	// with the new IP
	Update(name, oldIP, newIP string) error

	// Rename renames the given old domain name with the new domain name for
	// the given IP
	Rename(oldName, newName, currentIp string) error

	// Get returns a domain record for the given domain name
	Get(name string) (*Record, error)

	// HostedZone returns the top level domain on which the domains are going
	// to be handled. Such as dev.koding.io or koding.io
	HostedZone() string

	// Validate validates if the given domain name is valid
	Validate(domainName, username string) error
}

// Record represents a single record for a given domain
type Record struct {
	Name string
	IP   string
	TTL  int
}

// Domain represents a machines domain necessary information
type Domain struct {
	// MachineId defines the ID of the respective machine. Each domain is bound
	// to a single machine.
	MachineId string
	Name      string
}

// Machine is used as a data source for the appropriate interfaces
// provided by the Kloud package. A context is gathered by the Storage
// interface.
type Machine struct {
	// Id defines a unique ID in which the build informations are fetched from.
	// Is is used to gather the Username, ImageName, InstanceName etc..  For
	// example it could be a mongodb object id that would point to a document
	// that carries those informations or a key for a key/value storage.
	Id string<commit_msg>kloud/protocol: add a new OriginId field<commit_after>package protocol

import (
	"koding/kites/kloud/eventer"
	"koding/kites/kloud/machinestate"
)

// Provider manages a machine, it's start/stop/destroy/restart a machine.
type Provider interface {
	// Build the machine and creates an artifact that can be pass to other
	// methods
	Build(*Machine) (*Artifact, error)

	// Start starts the machine
	Start(*Machine) (*Artifact, error)

	// Stop stops the machine
	Stop(*Machine) error

	// Restart restarts the machine
	Restart(*Machine) error

	// Reinit destroys and builds the machine, basically re initializes
	// the machine to a new and clean state.
	Reinit(*Machine) (*Artifact, error)

	// Destroy destroys the machine
	Destroy(*Machine) error

	// Resize the machine and creates an artifact that can be pass to other
	// methods
	Resize(*Machine) (*Artifact, error)

	// Info returns full information about a single machine
	Info(*Machine) (*InfoArtifact, error)
}

// Domainer is responsible of managing DNS records
type Domainer interface {
	// Create creates a new domain record with the given name to the new IP
	Create(name, newIP string) error

	// Delete deletes the given domain name which was associated to the old IP
	Delete(name, oldIP string) error

	// Update updates the given domain name which was associated to the old IP
	// with the new IP
	Update(name, oldIP, newIP string) error

	// Rename renames the given old domain name with the new domain name for
	// the given IP
	Rename(oldName, newName, currentIp string) error

	// Get returns a domain record for the given domain name
	Get(name string) (*Record, error)

	// HostedZone returns the top level domain on which the domains are going
	// to be handled. Such as dev.koding.io or koding.io
	HostedZone() string

	// Validate validates if the given domain name is valid
	Validate(domainName, username string) error
}

// Record represents a single record for a given domain
type Record struct {
	Name string
	IP   string
	TTL  int
}

// Domain represents a machines domain necessary information
type Domain struct {
	// OriginId defines a unique ID that represents an ownership. There might
	// be several domains each with the same OriginId, which means they all
	// belong to a user.
	OriginId string

	// MachineId defines the ID of the respective machine. Each domain is bound
	// to a single machine.
	MachineId string

	// Name is the domain name, such as "arslan.koding.io" or
	// "fatih.arslan.koding.io"
	Name string
}

// Machine is used as a data source for the appropriate interfaces
// provided by the Kloud package. A context is gathered by the Storage
// interface.
type Machine struct {
	// Id defines a unique ID in which the build informations are fetched from.
	// Is is used to gather the Username, ImageName, InstanceName etc..  For
	// example it could be a mongodb object id that would point to a document
	// that carries those informations or a key for a key/value storage.
	Id string
{'fraction_non_alphanumeric': 0.06912928759894459, 'fraction_numerical': 0.0, 'mean_word_length': 3.5966046887631364, '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': '3512303', 'n_tokens_mistral': 1589, 'n_tokens_neox': 1541, 'n_words': 781}