interworks/thoughtspotrest 问题修复 & 功能扩展

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

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

interworks/thoughtspotrest

最新稳定版本:v0.0.4

Composer 安装命令:

composer require interworks/thoughtspotrest

包简介

This package allows simple REST API communication with your ThoughtSpot cluster.

README 文档

README

GitHub Workflow Status (Pest) GitHub Workflow Status (PHPStan) Latest Version License

This is a simple API for calling REST API's against your ThoughtSpot cluster. It handles authentication for you so install, add the environment variables, and start making REST API calls!

Getting Started

Installation

Requires PHP >= 8.2.

composer require interworks/thoughtspotrest

Next, add the following required environment variables to your .env file:

THOUGHTSPOT_REST_URL="https://YOUR-ORG.thoughtspot.cloud"
THOUGHTSPOT_REST_USERNAME="YOUR_USER"

Then, depending on your desired authentication, add these:

"Basic" authentication:

THOUGHTSPOT_REST_AUTH_TYPE="basic"
THOUGHTSPOT_REST_PASSWORD="YOUR_USER_PASSWORD"

"Trusted" authentication:

THOUGHTSPOT_REST_AUTH_TYPE="trusted"
THOUGHTSPOT_REST_SECRET_KEY="123abc-..."

"Cookie" authentication:

THOUGHTSPOT_REST_AUTH_TYPE="cookie"
THOUGHTSPOT_REST_PASSWORD="YOUR_USER_PASSWORD"

For more information on ThoughtSpot REST API authentication options, view their doc here.

Documentation

Every REST API call in ThoughtSpot's documentation has a function to call it with the same name in camel case. For instance, the "Search Metadata" API call can be called with:

$ts->searchMetadata($args);

ThoughtSpot's REST API documentation can be found here.

Usage Guide

Basic Usage

Instantiate a ThoughtSpotREST object and start making calls!

use InterWorks\ThoughtSpotREST\ThoughtSpotREST;

// Instantiate
$ts = new ThoughtSpotREST();

// Get first 10 Liveboards and create a collection.
$liveboards = $ts->searchMetadata(['metadata' => ['type' => 'LIVEBOARD'], 'record_size' => 10]);
$liveboards = collect($liveboards);

// Get a user by name and update it
$users  = $ts->searchUsers(['user_identifier' => 'jlyons', 'record_size' => 1]);
$user   = collect($users)->first();
$userID = $user['id'];
$ts->updateUser($userID, ['email' => 'justin.lyons@interworks.com']);

Unsupported Endpoints

If there's an endpoint missed, you can use the call function to specify the URL, arguments, and method. The function returns a Illuminate\Http\Client\Response object.

$response = $ts->call(
    url   : 'metadata/search',
    args  : ['metadata' => ['type' => 'LIVEBOARD'], 'record_size' => 10],
    method: 'POST'
);
$response->json();

Function Return Type Options

By default, either an array or boolean will be returned depending on the endpoint. If you'd like more control over how the response is processed, you can set returnResponseObject to true in the constructor to always receive the Illuminate\Http\Client\Response object.

$ts         = new ThoughtSpotREST(returnResponseObject: true);
$response   = $ts->searchMetadata(['metadata' => ['type' => 'LIVEBOARD'], 'record_size' => 10]);
$success    = $response->successful();
$body       = $response->body();
$liveboards = $response->json();

License

This package is released under the MIT License. See LICENSE for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-25