elastic/cloud-sdk-go

Support a ValidateOnly param when creating/updating a deployment

Opened this issue · 0 comments

Overview

It would be nice to use validate_only query parameter when creating/updating a deployment to just validate the deployment definition. It looks like the elastic client does support the param, but the elastic api doesn't yet.
https://www.elastic.co/guide/en/cloud-enterprise/current/create-deployment.html

Possible Implementation

Add a property for ValidateOnly to CreateParams/UpdateParams struct and pass them when calling CreateDeployment/UpdateDeployment

type UpdateParams struct {
	*api.API

        ...

	// Optional values
	SkipSnapshot      bool
	HidePrunedOrphans bool
	ValidateOnly      bool // Added
}

func Update(params UpdateParams) (*models.DeploymentUpdateResponse, error) {
	...
	
	res, err := params.V1API.Deployments.UpdateDeployment(
		deployments.NewUpdateDeploymentParams().
			WithDeploymentID(params.DeploymentID).
			WithBody(params.Request).
			WithSkipSnapshot(&params.SkipSnapshot).
			WithHidePrunedOrphans(&params.HidePrunedOrphans).
			WithValidateOnly(&params.ValidateOnly), // Added
		params.AuthWriter,
	)

        ...

	return res.Payload, nil
}

Testing

I couldn't find any test code for params, but I'm happy to add a test case

Context

It's always nicer to allow user to validate the deployment definition first before creating/updating a deployment