### Build CoreLib and API2 Dependencies
Source: https://github.com/europeana/api2/blob/develop/README.md
Clone the CoreLib and API2 repositories and build them using Maven. Ensure CoreLib is built and installed before API2.
```bash
$ git clone https://github.com/europeana/corelib.git
$ cd corelib
$ mvn clean install
$ git clone https://github.com/europeana/api2.git
$ cd api2
$ mvn clean install
```
--------------------------------
### Mockup RSS Feed for Google Field Trip
Source: https://github.com/europeana/api2/wiki/User-Manual
This is an example of the RSS feed structure generated for Google Field Trip, showcasing a single item with all required fields.
```xml
Kuuluisa poro piilopaikkoja
http://tama.on.sivusto.fi
Sulatettu kävellä kutsua verinen turisteja katsomaan meidän suurin historiallinen poroa diskot Helmi Pohjoiseenfihttp://piilopaikkoja.fi/kaviot/johtajat.jpghttp://europeana.eu/portal/record/12345/kaviot.htmlKAVIOT KNARRVIKEN
http://tama.on.sivusto.fi/valituksiin/knarrviken.html
Vakavasti! Sinun pitäisi nähdä joitakin paikkoja näin ilmoitettu.
On hämmästyttävää, varsinkin kun otetaan huomioon, että heillä oli vain seitsemän metriä
punaista puuvillalankaa loitolla jääkarhuja
]]>
http://tama.on.sivusto.fi/tilannekuvia/287_pohjoiseen.jpgCopyrights monimutkainen]]>68.324562 25.063433Wed, Aug 20 2014 13:36:43 +0200
```
--------------------------------
### Build and Deploy Search API Locally
Source: https://github.com/europeana/api2/blob/develop/k8s/Readme.md
Steps to build the API, create a Docker image, and apply Kubernetes manifests for local deployment.
```bash
mvn clean package -f ../pom.xml
```
```bash
docker build -t europeana/search-api ../
```
```bash
kustomize build overlays/dev
```
```bash
kubectl apply -k overlays/dev
```
```bash
kubectl get deployment/search-api-deployment
```
```bash
minikube ip
```
--------------------------------
### Build and Apply Kustomize Manifests
Source: https://github.com/europeana/api2/blob/develop/k8s/Readme.md
View the customized Kubernetes manifests by running 'kustomize build'. Apply the manifests to the cluster using 'kubectl apply'.
```bash
kustomize build overlays/cloud
```
```bash
kubectl apply -k overlays/cloud
```
--------------------------------
### Generate Kustomize Configuration Files
Source: https://github.com/europeana/api2/blob/develop/k8s/Readme.md
Use envsubst to generate YAML configuration files from templates. Ensure you are in the correct directory and adjust paths as needed.
```bash
envsubst < ingress.properties.yaml.template > ingress.properties.yaml
```
```bash
envsubst < hpa.properties.yaml.template > hpa.properties.yaml
```
```bash
envsubst < deployment_patch.properties.yaml.template > deployment_patch.properties.yaml
```
--------------------------------
### Set Application Image Version with Kustomize
Source: https://github.com/europeana/api2/blob/develop/k8s/Readme.md
Specify the application version to deploy using the kustomize edit set image command. Replace ${API_BRANCH} with the desired Git branch, tag, or commit hash.
```bash
kustomize edit set image search-api:${API_BRANCH}
```
--------------------------------
### Add Label to Kustomize Resources
Source: https://github.com/europeana/api2/blob/develop/k8s/Readme.md
Apply a label to resources and services using kustomize edit set label. The label format includes the application name and the resource suffix.
```bash
kustomize edit set label app:search-api-${RESOURCE_SUFFIX}
```
--------------------------------
### Generate Kubernetes Deployment Patch
Source: https://github.com/europeana/api2/blob/develop/README.md
Generate a Kubernetes deployment patch file by setting environment variables and using envsubst to substitute template variables. This is part of the deployment process.
```bash
envsubst < $WORKSPACE/api2/k8s/overlays/canary/deployment_patch.properties.yaml.template > $WORKSPACE/api2/k8s/overlays/canary/deployment_patch.properties.yaml
```
--------------------------------
### Login Request with cURL
Source: https://github.com/europeana/api2/wiki/User-Manual
Use this command to obtain a session identifier by POSTing API key and secret to the /login endpoint. Ensure to replace placeholders with your actual credentials.
```bash
$ curl -i -d "api2key=[your api key]&secret=[your secret key]" "http://localhost:8080/api2/login"
```
--------------------------------
### Login and Obtain Session Identifier
Source: https://github.com/europeana/api2/wiki/User-Manual
This snippet shows how to authenticate by POSTing your API key and secret to the /login endpoint to obtain a session identifier.
```APIDOC
## Login and Obtain Session Identifier
### Description
First you have to POST the api2key and secret parameters to the /login page to obtain a session identifier.
### Method
POST
### Endpoint
/login
### Request Body
- **api2key** (string) - Required - Your public API key.
- **secret** (string) - Required - Your secret API key.
### Request Example
```bash
curl -i -d "api2key=[your api key]&secret=[your secret key]" "http://localhost:8080/api2/login"
```
### Response
#### Success Response (302 Found)
- **Set-Cookie** (string) - Contains the JSESSIONID for subsequent requests.
#### Response Example
```
HTTP/1.1 302 Moved Temporarily
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=54B3FED3649FD8D205C297A52363825B; Path=/api2; HttpOnly
Location: http://localhost:8080/api2/
Content-Length: 0
Date: Fri, 13 Jul 2012 10:41:40 GMT
```
**Note**: The session ID is found in the `Set-Cookie` header, e.g., `JSESSIONID=54B3FED3649FD8D205C297A52363825B`.
```
--------------------------------
### Append Suffix to Kustomize Resources
Source: https://github.com/europeana/api2/blob/develop/k8s/Readme.md
Add a unique suffix to all resources in the deployment using kustomize edit set namesuffix. This is useful for deploying multiple instances of an application in the same namespace. Ensure ${RESOURCE_SUFFIX} is unique within the namespace.
```bash
kustomize edit set namesuffix -- ${RESOURCE_SUFFIX}
```
--------------------------------
### Perform a Search using Session Identifier
Source: https://github.com/europeana/api2/wiki/User-Manual
This snippet demonstrates how to use the obtained session identifier as a cookie to perform a search query.
```APIDOC
## Perform a Search using Session Identifier
### Description
Now use the obtained session identifier as a cookie to make authenticated requests, such as searching.
### Method
GET
### Endpoint
/search.json
### Parameters
#### Query Parameters
- **query** (string) - Required - The search term.
#### Cookie Parameters
- **JSESSIONID** (string) - Required - The session identifier obtained from the login response.
### Request Example
```bash
curl -i -b "JSESSIONID=54B3FED3649FD8D205C297A52363825B" "http://localhost:8080/api2/search.json?query=john"
```
### Response
#### Success Response (200 OK)
- **apikey** (string) - Your public API key.
- **action** (string) - The action performed (e.g., "search.json").
- **success** (boolean) - Indicates if the operation was successful.
- **statsDuration** (int) - Duration of the statistics in milliseconds.
- **itemsCount** (int) - The number of items returned in this request.
- **totalResults** (int) - The total number of results available.
- **items** (array) - An array of search result items.
#### Response Example
```json
{
"apikey": "[your api key]",
"action": "search.json",
"success": true,
"statsDuration": 0,
"itemsCount": 12,
"totalResults": 880,
"items": [{...},{...}...]
}
```
```
--------------------------------
### Search Request with Session Cookie using cURL
Source: https://github.com/europeana/api2/wiki/User-Manual
This command demonstrates how to use the extracted session identifier (JSESSIONID) as a cookie for subsequent authenticated requests, such as performing a search. Replace the session ID and query as needed.
```bash
$ curl -i -b "JSESSIONID=54B3FED3649FD8D205C297A52363825B" "http://localhost:8080/api2/search.json?query=john"
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.