elastic / terraform-provider-elasticstack

Terraform provider for Elastic Stack
https://registry.terraform.io/providers/elastic/elasticstack/latest/docs
Apache License 2.0
167 stars 91 forks source link

Kibana breaking change: Remove Deprecated Kibana Saved Object APIs #665

Closed TinaHeiligers closed 2 months ago

TinaHeiligers commented 3 months ago

Most of the Kibana Saved Objects HTTP APIs were deprecated in 8.7 (released Mar 30, 2023) and the deprecation period will run out by v9. Kibana Core plans to remove the deprecated APIs in v9 (except _import, _export, and _resolveImportErrors, which are public).

The APIs listed below need to be removed and all current and future use of the Saved Objects APIs will be restricted to the public APIs.

tobio commented 3 months ago

Duplicate of https://github.com/elastic/terraform-provider-elasticstack/issues/637

TinaHeiligers commented 3 months ago

I'd already discussed this with the team! This issue is for deleting the deprecated saved objects APIs:

We want:

type OptionalFindParameters struct {
    ObjectsPerPage        int
    Page                  int
    Search                string
    DefaultSearchOperator string
    SearchFields          []string
    Fields                []string
    SortField             string
    HasReference          string
}

// KibanaSavedObjectGet permit to get saved object from Kibana
type KibanaSavedObjectGet func(objectType string, id string, kibanaSpace string) (map[string]interface{}, error)

// KibanaSavedObjectFind permit to find saved objects from Kibana
type KibanaSavedObjectFind func(objectType string, kibanaSpace string, optionalParameters *OptionalFindParameters) (map[string]interface{}, error)

// KibanaSavedObjectCreate permit to create saved object in Kibana
type KibanaSavedObjectCreate func(data map[string]interface{}, objectType string, id string, overwrite bool, kibanaSpace string) (map[string]interface{}, error)

// KibanaSavedObjectUpdate permit to update saved object in Kibana
type KibanaSavedObjectUpdate func(data map[string]interface{}, objectType string, id string, kibanaSpace string) (map[string]interface{}, error)

// KibanaSavedObjectDelete permit to delete saved object in Kibana
type KibanaSavedObjectDelete func(objectType string, id string, kibanaSpace string) error

// KibanaSavedObjectExport permit to export saved objects from Kibana
type KibanaSavedObjectExport func(objectTypes []string, objects []map[string]string, deepReference bool, kibanaSpace string) ([]byte, error)

// KibanaSavedObjectImport permit to import saved objects in Kibana
type KibanaSavedObjectImport func(data []byte, overwrite bool, kibanaSpace string) (map[string]interface{}, error)

// String permit to return OptionalFindParameters object as JSON string
func (o *OptionalFindParameters) String() string {
    json, _ := json.Marshal(o)
    return string(json)
}
...rest

To become:

// KibanaSavedObjectExport permit to export saved objects from Kibana
type KibanaSavedObjectExport func(objectTypes []string, objects []map[string]string, deepReference bool, kibanaSpace string) ([]byte, error)

// KibanaSavedObjectImport permit to import saved objects in Kibana
type KibanaSavedObjectImport func(data []byte, overwrite bool, kibanaSpace string) (map[string]interface{}, error)
...whatever remains

@tobio I'm reopening the issue for further discussions and tracking the work.

cc @afharo @lukeelmers @jloleysens

TinaHeiligers commented 3 months ago

I followed the trail and came to the same conclusion as https://github.com/elastic/terraform-provider-elasticstack/issues/659#issuecomment-2163933288. The underlying kibana client isn't maintained anymore, forcing the need for a local copy.

Since our version is under our control, we should be fine with making the changes locally. @tobio I have a local branch where I've removed the code. I'll need some guidance for updating the tests.

TinaHeiligers commented 2 months ago

closing as superseded by https://github.com/elastic/terraform-provider-elasticstack/issues/637