Code Monkey home page Code Monkey logo

steampipe-plugin-btp's Introduction

image

SAP BTP plugin for Steampipe

Use SQL to query your SAP BTP account details.

Quick start

Install

Download and install the latest SAP BTP plugin:

steampipe plugin install ajmaradiaga/btp

Configure your credentials and config file.

Configure your account details in ~/.steampipe/config/btp.spc:

connection "btp" {
  plugin = "ajmaradiaga/btp"

  # User email used to log in to SAP BTP. Required.
  # This can also be set via the `BTP_USERNAME` environment variable.
  # username = "[email protected]"

  # User password used to log in to SAP BTP. Required.
  # This can also be set via the `BTP_PASSWORD` environment variable.
  # password = "My-BTP-Passw0rd"

  # You will need to create a service key for the Cloud Management Service. Required.
  # You can get the instructions on how to get an access token for the SAP Cloud Management Service APIs here: https://help.sap.com/docs/btp/sap-business-technology-platform/getting-access-token-for-sap-cloud-management-service-apis.
  # This can also be set via the `BTP_CIS_SERVICE_KEY_PATH` environment variable. Required.
  # cis_service_key_path = "~/service_keys/cis_global.json"

  # URL of the Accounts Service. Optional.
  # This can also be set via the `BTP_CIS_ACCOUNTS_SERVICE_URL` environment variable.
  # cis_accounts_service_url = "https://accounts-service.cfapps.[region].hana.ondemand.com"
  
  # URL of the Entitlements Service. Optional.
  # This can also be set via the `BTP_CIS_ENTITLEMENTS_SERVICE_URL` environment variable.
  # cis_entitlements_service_url = "https://entitlements-service.cfapps.[region].hana.ondemand.com"

  # Access token to communicate with the Cloud Management Service APIs. Optional.
  # You can get the instructions on how to get an access token for the SAP Cloud Management Service APIs here: https://help.sap.com/docs/btp/sap-business-technology-platform/getting-access-token-for-sap-cloud-management-service-apis. 
  # If no access token is provided, the plugin will try getting an access token using the details provided in cis_client_id, cis_client_secret, cis_token_url, username, password.
  # This can also be set via the `BTP_CIS_ACCESS_TOKEN` environment variable.
  # cis_access_token = "eyJhbGciOiDBNsO0JxFoAaodkDJ3Pmk7cFEsEr5ml5BwNWEafrEjy8Hsxt2mVACpD8B4AIPpRuMoGE71qXGoPcW0vCugceTwN4C3xM8qYmH7DLQrdVIlSX6kydYxnRNjSO8je56ckA4oTC8wm2E2clClPhinDBN6DxHhXlB0eVJnerl4ONpxaH43PYXmHjIsArTuBGK6nCFtApIGN1OvMDPmjHFtOjNgcPCPC5GDXTt5oaB6M2gUrfD5QQVGA7L6yFQlXYPvF6BSyMxpoQXywMUwYA6oqV"

  # A service key (https://help.sap.com/docs/btp/sap-business-technology-platform/creating-service-keys) for the Central Management Service is required to get an access token.  
  # The values for cis_client_id, cis_client_secret, cis_token_url can be retrieved from it. 

  # OAuth 2.0 Client ID (field in the service key: uua.clientid). Optional.
  # This can also be set via the `BTP_CIS_CLIENT_ID` environment variable.
  # cis_client_id = "sb-ut-6y0m0wr1-ai10-1a56-4bv1-52m478h011g6-clone!b017880|cis-central!b14"

  # OAuth 2.0 Client Secret (field in the service key: uua.clientsecret). Optional.
  # This can also be set via the `BTP_CIS_CLIENT_SECRET` environment variable. Optional.
  # cis_client_secret = "44s32264-285r-7101-g2n0-g036p1m214us$vm2_UCHAN_mX1FOW0lklBj2-igBsOUG77G-nE1TWsEu="

  # OAuth 2.0 Token URL (field in the service key: uua.url). Optional.
  # The value in the service key doesn't contain the path, /oauth/token, if not specified the plugin will append it automatically.
  # This can also be set via the `BTP_CIS_TOKEN_URL` environment variable. Optional.
  # cis_token_url = "https://[global-account-subdomain].authentication.[region].hana.ondemand.com"
}

Or through environment variables:

export [email protected]
export BTP_PASSWORD=My-BTP-Passw0rd
export BTP_CIS_SERVICE_KEY_PATH=~/service_keys/cis_global.json
export BTP_CIS_ACCOUNTS_SERVICE_URL=https://accounts-service.cfapps.eu10.hana.ondemand.com
export BTP_CIS_ENTITLEMENTS_SERVICE_URL=https://entitlements-service.cfapps.eu10.hana.ondemand.com
export BTP_CIS_ACCESS_TOKEN=eyJhbGciOiDBNsO0JxFoAaodkDJ3Pmk7cFEsEr5ml5BwNWEafrEjy8Hsxt2mVACpD8B4AIPpRuMoGE71qXGoPcW0vCugceTwN4C3xM8qYmH7DLQ

