Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add _connector API #2367

Conversation

jedrazb
Copy link
Member

@jedrazb jedrazb commented Dec 12, 2023

👋 Hey, I'm not sure if it's a best practice to add the client types after the FF. If I mislabelled it please let me know. The connectors API actions are introduced in 8.12.

Changes

  • Copy endpoints from es rest-api-spec
  • Copy and adapt types from Kibana ts definition
  • Added types for
    • connector.put
    • connector.post
    • connector.delete
    • connector.get
    • connector.list
    • connector.check_in
    • connector.update_error
    • connector.update_scheduling
    • connector.update_filtering
    • connector.update_configuration
    • connector.update_pipeline
    • connector.last_sync <- it should be update_last_sync, we should followup to fix this in 8.13 on ES side

@jedrazb jedrazb requested a review from a team as a code owner December 12, 2023 10:51
@jedrazb jedrazb changed the title [Connector API] Add types for create, list, get, delete endpoints [Connector API] Add types for Connector API endpoints Dec 13, 2023
@jedrazb jedrazb changed the title [Connector API] Add types for Connector API endpoints [Connector API] Add types for Connector API actions Dec 13, 2023
@jedrazb jedrazb changed the title [Connector API] Add types for Connector API actions [Connector API] Add _connector API Dec 13, 2023
@jedrazb jedrazb force-pushed the connectors-api-add-connectors-api-spec-create-update-delete-list-get branch from 8e44f4e to ba8f107 Compare December 13, 2023 13:30
@jedrazb jedrazb changed the title [Connector API] Add _connector API Add _connector API Dec 13, 2023
Copy link
Contributor

@Anaethelion Anaethelion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments.

I've also taken the liberty to add the links to the documentation within the endpoints, feel free to edit/update if I made any mistake.

specification/connector/_types/Connector.ts Outdated Show resolved Hide resolved
specification/connector/_types/Connector.ts Outdated Show resolved Hide resolved
specification/connector/_types/Connector.ts Outdated Show resolved Hide resolved
specification/connector/_types/Connector.ts Outdated Show resolved Hide resolved
specification/connector/_types/Connector.ts Outdated Show resolved Hide resolved
@jedrazb
Copy link
Member Author

jedrazb commented Jan 2, 2024

Hey @Anaethelion thank you for review and adding the documentation links 👍 . I addressed your feedback and also updated the json spec files with correct doc links.

Given the release timeline is it still ok to keep the backport 8.12 label?

There are couple of more endpoints to be added (related to _connector/_sync_job API) in a subsequent PR.

@jedrazb jedrazb requested review from Anaethelion and swallez January 2, 2024 16:27
@jedrazb
Copy link
Member Author

jedrazb commented Jan 4, 2024

Hey @swallez 👋 since Anaethelion is OOO this week, I was suggested to add you as a reviewer to this PR. Could you take a look?

Copy link
Member

@swallez swallez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this big PR! I left a number of comments related to the style and constraints expected by the API specification.

Some comments only appear once but have many occurrences, so let me restate them here:

  • string | number | boolean | null should be replaced by ScalarValue, or FieldValue if it actually also accepts objects
  • the use of ' | null' should be avoided unless null has a special meaning. Use optional fields instead.

specification/connector/_types/Connector.ts Outdated Show resolved Hide resolved
}

