Debian Codegraph @

catalogitem.go

raw symbols SCIP
1 /*
2 * Copyright 2014 VMware, Inc. All rights reserved. Licensed under the Apache v2 License.
3 */
4
5 package govcd
6
7 import (
8 "fmt"
9 "net/url"
10
11 types "github.com/hmrc/vmware-govcd/types/v56"
12 )
13
14 type CatalogItem struct {
15 CatalogItem *types.CatalogItem
16 c *Client
17 }
18
19 func NewCatalogItem(c *Client) *CatalogItem {
20 return &CatalogItem{
21 CatalogItem: new(types.CatalogItem),
22 c: c,
23 }
24 }
25
26 func (ci *CatalogItem) GetVAppTemplate() (VAppTemplate, error) {
27 url, err := url.ParseRequestURI(ci.CatalogItem.Entity.HREF)
28
29 if err != nil {
30 return VAppTemplate{}, fmt.Errorf("error decoding catalogitem response: %s", err)
31 }
32
33 req := ci.c.NewRequest(map[string]string{}, "GET", *url, nil)
34
35 resp, err := checkResp(ci.c.Http.Do(req))
36 if err != nil {
37 return VAppTemplate{}, fmt.Errorf("error retreiving vapptemplate: %s", err)
38 }
39
40 cat := NewVAppTemplate(ci.c)
41
42 if err = decodeBody(resp, cat.VAppTemplate); err != nil {
43 return VAppTemplate{}, fmt.Errorf("error decoding vapptemplate response: %s", err)
44 }
45
46 // The request was successful
47 return *cat, nil
48
49 }