func TestNodeGetOperation(t *testing.T) { // create the transport transport := httptransport.New("localhost:9090", "/api/1.1", []string{"http"}) // configure the host. include port with environment variable. For instance the vagrant image would be localhost:9090 if os.Getenv("GORACKHD_ENDPOINT") != "" { transport.Host = os.Getenv("GORACKHD_ENDPOINT") } // create the API client, with the transport client := apiclient.New(transport, strfmt.Default) //use any function to do REST operations resp, err := client.Nodes.GetNodes(nil) if err != nil { log.Fatal(err) } fmt.Printf("%#v\n", resp.Payload) }
func TestNodeDeleteOperation(t *testing.T) { // create the transport transport := httptransport.New("localhost:9090", "/api/1.1", []string{"http"}) // configure the host. include port with environment variable. For instance the vagrant image would be localhost:9090 if os.Getenv("GORACKHD_ENDPOINT") != "" { transport.Host = os.Getenv("GORACKHD_ENDPOINT") } // create the API client, with the transport client := apiclient.New(transport, strfmt.Default) //use any function to do REST operations resp, err := client.Nodes.DeleteNodesIdentifier(&nodes.DeleteNodesIdentifierParams{Identifier: "1234abcd1234abcd1234abcd"}) //resp, err := client.Skus.GetSkusIdentifier(&skus.GetSkusIdentifierParams{Identifier: "568e8b76c3354ff04bab27e0"}) if err != nil { log.Fatal(err) } fmt.Printf("%#v\n", resp) }
func TestNodePostOperation(t *testing.T) { // create the transport transport := httptransport.New("localhost:9090", "/api/1.1", []string{"http"}) // configure the host if os.Getenv("GORACKHD_ENDPOINT") != "" { transport.Host = os.Getenv("GORACKHD_ENDPOINT") } //fmt.Println(fmt.Sprintf("%+v", transport)) // create the API client, with the transport client := apiclient.New(transport, strfmt.Default) c := &Node{ ID: "1234abcd1234abcd1234abcd", Name: "somename", Type: "compute", ObmSettings: []*ObmSettings{&ObmSettings{ Service: "ipmi-obm-service", Config: &ObmConfig{ Host: "1.2.3.4", User: "******", Password: "******", }, }}, } b, err := json.Marshal(c) if err != nil { log.Fatal(err) } fmt.Println(string(b)) resp, err := client.Nodes.PostNodes(&nodes.PostNodesParams{Identifiers: c}) if err != nil { log.Fatal(err) } t.Logf("%+v", resp.Payload) }