Giter Club home page Giter Club logo

gomarathon's Introduction

Go client for marathon

GoDoc

Versions:

  • 2014/08/30 Tag V0.1.0: Fixed version compatible with marathon 0.6

Dev :

  • Branch marathon-0.7: Dev version for marathon 0.7

_ This is a BETA_*

This is a small go client to use with Marathon api v2. All endpoints are handled (EventSubscriptions have not yet been tested).

Feel free to hack.

TODO

  • Tests like everywhere
  • Params building might be much more clean

Usage example

================

package main

import (
    "encoding/json"
    "github.com/jbdalido/go-marathon"
    "log"
)

func main() {

    c, err := gomarathon.NewClient("http://example.io:8080", nil)
    if err != nil {
        log.Fatal(err)
    }

    // Update app
    a := &gomarathon.Application{
        ID:  "test_app",
        Mem: 515,
        Container: &gomarathon.Container{
            Docker: &gomarathon.Docker{
                Image: "docker://jbaptiste/envspitter",
                PortMappings: []*gomarathon.PortMapping{
                    {
                        ContainerPort: 80,
                        HostPort:      8080,
                    },
                },
            },
        },
    }
    r, err := c.CreateApp(a)
    if err != nil {
        log.Fatal(err)
    }
    v, _ := json.Marshal(r)
    log.Printf("%s", v)

    // List all apps
    r, err = c.ListApps()
    if err != nil {
        log.Fatal(err)
    }
    v, _ = json.Marshal(r)
    log.Printf("%s", v)

    // List one app
    r, err = c.GetApp("test_app")
    if err != nil {
        log.Fatal(err)
    }
    v, _ = json.Marshal(r)
    log.Printf("%s", v)

    // List Versions
    r, err = c.ListAppVersions("test_app")
    if err != nil {
        log.Fatal(err)
    }
    v, _ = json.Marshal(r)
    log.Printf("%s", v)

    // Update app
    a = &gomarathon.Application{
        Mem:       515,
        Instances: 2,
    }
    r, err = c.UpdateApp("test_app", a)
    if err != nil {
        log.Fatal(err)
    }
    v, _ = json.Marshal(r)
    log.Printf("%s", v)

    // Get all tasks
    r, err = c.ListTasks()
    if err != nil {
        log.Fatal(err)
    }
    v, _ = json.Marshal(r)
    log.Printf("%s", v)

    // Delete app
    r, err = c.DeleteApp("test_app")
    if err != nil {
        log.Fatal(err)
    }
    v, _ = json.Marshal(r)
    log.Printf("%s", v)

}

Authors

==========

gomarathon's People

Contributors

antonlindstrom avatar bradgearon avatar danielkrainas avatar dylanjha avatar frhwang avatar ikinsey avatar jbdalido avatar mcelligott avatar mikejihbe avatar npateriya avatar rasputnik avatar rheinwein avatar robby-robby avatar simonvc avatar slapbassist avatar

Watchers

 avatar  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.