Job Queue Public API PHP Client

Overview

Job Queue API PHP Client Build Status

PHP client for the Job Queue API (API docs).

Usage

composer require keboola/job-queue-api-php-client
use Keboola\JobQueueClient\Client;
use Keboola\JobQueueClient\JobData;use Psr\Log\NullLogger;

$client = new Client(
    new NullLogger(),
    'http://queue.conenection.keboola.com/',
    'xxx-xxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
);
$result = $client->createJob(new JobData(
    'keboola.ex-db-snowflake',
    '123',
    [],
    'run'
));
var_dump($result['id']);

Development

  • Create a service principal to download the required images and login:

        SERVICE_PRINCIPAL_NAME=[USERNAME]-job-queue-internal-api-pull
        ACR_REGISTRY_ID=$(az acr show --name keboolapes --query id --output tsv --subscription c5182964-8dca-42c8-a77a-fa2a3c6946ea)
        SP_PASSWORD=$(az ad sp create-for-rbac --name http://$SERVICE_PRINCIPAL_NAME --scopes $ACR_REGISTRY_ID --role acrpull --query password --output tsv)
        SP_APP_ID=$(az ad sp show --id http://$SERVICE_PRINCIPAL_NAME --query appId --output tsv)    
  • Login and check that you can pull the image:

        docker login keboolapes.azurecr.io --username $SP_APP_ID --password $SP_PASSWORD
        docker pull keboolapes.azurecr.io/job-queue-internal-api:latest
        docker pull keboolapes.azurecr.io/job-queue-api:latest
  • Add the credentials to the k8s cluster:

        kubectl create secret docker-registry regcred --docker-server="https://keboolapes.azurecr.io" --docker-username="$SP_APP_ID" --docker-password="$SP_PASSWORD" --namespace dev-job-queue-api-php-client
        kubectl patch serviceaccount default -p "{\"imagePullSecrets\":[{\"name\":\"regcred\"}]}" --namespace dev-job-queue-api-php-client
  • Set the following environment variables in set-env.sh file (use set-env.template.sh as sample):

    • test_storage_api_url - Keboola Connection URL.
    • test_storage_api_token - Token to a test project.
  • Set one of Azure or AWS resources (or both, but only one is needed).

AWS Setup

  • Create a user (JobQueueApiPhpClient) for local development using the provisioning/aws.json CF template.
    • Create AWS key for the created user.
    • Set the following environment variables in set-env.sh file (use set-env.template.sh as sample):
      • test_aws_access_key_id - The created security credentials for the JobQueueApiPhpClient user.
      • test_aws_secret_access_key - The created security credentials for the JobQueueApiPhpClient user.
      • test_kms_region - Region output of the above stack.
      • test_kms_key_id - KmsKey output of the above stack.

Azure Setup

  • Create a resource group:

    az account set --subscription "Keboola DEV PS Team CI"
    az group create --name testing-job-queue-api-php-client --location "East US"
  • Create a service principal:

    az ad sp create-for-rbac --name testing-job-queue-api-php-client
  • Use the response to set values test_azure_client_id, test_azure_client_secret and test_azure_tenant_id in the set-env.sh file:

    test_azure_client_id "displayName": "testing-job-queue-internal-api-php-client", "name": "http://testing-job-queue-internal-api-php-client", "password": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", //-> test_azure_client_secret "tenant": "9b85ee6f-xxxxxxxxxxxxxxxxxxxxxxxxxxx" //-> test_azure_tenant_id }">
    {
      "appId": "268a6f05-xxxxxxxxxxxxxxxxxxxxxxxxxxx", //-> test_azure_client_id
      "displayName": "testing-job-queue-internal-api-php-client",
      "name": "http://testing-job-queue-internal-api-php-client",
      "password": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", //-> test_azure_client_secret
      "tenant": "9b85ee6f-xxxxxxxxxxxxxxxxxxxxxxxxxxx" //-> test_azure_tenant_id
    }
  • Get ID of the service principal:

    SERVICE_PRINCIPAL_ID=$(az ad sp list --display-name testing-job-queue-api-php-client --query "[0].objectId" --output tsv)
  • Deploy the key vault, provide tenant ID, service principal ID and group ID from the previous commands:

    ./set-env.sh # set $test_azure_tenant_id env
    az deployment group create --resource-group testing-job-queue-api-php-client --template-file provisioning/azure.json --parameters vault_name=test-job-queue-client tenant_id=$test_azure_tenant_id service_principal_object_id=$SERVICE_PRINCIPAL_ID
  • Show Key Vault URL

    az keyvault show --name test-job-queue-client --query "properties.vaultUri" --output tsv

returns e.g. https://test-job-queue-client.vault.azure.net/, use this to set values in set-env.sh file: - test_azure_key_vault_url - https://test-job-queue-client.vault.azure.net/

Generate environment configuration

provisioning/environments.yaml kubectl apply -f ./provisioning/environments.yaml kubectl apply -f ./provisioning/public-api.yaml queue_public_api_ip=`kubectl get svc --output jsonpath --template "{.items[?(@.metadata.name==\"dev-job-queue-api-service\")].status.loadBalancer.ingress[].ip}" --namespace=dev-job-queue-api-php-client` echo "queue_public_api_url: http://$(queue_public_api_ip):94"">
export db_password="cm9vdA==" #root
export db_password_urlencoded="cm9vdA=="
export test_azure_client_secret_base64=$(printf "%s" "$test_azure_client_secret"| base64 --wrap=0)
export test_aws_secret_access_key_base64=$(printf "%s" "$test_aws_secret_access_key"| base64 --wrap=0)

./set-env.sh
envsubst < provisioning/environments.yaml.template > provisioning/environments.yaml
kubectl apply -f ./provisioning/environments.yaml
kubectl apply -f ./provisioning/public-api.yaml
queue_public_api_ip=`kubectl get svc --output jsonpath --template "{.items[?(@.metadata.name==\"dev-job-queue-api-service\")].status.loadBalancer.ingress[].ip}" --namespace=dev-job-queue-api-php-client`

echo "queue_public_api_url: http://$(queue_public_api_ip):94"

Store the result queue_public_api_ip in set-env.sh.

Run tests

  • With the above setup, you can run tests:

    docker-compose build
    source ./set-env.sh && docker-compose run tests
  • To run tests with local code use:

    docker-compose run tests-local composer install
    source ./set-env.sh && docker-compose run tests-local

License

MIT licensed, see LICENSE file.

You might also like...
A simple Object Oriented PHP Client for Termii SMS API

Termii Client A simple Object Oriented PHP Client for Termii SMS API. Uses Termii API. Requirements PHP = 7.2 Guzzlehttp ~6|~7 Installation Via Compo

Xendit REST API Client for PHP - Card, Virtual Account, Invoice, Disbursement, Recurring Payments, Payout, EWallet, Balance, Retail Outlets Services

Xendit REST API Client for PHP - Card, Virtual Account, Invoice, Disbursement, Recurring Payments, Payout, EWallet, Balance, Retail Outlets Services

php 8 client for the lemon.markets api

lemon.markets php client This repository contains a php 8+ compatible client for the https://lemon.markets API. The documentation of the API can be fo

PHP client for Microsoft Azure Face API.

Microsoft Azure Face API PHP client A PHP library that utilizes Azure Face REST API. Requirements PHP = 7.4 Installation composer require darmen/php-

Google PHP API Client Services

Google PHP API Client Services

PHP Client for the GoFlink API

GoFlink PHP API Client This project is an unofficial library to communicate with the GoFlink API from your PHP project. Documentation about the API is

A PHP client for the official Kizeo Forms API V3+. 📌

Kizeo Forms API V3+ - PHP This is a Swagger generated doc for Kizeo REST API 3. You can find additionnal documentation here : Online documentation. Th

Shopee Open API v2 Client build with php

Shopee PHP Client This is a Shopee PHP Client, currently supported for API V2 in ShopeeOpenPlatform Composer Install composer require haistar/shopee-p

GitLab PHP API Client
GitLab PHP API Client

GitLab PHP API Client We present a modern GitLab API v4 client for PHP. This is strongly based on php-github-api by KnpLabs. With this in mind, we now

Releases(2.4.0)
Owner
Keboola
Keboola
Binance Connector PHP - a thin library that working as a connector to the Binance public API

Binance Connector PHP This is a thin library that working as a connector to the Binance public API. Installation composer require binance/binance-conn

Binance 13 Nov 1, 2022
Google-api-php-client - A PHP client library for accessing Google APIs

Google APIs Client Library for PHP Reference Docs https://googleapis.github.io/google-api-php-client/main/ License Apache 2.0 The Google API Client Li

Google APIs 8.4k Dec 30, 2022
The Kafka Enqueue transport - This is an implementation of Queue Interop specification

Supporting Enqueue Enqueue is an MIT-licensed open source project with its ongoing development made possible entirely by the support of community and

Enqueue 40 Oct 6, 2022
PHP JSON-RPC 2.0 Server/Client Implementation with Automatic Client Class Generation via SMD

PHP JSON-RPC 2.0 Server/Client Implementation with Automatic Client Class Generation via SMD

Sergey Bykov 63 Feb 14, 2022
Nexmo REST API client for PHP. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.

Client Library for PHP Support Notice This library and it's associated packages, nexmo/client and nexmo/client-core have transitioned into a "Maintena

Nexmo 75 Sep 23, 2022
DigitalOcean API v2 client for Symfony and API Platform

DigitalOcean Bundle for Symfony and API Platform DunglasDigitalOceanBundle allows using the DigitalOcean API from your Symfony and API Platform projec

Kévin Dunglas 25 Jul 27, 2022
API client for ThePay - payment gate API

This is the official highly compatible public package of The Pay SDK which interacts with The Pay's REST API. To get started see examples below.

ThePay.cz s.r.o. 3 Oct 27, 2022
Code Quiz MonoRepo (API, API Client, App)

Code Quiz Welcome to the Code Quiz Open Source project from How To Code Well. This is an Open Source project that includes an API and an App for the d

How To Code Well 2 Nov 20, 2022
⚡️ Web3 PHP is a supercharged PHP API client that allows you to interact with a generic Ethereum RPC.

Web3 PHP is a supercharged PHP API client that allows you to interact with a generic Ethereum RPC. This project is a work-in-progress. Code and docume

Web3 PHP 665 Dec 23, 2022
A simple PHP GitHub API client, Object Oriented, tested and documented.

PHP GitHub API A simple Object Oriented wrapper for GitHub API, written with PHP. Uses GitHub API v3 & supports GitHub API v4. The object API (v3) is

KNP Labs 2k Jan 7, 2023