Save Environment

Saves environment variables for a repository.

Request Body

1{
2  "repository": "my-project/my-app",
3  "env": [
4    {"key": "LOG_LEVEL", "desired_value": "info"},
5    {"key": "DATABASE_URL", "desired_value": "postgres://user:pass@host:5432/db"}
6  ]
7}

Example

curl -X PUT "https://api.hola.cloud/api/console/env" \
  -H "Content-Type: application/json" \
  -d '{
    "repository": "my-project/my-app",
    "env": [
      {"key": "LOG_LEVEL", "desired_value": "info"},
      {"key": "DATABASE_URL", "desired_value": "postgres://user:pass@host:5432/db"}
    ]
  }'
PUT /api/console/env HTTP/1.1
Host: api.hola.cloud
Content-Type: application/json

{
    "repository": "my-project/my-app",
    "env": [
      {"key": "LOG_LEVEL", "desired_value": "info"},
      {"key": "DATABASE_URL", "desired_value": "postgres://user:pass@host:5432/db"}
    ]
  }
package main

import (
	"fmt"
	"io"
	"net/http"
	"encoding/json"
	"strings"
)

func main() {
	payload := map[string]any{"env": []any{map[string]any{"desired_value": "info", "key": "LOG_LEVEL"}, map[string]any{"desired_value": "postgres://user:pass@host:5432/db", "key": "DATABASE_URL"}}, "repository": "my-project/my-app"}
	bodyBytes, err := json.Marshal(payload)
	if err != nil {
		panic(err)
	}
	body := string(bodyBytes)

	req, err := http.NewRequest("PUT", "https://api.hola.cloud/api/console/env", strings.NewReader(body))
	if err != nil {
		panic(err)
	}
	req.Header.Set("Content-Type", "application/json")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	responseBody, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(responseBody))
}
<?php
$payload = ['env' => [['desired_value' => 'info', 'key' => 'LOG_LEVEL'], ['desired_value' => 'postgres://user:pass@host:5432/db', 'key' => 'DATABASE_URL']], 'repository' => 'my-project/my-app'];
$body = json_encode($payload);

$ch = curl_init();

curl_setopt_array($ch, [
    CURLOPT_URL => 'https://api.hola.cloud/api/console/env',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'PUT',
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
    ],
]);

$response = curl_exec($ch);
if ($response === false) {
    throw new Exception(curl_error($ch));
}
curl_close($ch);

echo $response;
import requests

import json

headers = {
    "Content-Type": "application/json",
}

payload = {"env": [{"desired_value": "info", "key": "LOG_LEVEL"}, {"desired_value": "postgres://user:pass@host:5432/db", "key": "DATABASE_URL"}], "repository": "my-project/my-app"}
body = json.dumps(payload)

response = requests.request(
    "PUT",
    "https://api.hola.cloud/api/console/env",
    headers=headers,
    data=body
)

print(response.text)
const payload = {"env": [{"desired_value": "info", "key": "LOG_LEVEL"}, {"desired_value": "postgres://user:pass@host:5432/db", "key": "DATABASE_URL"}], "repository": "my-project/my-app"};

const response = await fetch("https://api.hola.cloud/api/console/env", {
  method: "PUT",
  headers: {
    "Content-Type": "application/json"
  },
  body: JSON.stringify(payload)
});

console.log(await response.text());
const payload = {"env": [{"desired_value": "info", "key": "LOG_LEVEL"}, {"desired_value": "postgres://user:pass@host:5432/db", "key": "DATABASE_URL"}], "repository": "my-project/my-app"};

const response = await fetch("https://api.hola.cloud/api/console/env", {
  method: "PUT",
  headers: {
    "Content-Type": "application/json"
  },
  body: JSON.stringify(payload)
});

const text = await response.text();
console.log(text);
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Map;
import java.util.List;

public class Main {
    public static void main(String[] args) throws Exception {
        var payload = Map.of("env", List.of(Map.of("desired_value", "info", "key", "LOG_LEVEL"), Map.of("desired_value", "postgres://user:pass@host:5432/db", "key", "DATABASE_URL")), "repository", "my-project/my-app");
        var body = new ObjectMapper().writeValueAsString(payload);

        var request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.hola.cloud/api/console/env"))
            .method("PUT", HttpRequest.BodyPublishers.ofString(body))
            .header("Content-Type", "application/json")
            .build();

        var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}

Comments

Leave a comment