github.com/vmware/go-vcloud-director/v2@v2.24.0/govcd/productsection.go (about) 1 /* 2 * Copyright 2019 VMware, Inc. All rights reserved. Licensed under the Apache v2 License. 3 */ 4 5 package govcd 6 7 import ( 8 "fmt" 9 "net/http" 10 11 "github.com/vmware/go-vcloud-director/v2/types/v56" 12 ) 13 14 // setProductSectionList is a shared function for both vApp and VM 15 func setProductSectionList(client *Client, href string, productSection *types.ProductSectionList) error { 16 if href == "" { 17 return fmt.Errorf("href cannot be empty to set product section") 18 } 19 20 productSection.Xmlns = types.XMLNamespaceVCloud 21 productSection.Ovf = types.XMLNamespaceOVF 22 23 task, err := client.ExecuteTaskRequest(href+"/productSections", http.MethodPut, 24 types.MimeProductSection, "error setting product section: %s", productSection) 25 26 if err != nil { 27 return fmt.Errorf("unable to set product section: %s", err) 28 } 29 30 err = task.WaitTaskCompletion() 31 if err != nil { 32 return fmt.Errorf("task for setting product section failed: %s", err) 33 } 34 35 return nil 36 } 37 38 // getProductSectionList is a shared function for both vApp and VM 39 func getProductSectionList(client *Client, href string) (*types.ProductSectionList, error) { 40 if href == "" { 41 return nil, fmt.Errorf("href cannot be empty to get product section") 42 } 43 productSection := &types.ProductSectionList{} 44 45 _, err := client.ExecuteRequest(href+"/productSections", http.MethodGet, 46 types.MimeProductSection, "error retrieving product section : %s", nil, productSection) 47 48 if err != nil { 49 return nil, fmt.Errorf("unable to retrieve product section: %s", err) 50 } 51 52 return productSection, nil 53 }