Run steampipe:

steampipe query

List your SAP BTP Global account details:

select
   guid,
   display_name,
   created_date,
   modified_date 
from
   btp_accounts_global_account;
+--------------------------------------+-----------------------+---------------+---------------+
| guid                                 | display_name          | created_date  | modified_date |
+--------------------------------------+-----------------------+---------------+---------------+
| 010788v8-7s64-1801-6680-l6g2253646b2 | My BTP global account | 1638221010619 | 1693587625761 |
+--------------------------------------+-----------------------+---------------+---------------+

Engines

This plugin is available for the following engines:

Engine Description
Steampipe The Steampipe CLI exposes APIs and services as a high-performance relational database, giving you the ability to write SQL-based queries to explore dynamic data. Mods extend Steampipe's capabilities with dashboards, reports, and controls built with simple HCL. The Steampipe CLI is a turnkey solution that includes its own Postgres database, plugin management, and mod support.
Postgres FDW Steampipe Postgres FDWs are native Postgres Foreign Data Wrappers that translate APIs to foreign tables. Unlike Steampipe CLI, which ships with its own Postgres server instance, the Steampipe Postgres FDWs can be installed in any supported Postgres database version.
SQLite Extension Steampipe SQLite Extensions provide SQLite virtual tables that translate your queries into API calls, transparently fetching information from your API or service as you request it.
Export Steampipe Plugin Exporters provide a flexible mechanism for exporting information from cloud services and APIs. Each exporter is a stand-alone binary that allows you to extract data using Steampipe plugins without a database.
Turbot Pipes Turbot Pipes is the only intelligence, automation & security platform built specifically for DevOps. Pipes provide hosted Steampipe database instances, shared dashboards, snapshots, and more.

Developing

Prerequisites:

Clone:

git clone https://github.com/ajmaradiaga/steampipe-plugin-btp.git
cd steampipe-plugin-btp

Build, which automatically installs the new version to your ~/.steampipe/plugins directory:

make

Configure the plugin:

