mirror of
https://github.com/chirpstack/chirpstack.git
synced 2024-12-24 07:16:42 +00:00
api: add grpc php support (#431)
This commit is contained in:
parent
880b319bfd
commit
38d544a5f7
1
Makefile
1
Makefile
@ -27,6 +27,7 @@ version:
|
||||
sed -i 's/^version.*/version = "$(VERSION)"/g' ./api/rust/Cargo.toml
|
||||
sed -i 's/^version.*/version = "$(VERSION)"/g' ./api/java/build.gradle.kts
|
||||
sed -i 's/^version.*/version = "$(VERSION)"/g' ./api/kotlin/build.gradle.kts
|
||||
sed -i 's/"version.*/"version": "$(VERSION)",/g' ./api/php/composer.json
|
||||
|
||||
cd api && make
|
||||
make build-ui
|
||||
|
9
api/Dockerfile-php
vendored
Normal file
9
api/Dockerfile-php
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
FROM php:8.1-bookworm
|
||||
|
||||
RUN apt update -y
|
||||
RUN apt install -y make protobuf-compiler protobuf-compiler-grpc
|
||||
|
||||
ENV PROJECT_PATH=/chirpstack/api
|
||||
|
||||
RUN mkdir -p PROJECT_PATH
|
||||
WORKDIR $PROJECT_PATH
|
7
api/Makefile
vendored
7
api/Makefile
vendored
@ -1,6 +1,6 @@
|
||||
.PHONY: rust grpc-web go js python md java kotlin csharp
|
||||
.PHONY: rust grpc-web go js python md java kotlin csharp php
|
||||
|
||||
all: rust grpc-web go js python md java kotlin csharp
|
||||
all: rust grpc-web go js python md java kotlin csharp php
|
||||
|
||||
rust:
|
||||
cd rust && make
|
||||
@ -28,3 +28,6 @@ kotlin:
|
||||
|
||||
csharp:
|
||||
docker compose run --rm chirpstack-csharp
|
||||
|
||||
php:
|
||||
docker compose run --rm chirpstack-api-php
|
7
api/docker-compose.yml
vendored
7
api/docker-compose.yml
vendored
@ -42,3 +42,10 @@ services:
|
||||
command: bash -c "cd csharp && make all"
|
||||
volumes:
|
||||
- ./:/chirpstack/api
|
||||
chirpstack-api-php:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile-php
|
||||
command: bash -c "cd php && make all"
|
||||
volumes:
|
||||
- ./:/chirpstack/api
|
||||
|
40
api/php/Makefile
vendored
Normal file
40
api/php/Makefile
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
.PHONY: requirements common gw api integration stream google
|
||||
|
||||
PROTOC_ARGS := -I=../proto --grpc_out=./generated --plugin=protoc-gen-grpc=/usr/bin/grpc_php_plugin --php_out=./generated
|
||||
|
||||
all: requirements common gw api integration stream google
|
||||
|
||||
requirements:
|
||||
rm -rf generated
|
||||
mkdir generated
|
||||
|
||||
common:
|
||||
protoc ${PROTOC_ARGS} common/common.proto
|
||||
|
||||
gw:
|
||||
protoc ${PROTOC_ARGS} gw/gw.proto
|
||||
|
||||
api:
|
||||
protoc ${PROTOC_ARGS} api/internal.proto
|
||||
protoc ${PROTOC_ARGS} api/user.proto
|
||||
protoc ${PROTOC_ARGS} api/tenant.proto
|
||||
protoc ${PROTOC_ARGS} api/application.proto
|
||||
protoc ${PROTOC_ARGS} api/device_profile.proto
|
||||
protoc ${PROTOC_ARGS} api/device_profile_template.proto
|
||||
protoc ${PROTOC_ARGS} api/device.proto
|
||||
protoc ${PROTOC_ARGS} api/gateway.proto
|
||||
protoc ${PROTOC_ARGS} api/multicast_group.proto
|
||||
protoc ${PROTOC_ARGS} api/relay.proto
|
||||
|
||||
integration:
|
||||
protoc ${PROTOC_ARGS} integration/integration.proto
|
||||
|
||||
stream:
|
||||
protoc ${PROTOC_ARGS} stream/meta.proto
|
||||
protoc ${PROTOC_ARGS} stream/frame.proto
|
||||
protoc ${PROTOC_ARGS} stream/api_request.proto
|
||||
protoc ${PROTOC_ARGS} stream/backend_interfaces.proto
|
||||
|
||||
google:
|
||||
protoc ${PROTOC_ARGS} google/api/annotations.proto
|
||||
protoc ${PROTOC_ARGS} google/api/http.proto
|
44
api/php/README.md
vendored
Normal file
44
api/php/README.md
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
# chirpstack-api
|
||||
|
||||
ChirpStack gRPC API message and service wrappers for PHP.
|
||||
|
||||
## Install
|
||||
|
||||
With composer:
|
||||
|
||||
```sh
|
||||
composer require chirpstack/chirpstack-api
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
All messages, services, constants, etc. are auto-generated from the ChirpStack protobuf definitions. The result is that
|
||||
this package structure matches that of the protobuf definitions.
|
||||
|
||||
The protobuf definitions can be found here: https://github.com/chirpstack/chirpstack/tree/master/api/proto
|
||||
|
||||
## Example
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
namespace Test;
|
||||
|
||||
use Chirpstack\API\ApplicationServiceClient;
|
||||
use Chirpstack\API\ListApplicationsRequest;
|
||||
use Grpc\Channel;
|
||||
use Grpc\ChannelCredentials;
|
||||
|
||||
require dirname(__FILE__) . '/vendor/autoload.php';
|
||||
|
||||
function main() {
|
||||
$channel = new Channel('url', ['credentials' => ChannelCredentials::createInsecure()]);
|
||||
$client = new ApplicationServiceClient('url', [], $channel);
|
||||
$request = new ListApplicationsRequest();
|
||||
$response = $client->List($request);
|
||||
$data = $response->wait();
|
||||
print_r($data);
|
||||
}
|
||||
|
||||
main();
|
||||
```
|
23
api/php/composer.json
vendored
Normal file
23
api/php/composer.json
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "chirpstack/chirpstack-api",
|
||||
"description": "Chirpstack PHP API",
|
||||
"license": "MIT",
|
||||
"type": "library",
|
||||
"version": "4.8.1",
|
||||
"require": {
|
||||
"php": ">=7.0.0",
|
||||
"grpc/grpc": "^v1.57.0",
|
||||
"google/protobuf": "^v4.27.1"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-grpc": "To make it all work"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Chirpstack\\": "generated/Chirpstack/",
|
||||
"Google\\": "generated/Google/",
|
||||
"GPBMetadata\\Chirpstack\\": "generated/GPBMetadata/Chirpstack/",
|
||||
"GPBMetadata\\Google\\": "generated/GPBMetadata/Google/"
|
||||
}
|
||||
}
|
||||
}
|
2
api/proto/api/application.proto
vendored
2
api/proto/api/application.proto
vendored
@ -7,6 +7,8 @@ option java_package = "io.chirpstack.api";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "ApplicationProto";
|
||||
option csharp_namespace = "Chirpstack.Api";
|
||||
option php_namespace = "Chirpstack\\Api";
|
||||
option php_metadata_namespace = "GPBMetadata\\Chirpstack\\Api";
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
2
api/proto/api/device.proto
vendored
2
api/proto/api/device.proto
vendored
@ -7,6 +7,8 @@ option java_package = "io.chirpstack.api";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "DeviceProto";
|
||||
option csharp_namespace = "Chirpstack.Api";
|
||||
option php_namespace = "Chirpstack\\Api";
|
||||
option php_metadata_namespace = "GPBMetadata\\Chirpstack\\Api";
|
||||
|
||||
import "common/common.proto";
|
||||
import "google/api/annotations.proto";
|
||||
|
2
api/proto/api/device_profile.proto
vendored
2
api/proto/api/device_profile.proto
vendored
@ -7,6 +7,8 @@ option java_package = "io.chirpstack.api";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "DeviceProfileProto";
|
||||
option csharp_namespace = "Chirpstack.Api";
|
||||
option php_namespace = "Chirpstack\\Api";
|
||||
option php_metadata_namespace = "GPBMetadata\\Chirpstack\\Api";
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
2
api/proto/api/device_profile_template.proto
vendored
2
api/proto/api/device_profile_template.proto
vendored
@ -7,6 +7,8 @@ option java_package = "io.chirpstack.api";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "DeviceProfileTemplateProto";
|
||||
option csharp_namespace = "Chirpstack.Api";
|
||||
option php_namespace = "Chirpstack\\Api";
|
||||
option php_metadata_namespace = "GPBMetadata\\Chirpstack\\Api";
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
2
api/proto/api/gateway.proto
vendored
2
api/proto/api/gateway.proto
vendored
@ -7,6 +7,8 @@ option java_package = "io.chirpstack.api";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "GatewayProto";
|
||||
option csharp_namespace = "Chirpstack.Api";
|
||||
option php_namespace = "Chirpstack\\Api";
|
||||
option php_metadata_namespace = "GPBMetadata\\Chirpstack\\Api";
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
2
api/proto/api/internal.proto
vendored
2
api/proto/api/internal.proto
vendored
@ -7,6 +7,8 @@ option java_package = "io.chirpstack.api";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "InternalProto";
|
||||
option csharp_namespace = "Chirpstack.Api";
|
||||
option php_namespace = "Chirpstack\\Api";
|
||||
option php_metadata_namespace = "GPBMetadata\\Chirpstack\\Api";
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
|
2
api/proto/api/multicast_group.proto
vendored
2
api/proto/api/multicast_group.proto
vendored
@ -7,6 +7,8 @@ option java_package = "io.chirpstack.api";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "MulticastGroupProto";
|
||||
option csharp_namespace = "Chirpstack.Api";
|
||||
option php_namespace = "Chirpstack\\Api";
|
||||
option php_metadata_namespace = "GPBMetadata\\Chirpstack\\Api";
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
2
api/proto/api/relay.proto
vendored
2
api/proto/api/relay.proto
vendored
@ -7,6 +7,8 @@ option java_package = "io.chirpstack.api";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "RelayProto";
|
||||
option csharp_namespace = "Chirpstack.Api";
|
||||
option php_namespace = "Chirpstack\\Api";
|
||||
option php_metadata_namespace = "GPBMetadata\\Chirpstack\\Api";
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
2
api/proto/api/tenant.proto
vendored
2
api/proto/api/tenant.proto
vendored
@ -7,6 +7,8 @@ option java_package = "io.chirpstack.api";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "TenantProto";
|
||||
option csharp_namespace = "Chirpstack.Api";
|
||||
option php_namespace = "Chirpstack\\Api";
|
||||
option php_metadata_namespace = "GPBMetadata\\Chirpstack\\Api";
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
2
api/proto/api/user.proto
vendored
2
api/proto/api/user.proto
vendored
@ -7,6 +7,8 @@ option java_package = "io.chirpstack.api";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "UserProto";
|
||||
option csharp_namespace = "Chirpstack.Api";
|
||||
option php_namespace = "Chirpstack\\Api";
|
||||
option php_metadata_namespace = "GPBMetadata\\Chirpstack\\Api";
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
2
api/proto/common/common.proto
vendored
2
api/proto/common/common.proto
vendored
@ -7,6 +7,8 @@ option java_package = "io.chirpstack.api";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "CommonProto";
|
||||
option csharp_namespace = "Chirpstack.Common";
|
||||
option php_namespace = "Chirpstack\\Common";
|
||||
option php_metadata_namespace = "GPBMetadata\\Chirpstack\\Common";
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
|
2
api/proto/gw/gw.proto
vendored
2
api/proto/gw/gw.proto
vendored
@ -7,6 +7,8 @@ option java_package = "io.chirpstack.api.gw";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "GatewayProto";
|
||||
option csharp_namespace = "Chirpstack.Gateway";
|
||||
option php_namespace = "Chirpstack\\Gateway";
|
||||
option php_metadata_namespace = "GPBMetadata\\Chirpstack\\Gateway";
|
||||
|
||||
import "common/common.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
2
api/proto/integration/integration.proto
vendored
2
api/proto/integration/integration.proto
vendored
@ -7,6 +7,8 @@ option java_package = "io.chirpstack.api.integration";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "IntegrationProto";
|
||||
option csharp_namespace = "Chirpstack.Integration";
|
||||
option php_namespace = "Chirpstack\\Integration";
|
||||
option php_metadata_namespace = "GPBMetadata\\Chirpstack\\Integration";
|
||||
|
||||
import "common/common.proto";
|
||||
import "gw/gw.proto";
|
||||
|
2
api/proto/stream/api_request.proto
vendored
2
api/proto/stream/api_request.proto
vendored
@ -7,6 +7,8 @@ option java_package = "io.chirpstack.api.stream";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "ApiRequestProto";
|
||||
option csharp_namespace = "Chirpstack.Stream";
|
||||
option php_namespace = "Chirpstack\\Stream";
|
||||
option php_metadata_namespace = "GPBMetadata\\Chirpstack\\Stream";
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "common/common.proto";
|
||||
|
2
api/proto/stream/backend_interfaces.proto
vendored
2
api/proto/stream/backend_interfaces.proto
vendored
@ -7,6 +7,8 @@ option java_package = "io.chirpstack.api.stream";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "BackendInterfacesProto";
|
||||
option csharp_namespace = "Chirpstack.Stream";
|
||||
option php_namespace = "Chirpstack\\Stream";
|
||||
option php_metadata_namespace = "GPBMetadata\\Chirpstack\\Stream";
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
|
2
api/proto/stream/frame.proto
vendored
2
api/proto/stream/frame.proto
vendored
@ -7,6 +7,8 @@ option java_package = "io.chirpstack.api.stream";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "FrameProto";
|
||||
option csharp_namespace = "Chirpstack.Stream";
|
||||
option php_namespace = "Chirpstack\\Stream";
|
||||
option php_metadata_namespace = "GPBMetadata\\Chirpstack\\Stream";
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "common/common.proto";
|
||||
|
2
api/proto/stream/meta.proto
vendored
2
api/proto/stream/meta.proto
vendored
@ -7,6 +7,8 @@ option java_package = "io.chirpstack.api.stream";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "MetaProto";
|
||||
option csharp_namespace = "Chirpstack.Stream";
|
||||
option php_namespace = "Chirpstack\\Stream";
|
||||
option php_metadata_namespace = "GPBMetadata\\Chirpstack\\Stream";
|
||||
|
||||
import "common/common.proto";
|
||||
import "gw/gw.proto";
|
||||
|
Loading…
Reference in New Issue
Block a user