akeyless/grpc 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

akeyless/grpc

最新稳定版本:0.0.1

Composer 安装命令:

composer require akeyless/grpc

包简介

Akeyless gRPC SDK

README 文档

README

PHP library for interacting with the Akeyless API using gRPC

Table of Contents

Introduction

The akeyless/grpc library provides a convenient way to interact with the Akeyless API using gRPC.

Installation

To use akeyless/grpc in your project, run the following command composer require akeyless/grpc

    "require": {
        "akeyless/grpc": "*"
    },

Example

<?php

require "vendor/autoload.php";

use Akeyless\gRPC\AkeylessV2ServiceClient;
use Akeyless\gRPC\Auth;
use Akeyless\gRPC\AuthRequest;
use Akeyless\gRPC\GetSecretValue;
use Akeyless\gRPC\GetSecretValueRequest;
use Akeyless\gRPC\ListItems;
use Akeyless\gRPC\ListItemsRequest;

// Replace with your actual hostname, options, and channel if needed
$hostname = "localhost:8085";

// Specify your channel options as needed
$opts = [
    "credentials" => Grpc\ChannelCredentials::createInsecure(),
];

// Create an client of AkeylessV2ServiceClient
$client = new AkeylessV2ServiceClient($hostname, $opts);

// Authenticate
$auth = new Auth([
    "access_id" => "********",
    "access_key" => "********",
    "access_type" => "access_key",
]);

$authRequest = new AuthRequest();
$authRequest->setBody($auth);

// Auth
list($authResponse, $status) = $client->Auth($authRequest)->wait();

$token = $authResponse->getToken();

$listItems = new ListItems();
$listItems->setToken($token);

$listItemsRequest = new ListItemsRequest();
$listItemsRequest->setBody($listItems);

//List items
list($listItemsResponse, $status) = $client
    ->ListItems($listItemsRequest)
    ->wait();

foreach ($listItemsResponse->getItems() as $item) {
    echo $item->getItemName() . PHP_EOL;
}

$getSecretValue = new GetSecretValue();
$getSecretValue->setToken($token);
$getSecretValue->setNames(["/MyFirstSecret"]);

$getSecretValueRequest = new GetSecretValueRequest();
$getSecretValueRequest->setBody($getSecretValue);

//Get secret value
list($getSecretValueResponse, $status) = $client
    ->GetSecretValue($getSecretValueRequest)
    ->wait();

$fields = $getSecretValueResponse->getData()->getFields();

// Iterate over each field
foreach ($fields as $key => $value) {
    $stringValue = $value->getStringValue();

    // Use the values as needed
    echo "Field: $key, Value: $stringValue" . PHP_EOL;
}

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2024-07-21