go-redfish/api_generator.go
Alexander Hughes 3ab47e28ba Update module to point to opendev
This patch updates documentation and the go-redfish module to change
references of 'github.com/Nordix/' to 'opendev.org/airship/'

Change-Id: I9ceddcb8a6ed6c888a3f6e143ada730718999100
2020-01-10 18:52:54 +00:00

54 lines
926 B
Go

package main
import (
"fmt"
"reflect"
. "opendev.org/airship/go-redfish/client"
)
func main() {
header := `
package client
import (
"context"
"net/http"
client "opendev.org/airship/go-redfish/client"
)
//go:generate mockery -name=RedfishAPI -output ./mocks
type RedfishAPI interface {
`
apiServiceType := reflect.TypeOf(&DefaultApiService{})
fmt.Println(header)
for i := 0; i < apiServiceType.NumMethod(); i++ {
method := apiServiceType.Method(i)
// Get args of method
args := ""
for n_in := 1; n_in < method.Type.NumIn(); n_in++ {
args += method.Type.In(n_in).String()
args += ",\n"
}
// Get return type of method
rets := ""
for n_out := 0; n_out < method.Type.NumOut(); n_out++ {
rets += method.Type.Out(n_out).String()
rets += ",\n"
}
func_sig := fmt.Sprintf("%s(%s) (%s)", method.Name, args, rets)
fmt.Println(func_sig)
fmt.Println("")
}
fmt.Println("}")
}