enum DisplayType {
TEXTBOX = 'textbox',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For enums you don't need to specify both identifier and value if they are the same (even with a different casing). Language generators will take care of using their casing convention. So this can be

enum DisplayType {
  textbox,
  textarea,
  numeric...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pointing this out 👍 I'm guilty of just copy-pasting most of the types from defs in Kibana

specification/connector/_types/Connector.ts Outdated Show resolved Hide resolved
specification/connector/_types/Connector.ts Outdated Show resolved Hide resolved
specification/connector/_types/Connector.ts Outdated Show resolved Hide resolved
display: DisplayType
label: string
options: SelectOption[]
order?: number | null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the value null different from missing (i.e. optional) field? If not, remove null (many occurrences).

Copy link
Member Author

@jedrazb jedrazb Jan 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I revised the types and I think for majority of cases we can safely mark fields as optional (instead of having them nullable).

The are some exceptions like: error fields that are (string | null), I can think of some situations where we want to mark error as null (when connector gets back to a healthy state).

Also, last_sync... fields can have explicit null value in index. Could marking them optional instead of nullable break things, given that we use Connector type to describe return type of get/list endpoints?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. So we have to implement #2049 that clearly distinguishes "null as optional" and "null as an actual value" in the spec. Adding that on my immediate todo list.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it imply that this PR needs to wait until #2049 is implemented? We are not in a rush, just want to clarify

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because currently null is considered as the equivalent of "missing" in languages where objects are represented as data structures and not dictionaries (i.e. all strictly typed languages). #2049 is meant to capture "null is an actual value" in the API spec so that we can generate code that correctly handles this.

Copy link
Member Author

@jedrazb jedrazb Jan 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @swallez, just a gentle ping regarding #2049. Do you have a timeline when we can expect this to be available?

specification/connector/_types/Connector.ts Outdated Show resolved Hide resolved
specification/connector/_types/Connector.ts Outdated Show resolved Hide resolved
specification/connector/_types/Connector.ts Outdated Show resolved Hide resolved
specification/connector/_types/Connector.ts Outdated Show resolved Hide resolved
@jedrazb jedrazb requested a review from swallez January 8, 2024 11:28
@jedrazb
Copy link
Member Author

jedrazb commented Jan 9, 2024

Hey @Anaethelion @swallez I hope that all feedback is addressed now, can you take a look at this PR again?
Edit, I just realised you left some comments, taking a look 👀

@jedrazb
Copy link
Member Author

jedrazb commented Jan 9, 2024

CI steps are breaking in the setup job phase with

Error: Internal server error occurred while resolving "actions/checkout@v[2](https://github.com/elastic/elasticsearch-specification/actions/runs/7461636399/job/20302186145?pr=2367#step:1:2)"

Ahh probably it's github issue, see https://www.githubstatus.com/ - rerunning manually fixed it

Copy link
Member

@swallez swallez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! There are a few minor naming issues left, and we'll be good to go!

/**
* A comma-separated list of connector index names to fetch connector documents for
*/
index_name?: Fields
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fields is meant to hold a list of index field names. If these are ES indices, then Indices should be used.

/**
* A comma-separated list of connector names to fetch connector documents for
*/
connector_name?: Fields
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Names instead

/**
* A comma-separated list of connector service types to fetch connector documents for
*/
service_type?: Fields
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are service type identifiers? Then use Ids, or otherwise Names.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are arbitrary strings, so it is Names for our case

configuration: ConnectorConfiguration
custom_scheduling: ConnectorCustomScheduling
description?: string
error: WithNullValue<string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this field really required? Will it always be present? If yes, this means that null will mean "meaningful null" in responses. What does this mean?

Same question for a few other uses of required WithNullValue fields in this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I do agree with you here. Since the Connector denotes a response type. In a response, a missing (optional) field does indicate that the field is in fact null.

I will adapt this, but I the meaningful is needed for requests definitions to set certain fields to null.

@pquentin
Copy link
Member

"Validate APIs / build" was failing because of me, I fixed it and retried the build.

Copy link
Contributor

Following you can find the validation results for the APIs you have changed.

API Status Request Response
connector.check_in Missing test Missing test
connector.delete Missing test Missing test
connector.get Missing test Missing test
connector.last_sync Missing test Missing test
connector.list Missing test Missing test
connector.post Missing test Missing test
connector.put Missing test Missing test
connector.update_api_key_id Missing test Missing test
connector.update_configuration Missing test Missing test
connector.update_error Missing test Missing test
connector.update_filtering Missing test Missing test
connector.update_index_name Missing test Missing test
connector.update_name Missing test Missing test
connector.update_native Missing test Missing test
connector.update_pipeline Missing test Missing test
connector.update_scheduling Missing test Missing test
connector.update_service_type Missing test Missing test
connector.update_status Missing test Missing test

You can validate these APIs yourself by using the make validate target.

@jedrazb jedrazb requested a review from swallez April 11, 2024 08:02
Copy link
Member

@swallez swallez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🎉

@jedrazb jedrazb enabled auto-merge (squash) April 11, 2024 09:41
@jedrazb jedrazb merged commit c1ed27e into main Apr 11, 2024
6 checks passed
@jedrazb jedrazb deleted the connectors-api-add-connectors-api-spec-create-update-delete-list-get branch April 11, 2024 11:01
* The connector index name
*/
body: {
index_name: WithNullValue<string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@swallez @Anaethelion I'm late to the party, but shouldn't we use the IndexName alias instead of string at these places?

Like:

index_name: WithNullValue<IndexName>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants