Ping-eindpunten

Gezondheidstoezicht en verbindingscontrole voor de Actions API.

Overzicht

Ping-eindpunten bieden een eenvoudige manier om de connectiviteit te testen en authenticatie met de mindzieAPI te valideren. Deze eindpunten zijn essentieel voor het monitoren van de systeemgezondheid en het oplossen van verbindingsproblemen.

Ongeautoriseerde Ping

GET /api/{tenantId}/{projectId}/action/unauthorized-ping

Basistest voor connectiviteit die geen authenticatie vereist. Gebruik dit om te verifiëren dat de API toegankelijk is.

Verzoek

GET https://your-mindzie-instance.com/api/{tenantId}/{projectId}/action/unauthorized-ping

Padparameters

Parameter Type Verplicht Beschrijving
tenantId GUID Ja Uw tenant-identificatie
projectId GUID Ja Uw projectidentificatie

Respons

HTTP/1.1 200 OK
Content-Type: text/plain

Ping Successful

Gebruiksscenario's

  • Basistesten van connectiviteit
  • Gezondheidstests voor load balancers
  • Netwerkproblemen oplossen
  • Monitoring van servicebeschikbaarheid

Geauthentiseerde Ping

GET /api/{tenantId}/{projectId}/action/ping

Geauthentiseerde connectiviteitstest die referenties valideert en toegang tot de opgegeven tenant en het project controleert.

Verzoek

GET https://your-mindzie-instance.com/api/{tenantId}/{projectId}/action/ping
Authorization: Bearer {your-access-token}

Padparameters

Parameter Type Verplicht Beschrijving
tenantId GUID Ja Uw tenant-identificatie
projectId GUID Ja Uw projectidentificatie

Respons

Succes (200 OK):

HTTP/1.1 200 OK
Content-Type: text/plain

Ping Successful (tenant id: 12345678-1234-1234-1234-123456789012)

Ongeautoriseerd (401):

HTTP/1.1 401 Unauthorized
Content-Type: text/plain

{error message describing authorization failure}

Gebruiksscenario's

  • Validatie van authenticatie
  • Verificatie van permissies
  • Testen van tokengeldigheid
  • Validatie van toegang tot tenant/project

Implementatievoorbeelden

cURL

# Ongeautoriseerde ping
curl -X GET "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/87654321-4321-4321-4321-210987654321/action/unauthorized-ping"

# Geauthentiseerde ping
curl -X GET "https://your-mindzie-instance.com/api/12345678-1234-1234-1234-123456789012/87654321-4321-4321-4321-210987654321/action/ping" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

JavaScript/Node.js

const TENANT_ID = '12345678-1234-1234-1234-123456789012';
const PROJECT_ID = '87654321-4321-4321-4321-210987654321';
const BASE_URL = 'https://your-mindzie-instance.com';

// Ongeautoriseerde ping
const unauthorizedPing = async () => {
  const response = await fetch(
    `${BASE_URL}/api/${TENANT_ID}/${PROJECT_ID}/action/unauthorized-ping`
  );
  const text = await response.text();
  console.log('Ongeautoriseerde ping:', text);
  return response.ok;
};

// Geauthentiseerde ping
const authenticatedPing = async (token) => {
  const response = await fetch(
    `${BASE_URL}/api/${TENANT_ID}/${PROJECT_ID}/action/ping`,
    {
      headers: {
        'Authorization': `Bearer ${token}`
      }
    }
  );

  if (response.ok) {
    const text = await response.text();
    console.log('Geauthentiseerde ping:', text);
    return true;
  } else {
    console.error('Authenticatie mislukt:', response.status);
    return false;
  }
};

Python

import requests

TENANT_ID = '12345678-1234-1234-1234-123456789012'
PROJECT_ID = '87654321-4321-4321-4321-210987654321'
BASE_URL = 'https://your-mindzie-instance.com'

def unauthorized_ping():
    """Basistest voor connectiviteit zonder authenticatie."""
    url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/action/unauthorized-ping'
    response = requests.get(url)
    print(f'Ongeautoriseerde ping: {response.text}')
    return response.ok

def authenticated_ping(token):
    """Geauthentiseerde connectiviteitstest."""
    url = f'{BASE_URL}/api/{TENANT_ID}/{PROJECT_ID}/action/ping'
    headers = {
        'Authorization': f'Bearer {token}'
    }

    response = requests.get(url, headers=headers)

    if response.ok:
        print(f'Geauthentiseerde ping: {response.text}')
        return True
    else:
        print(f'Authenticatie mislukt: {response.status_code}')
        return False

C#

using System.Net.Http;
using System.Threading.Tasks;

public class ActionApiClient
{
    private readonly HttpClient _httpClient;
    private readonly string _baseUrl;
    private readonly Guid _tenantId;
    private readonly Guid _projectId;

    public ActionApiClient(string baseUrl, Guid tenantId, Guid projectId, string accessToken)
    {
        _baseUrl = baseUrl;
        _tenantId = tenantId;
        _projectId = projectId;
        _httpClient = new HttpClient();
        _httpClient.DefaultRequestHeaders.Authorization =
            new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accessToken);
    }

    public async Task<bool> UnauthorizedPingAsync()
    {
        var url = $"{_baseUrl}/api/{_tenantId}/{_projectId}/action/unauthorized-ping";
        var response = await _httpClient.GetAsync(url);
        var content = await response.Content.ReadAsStringAsync();
        Console.WriteLine($"Ongeautoriseerde ping: {content}");
        return response.IsSuccessStatusCode;
    }

    public async Task<bool> AuthenticatedPingAsync()
    {
        var url = $"{_baseUrl}/api/{_tenantId}/{_projectId}/action/ping";
        var response = await _httpClient.GetAsync(url);
        var content = await response.Content.ReadAsStringAsync();

        if (response.IsSuccessStatusCode)
        {
            Console.WriteLine($"Geauthentiseerde ping: {content}");
            return true;
        }
        else
        {
            Console.WriteLine($"Authenticatie mislukt: {response.StatusCode}");
            return false;
        }
    }
}

Best Practices

  • Gezondheidstests: Gebruik de ongeautoriseerde ping voor geautomatiseerde gezondheidsmonitoringsystemen
  • Pre-flight validatie: Roep geauthentiseerde ping aan voordat acties worden uitgevoerd om referenties te valideren
  • Foutafhandeling: Verwerk netwerk time-outs en authenticatiefouten altijd op een nette manier
  • Monitoring: Stel geautomatiseerde meldingen in op basis van falende pings om storingen vroegtijdig te detecteren