package configurations

import (
	"errors"

	"github.com/rackspace/gophercloud"
	"github.com/rackspace/gophercloud/openstack/db/v1/instances"
	"github.com/rackspace/gophercloud/pagination"
)

// List will list all of the available configurations.
func List(client *gophercloud.ServiceClient) pagination.Pager {
	pageFn := func(r pagination.PageResult) pagination.Page {
		return ConfigPage{pagination.SinglePageBase(r)}
	}

	return pagination.NewPager(client, baseURL(client), pageFn)
}

// CreateOptsBuilder is a top-level interface which renders a JSON map.
type CreateOptsBuilder interface {
	ToConfigCreateMap() (map[string]interface{}, error)
}

// DatastoreOpts is the primary options struct for creating and modifying
// how configuration resources are associated with datastores.
type DatastoreOpts struct {
	// [OPTIONAL] The type of datastore. Defaults to "MySQL".
	Type string

	// [OPTIONAL] The specific version of a datastore. Defaults to "5.6".
	Version string
}

// ToMap renders a JSON map for a datastore setting.
func (opts DatastoreOpts) ToMap() (map[string]string, error) {
	datastore := map[string]string{}

	if opts.Type != "" {
		datastore["type"] = opts.Type
	}

	if opts.Version != "" {
		datastore["version"] = opts.Version
	}

	return datastore, nil
}

// CreateOpts is the struct responsible for configuring new configurations.
type CreateOpts struct {
	// [REQUIRED] The configuration group name
	Name string

	// [REQUIRED] A map of user-defined configuration settings that will define
	// how each associated datastore works. Each key/value pair is specific to a
	// datastore type.
	Values map[string]interface{}

	// [OPTIONAL] Associates the configuration group with a particular datastore.
	Datastore *DatastoreOpts

	// [OPTIONAL] A human-readable explanation for the group.
	Description string
}

// ToConfigCreateMap casts a CreateOpts struct into a JSON map.
func (opts CreateOpts) ToConfigCreateMap() (map[string]interface{}, error) {
	if opts.Name == "" {
		return nil, errors.New("Name is a required field")
	}
	if len(opts.Values) == 0 {
		return nil, errors.New("Values must be a populated map")
	}

	config := map[string]interface{}{
		"name":   opts.Name,
		"values": opts.Values,
	}

	if opts.Datastore != nil {
		ds, err := opts.Datastore.ToMap()
		if err != nil {
			return config, err
		}
		config["datastore"] = ds
	}

	if opts.Description != "" {
		config["description"] = opts.Description
	}

	return map[string]interface{}{"configuration": config}, nil
}

// Create will create a new configuration group.
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult {
	var res CreateResult

	reqBody, err := opts.ToConfigCreateMap()
	if err != nil {
		res.Err = err
		return res
	}

	_, res.Err = client.Request("POST", baseURL(client), gophercloud.RequestOpts{
		OkCodes:      []int{201},
		JSONBody:     &reqBody,
		JSONResponse: &res.Body,
	})

	return res
}

// Get will retrieve the details for a specified configuration group.
func Get(client *gophercloud.ServiceClient, configID string) GetResult {
	var res GetResult

	_, res.Err = client.Request("GET", resourceURL(client, configID), gophercloud.RequestOpts{
		OkCodes:      []int{200},
		JSONResponse: &res.Body,
	})

	return res
}

// UpdateOptsBuilder is the top-level interface for casting update options into
// JSON maps.
type UpdateOptsBuilder interface {
	ToConfigUpdateMap() (map[string]interface{}, error)
}

// UpdateOpts is the struct responsible for modifying existing configurations.
type UpdateOpts struct {
	// [OPTIONAL] The configuration group name
	Name string

	// [OPTIONAL] A map of user-defined configuration settings that will define
	// how each associated datastore works. Each key/value pair is specific to a
	// datastore type.
	Values map[string]interface{}

	// [OPTIONAL] Associates the configuration group with a particular datastore.
	Datastore *DatastoreOpts

	// [OPTIONAL] A human-readable explanation for the group.
	Description string
}

// ToConfigUpdateMap will cast an UpdateOpts struct into a JSON map.
func (opts UpdateOpts) ToConfigUpdateMap() (map[string]interface{}, error) {
	config := map[string]interface{}{}

	if opts.Name != "" {
		config["name"] = opts.Name
	}

	if opts.Description != "" {
		config["description"] = opts.Description
	}

	if opts.Datastore != nil {
		ds, err := opts.Datastore.ToMap()
		if err != nil {
			return config, err
		}
		config["datastore"] = ds
	}

	if len(opts.Values) > 0 {
		config["values"] = opts.Values
	}

	return map[string]interface{}{"configuration": config}, nil
}

