GithubHelp home page GithubHelp logo

isabella232 / cloud-sdk-go Goto Github PK

View Code? Open in Web Editor NEW

This project forked from elastic/cloud-sdk-go

0.0 0.0 0.0 2.39 MB

Go client library for Elastic Cloud and Elastic Cloud Enterprise (ECE)

License: Apache License 2.0

Dockerfile 0.01% Makefile 0.02% Go 99.89% Shell 0.08%

cloud-sdk-go's Introduction

Elastic Cloud Go SDK

Go SDK for Elastic Cloud. Its goal is to provide common ground for all Elastic Cloud programmatic code in Go.

Installation

Run the following go get command to install the SDK in your module dependencies directory:

go get -u github.com/elastic/cloud-sdk-go

Usage

See the pkg/api package for more in depth documentation.

package main

import (
    "encoding/json"
    "net/http"
    "os"

    "github.com/elastic/cloud-sdk-go/pkg/api"
    "github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi"
    "github.com/elastic/cloud-sdk-go/pkg/auth"
)

func main() {
    // Create a API instance with an API key as means of authentication.
    ess, err := api.NewAPI(api.Config{
        Client:        new(http.Client),
        AuthWriter:    auth.APIKey("some-apikey"),
    })
    if err != nil {
        panic(err)
    }

    // List the user's deployments via the `deploymentapi` package (Recommended).
    res, err := deploymentapi.List(deploymentapi.ListParams{API: ess.V1API})
    if err != nil {
        panic(err)
    }

    var encoder = json.NewEncoder(os.Stdout)
    if err := encoder.Encode(res); err != nil {
        panic(err)
    }
}

High level package overview

The project's structure is based off the standard Go project layout. Therefore, all of our library code that we expect other projects to import is placed in the pkg/ directory.

The main packages for interacting directly with our public API endpoints can be found within the pkg/api directory. The source code for these APIs are the client and models, which are generated off the public API swagger specification.

The rest are a series of packages that can be leveraged in many ways. For a detailed package description visit the SDK's packages documentation at pkg.go.dev. Alternatively you can use the godoc command on the root level of this project.

Getting started

Ecctl (the Elastic Cloud CLI tool) depends heavily on cloud-sdk-go. You can use ecctl command packages as a reference on how to leverage the SDK. One good example is the command used to list deployments.

Alternatively, if you wish to write your own APIs, take a look at our sample code, which retrieves information about the active platform, to get an idea on how the client is used.

We always welcome contributions! Take a look at our contributing guide if this is something that interests you.

cloud-sdk-go's People

Contributors

artemnikitin avatar dependabot-preview[bot] avatar gordonbondon avatar karencfv avatar lswith avatar marclop avatar ppapapetrou76 avatar renovate[bot] avatar zenithar avatar

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.