cp config/* ~/.steampipe/config
vi ~/.steampipe/config/btp.spc

Try it!

steampipe query
> .inspect btp

Further reading:

Open Source & Contributing

This repository is published under the Apache 2.0 (source code) and CC BY-NC-ND (docs) licenses. Please see our code of conduct. We look forward to collaborating with you!

Steampipe is a product produced from this open source software, exclusively by Turbot HQ, Inc. It is distributed under our commercial terms. Others are allowed to make their own distribution of the software, but cannot use any of the Turbot trademarks, cloud services, etc. You can learn more in our Open Source FAQ.

Get Involved

Join #steampipe on Slack →

Want to help but don't know where to start? Pick up one of the help wanted issues:

steampipe-plugin-btp's People

Contributors

ajmaradiaga avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

8to5

steampipe-plugin-btp's Issues

Initial suggestions for plugin release

Thanks @ajmaradiaga for this new plugin. Great work 🎉 !!

The basic structure looks good so far. While using the plugin, we did come up with a few suggestions based on our best practices:

config/btp.spc

  • We should have a single file named btp.spc under the config folder that will contain a basic connection for the plugin (see namecheap plugin for reference)
  • Could you please update the btp.spc file to follow the format of the namecheap plugin
  • Can you mention which of these parameters are required and which are optional as done in the namecheap plugin
  • We should mention values for all the config arguments however commented out and the values should be in the format of the actual values (however incorrect)
  • We should also add details to set these parameters via the environment variable (if any)

docs/tables/*

  • We should have a folder called docs under which we will have a single file called index.md (reference) and individual table docs for each table
  • The table docs should be named as eg > btp_datacenter.md (note: The table names should be singular)
  • Each table doc should have the following parts >
    • A heading in the format > # Table: btp_datacenter
    • A description of the table
    • A number of queries which will have the title followed by the query (Note: We do not include the query outputs in the docs)

docs/index.md

btp/*

  • Please add the configuration for setting the config arguments via the environment variable
  • The table file names should be in singular and in snake_case for example : table_btp_accounts_directories.go
  • The table file name should be in sync with the table name in the code
  • It is better to print the type of error when we encounter any like connection_error or api_error for easier debugging if needed

btp/table_btp_datacenter

  • The name of the file should be table_btp_datacenter.go
  • The function name should be tableBTPDatacenter
  • The name of the table should be btp_datacenter
  • The column descriptions should end with a .
  • The geo_access column does not have a description we should add it
  • It is better to use d.EqualsQualString["region"] instead of equalQuals["region"].GetStringValue()

btp/table_btp_directory

  • The name of the file should be table_btp_directory.go
  • The function name should be tableBTPDirectory
  • The name of the table should be btp_directory
  • The column descriptions should end with a .
  • The directory_type and parent_guid1 columns do not have a description we should add it
  • It is better to use d.EqualsQualString["region"] instead of equalQuals["region"].GetStringValue()

btp/table_btp_global_account

  • The name of the file should be table_btp_global_account.go
  • The name of the table should be btp_global_account
  • The name of the list call should be listGlobalAccounts
  • The column descriptions should end with a .

btp/table_btp_subaccount

  • The name of the file should be table_btp_subaccount.go
  • The name of the table should be btp_subaccount
  • The name of the list call should be listSubaccounts
  • The column descriptions should end with a .
  • The parent_type column does not have a description we should add it

btp/plugin.go

  • The list of tables should be sorted in ascending order

btp/utils.go

  • Please rename the btp.go file to utils.go

bt/types.go

  • Rename to types.go

README.md

  • Please update the file to follow the format of the namecheap plugin
  • Please include all the necessary sections as mentioned above

CHANGELOG.md

  • Please draft an initial Changelog for the plugin release, an example would be as follows:
## v0.0.1 [TBD]

_What's new?_

- New tables added
  - [btp_datacenter](https://github.com/ajmaradiaga/steampipe-plugin-btp/blob/main/btp/table_btp_datacenter.go)
  - [btp_directory](https://github.com/ajmaradiaga/steampipe-plugin-btp/blob/main/btp/table_btp_directory.go)
  - [btp_global_account](https://github.com/ajmaradiaga/steampipe-plugin-btp/blob/main/btp/table_btp_global_account.go)
  - [btp_subaccount](https://github.com/ajmaradiaga/steampipe-plugin-btp/blob/main/btp/table_btp_subaccount.go)

Please note that the example contains the name in singular assuming that the changelog will be added after updating the table names.

Makefile

  • The path is incorrect please update it to
go build -o ~/.steampipe/plugins/hub.steampipe.io/plugins/ajmaradiaga/btp@latest/teampipe-plugin-btp.plugin *.go

Follow-up questions

  • A couple of follow-up questions:
    • How are we handling the resource not found errors?
    • Do the APIs support pagination? I did not find any reference to it, but I want to make sure that we have checked that box before releasing it.
    • While working with the APIs did you encounter rate limit errors?
    • Please refer to https://steampipe.io/docs/develop/plugin-release-checklist#data-ingestion for more information

Please let us know if you have questions, happy to help 👍

Initial suggestions for plugin release. Continue on issue #1

Hey @ajmaradiaga Few things that we are missing out on this plugin are listed out, can you please work on them and then we can get it on the hub as soon as possible :

  1. Can you remove the //Endpoints and //username comments as the variables are good enough to understand >
  2. Why have we kept the required : false in access_token? Is it not a required parameter? >
  3. Does this fetch a single result ? >
    func getGlobalAccount(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
    why do we have a get call in a list config?. Since you are streamlisting I believe this gives all teh global accounts, so can you please rename it to listGlobalAccounts
  4. Instead of using * can you please mention the important columns>
  1. I don't think we need the connection name to be mentioned here just the table name (btp_accounts_directory) would be good as the connection name may vary depending on the number of connections someone is using >
  1. I think we can have 1-2 more example queries for the table btp_accounts_global_account like eg : List the global accounts create din the last 7 days, List the consumption-based global accounts, List all suspended global accounts, etc.
  2. What does the distinct do here is it only on the parent_guid? If so then we should put it in the second column, But why do we need it? >
  3. Please remove this extra line >
  4. We do not need an alias when we have only one table with no joins >
  1. Why do we need the distinct here? Again can you please write it in the next line as distinct business_category ->> 'id' as bc_id if the distinct is needed. >
  2. Please change the WHERE to lower case >
  3. Is the query output correct? The created_date and modified_date is not in date format >
  1. The credential section should have all 4 > Credentials, Permissions, Radius, Resolution.>
    | Item | Description |
  2. The get involved section should contain - Community: Join #steampipe on Slack → as well >
    ## Get involved
  3. The install command is incorrect it should be > steampipe plugin install ajmaradiaga/btp
  1. The community link is missing after documentation - Community: Slack Channel > https://github.com/ajmaradiaga/steampipe-plugin-btp/blob/316ef2c211838a9d58ce9fcbde038b59e2c10042/README.md?plain=1#L6C1-L6C1

Please reach out to us in case of any don't, thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.