// Update will modify an existing configuration group by performing a merge
// between new and existing values. If the key already exists, the new value
// will overwrite. All other keys will remain unaffected.
func Update(client *gophercloud.ServiceClient, configID string, opts UpdateOptsBuilder) UpdateResult {
	var res UpdateResult

	reqBody, err := opts.ToConfigUpdateMap()
	if err != nil {
		res.Err = err
		return res
	}

	_, res.Err = client.Request("PATCH", resourceURL(client, configID), gophercloud.RequestOpts{
		OkCodes:      []int{200},
		JSONBody:     &reqBody,
		JSONResponse: &res.Body,
	})

	return res
}

// Replace will modify an existing configuration group by overwriting the
// entire parameter group with the new values provided. Any existing keys not
// included in UpdateOptsBuilder will be deleted.
func Replace(client *gophercloud.ServiceClient, configID string, opts UpdateOptsBuilder) ReplaceResult {
	var res ReplaceResult

	reqBody, err := opts.ToConfigUpdateMap()
	if err != nil {
		res.Err = err
		return res
	}

	_, res.Err = client.Request("PUT", resourceURL(client, configID), gophercloud.RequestOpts{
		OkCodes:      []int{202},
		JSONBody:     &reqBody,
		JSONResponse: &res.Body,
	})

	return res
}

// Delete will permanently delete a configuration group.
func Delete(client *gophercloud.ServiceClient, configID string) DeleteResult {
	var res DeleteResult

	_, res.Err = client.Request("DELETE", resourceURL(client, configID), gophercloud.RequestOpts{
		OkCodes: []int{202},
	})

	return res
}

// ListInstances will list all the instances associated with a particular
// configuration group.
func ListInstances(client *gophercloud.ServiceClient, configID string) pagination.Pager {
	pageFn := func(r pagination.PageResult) pagination.Page {
		return instances.InstancePage{pagination.LinkedPageBase{PageResult: r}}
	}
	return pagination.NewPager(client, instancesURL(client, configID), pageFn)
}

// ListDatastoreParams will list all the available and supported parameters
// that can be used for a particular datastore ID and a particular version.
// For example, if you are wondering how you can configure a MySQL 5.6 instance,
// you can use this operation (you will need to retrieve the MySQL datastore ID
// by using the datastores API).
func ListDatastoreParams(client *gophercloud.ServiceClient, datastoreID, versionID string) pagination.Pager {
	pageFn := func(r pagination.PageResult) pagination.Page {
		return ParamPage{pagination.SinglePageBase(r)}
	}
	return pagination.NewPager(client, listDSParamsURL(client, datastoreID, versionID), pageFn)
}

// GetDatastoreParam will retrieve information about a specific configuration
// parameter. For example, you can use this operation to understand more about
// "innodb_file_per_table" configuration param for MySQL datastores. You will
// need the param's ID first, which can be attained by using the ListDatastoreParams
// operation.
func GetDatastoreParam(client *gophercloud.ServiceClient, datastoreID, versionID, paramID string) ParamResult {
	var res ParamResult

	_, res.Err = client.Request("GET", getDSParamURL(client, datastoreID, versionID, paramID), gophercloud.RequestOpts{
		OkCodes:      []int{200},
		JSONResponse: &res.Body,
	})

	return res
}

// ListGlobalParams is similar to ListDatastoreParams but does not require a
// DatastoreID.
func ListGlobalParams(client *gophercloud.ServiceClient, versionID string) pagination.Pager {
	pageFn := func(r pagination.PageResult) pagination.Page {
		return ParamPage{pagination.SinglePageBase(r)}
	}
	return pagination.NewPager(client, listGlobalParamsURL(client, versionID), pageFn)
}

// GetGlobalParam is similar to GetDatastoreParam but does not require a
// DatastoreID.
func GetGlobalParam(client *gophercloud.ServiceClient, versionID, paramID string) ParamResult {
	var res ParamResult

	_, res.Err = client.Request("GET", getGlobalParamURL(client, versionID, paramID), gophercloud.RequestOpts{
		OkCodes:      []int{200},
		JSONResponse: &res.Body,
	})

	return res
}
