diff --git a/CHANGELOG.md b/CHANGELOG.md index 126173032..04203ac8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ - Add `elasticstack_kibana_alerting_rule` for managing Kibana alerting rules ([#292](https://github.com/elastic/terraform-provider-elasticstack/pull/292)) - Add client for communicating with the Fleet APIs ([#311](https://github.com/elastic/terraform-provider-elasticstack/pull/311)]) - Add `elasticstack_fleet_enrollment_tokens` and `elasticstack_fleet_agent_policy` for managing Fleet enrollment tokens and agent policies ([#322](https://github.com/elastic/terraform-provider-elasticstack/pull/322)]) +- Add `elasticstack_fleet_output` and `elasticstack_fleet_server_host` for managing Fleet outputs and server hosts ([#327](https://github.com/elastic/terraform-provider-elasticstack/pull/327)]) ### Fixed - Updated unsupported queue_max_bytes_number and queue_max_bytes_units with queue.max_bytes ([#266](https://github.com/elastic/terraform-provider-elasticstack/issues/266)) diff --git a/docs/resources/fleet_output.md b/docs/resources/fleet_output.md new file mode 100644 index 000000000..7482ed1f3 --- /dev/null +++ b/docs/resources/fleet_output.md @@ -0,0 +1,61 @@ +--- +subcategory: "Fleet" +layout: "" +page_title: "Elasticstack: elasticstack_fleet_output Resource" +description: |- + Creates or updates a Fleet Output. +--- + +# Resource: elasticstack_fleet_output + +Creates or updates a Fleet Output. + +## Example Usage + +```terraform +provider "elasticstack" { + kibana {} +} + +resource "elasticstack_fleet_output" "test_output" { + name = "Test Output" + type = "elasticsearch" + config_yaml = yamlencode({ + "ssl.verification_mode" : "none" + }) + default_integrations = false + default_monitoring = false + hosts = [ + "https://elasticsearch:9200" + ] +} +``` + + +## Schema + +### Required + +- `name` (String) The name of the output. +- `type` (String) The output type. + +### Optional + +- `ca_sha256` (String) Fingerprint of the Elasticsearch CA certificate. +- `config_yaml` (String, Sensitive) Advanced YAML configuration. YAML settings here will be added to the output section of each agent policy. +- `default_integrations` (Boolean) Make this output the default for agent integrations. +- `default_monitoring` (Boolean) Make this output the default for agent monitoring. +- `hosts` (List of String) A list of hosts. +- `output_id` (String) Unique identifier of the output. + +### Read-Only + +- `id` (String) The ID of this resource. + +## Import + +Import is supported using the following syntax: + +```shell +terraform import elasticstack_fleet_output.my_output / +``` diff --git a/docs/resources/fleet_server_host.md b/docs/resources/fleet_server_host.md new file mode 100644 index 000000000..47b9ee24e --- /dev/null +++ b/docs/resources/fleet_server_host.md @@ -0,0 +1,52 @@ +--- +subcategory: "Fleet" +layout: "" +page_title: "Elasticstack: elasticstack_fleet_server_host Resource" +description: |- + Creates or updates a Fleet Server Host. +--- + +# Resource: elasticstack_fleet_server_host + +Creates or updates a Fleet Server Host. + +## Example Usage + +```terraform +provider "elasticstack" { + kibana {} +} + +resource "elasticstack_fleet_server_host" "test_host" { + name = "Test Host" + default = false + hosts = [ + "https://fleet-server:8220" + ] +} +``` + + +## Schema + +### Required + +- `hosts` (List of String) A list of hosts. +- `name` (String) The name of the Fleet server host. + +### Optional + +- `default` (Boolean) Set as default. +- `host_id` (String) Unique identifier of the Fleet server host. + +### Read-Only + +- `id` (String) The ID of this resource. + +## Import + +Import is supported using the following syntax: + +```shell +terraform import elasticstack_fleet_server_host.my_host / +``` diff --git a/examples/resources/elasticstack_fleet_output/import.sh b/examples/resources/elasticstack_fleet_output/import.sh new file mode 100644 index 000000000..8d64683c5 --- /dev/null +++ b/examples/resources/elasticstack_fleet_output/import.sh @@ -0,0 +1 @@ +terraform import elasticstack_fleet_output.my_output / diff --git a/examples/resources/elasticstack_fleet_output/resource.tf b/examples/resources/elasticstack_fleet_output/resource.tf new file mode 100644 index 000000000..a12aa7c30 --- /dev/null +++ b/examples/resources/elasticstack_fleet_output/resource.tf @@ -0,0 +1,16 @@ +provider "elasticstack" { + kibana {} +} + +resource "elasticstack_fleet_output" "test_output" { + name = "Test Output" + type = "elasticsearch" + config_yaml = yamlencode({ + "ssl.verification_mode" : "none" + }) + default_integrations = false + default_monitoring = false + hosts = [ + "https://elasticsearch:9200" + ] +} diff --git a/examples/resources/elasticstack_fleet_server_host/import.sh b/examples/resources/elasticstack_fleet_server_host/import.sh new file mode 100644 index 000000000..8c590ce7a --- /dev/null +++ b/examples/resources/elasticstack_fleet_server_host/import.sh @@ -0,0 +1 @@ +terraform import elasticstack_fleet_server_host.my_host / diff --git a/examples/resources/elasticstack_fleet_server_host/resource.tf b/examples/resources/elasticstack_fleet_server_host/resource.tf new file mode 100644 index 000000000..bd415fbe6 --- /dev/null +++ b/examples/resources/elasticstack_fleet_server_host/resource.tf @@ -0,0 +1,11 @@ +provider "elasticstack" { + kibana {} +} + +resource "elasticstack_fleet_server_host" "test_host" { + name = "Test Host" + default = false + hosts = [ + "https://fleet-server:8220" + ] +} diff --git a/internal/clients/fleet/fleet.go b/internal/clients/fleet/fleet.go index 0ed194b98..5ca57cc4e 100644 --- a/internal/clients/fleet/fleet.go +++ b/internal/clients/fleet/fleet.go @@ -90,6 +90,134 @@ func DeleteAgentPolicy(ctx context.Context, client *Client, id string) diag.Diag } } +// ReadOutput reads a specific output from the API. +func ReadOutput(ctx context.Context, client *Client, id string) (*fleetapi.Output, diag.Diagnostics) { + resp, err := client.API.GetOutputWithResponse(ctx, id) + if err != nil { + return nil, diag.FromErr(err) + } + + switch resp.StatusCode() { + case http.StatusOK: + return &resp.JSON200.Item, nil + case http.StatusNotFound: + return nil, nil + default: + return nil, reportUnknownError(resp.StatusCode(), resp.Body) + } +} + +// CreateOutput creates a new output. +func CreateOutput(ctx context.Context, client *Client, req fleetapi.PostOutputsJSONRequestBody) (*fleetapi.Output, diag.Diagnostics) { + resp, err := client.API.PostOutputsWithResponse(ctx, req) + if err != nil { + return nil, diag.FromErr(err) + } + + switch resp.StatusCode() { + case http.StatusOK: + return resp.JSON200.Item, nil + default: + return nil, reportUnknownError(resp.StatusCode(), resp.Body) + } +} + +// UpdateOutput updates an existing output. +func UpdateOutput(ctx context.Context, client *Client, id string, req fleetapi.UpdateOutputJSONRequestBody) (*fleetapi.Output, diag.Diagnostics) { + resp, err := client.API.UpdateOutputWithResponse(ctx, id, req) + if err != nil { + return nil, diag.FromErr(err) + } + + switch resp.StatusCode() { + case http.StatusOK: + return &resp.JSON200.Item, nil + default: + return nil, reportUnknownError(resp.StatusCode(), resp.Body) + } +} + +// DeleteOutput deletes an existing output +func DeleteOutput(ctx context.Context, client *Client, id string) diag.Diagnostics { + resp, err := client.API.DeleteOutputWithResponse(ctx, id) + if err != nil { + return diag.FromErr(err) + } + + switch resp.StatusCode() { + case http.StatusOK: + return nil + case http.StatusNotFound: + return nil + default: + return reportUnknownError(resp.StatusCode(), resp.Body) + } +} + +// ReadFleetServerHost reads a specific fleet server host from the API. +func ReadFleetServerHost(ctx context.Context, client *Client, id string) (*fleetapi.FleetServerHost, diag.Diagnostics) { + resp, err := client.API.GetOneFleetServerHostsWithResponse(ctx, id) + if err != nil { + return nil, diag.FromErr(err) + } + + switch resp.StatusCode() { + case http.StatusOK: + return &resp.JSON200.Item, nil + case http.StatusNotFound: + return nil, nil + default: + return nil, reportUnknownError(resp.StatusCode(), resp.Body) + } +} + +// CreateFleetServerHost creates a new fleet server host. +func CreateFleetServerHost(ctx context.Context, client *Client, req fleetapi.PostFleetServerHostsJSONRequestBody) (*fleetapi.FleetServerHost, diag.Diagnostics) { + resp, err := client.API.PostFleetServerHostsWithResponse(ctx, req) + if err != nil { + return nil, diag.FromErr(err) + } + + switch resp.StatusCode() { + case http.StatusOK: + return resp.JSON200.Item, nil + default: + return nil, reportUnknownError(resp.StatusCode(), resp.Body) + } +} + +// UpdateFleetServerHost updates an existing fleet server host. +func UpdateFleetServerHost(ctx context.Context, client *Client, id string, req fleetapi.UpdateFleetServerHostsJSONRequestBody) (*fleetapi.FleetServerHost, diag.Diagnostics) { + resp, err := client.API.UpdateFleetServerHostsWithResponse(ctx, id, req) + if err != nil { + return nil, diag.FromErr(err) + } + + switch resp.StatusCode() { + case http.StatusOK: + return &resp.JSON200.Item, nil + default: + return nil, reportUnknownError(resp.StatusCode(), resp.Body) + } +} + +// DeleteFleetServerHost deletes an existing fleet server host. +func DeleteFleetServerHost(ctx context.Context, client *Client, id string) diag.Diagnostics { + resp, err := client.API.DeleteFleetServerHostsWithResponse(ctx, id) + if err != nil { + return diag.FromErr(err) + } + + switch resp.StatusCode() { + case http.StatusOK: + return nil + case http.StatusNotFound: + return nil + default: + return reportUnknownError(resp.StatusCode(), resp.Body) + } +} + func reportUnknownError(statusCode int, body []byte) diag.Diagnostics { return diag.Diagnostics{ diag.Diagnostic{ diff --git a/internal/clients/fleet/fleetapi/client_gen.go b/internal/clients/fleet/fleetapi/client_gen.go index 6e83a7a74..f1fa80bd3 100644 --- a/internal/clients/fleet/fleetapi/client_gen.go +++ b/internal/clients/fleet/fleetapi/client_gen.go @@ -109,6 +109,38 @@ type ClientInterface interface { // GetEnrollmentApiKeys request GetEnrollmentApiKeys(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostFleetServerHosts request with any body + PostFleetServerHostsWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostFleetServerHosts(ctx context.Context, body PostFleetServerHostsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteFleetServerHosts request + DeleteFleetServerHosts(ctx context.Context, itemId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetOneFleetServerHosts request + GetOneFleetServerHosts(ctx context.Context, itemId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateFleetServerHosts request with any body + UpdateFleetServerHostsWithBody(ctx context.Context, itemId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + UpdateFleetServerHosts(ctx context.Context, itemId string, body UpdateFleetServerHostsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostOutputs request with any body + PostOutputsWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostOutputs(ctx context.Context, body PostOutputsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteOutput request + DeleteOutput(ctx context.Context, outputId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetOutput request + GetOutput(ctx context.Context, outputId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateOutput request with any body + UpdateOutputWithBody(ctx context.Context, outputId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + UpdateOutput(ctx context.Context, outputId string, body UpdateOutputJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) } func (c *Client) CreateAgentPolicyWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { @@ -207,6 +239,150 @@ func (c *Client) GetEnrollmentApiKeys(ctx context.Context, reqEditors ...Request return c.Client.Do(req) } +func (c *Client) PostFleetServerHostsWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostFleetServerHostsRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostFleetServerHosts(ctx context.Context, body PostFleetServerHostsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostFleetServerHostsRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) DeleteFleetServerHosts(ctx context.Context, itemId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteFleetServerHostsRequest(c.Server, itemId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetOneFleetServerHosts(ctx context.Context, itemId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetOneFleetServerHostsRequest(c.Server, itemId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UpdateFleetServerHostsWithBody(ctx context.Context, itemId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateFleetServerHostsRequestWithBody(c.Server, itemId, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UpdateFleetServerHosts(ctx context.Context, itemId string, body UpdateFleetServerHostsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateFleetServerHostsRequest(c.Server, itemId, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostOutputsWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostOutputsRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostOutputs(ctx context.Context, body PostOutputsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostOutputsRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) DeleteOutput(ctx context.Context, outputId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteOutputRequest(c.Server, outputId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetOutput(ctx context.Context, outputId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetOutputRequest(c.Server, outputId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UpdateOutputWithBody(ctx context.Context, outputId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateOutputRequestWithBody(c.Server, outputId, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UpdateOutput(ctx context.Context, outputId string, body UpdateOutputJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateOutputRequest(c.Server, outputId, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + // NewCreateAgentPolicyRequest calls the generic CreateAgentPolicy builder with application/json body func NewCreateAgentPolicyRequest(server string, body CreateAgentPolicyJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader @@ -395,116 +571,448 @@ func NewGetEnrollmentApiKeysRequest(server string) (*http.Request, error) { return req, nil } -func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { - for _, r := range c.RequestEditors { - if err := r(ctx, req); err != nil { - return err - } - } - for _, r := range additionalEditors { - if err := r(ctx, req); err != nil { - return err - } +// NewPostFleetServerHostsRequest calls the generic PostFleetServerHosts builder with application/json body +func NewPostFleetServerHostsRequest(server string, body PostFleetServerHostsJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err } - return nil + bodyReader = bytes.NewReader(buf) + return NewPostFleetServerHostsRequestWithBody(server, "application/json", bodyReader) } -// ClientWithResponses builds on ClientInterface to offer response payloads -type ClientWithResponses struct { - ClientInterface -} +// NewPostFleetServerHostsRequestWithBody generates requests for PostFleetServerHosts with any type of body +func NewPostFleetServerHostsRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error -// NewClientWithResponses creates a new ClientWithResponses, which wraps -// Client with return type handling -func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { - client, err := NewClient(server, opts...) + serverURL, err := url.Parse(server) if err != nil { return nil, err } - return &ClientWithResponses{client}, nil -} -// WithBaseURL overrides the baseURL. -func WithBaseURL(baseURL string) ClientOption { - return func(c *Client) error { - newBaseURL, err := url.Parse(baseURL) - if err != nil { - return err - } - c.Server = newBaseURL.String() - return nil + operationPath := fmt.Sprintf("/fleet_server_hosts") + if operationPath[0] == '/' { + operationPath = "." + operationPath } -} -// ClientWithResponsesInterface is the interface specification for the client with responses above. -type ClientWithResponsesInterface interface { - // CreateAgentPolicy request with any body - CreateAgentPolicyWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateAgentPolicyResponse, error) + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } - CreateAgentPolicyWithResponse(ctx context.Context, body CreateAgentPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateAgentPolicyResponse, error) + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } - // DeleteAgentPolicy request with any body - DeleteAgentPolicyWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*DeleteAgentPolicyResponse, error) + req.Header.Add("Content-Type", contentType) - DeleteAgentPolicyWithResponse(ctx context.Context, body DeleteAgentPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*DeleteAgentPolicyResponse, error) + return req, nil +} - // AgentPolicyInfo request - AgentPolicyInfoWithResponse(ctx context.Context, agentPolicyId string, reqEditors ...RequestEditorFn) (*AgentPolicyInfoResponse, error) +// NewDeleteFleetServerHostsRequest generates requests for DeleteFleetServerHosts +func NewDeleteFleetServerHostsRequest(server string, itemId string) (*http.Request, error) { + var err error - // UpdateAgentPolicy request with any body - UpdateAgentPolicyWithBodyWithResponse(ctx context.Context, agentPolicyId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateAgentPolicyResponse, error) + var pathParam0 string - UpdateAgentPolicyWithResponse(ctx context.Context, agentPolicyId string, body UpdateAgentPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateAgentPolicyResponse, error) + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "itemId", runtime.ParamLocationPath, itemId) + if err != nil { + return nil, err + } - // GetEnrollmentApiKeys request - GetEnrollmentApiKeysWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetEnrollmentApiKeysResponse, error) -} + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } -type CreateAgentPolicyResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *struct { - Item *AgentPolicy `json:"item,omitempty"` + operationPath := fmt.Sprintf("/fleet_server_hosts/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath } - JSON400 *struct { - Error *string `json:"error,omitempty"` - Message *string `json:"message,omitempty"` - StatusCode *float32 `json:"statusCode,omitempty"` + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err } -} -// Status returns HTTPResponse.Status -func (r CreateAgentPolicyResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err } - return http.StatusText(0) + + return req, nil } -// StatusCode returns HTTPResponse.StatusCode -func (r CreateAgentPolicyResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +// NewGetOneFleetServerHostsRequest generates requests for GetOneFleetServerHosts +func NewGetOneFleetServerHostsRequest(server string, itemId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "itemId", runtime.ParamLocationPath, itemId) + if err != nil { + return nil, err } - return 0 -} -type DeleteAgentPolicyResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *struct { - Id string `json:"id"` - Success bool `json:"success"` + serverURL, err := url.Parse(server) + if err != nil { + return nil, err } - JSON400 *struct { - Error *string `json:"error,omitempty"` - Message *string `json:"message,omitempty"` - StatusCode *float32 `json:"statusCode,omitempty"` + + operationPath := fmt.Sprintf("/fleet_server_hosts/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath } -} -// Status returns HTTPResponse.Status -func (r DeleteAgentPolicyResponse) Status() string { + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateFleetServerHostsRequest calls the generic UpdateFleetServerHosts builder with application/json body +func NewUpdateFleetServerHostsRequest(server string, itemId string, body UpdateFleetServerHostsJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateFleetServerHostsRequestWithBody(server, itemId, "application/json", bodyReader) +} + +// NewUpdateFleetServerHostsRequestWithBody generates requests for UpdateFleetServerHosts with any type of body +func NewUpdateFleetServerHostsRequestWithBody(server string, itemId string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "itemId", runtime.ParamLocationPath, itemId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/fleet_server_hosts/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPostOutputsRequest calls the generic PostOutputs builder with application/json body +func NewPostOutputsRequest(server string, body PostOutputsJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostOutputsRequestWithBody(server, "application/json", bodyReader) +} + +// NewPostOutputsRequestWithBody generates requests for PostOutputs with any type of body +func NewPostOutputsRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/outputs") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteOutputRequest generates requests for DeleteOutput +func NewDeleteOutputRequest(server string, outputId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "outputId", runtime.ParamLocationPath, outputId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/outputs/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetOutputRequest generates requests for GetOutput +func NewGetOutputRequest(server string, outputId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "outputId", runtime.ParamLocationPath, outputId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/outputs/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateOutputRequest calls the generic UpdateOutput builder with application/json body +func NewUpdateOutputRequest(server string, outputId string, body UpdateOutputJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateOutputRequestWithBody(server, outputId, "application/json", bodyReader) +} + +// NewUpdateOutputRequestWithBody generates requests for UpdateOutput with any type of body +func NewUpdateOutputRequestWithBody(server string, outputId string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "outputId", runtime.ParamLocationPath, outputId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/outputs/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { + for _, r := range c.RequestEditors { + if err := r(ctx, req); err != nil { + return err + } + } + for _, r := range additionalEditors { + if err := r(ctx, req); err != nil { + return err + } + } + return nil +} + +// ClientWithResponses builds on ClientInterface to offer response payloads +type ClientWithResponses struct { + ClientInterface +} + +// NewClientWithResponses creates a new ClientWithResponses, which wraps +// Client with return type handling +func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { + client, err := NewClient(server, opts...) + if err != nil { + return nil, err + } + return &ClientWithResponses{client}, nil +} + +// WithBaseURL overrides the baseURL. +func WithBaseURL(baseURL string) ClientOption { + return func(c *Client) error { + newBaseURL, err := url.Parse(baseURL) + if err != nil { + return err + } + c.Server = newBaseURL.String() + return nil + } +} + +// ClientWithResponsesInterface is the interface specification for the client with responses above. +type ClientWithResponsesInterface interface { + // CreateAgentPolicy request with any body + CreateAgentPolicyWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateAgentPolicyResponse, error) + + CreateAgentPolicyWithResponse(ctx context.Context, body CreateAgentPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateAgentPolicyResponse, error) + + // DeleteAgentPolicy request with any body + DeleteAgentPolicyWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*DeleteAgentPolicyResponse, error) + + DeleteAgentPolicyWithResponse(ctx context.Context, body DeleteAgentPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*DeleteAgentPolicyResponse, error) + + // AgentPolicyInfo request + AgentPolicyInfoWithResponse(ctx context.Context, agentPolicyId string, reqEditors ...RequestEditorFn) (*AgentPolicyInfoResponse, error) + + // UpdateAgentPolicy request with any body + UpdateAgentPolicyWithBodyWithResponse(ctx context.Context, agentPolicyId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateAgentPolicyResponse, error) + + UpdateAgentPolicyWithResponse(ctx context.Context, agentPolicyId string, body UpdateAgentPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateAgentPolicyResponse, error) + + // GetEnrollmentApiKeys request + GetEnrollmentApiKeysWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetEnrollmentApiKeysResponse, error) + + // PostFleetServerHosts request with any body + PostFleetServerHostsWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostFleetServerHostsResponse, error) + + PostFleetServerHostsWithResponse(ctx context.Context, body PostFleetServerHostsJSONRequestBody, reqEditors ...RequestEditorFn) (*PostFleetServerHostsResponse, error) + + // DeleteFleetServerHosts request + DeleteFleetServerHostsWithResponse(ctx context.Context, itemId string, reqEditors ...RequestEditorFn) (*DeleteFleetServerHostsResponse, error) + + // GetOneFleetServerHosts request + GetOneFleetServerHostsWithResponse(ctx context.Context, itemId string, reqEditors ...RequestEditorFn) (*GetOneFleetServerHostsResponse, error) + + // UpdateFleetServerHosts request with any body + UpdateFleetServerHostsWithBodyWithResponse(ctx context.Context, itemId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateFleetServerHostsResponse, error) + + UpdateFleetServerHostsWithResponse(ctx context.Context, itemId string, body UpdateFleetServerHostsJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateFleetServerHostsResponse, error) + + // PostOutputs request with any body + PostOutputsWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostOutputsResponse, error) + + PostOutputsWithResponse(ctx context.Context, body PostOutputsJSONRequestBody, reqEditors ...RequestEditorFn) (*PostOutputsResponse, error) + + // DeleteOutput request + DeleteOutputWithResponse(ctx context.Context, outputId string, reqEditors ...RequestEditorFn) (*DeleteOutputResponse, error) + + // GetOutput request + GetOutputWithResponse(ctx context.Context, outputId string, reqEditors ...RequestEditorFn) (*GetOutputResponse, error) + + // UpdateOutput request with any body + UpdateOutputWithBodyWithResponse(ctx context.Context, outputId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateOutputResponse, error) + + UpdateOutputWithResponse(ctx context.Context, outputId string, body UpdateOutputJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateOutputResponse, error) +} + +type CreateAgentPolicyResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + Item *AgentPolicy `json:"item,omitempty"` + } +} + +// Status returns HTTPResponse.Status +func (r CreateAgentPolicyResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateAgentPolicyResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DeleteAgentPolicyResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + Id string `json:"id"` + Success bool `json:"success"` + } +} + +// Status returns HTTPResponse.Status +func (r DeleteAgentPolicyResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -525,11 +1033,6 @@ type AgentPolicyInfoResponse struct { JSON200 *struct { Item AgentPolicy `json:"item"` } - JSON400 *struct { - Error *string `json:"error,omitempty"` - Message *string `json:"message,omitempty"` - StatusCode *float32 `json:"statusCode,omitempty"` - } } // Status returns HTTPResponse.Status @@ -554,11 +1057,6 @@ type UpdateAgentPolicyResponse struct { JSON200 *struct { Item AgentPolicy `json:"item"` } - JSON400 *struct { - Error *string `json:"error,omitempty"` - Message *string `json:"message,omitempty"` - StatusCode *float32 `json:"statusCode,omitempty"` - } } // Status returns HTTPResponse.Status @@ -587,96 +1085,387 @@ type GetEnrollmentApiKeysResponse struct { PerPage float32 `json:"perPage"` Total float32 `json:"total"` } - JSON400 *struct { - Error *string `json:"error,omitempty"` - Message *string `json:"message,omitempty"` - StatusCode *float32 `json:"statusCode,omitempty"` +} + +// Status returns HTTPResponse.Status +func (r GetEnrollmentApiKeysResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetEnrollmentApiKeysResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostFleetServerHostsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + Item *FleetServerHost `json:"item,omitempty"` + } +} + +// Status returns HTTPResponse.Status +func (r PostFleetServerHostsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostFleetServerHostsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DeleteFleetServerHostsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + Id string `json:"id"` + } +} + +// Status returns HTTPResponse.Status +func (r DeleteFleetServerHostsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteFleetServerHostsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetOneFleetServerHostsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + Item FleetServerHost `json:"item"` + } +} + +// Status returns HTTPResponse.Status +func (r GetOneFleetServerHostsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetOneFleetServerHostsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type UpdateFleetServerHostsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + Item FleetServerHost `json:"item"` + } +} + +// Status returns HTTPResponse.Status +func (r UpdateFleetServerHostsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateFleetServerHostsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostOutputsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + Item *Output `json:"item,omitempty"` + } +} + +// Status returns HTTPResponse.Status +func (r PostOutputsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostOutputsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DeleteOutputResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + Id string `json:"id"` + } +} + +// Status returns HTTPResponse.Status +func (r DeleteOutputResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteOutputResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetOutputResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + Item Output `json:"item"` + } +} + +// Status returns HTTPResponse.Status +func (r GetOutputResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetOutputResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type UpdateOutputResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + Item Output `json:"item"` + } +} + +// Status returns HTTPResponse.Status +func (r UpdateOutputResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateOutputResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// CreateAgentPolicyWithBodyWithResponse request with arbitrary body returning *CreateAgentPolicyResponse +func (c *ClientWithResponses) CreateAgentPolicyWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateAgentPolicyResponse, error) { + rsp, err := c.CreateAgentPolicyWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateAgentPolicyResponse(rsp) +} + +func (c *ClientWithResponses) CreateAgentPolicyWithResponse(ctx context.Context, body CreateAgentPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateAgentPolicyResponse, error) { + rsp, err := c.CreateAgentPolicy(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateAgentPolicyResponse(rsp) +} + +// DeleteAgentPolicyWithBodyWithResponse request with arbitrary body returning *DeleteAgentPolicyResponse +func (c *ClientWithResponses) DeleteAgentPolicyWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*DeleteAgentPolicyResponse, error) { + rsp, err := c.DeleteAgentPolicyWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteAgentPolicyResponse(rsp) +} + +func (c *ClientWithResponses) DeleteAgentPolicyWithResponse(ctx context.Context, body DeleteAgentPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*DeleteAgentPolicyResponse, error) { + rsp, err := c.DeleteAgentPolicy(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteAgentPolicyResponse(rsp) +} + +// AgentPolicyInfoWithResponse request returning *AgentPolicyInfoResponse +func (c *ClientWithResponses) AgentPolicyInfoWithResponse(ctx context.Context, agentPolicyId string, reqEditors ...RequestEditorFn) (*AgentPolicyInfoResponse, error) { + rsp, err := c.AgentPolicyInfo(ctx, agentPolicyId, reqEditors...) + if err != nil { + return nil, err + } + return ParseAgentPolicyInfoResponse(rsp) +} + +// UpdateAgentPolicyWithBodyWithResponse request with arbitrary body returning *UpdateAgentPolicyResponse +func (c *ClientWithResponses) UpdateAgentPolicyWithBodyWithResponse(ctx context.Context, agentPolicyId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateAgentPolicyResponse, error) { + rsp, err := c.UpdateAgentPolicyWithBody(ctx, agentPolicyId, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateAgentPolicyResponse(rsp) +} + +func (c *ClientWithResponses) UpdateAgentPolicyWithResponse(ctx context.Context, agentPolicyId string, body UpdateAgentPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateAgentPolicyResponse, error) { + rsp, err := c.UpdateAgentPolicy(ctx, agentPolicyId, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateAgentPolicyResponse(rsp) +} + +// GetEnrollmentApiKeysWithResponse request returning *GetEnrollmentApiKeysResponse +func (c *ClientWithResponses) GetEnrollmentApiKeysWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetEnrollmentApiKeysResponse, error) { + rsp, err := c.GetEnrollmentApiKeys(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetEnrollmentApiKeysResponse(rsp) +} + +// PostFleetServerHostsWithBodyWithResponse request with arbitrary body returning *PostFleetServerHostsResponse +func (c *ClientWithResponses) PostFleetServerHostsWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostFleetServerHostsResponse, error) { + rsp, err := c.PostFleetServerHostsWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostFleetServerHostsResponse(rsp) +} + +func (c *ClientWithResponses) PostFleetServerHostsWithResponse(ctx context.Context, body PostFleetServerHostsJSONRequestBody, reqEditors ...RequestEditorFn) (*PostFleetServerHostsResponse, error) { + rsp, err := c.PostFleetServerHosts(ctx, body, reqEditors...) + if err != nil { + return nil, err } + return ParsePostFleetServerHostsResponse(rsp) } -// Status returns HTTPResponse.Status -func (r GetEnrollmentApiKeysResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +// DeleteFleetServerHostsWithResponse request returning *DeleteFleetServerHostsResponse +func (c *ClientWithResponses) DeleteFleetServerHostsWithResponse(ctx context.Context, itemId string, reqEditors ...RequestEditorFn) (*DeleteFleetServerHostsResponse, error) { + rsp, err := c.DeleteFleetServerHosts(ctx, itemId, reqEditors...) + if err != nil { + return nil, err } - return http.StatusText(0) + return ParseDeleteFleetServerHostsResponse(rsp) } -// StatusCode returns HTTPResponse.StatusCode -func (r GetEnrollmentApiKeysResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +// GetOneFleetServerHostsWithResponse request returning *GetOneFleetServerHostsResponse +func (c *ClientWithResponses) GetOneFleetServerHostsWithResponse(ctx context.Context, itemId string, reqEditors ...RequestEditorFn) (*GetOneFleetServerHostsResponse, error) { + rsp, err := c.GetOneFleetServerHosts(ctx, itemId, reqEditors...) + if err != nil { + return nil, err } - return 0 + return ParseGetOneFleetServerHostsResponse(rsp) } -// CreateAgentPolicyWithBodyWithResponse request with arbitrary body returning *CreateAgentPolicyResponse -func (c *ClientWithResponses) CreateAgentPolicyWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateAgentPolicyResponse, error) { - rsp, err := c.CreateAgentPolicyWithBody(ctx, contentType, body, reqEditors...) +// UpdateFleetServerHostsWithBodyWithResponse request with arbitrary body returning *UpdateFleetServerHostsResponse +func (c *ClientWithResponses) UpdateFleetServerHostsWithBodyWithResponse(ctx context.Context, itemId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateFleetServerHostsResponse, error) { + rsp, err := c.UpdateFleetServerHostsWithBody(ctx, itemId, contentType, body, reqEditors...) if err != nil { return nil, err } - return ParseCreateAgentPolicyResponse(rsp) + return ParseUpdateFleetServerHostsResponse(rsp) } -func (c *ClientWithResponses) CreateAgentPolicyWithResponse(ctx context.Context, body CreateAgentPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateAgentPolicyResponse, error) { - rsp, err := c.CreateAgentPolicy(ctx, body, reqEditors...) +func (c *ClientWithResponses) UpdateFleetServerHostsWithResponse(ctx context.Context, itemId string, body UpdateFleetServerHostsJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateFleetServerHostsResponse, error) { + rsp, err := c.UpdateFleetServerHosts(ctx, itemId, body, reqEditors...) if err != nil { return nil, err } - return ParseCreateAgentPolicyResponse(rsp) + return ParseUpdateFleetServerHostsResponse(rsp) } -// DeleteAgentPolicyWithBodyWithResponse request with arbitrary body returning *DeleteAgentPolicyResponse -func (c *ClientWithResponses) DeleteAgentPolicyWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*DeleteAgentPolicyResponse, error) { - rsp, err := c.DeleteAgentPolicyWithBody(ctx, contentType, body, reqEditors...) +// PostOutputsWithBodyWithResponse request with arbitrary body returning *PostOutputsResponse +func (c *ClientWithResponses) PostOutputsWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostOutputsResponse, error) { + rsp, err := c.PostOutputsWithBody(ctx, contentType, body, reqEditors...) if err != nil { return nil, err } - return ParseDeleteAgentPolicyResponse(rsp) + return ParsePostOutputsResponse(rsp) } -func (c *ClientWithResponses) DeleteAgentPolicyWithResponse(ctx context.Context, body DeleteAgentPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*DeleteAgentPolicyResponse, error) { - rsp, err := c.DeleteAgentPolicy(ctx, body, reqEditors...) +func (c *ClientWithResponses) PostOutputsWithResponse(ctx context.Context, body PostOutputsJSONRequestBody, reqEditors ...RequestEditorFn) (*PostOutputsResponse, error) { + rsp, err := c.PostOutputs(ctx, body, reqEditors...) if err != nil { return nil, err } - return ParseDeleteAgentPolicyResponse(rsp) + return ParsePostOutputsResponse(rsp) } -// AgentPolicyInfoWithResponse request returning *AgentPolicyInfoResponse -func (c *ClientWithResponses) AgentPolicyInfoWithResponse(ctx context.Context, agentPolicyId string, reqEditors ...RequestEditorFn) (*AgentPolicyInfoResponse, error) { - rsp, err := c.AgentPolicyInfo(ctx, agentPolicyId, reqEditors...) +// DeleteOutputWithResponse request returning *DeleteOutputResponse +func (c *ClientWithResponses) DeleteOutputWithResponse(ctx context.Context, outputId string, reqEditors ...RequestEditorFn) (*DeleteOutputResponse, error) { + rsp, err := c.DeleteOutput(ctx, outputId, reqEditors...) if err != nil { return nil, err } - return ParseAgentPolicyInfoResponse(rsp) + return ParseDeleteOutputResponse(rsp) } -// UpdateAgentPolicyWithBodyWithResponse request with arbitrary body returning *UpdateAgentPolicyResponse -func (c *ClientWithResponses) UpdateAgentPolicyWithBodyWithResponse(ctx context.Context, agentPolicyId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateAgentPolicyResponse, error) { - rsp, err := c.UpdateAgentPolicyWithBody(ctx, agentPolicyId, contentType, body, reqEditors...) +// GetOutputWithResponse request returning *GetOutputResponse +func (c *ClientWithResponses) GetOutputWithResponse(ctx context.Context, outputId string, reqEditors ...RequestEditorFn) (*GetOutputResponse, error) { + rsp, err := c.GetOutput(ctx, outputId, reqEditors...) if err != nil { return nil, err } - return ParseUpdateAgentPolicyResponse(rsp) + return ParseGetOutputResponse(rsp) } -func (c *ClientWithResponses) UpdateAgentPolicyWithResponse(ctx context.Context, agentPolicyId string, body UpdateAgentPolicyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateAgentPolicyResponse, error) { - rsp, err := c.UpdateAgentPolicy(ctx, agentPolicyId, body, reqEditors...) +// UpdateOutputWithBodyWithResponse request with arbitrary body returning *UpdateOutputResponse +func (c *ClientWithResponses) UpdateOutputWithBodyWithResponse(ctx context.Context, outputId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateOutputResponse, error) { + rsp, err := c.UpdateOutputWithBody(ctx, outputId, contentType, body, reqEditors...) if err != nil { return nil, err } - return ParseUpdateAgentPolicyResponse(rsp) + return ParseUpdateOutputResponse(rsp) } -// GetEnrollmentApiKeysWithResponse request returning *GetEnrollmentApiKeysResponse -func (c *ClientWithResponses) GetEnrollmentApiKeysWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetEnrollmentApiKeysResponse, error) { - rsp, err := c.GetEnrollmentApiKeys(ctx, reqEditors...) +func (c *ClientWithResponses) UpdateOutputWithResponse(ctx context.Context, outputId string, body UpdateOutputJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateOutputResponse, error) { + rsp, err := c.UpdateOutput(ctx, outputId, body, reqEditors...) if err != nil { return nil, err } - return ParseGetEnrollmentApiKeysResponse(rsp) + return ParseUpdateOutputResponse(rsp) } // ParseCreateAgentPolicyResponse parses an HTTP response from a CreateAgentPolicyWithResponse call @@ -702,17 +1491,6 @@ func ParseCreateAgentPolicyResponse(rsp *http.Response) (*CreateAgentPolicyRespo } response.JSON200 = &dest - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: - var dest struct { - Error *string `json:"error,omitempty"` - Message *string `json:"message,omitempty"` - StatusCode *float32 `json:"statusCode,omitempty"` - } - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON400 = &dest - } return response, nil @@ -742,31 +1520,48 @@ func ParseDeleteAgentPolicyResponse(rsp *http.Response) (*DeleteAgentPolicyRespo } response.JSON200 = &dest - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + } + + return response, nil +} + +// ParseAgentPolicyInfoResponse parses an HTTP response from a AgentPolicyInfoWithResponse call +func ParseAgentPolicyInfoResponse(rsp *http.Response) (*AgentPolicyInfoResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &AgentPolicyInfoResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: var dest struct { - Error *string `json:"error,omitempty"` - Message *string `json:"message,omitempty"` - StatusCode *float32 `json:"statusCode,omitempty"` + Item AgentPolicy `json:"item"` } if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } - response.JSON400 = &dest + response.JSON200 = &dest } return response, nil } -// ParseAgentPolicyInfoResponse parses an HTTP response from a AgentPolicyInfoWithResponse call -func ParseAgentPolicyInfoResponse(rsp *http.Response) (*AgentPolicyInfoResponse, error) { +// ParseUpdateAgentPolicyResponse parses an HTTP response from a UpdateAgentPolicyWithResponse call +func ParseUpdateAgentPolicyResponse(rsp *http.Response) (*UpdateAgentPolicyResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &AgentPolicyInfoResponse{ + response := &UpdateAgentPolicyResponse{ Body: bodyBytes, HTTPResponse: rsp, } @@ -781,31 +1576,52 @@ func ParseAgentPolicyInfoResponse(rsp *http.Response) (*AgentPolicyInfoResponse, } response.JSON200 = &dest - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + } + + return response, nil +} + +// ParseGetEnrollmentApiKeysResponse parses an HTTP response from a GetEnrollmentApiKeysWithResponse call +func ParseGetEnrollmentApiKeysResponse(rsp *http.Response) (*GetEnrollmentApiKeysResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetEnrollmentApiKeysResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: var dest struct { - Error *string `json:"error,omitempty"` - Message *string `json:"message,omitempty"` - StatusCode *float32 `json:"statusCode,omitempty"` + Items []EnrollmentApiKey `json:"items"` + List *[]EnrollmentApiKey `json:"list,omitempty"` + Page float32 `json:"page"` + PerPage float32 `json:"perPage"` + Total float32 `json:"total"` } if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } - response.JSON400 = &dest + response.JSON200 = &dest } return response, nil } -// ParseUpdateAgentPolicyResponse parses an HTTP response from a UpdateAgentPolicyWithResponse call -func ParseUpdateAgentPolicyResponse(rsp *http.Response) (*UpdateAgentPolicyResponse, error) { +// ParsePostFleetServerHostsResponse parses an HTTP response from a PostFleetServerHostsWithResponse call +func ParsePostFleetServerHostsResponse(rsp *http.Response) (*PostFleetServerHostsResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &UpdateAgentPolicyResponse{ + response := &PostFleetServerHostsResponse{ Body: bodyBytes, HTTPResponse: rsp, } @@ -813,38 +1629,83 @@ func ParseUpdateAgentPolicyResponse(rsp *http.Response) (*UpdateAgentPolicyRespo switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: var dest struct { - Item AgentPolicy `json:"item"` + Item *FleetServerHost `json:"item,omitempty"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseDeleteFleetServerHostsResponse parses an HTTP response from a DeleteFleetServerHostsWithResponse call +func ParseDeleteFleetServerHostsResponse(rsp *http.Response) (*DeleteFleetServerHostsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteFleetServerHostsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + Id string `json:"id"` } if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } response.JSON200 = &dest - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + } + + return response, nil +} + +// ParseGetOneFleetServerHostsResponse parses an HTTP response from a GetOneFleetServerHostsWithResponse call +func ParseGetOneFleetServerHostsResponse(rsp *http.Response) (*GetOneFleetServerHostsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetOneFleetServerHostsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: var dest struct { - Error *string `json:"error,omitempty"` - Message *string `json:"message,omitempty"` - StatusCode *float32 `json:"statusCode,omitempty"` + Item FleetServerHost `json:"item"` } if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } - response.JSON400 = &dest + response.JSON200 = &dest } return response, nil } -// ParseGetEnrollmentApiKeysResponse parses an HTTP response from a GetEnrollmentApiKeysWithResponse call -func ParseGetEnrollmentApiKeysResponse(rsp *http.Response) (*GetEnrollmentApiKeysResponse, error) { +// ParseUpdateFleetServerHostsResponse parses an HTTP response from a UpdateFleetServerHostsWithResponse call +func ParseUpdateFleetServerHostsResponse(rsp *http.Response) (*UpdateFleetServerHostsResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &GetEnrollmentApiKeysResponse{ + response := &UpdateFleetServerHostsResponse{ Body: bodyBytes, HTTPResponse: rsp, } @@ -852,27 +1713,124 @@ func ParseGetEnrollmentApiKeysResponse(rsp *http.Response) (*GetEnrollmentApiKey switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: var dest struct { - Items []EnrollmentApiKey `json:"items"` - List *[]EnrollmentApiKey `json:"list,omitempty"` - Page float32 `json:"page"` - PerPage float32 `json:"perPage"` - Total float32 `json:"total"` + Item FleetServerHost `json:"item"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePostOutputsResponse parses an HTTP response from a PostOutputsWithResponse call +func ParsePostOutputsResponse(rsp *http.Response) (*PostOutputsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostOutputsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + Item *Output `json:"item,omitempty"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseDeleteOutputResponse parses an HTTP response from a DeleteOutputWithResponse call +func ParseDeleteOutputResponse(rsp *http.Response) (*DeleteOutputResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteOutputResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + Id string `json:"id"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetOutputResponse parses an HTTP response from a GetOutputWithResponse call +func ParseGetOutputResponse(rsp *http.Response) (*GetOutputResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetOutputResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + Item Output `json:"item"` } if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } response.JSON200 = &dest - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + } + + return response, nil +} + +// ParseUpdateOutputResponse parses an HTTP response from a UpdateOutputWithResponse call +func ParseUpdateOutputResponse(rsp *http.Response) (*UpdateOutputResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateOutputResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: var dest struct { - Error *string `json:"error,omitempty"` - Message *string `json:"message,omitempty"` - StatusCode *float32 `json:"statusCode,omitempty"` + Item Output `json:"item"` } if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } - response.JSON400 = &dest + response.JSON200 = &dest } diff --git a/internal/clients/fleet/fleetapi/doc.go b/internal/clients/fleet/fleetapi/doc.go index f5725558b..027f759bb 100644 --- a/internal/clients/fleet/fleetapi/doc.go +++ b/internal/clients/fleet/fleetapi/doc.go @@ -1,5 +1,5 @@ package fleetapi -//go:generate go run generate.go -o fleet-filtered.json +//go:generate go run generate.go -v v8.7.1 -o fleet-filtered.json //go:generate go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.12.4 -package=fleetapi -generate=types -o ./fleetapi_gen.go fleet-filtered.json //go:generate go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.12.4 -package=fleetapi -generate=client -o ./client_gen.go fleet-filtered.json diff --git a/internal/clients/fleet/fleetapi/fleetapi_gen.go b/internal/clients/fleet/fleetapi/fleetapi_gen.go index ef115016a..8ddc2ef20 100644 --- a/internal/clients/fleet/fleetapi/fleetapi_gen.go +++ b/internal/clients/fleet/fleetapi/fleetapi_gen.go @@ -29,6 +29,22 @@ const ( Metrics AgentPolicyUpdateRequestMonitoringEnabled = "metrics" ) +// Defines values for OutputType. +const ( + OutputTypeElasticsearch OutputType = "elasticsearch" + OutputTypeLogstash OutputType = "logstash" +) + +// Defines values for PostOutputsJSONBodyType. +const ( + PostOutputsJSONBodyTypeElasticsearch PostOutputsJSONBodyType = "elasticsearch" +) + +// Defines values for UpdateOutputJSONBodyType. +const ( + Elasticsearch UpdateOutputJSONBodyType = "elasticsearch" +) + // AgentPolicy defines model for agent_policy. type AgentPolicy struct { AgentFeatures *[]struct { @@ -112,6 +128,15 @@ type EnrollmentApiKey struct { PolicyId *string `json:"policy_id,omitempty"` } +// FleetServerHost defines model for fleet_server_host. +type FleetServerHost struct { + HostUrls []string `json:"host_urls"` + Id string `json:"id"` + IsDefault bool `json:"is_default"` + IsPreconfigured bool `json:"is_preconfigured"` + Name *string `json:"name,omitempty"` +} + // NewPackagePolicy defines model for new_package_policy. type NewPackagePolicy struct { Description *string `json:"description,omitempty"` @@ -135,6 +160,38 @@ type NewPackagePolicy struct { PolicyId *string `json:"policy_id,omitempty"` } +// Output defines model for output. +type Output struct { + CaSha256 *string `json:"ca_sha256,omitempty"` + CaTrustedFingerprint *string `json:"ca_trusted_fingerprint,omitempty"` + Config *map[string]interface{} `json:"config,omitempty"` + ConfigYaml *string `json:"config_yaml,omitempty"` + Hosts *[]string `json:"hosts,omitempty"` + Id string `json:"id"` + IsDefault bool `json:"is_default"` + IsDefaultMonitoring *bool `json:"is_default_monitoring,omitempty"` + Name string `json:"name"` + ProxyId *string `json:"proxy_id,omitempty"` + Shipper *struct { + CompressionLevel *float32 `json:"compression_level,omitempty"` + DiskQueueCompressionEnabled *bool `json:"disk_queue_compression_enabled,omitempty"` + DiskQueueEnabled *bool `json:"disk_queue_enabled,omitempty"` + DiskQueueEncryptionEnabled *bool `json:"disk_queue_encryption_enabled,omitempty"` + DiskQueueMaxSize *float32 `json:"disk_queue_max_size,omitempty"` + DiskQueuePath *string `json:"disk_queue_path,omitempty"` + Loadbalance *bool `json:"loadbalance,omitempty"` + } `json:"shipper,omitempty"` + Ssl *struct { + Certificate *string `json:"certificate,omitempty"` + CertificateAuthorities *[]string `json:"certificate_authorities,omitempty"` + Key *string `json:"key,omitempty"` + } `json:"ssl,omitempty"` + Type OutputType `json:"type"` +} + +// OutputType defines model for Output.Type. +type OutputType string + // PackagePolicy defines model for package_policy. type PackagePolicy struct { Description *string `json:"description,omitempty"` @@ -160,18 +217,56 @@ type PackagePolicy struct { Revision float32 `json:"revision"` } -// Error defines model for error. -type Error struct { - Error *string `json:"error,omitempty"` - Message *string `json:"message,omitempty"` - StatusCode *float32 `json:"statusCode,omitempty"` -} - // DeleteAgentPolicyJSONBody defines parameters for DeleteAgentPolicy. type DeleteAgentPolicyJSONBody struct { AgentPolicyId string `json:"agentPolicyId"` } +// PostFleetServerHostsJSONBody defines parameters for PostFleetServerHosts. +type PostFleetServerHostsJSONBody struct { + HostUrls []string `json:"host_urls"` + Id *string `json:"id,omitempty"` + IsDefault *bool `json:"is_default,omitempty"` + Name string `json:"name"` +} + +// UpdateFleetServerHostsJSONBody defines parameters for UpdateFleetServerHosts. +type UpdateFleetServerHostsJSONBody struct { + HostUrls *[]string `json:"host_urls,omitempty"` + IsDefault *bool `json:"is_default,omitempty"` + Name *string `json:"name,omitempty"` +} + +// PostOutputsJSONBody defines parameters for PostOutputs. +type PostOutputsJSONBody struct { + CaSha256 *string `json:"ca_sha256,omitempty"` + ConfigYaml *string `json:"config_yaml,omitempty"` + Hosts *[]string `json:"hosts,omitempty"` + Id *string `json:"id,omitempty"` + IsDefault *bool `json:"is_default,omitempty"` + IsDefaultMonitoring *bool `json:"is_default_monitoring,omitempty"` + Name string `json:"name"` + Type PostOutputsJSONBodyType `json:"type"` +} + +// PostOutputsJSONBodyType defines parameters for PostOutputs. +type PostOutputsJSONBodyType string + +// UpdateOutputJSONBody defines parameters for UpdateOutput. +type UpdateOutputJSONBody struct { + CaSha256 *string `json:"ca_sha256,omitempty"` + CaTrustedFingerprint *string `json:"ca_trusted_fingerprint,omitempty"` + ConfigYaml *string `json:"config_yaml,omitempty"` + Hosts *[]string `json:"hosts,omitempty"` + IsDefault *bool `json:"is_default,omitempty"` + IsDefaultMonitoring *bool `json:"is_default_monitoring,omitempty"` + Name string `json:"name"` + Type UpdateOutputJSONBodyType `json:"type"` +} + +// UpdateOutputJSONBodyType defines parameters for UpdateOutput. +type UpdateOutputJSONBodyType string + // CreateAgentPolicyJSONRequestBody defines body for CreateAgentPolicy for application/json ContentType. type CreateAgentPolicyJSONRequestBody = AgentPolicyCreateRequest @@ -180,3 +275,15 @@ type DeleteAgentPolicyJSONRequestBody DeleteAgentPolicyJSONBody // UpdateAgentPolicyJSONRequestBody defines body for UpdateAgentPolicy for application/json ContentType. type UpdateAgentPolicyJSONRequestBody = AgentPolicyUpdateRequest + +// PostFleetServerHostsJSONRequestBody defines body for PostFleetServerHosts for application/json ContentType. +type PostFleetServerHostsJSONRequestBody PostFleetServerHostsJSONBody + +// UpdateFleetServerHostsJSONRequestBody defines body for UpdateFleetServerHosts for application/json ContentType. +type UpdateFleetServerHostsJSONRequestBody UpdateFleetServerHostsJSONBody + +// PostOutputsJSONRequestBody defines body for PostOutputs for application/json ContentType. +type PostOutputsJSONRequestBody PostOutputsJSONBody + +// UpdateOutputJSONRequestBody defines body for UpdateOutput for application/json ContentType. +type UpdateOutputJSONRequestBody UpdateOutputJSONBody diff --git a/internal/clients/fleet/fleetapi/generate.go b/internal/clients/fleet/fleetapi/generate.go index 47b16ded6..6741fa299 100644 --- a/internal/clients/fleet/fleetapi/generate.go +++ b/internal/clients/fleet/fleetapi/generate.go @@ -49,6 +49,10 @@ var includePaths = map[string][]string{ "/agent_policies/{agentPolicyId}": {"get", "put"}, "/agent_policies/delete": {"post"}, "/enrollment_api_keys": {"get"}, + "/fleet_server_hosts": {"post"}, + "/fleet_server_hosts/{itemId}": {"get", "put", "delete"}, + "/outputs": {"post"}, + "/outputs/{outputId}": {"get", "put", "delete"}, } func downloadFile(url string) ([]byte, error) { diff --git a/internal/fleet/fleet_server_host_resource.go b/internal/fleet/fleet_server_host_resource.go new file mode 100644 index 000000000..623434fb3 --- /dev/null +++ b/internal/fleet/fleet_server_host_resource.go @@ -0,0 +1,178 @@ +package fleet + +import ( + "context" + + "github.com/elastic/terraform-provider-elasticstack/internal/clients/fleet" + "github.com/elastic/terraform-provider-elasticstack/internal/clients/fleet/fleetapi" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func ResourceFleetServerHost() *schema.Resource { + fleetServerHostSchema := map[string]*schema.Schema{ + "host_id": { + Description: "Unique identifier of the Fleet server host.", + Type: schema.TypeString, + Computed: true, + Optional: true, + }, + "name": { + Description: "The name of the Fleet server host.", + Type: schema.TypeString, + Required: true, + }, + "hosts": { + Description: "A list of hosts.", + Type: schema.TypeList, + Required: true, + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "default": { + Description: "Set as default.", + Type: schema.TypeBool, + Optional: true, + }, + } + + return &schema.Resource{ + Description: "Creates a new Fleet Server Host.", + + CreateContext: resourceFleetServerHostCreate, + ReadContext: resourceFleetServerHostRead, + UpdateContext: resourceFleetServerHostUpdate, + DeleteContext: resourceFleetServerHostDelete, + + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: fleetServerHostSchema, + } +} + +func resourceFleetServerHostCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + fleetClient, diags := getFleetClient(d, meta) + if diags.HasError() { + return diags + } + + req := fleetapi.PostFleetServerHostsJSONRequestBody{ + Name: d.Get("name").(string), + } + + if value := d.Get("hosts").([]interface{}); len(value) > 0 { + for _, v := range value { + if vStr, ok := v.(string); ok && vStr != "" { + req.HostUrls = append(req.HostUrls, vStr) + } + } + } + if value := d.Get("default").(bool); value { + req.IsDefault = &value + } + + host, diags := fleet.CreateFleetServerHost(ctx, fleetClient, req) + if diags.HasError() { + return diags + } + + d.SetId(host.Id) + if err := d.Set("host_id", host.Id); err != nil { + return diag.FromErr(err) + } + + return resourceFleetServerHostRead(ctx, d, meta) +} + +func resourceFleetServerHostUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + fleetClient, diags := getFleetClient(d, meta) + if diags.HasError() { + return diags + } + + id := d.Get("host_id").(string) + d.SetId(id) + + req := fleetapi.UpdateFleetServerHostsJSONRequestBody{} + + if value, ok := d.Get("name").(string); ok && value != "" { + req.Name = &value + } + var hosts []string + if value, ok := d.Get("hosts").([]interface{}); ok && len(value) > 0 { + for _, v := range value { + if vStr, ok := v.(string); ok && vStr != "" { + hosts = append(hosts, vStr) + } + } + } + if hosts != nil { + req.HostUrls = &hosts + } + if value := d.Get("default").(bool); value { + req.IsDefault = &value + } + + _, diags = fleet.UpdateFleetServerHost(ctx, fleetClient, id, req) + if diags.HasError() { + return diags + } + + return resourceFleetServerHostRead(ctx, d, meta) +} + +func resourceFleetServerHostRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + fleetClient, diags := getFleetClient(d, meta) + if diags.HasError() { + return diags + } + + id := d.Get("host_id").(string) + d.SetId(id) + + host, diags := fleet.ReadFleetServerHost(ctx, fleetClient, id) + if diags.HasError() { + return diags + } + + // Not found. + if host == nil { + d.SetId("") + return nil + } + + if host.Name != nil { + if err := d.Set("name", *host.Name); err != nil { + return diag.FromErr(err) + } + } + if err := d.Set("hosts", host.HostUrls); err != nil { + return diag.FromErr(err) + } + if err := d.Set("default", host.IsDefault); err != nil { + return diag.FromErr(err) + } + + return nil +} + +func resourceFleetServerHostDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + fleetClient, diags := getFleetClient(d, meta) + if diags.HasError() { + return diags + } + + id := d.Get("host_id").(string) + d.SetId(id) + + if diags = fleet.DeleteFleetServerHost(ctx, fleetClient, id); diags.HasError() { + return diags + } + d.SetId("") + + return diags +} diff --git a/internal/fleet/fleet_server_host_resource_test.go b/internal/fleet/fleet_server_host_resource_test.go new file mode 100644 index 000000000..c1c5d6fd6 --- /dev/null +++ b/internal/fleet/fleet_server_host_resource_test.go @@ -0,0 +1,109 @@ +package fleet_test + +import ( + "context" + "fmt" + "testing" + + "github.com/elastic/terraform-provider-elasticstack/internal/acctest" + "github.com/elastic/terraform-provider-elasticstack/internal/clients" + "github.com/elastic/terraform-provider-elasticstack/internal/clients/fleet" + "github.com/elastic/terraform-provider-elasticstack/internal/versionutils" + "github.com/hashicorp/go-version" + sdkacctest "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +var minVersionFleetServerHost = version.Must(version.NewVersion("8.6.0")) + +func TestAccResourceFleetServerHost(t *testing.T) { + policyName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + CheckDestroy: checkResourceFleetServerHostDestroy, + ProtoV5ProviderFactories: acctest.Providers, + Steps: []resource.TestStep{ + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minVersionFleetServerHost), + Config: testAccResourceFleetServerHostCreate(policyName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("elasticstack_fleet_server_host.test_host", "name", fmt.Sprintf("FleetServerHost %s", policyName)), + resource.TestCheckResourceAttr("elasticstack_fleet_server_host.test_host", "default", "false"), + resource.TestCheckResourceAttr("elasticstack_fleet_server_host.test_host", "hosts.0", "https://fleet-server:8220"), + ), + }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minVersionFleetServerHost), + Config: testAccResourceFleetServerHostUpdate(policyName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("elasticstack_fleet_server_host.test_host", "name", fmt.Sprintf("Updated FleetServerHost %s", policyName)), + resource.TestCheckResourceAttr("elasticstack_fleet_server_host.test_host", "default", "false"), + resource.TestCheckResourceAttr("elasticstack_fleet_server_host.test_host", "hosts.0", "https://fleet-server:8220"), + ), + }, + }, + }) +} + +func testAccResourceFleetServerHostCreate(id string) string { + return fmt.Sprintf(` +provider "elasticstack" { + elasticsearch {} + kibana {} +} + +resource "elasticstack_fleet_server_host" "test_host" { + name = "%s" + default = false + hosts = [ + "https://fleet-server:8220" + ] +} +`, fmt.Sprintf("FleetServerHost %s", id)) +} + +func testAccResourceFleetServerHostUpdate(id string) string { + return fmt.Sprintf(` +provider "elasticstack" { + elasticsearch {} + kibana {} +} + +resource "elasticstack_fleet_server_host" "test_host" { + name = "%s" + default = false + hosts = [ + "https://fleet-server:8220" + ] +} + +`, fmt.Sprintf("Updated FleetServerHost %s", id)) +} + +func checkResourceFleetServerHostDestroy(s *terraform.State) error { + client, err := clients.NewAcceptanceTestingClient() + if err != nil { + return err + } + + for _, rs := range s.RootModule().Resources { + if rs.Type != "elasticstack_fleet_server_host" { + continue + } + + fleetClient, err := client.GetFleetClient() + if err != nil { + return err + } + packagePolicy, diag := fleet.ReadFleetServerHost(context.Background(), fleetClient, rs.Primary.ID) + if diag.HasError() { + return fmt.Errorf(diag[0].Summary) + } + if packagePolicy != nil { + return fmt.Errorf("FleetServerHost id=%v still exists, but it should have been removed", rs.Primary.ID) + } + } + return nil +} diff --git a/internal/fleet/output_resource.go b/internal/fleet/output_resource.go new file mode 100644 index 000000000..ae8279f6f --- /dev/null +++ b/internal/fleet/output_resource.go @@ -0,0 +1,241 @@ +package fleet + +import ( + "context" + + "github.com/elastic/terraform-provider-elasticstack/internal/clients/fleet" + "github.com/elastic/terraform-provider-elasticstack/internal/clients/fleet/fleetapi" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" +) + +func ResourceOutput() *schema.Resource { + outputSchema := map[string]*schema.Schema{ + "output_id": { + Description: "Unique identifier of the output.", + Type: schema.TypeString, + Computed: true, + Optional: true, + }, + "name": { + Description: "The name of the output.", + Type: schema.TypeString, + Required: true, + }, + "type": { + Description: "The output type.", + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"elasticsearch", "logstash"}, false), + }, + "hosts": { + Description: "A list of hosts.", + Type: schema.TypeList, + Optional: true, + MinItems: 1, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "ca_sha256": { + Description: "Fingerprint of the Elasticsearch CA certificate.", + Type: schema.TypeString, + Optional: true, + }, + "default_integrations": { + Description: "Make this output the default for agent integrations.", + Type: schema.TypeBool, + Optional: true, + }, + "default_monitoring": { + Description: "Make this output the default for agent monitoring.", + Type: schema.TypeBool, + Optional: true, + }, + "config_yaml": { + Description: "Advanced YAML configuration. YAML settings here will be added to the output section of each agent policy.", + Type: schema.TypeString, + Optional: true, + Sensitive: true, + }, + } + + return &schema.Resource{ + Description: "Creates a new Fleet Output.", + + CreateContext: resourceOutputCreate, + ReadContext: resourceOutputRead, + UpdateContext: resourceOutputUpdate, + DeleteContext: resourceOutputDelete, + + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: outputSchema, + } +} + +func resourceOutputCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + fleetClient, diags := getFleetClient(d, meta) + if diags.HasError() { + return diags + } + + req := fleetapi.PostOutputsJSONRequestBody{ + Name: d.Get("name").(string), + Type: fleetapi.PostOutputsJSONBodyType(d.Get("type").(string)), + } + + var hosts []string + if value := d.Get("hosts").([]interface{}); len(value) > 0 { + for _, v := range value { + if vStr, ok := v.(string); ok && vStr != "" { + hosts = append(hosts, vStr) + } + } + } + if hosts != nil { + req.Hosts = &hosts + } + if value := d.Get("default_integrations").(bool); value { + req.IsDefault = &value + } + if value := d.Get("default_monitoring").(bool); value { + req.IsDefaultMonitoring = &value + } + if value, ok := d.Get("ca_sha256").(string); ok && value != "" { + req.CaSha256 = &value + } + if value, ok := d.Get("config_yaml").(string); ok && value != "" { + req.ConfigYaml = &value + } + + host, diags := fleet.CreateOutput(ctx, fleetClient, req) + if diags.HasError() { + return diags + } + + d.SetId(host.Id) + if err := d.Set("output_id", host.Id); err != nil { + return diag.FromErr(err) + } + + return resourceOutputRead(ctx, d, meta) +} + +func resourceOutputUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + fleetClient, diags := getFleetClient(d, meta) + if diags.HasError() { + return diags + } + + id := d.Get("output_id").(string) + d.SetId(id) + + req := fleetapi.UpdateOutputJSONRequestBody{ + Name: d.Get("name").(string), + } + + var hosts []string + if value := d.Get("hosts").([]interface{}); len(value) > 0 { + for _, v := range value { + if vStr, ok := v.(string); ok && vStr != "" { + hosts = append(hosts, vStr) + } + } + } + if hosts != nil { + req.Hosts = &hosts + } + if value := d.Get("default_integrations").(bool); value { + req.IsDefault = &value + } + if value := d.Get("default_monitoring").(bool); value { + req.IsDefaultMonitoring = &value + } + if value, ok := d.Get("ca_sha256").(string); ok && value != "" { + req.CaSha256 = &value + } + if value, ok := d.Get("config_yaml").(string); ok && value != "" { + req.ConfigYaml = &value + } + if value, ok := d.Get("type").(string); ok && value != "" { + req.Type = fleetapi.UpdateOutputJSONBodyType(value) + } + + _, diags = fleet.UpdateOutput(ctx, fleetClient, id, req) + if diags.HasError() { + return diags + } + + return resourceOutputRead(ctx, d, meta) +} + +func resourceOutputRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + fleetClient, diags := getFleetClient(d, meta) + if diags.HasError() { + return diags + } + + id := d.Get("output_id").(string) + d.SetId(id) + + output, diags := fleet.ReadOutput(ctx, fleetClient, id) + if diags.HasError() { + return diags + } + + // Not found. + if output == nil { + d.SetId("") + return nil + } + + if err := d.Set("name", output.Name); err != nil { + return diag.FromErr(err) + } + if output.Hosts != nil { + if err := d.Set("hosts", *output.Hosts); err != nil { + return diag.FromErr(err) + } + } + if err := d.Set("default_integrations", output.IsDefault); err != nil { + return diag.FromErr(err) + } + if output.IsDefaultMonitoring != nil { + if err := d.Set("default_monitoring", *output.IsDefaultMonitoring); err != nil { + return diag.FromErr(err) + } + } + if output.CaSha256 != nil { + if err := d.Set("ca_sha256", *output.CaSha256); err != nil { + return diag.FromErr(err) + } + } + if output.ConfigYaml != nil { + if err := d.Set("config_yaml", *output.ConfigYaml); err != nil { + return diag.FromErr(err) + } + } + + return nil +} + +func resourceOutputDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + fleetClient, diags := getFleetClient(d, meta) + if diags.HasError() { + return diags + } + + id := d.Get("output_id").(string) + d.SetId(id) + + if diags = fleet.DeleteOutput(ctx, fleetClient, id); diags.HasError() { + return diags + } + d.SetId("") + + return diags +} diff --git a/internal/fleet/output_resource_test.go b/internal/fleet/output_resource_test.go new file mode 100644 index 000000000..98f7ca348 --- /dev/null +++ b/internal/fleet/output_resource_test.go @@ -0,0 +1,125 @@ +package fleet_test + +import ( + "context" + "fmt" + "testing" + + "github.com/elastic/terraform-provider-elasticstack/internal/acctest" + "github.com/elastic/terraform-provider-elasticstack/internal/clients" + "github.com/elastic/terraform-provider-elasticstack/internal/clients/fleet" + "github.com/elastic/terraform-provider-elasticstack/internal/versionutils" + "github.com/hashicorp/go-version" + sdkacctest "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +var minVersionOutput = version.Must(version.NewVersion("8.6.0")) + +func TestAccResourceOutput(t *testing.T) { + policyName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + CheckDestroy: checkResourceOutputDestroy, + ProtoV5ProviderFactories: acctest.Providers, + Steps: []resource.TestStep{ + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minVersionOutput), + Config: testAccResourceOutputCreate(policyName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("elasticstack_fleet_output.test_output", "name", fmt.Sprintf("Output %s", policyName)), + resource.TestCheckResourceAttr("elasticstack_fleet_output.test_output", "type", "elasticsearch"), + resource.TestCheckResourceAttr("elasticstack_fleet_output.test_output", "config_yaml", "\"ssl.verification_mode\": \"none\"\n"), + resource.TestCheckResourceAttr("elasticstack_fleet_output.test_output", "default_integrations", "false"), + resource.TestCheckResourceAttr("elasticstack_fleet_output.test_output", "default_monitoring", "false"), + resource.TestCheckResourceAttr("elasticstack_fleet_output.test_output", "hosts.0", "https://elasticsearch:9200"), + ), + }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minVersionOutput), + Config: testAccResourceOutputUpdate(policyName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("elasticstack_fleet_output.test_output", "name", fmt.Sprintf("Updated Output %s", policyName)), + resource.TestCheckResourceAttr("elasticstack_fleet_output.test_output", "type", "elasticsearch"), + resource.TestCheckResourceAttr("elasticstack_fleet_output.test_output", "config_yaml", "\"ssl.verification_mode\": \"none\"\n"), + resource.TestCheckResourceAttr("elasticstack_fleet_output.test_output", "default_integrations", "false"), + resource.TestCheckResourceAttr("elasticstack_fleet_output.test_output", "default_monitoring", "false"), + resource.TestCheckResourceAttr("elasticstack_fleet_output.test_output", "hosts.0", "https://elasticsearch:9200"), + ), + }, + }, + }) +} + +func testAccResourceOutputCreate(id string) string { + return fmt.Sprintf(` +provider "elasticstack" { + elasticsearch {} + kibana {} +} + +resource "elasticstack_fleet_output" "test_output" { + name = "%s" + type = "elasticsearch" + config_yaml = yamlencode({ + "ssl.verification_mode" : "none" + }) + default_integrations = false + default_monitoring = false + hosts = [ + "https://elasticsearch:9200" + ] +} +`, fmt.Sprintf("Output %s", id)) +} + +func testAccResourceOutputUpdate(id string) string { + return fmt.Sprintf(` +provider "elasticstack" { + elasticsearch {} + kibana {} +} + +resource "elasticstack_fleet_output" "test_output" { + name = "%s" + type = "elasticsearch" + config_yaml = yamlencode({ + "ssl.verification_mode" : "none" + }) + default_integrations = false + default_monitoring = false + hosts = [ + "https://elasticsearch:9200" + ] +} + +`, fmt.Sprintf("Updated Output %s", id)) +} + +func checkResourceOutputDestroy(s *terraform.State) error { + client, err := clients.NewAcceptanceTestingClient() + if err != nil { + return err + } + + for _, rs := range s.RootModule().Resources { + if rs.Type != "elasticstack_fleet_output" { + continue + } + + fleetClient, err := client.GetFleetClient() + if err != nil { + return err + } + packagePolicy, diag := fleet.ReadOutput(context.Background(), fleetClient, rs.Primary.ID) + if diag.HasError() { + return fmt.Errorf(diag[0].Summary) + } + if packagePolicy != nil { + return fmt.Errorf("output id=%v still exists, but it should have been removed", rs.Primary.ID) + } + } + return nil +} diff --git a/provider/provider.go b/provider/provider.go index 5fa0dba4b..e70798a38 100644 --- a/provider/provider.go +++ b/provider/provider.go @@ -103,6 +103,8 @@ func New(version string) *schema.Provider { "elasticstack_kibana_space": kibana.ResourceSpace(), "elasticstack_fleet_agent_policy": fleet.ResourceAgentPolicy(), + "elasticstack_fleet_output": fleet.ResourceOutput(), + "elasticstack_fleet_server_host": fleet.ResourceFleetServerHost(), }, } diff --git a/templates/resources/fleet_output.md.tmpl b/templates/resources/fleet_output.md.tmpl new file mode 100644 index 000000000..d709042e6 --- /dev/null +++ b/templates/resources/fleet_output.md.tmpl @@ -0,0 +1,23 @@ +--- +subcategory: "Fleet" +layout: "" +page_title: "Elasticstack: elasticstack_fleet_output Resource" +description: |- + Creates or updates a Fleet Output. +--- + +# Resource: elasticstack_fleet_output + +Creates or updates a Fleet Output. + +## Example Usage + +{{ tffile "examples/resources/elasticstack_fleet_output/resource.tf" }} + +{{ .SchemaMarkdown | trimspace }} + +## Import + +Import is supported using the following syntax: + +{{ codefile "shell" "examples/resources/elasticstack_fleet_output/import.sh" }} diff --git a/templates/resources/fleet_server_host.md.tmpl b/templates/resources/fleet_server_host.md.tmpl new file mode 100644 index 000000000..fe47c7c0c --- /dev/null +++ b/templates/resources/fleet_server_host.md.tmpl @@ -0,0 +1,23 @@ +--- +subcategory: "Fleet" +layout: "" +page_title: "Elasticstack: elasticstack_fleet_server_host Resource" +description: |- + Creates or updates a Fleet Server Host. +--- + +# Resource: elasticstack_fleet_server_host + +Creates or updates a Fleet Server Host. + +## Example Usage + +{{ tffile "examples/resources/elasticstack_fleet_server_host/resource.tf" }} + +{{ .SchemaMarkdown | trimspace }} + +## Import + +Import is supported using the following syntax: + +{{ codefile "shell" "examples/resources/elasticstack_fleet_server_host/import.sh" }}