-
Notifications
You must be signed in to change notification settings - Fork 163
Adds Serverless API examples page #2208
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6e8d32f
Adds Serverless API example page
kosabogi 326fcb0
Adds serverless API examples page
kosabogi 04f0fdb
Removes duplicated page
kosabogi 0e9bfb1
Merge branch 'main' into serverless-api
kosabogi b08014e
Update deploy-manage/deploy/elastic-cloud/manage-serverless-projects-…
kosabogi 5d05994
Update deploy-manage/deploy/elastic-cloud/manage-serverless-projects-…
kosabogi 47636ee
Update deploy-manage/deploy/elastic-cloud/manage-serverless-projects-…
kosabogi d558d7f
Update deploy-manage/deploy/elastic-cloud/manage-serverless-projects-…
kosabogi 86ae8a6
Update deploy-manage/deploy/elastic-cloud/manage-serverless-projects-…
kosabogi e817771
Update deploy-manage/deploy/elastic-cloud/manage-serverless-projects-…
kosabogi ea9b598
Update deploy-manage/deploy/elastic-cloud/manage-serverless-projects-…
kosabogi 9516fa5
Merge branch 'main' into serverless-api
kosabogi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
158 changes: 158 additions & 0 deletions
158
deploy-manage/deploy/elastic-cloud/manage-serverless-projects-using-api.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
--- | ||
mapped_pages: | ||
- https://www.elastic.co/guide/en/serverless/current/security-project-settings.html | ||
applies_to: | ||
serverless: ga | ||
navigation_title: Manage serverless projects using the API | ||
--- | ||
|
||
# Manage serverless projects using the API [serverless-api] | ||
|
||
On this page, you can find examples of how to create and manage serverless projects using the [Elastic Cloud Serverless API](https://www.elastic.co/docs/api/doc/elastic-cloud-serverless/). | ||
|
||
To learn about API principles, authentication, and how to use the OpenAPI specification, refer to the [Elastic Cloud Serverless API](https://www.elastic.co/docs/api/doc/elastic-cloud-serverless/) documentation. | ||
|
||
The available APIs are grouped by project type: | ||
|
||
- APIs for [Search projects](https://www.elastic.co/docs/api/doc/elastic-cloud-serverless/group/endpoint-elasticsearch-projects) | ||
- APIs for [Observatibility projects](https://www.elastic.co/docs/api/doc/elastic-cloud-serverless/group/endpoint-observability-projects) | ||
- APIs for [Security projects](https://www.elastic.co/docs/api/doc/elastic-cloud-serverless/group/endpoint-security-projects) | ||
|
||
To try the examples in this section, [set up an API key](#general-manage-project-with-api-set-up-api-key) and [create an {{serverless-full}} project](#general-manage-project-with-api-create-a-serverless-elasticsearch-project). | ||
|
||
## Set up an API key [general-manage-project-with-api-set-up-api-key] | ||
|
||
1. [Create an API key](https://www.elastic.co/docs/deploy-manage/api-keys/elastic-cloud-api-keys). | ||
2. Store the generated API key as an environment variable so that you don’t need to specify it again for each request: | ||
|
||
```console | ||
export API_KEY="YOUR_GENERATED_API_KEY" | ||
``` | ||
|
||
## Create an {{serverless-full}} project [general-manage-project-with-api-create-a-serverless-elasticsearch-project] | ||
|
||
```bash | ||
curl -H "Authorization: ApiKey $API_KEY" \ | ||
-H "Content-Type: application/json" \ | ||
"https://api.elastic-cloud.com/api/v1/serverless/projects/elasticsearch" \ | ||
-XPOST --data '{ | ||
"name": "My project", <1> | ||
"region_id": "aws-us-east-1" <2> | ||
}' | ||
``` | ||
1. Replace `My project` with a more descriptive name in this call. | ||
2. You can obtain a [list of available regions](#general-manage-project-with-api-list-available-regions). | ||
|
||
The response from the create project request will include the created project details, such as the project ID, the credentials to access the project, and the endpoints to access different apps such as {{es}} and {{kib}}. | ||
|
||
Example of `Create project` response: | ||
|
||
```console-response | ||
{ | ||
"id": "cace8e65457043698ed3d99da2f053f6", | ||
"endpoints": { | ||
"elasticsearch": "https://sample-project-c990cb.es.us-east-1.aws.elastic.cloud", | ||
"kibana": "https://sample-project-c990cb-c990cb.kb.us-east-1.aws.elastic.cloud" | ||
}, | ||
"credentials": { | ||
"username": "admin", | ||
"password": "abcd12345" | ||
} | ||
(...) | ||
} | ||
``` | ||
|
||
You can store the project ID as an environment variable for the next requests: | ||
|
||
```console | ||
export PROJECT_ID=cace8e65457043698ed3d99da2f053f6 | ||
``` | ||
|
||
## API examples | ||
|
||
The following examples show how to interact with the APIs, covering common operations such as: | ||
|
||
- [Creating a project](#general-manage-project-with-api-create-a-serverless-elasticsearch-project) | ||
- [Retrieving project details](#general-manage-project-with-api-get-project) | ||
- [Retrieving the project's status](#general-manage-project-with-api-get-project-status) | ||
- [Resetting credentials](#general-manage-project-with-api-reset-credentials) | ||
- [Deleting a project](#general-manage-project-with-api-delete-project) | ||
- [Updating a project](#general-manage-project-with-api-update-project) | ||
- [Listing regions where projects can be created](#general-manage-project-with-api-list-available-regions) | ||
|
||
### Get project [general-manage-project-with-api-get-project] | ||
kosabogi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
You can retrieve your project details through an API call: | ||
|
||
```bash | ||
curl -H "Authorization: ApiKey $API_KEY" \ | ||
"https://api.elastic-cloud.com/api/v1/serverless/projects/elasticsearch/${PROJECT_ID}" | ||
``` | ||
|
||
### Get project status [general-manage-project-with-api-get-project-status] | ||
kosabogi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
The 'status' endpoint indicates whether the project is initialized and ready to be used. In the response, the project's `phase` will change from "initializing" to "initialized" when it is ready: | ||
|
||
```bash | ||
curl -H "Authorization: ApiKey $API_KEY" \ | ||
"https://api.elastic-cloud.com/api/v1/serverless/projects/elasticsearch/${PROJECT_ID}/status" | ||
``` | ||
|
||
Example response: | ||
|
||
```console-response | ||
{ | ||
"phase":"initializing" | ||
} | ||
``` | ||
|
||
### Reset Credentials [general-manage-project-with-api-reset-credentials] | ||
kosabogi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
If you lose the credentials provided at the time of the project creation, you can reset the credentials by using the following endpoint: | ||
|
||
```bash | ||
curl -H "Authorization: ApiKey $API_KEY" \ | ||
-XPOST \ | ||
"https://api.elastic-cloud.com/api/v1/serverless/projects/elasticsearch/${PROJECT_ID}/_reset-credentials" | ||
``` | ||
|
||
### Delete Project [general-manage-project-with-api-delete-project] | ||
kosabogi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
You can delete your project via the API: | ||
|
||
```bash | ||
curl -XDELETE -H "Authorization: ApiKey $API_KEY" \ | ||
"https://api.elastic-cloud.com/api/v1/serverless/projects/elasticsearch/${PROJECT_ID}" | ||
``` | ||
|
||
### Update Project [general-manage-project-with-api-update-project] | ||
kosabogi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
You can update your project using a PATCH request. Only the fields included in the body of the request will be updated. | ||
|
||
```bash | ||
curl -H "Authorization: ApiKey $API_KEY" \ | ||
-H "Content-Type: application/json" \ | ||
"https://api.elastic-cloud.com/api/v1/serverless/projects/elasticsearch/${PROJECT_ID}" \ | ||
-XPATCH --data '{ | ||
"name": "new name", | ||
"alias": "new-project-alias" | ||
}' | ||
``` | ||
|
||
### List available regions [general-manage-project-with-api-list-available-regions] | ||
|
||
You can obtain the list of regions where projects can be created using the API: | ||
|
||
```bash | ||
curl -H "Authorization: ApiKey $API_KEY" \ | ||
"https://api.elastic-cloud.com/api/v1/serverless/regions" | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
kosabogi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.