123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- /*
- Copyright (c) 2015 VMware, Inc. All Rights Reserved.
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
- package object
- import (
- "context"
- "github.com/vmware/govmomi/vim25"
- "github.com/vmware/govmomi/vim25/methods"
- "github.com/vmware/govmomi/vim25/types"
- )
- type CustomizationSpecManager struct {
- Common
- }
- func NewCustomizationSpecManager(c *vim25.Client) *CustomizationSpecManager {
- cs := CustomizationSpecManager{
- Common: NewCommon(c, *c.ServiceContent.CustomizationSpecManager),
- }
- return &cs
- }
- func (cs CustomizationSpecManager) DoesCustomizationSpecExist(ctx context.Context, name string) (bool, error) {
- req := types.DoesCustomizationSpecExist{
- This: cs.Reference(),
- Name: name,
- }
- res, err := methods.DoesCustomizationSpecExist(ctx, cs.c, &req)
- if err != nil {
- return false, err
- }
- return res.Returnval, nil
- }
- func (cs CustomizationSpecManager) GetCustomizationSpec(ctx context.Context, name string) (*types.CustomizationSpecItem, error) {
- req := types.GetCustomizationSpec{
- This: cs.Reference(),
- Name: name,
- }
- res, err := methods.GetCustomizationSpec(ctx, cs.c, &req)
- if err != nil {
- return nil, err
- }
- return &res.Returnval, nil
- }
- func (cs CustomizationSpecManager) CreateCustomizationSpec(ctx context.Context, item types.CustomizationSpecItem) error {
- req := types.CreateCustomizationSpec{
- This: cs.Reference(),
- Item: item,
- }
- _, err := methods.CreateCustomizationSpec(ctx, cs.c, &req)
- if err != nil {
- return err
- }
- return nil
- }
- func (cs CustomizationSpecManager) OverwriteCustomizationSpec(ctx context.Context, item types.CustomizationSpecItem) error {
- req := types.OverwriteCustomizationSpec{
- This: cs.Reference(),
- Item: item,
- }
- _, err := methods.OverwriteCustomizationSpec(ctx, cs.c, &req)
- if err != nil {
- return err
- }
- return nil
- }
- func (cs CustomizationSpecManager) DeleteCustomizationSpec(ctx context.Context, name string) error {
- req := types.DeleteCustomizationSpec{
- This: cs.Reference(),
- Name: name,
- }
- _, err := methods.DeleteCustomizationSpec(ctx, cs.c, &req)
- if err != nil {
- return err
- }
- return nil
- }
- func (cs CustomizationSpecManager) DuplicateCustomizationSpec(ctx context.Context, name string, newName string) error {
- req := types.DuplicateCustomizationSpec{
- This: cs.Reference(),
- Name: name,
- NewName: newName,
- }
- _, err := methods.DuplicateCustomizationSpec(ctx, cs.c, &req)
- if err != nil {
- return err
- }
- return nil
- }
- func (cs CustomizationSpecManager) RenameCustomizationSpec(ctx context.Context, name string, newName string) error {
- req := types.RenameCustomizationSpec{
- This: cs.Reference(),
- Name: name,
- NewName: newName,
- }
- _, err := methods.RenameCustomizationSpec(ctx, cs.c, &req)
- if err != nil {
- return err
- }
- return nil
- }
- func (cs CustomizationSpecManager) CustomizationSpecItemToXml(ctx context.Context, item types.CustomizationSpecItem) (string, error) {
- req := types.CustomizationSpecItemToXml{
- This: cs.Reference(),
- Item: item,
- }
- res, err := methods.CustomizationSpecItemToXml(ctx, cs.c, &req)
- if err != nil {
- return "", err
- }
- return res.Returnval, nil
- }
- func (cs CustomizationSpecManager) XmlToCustomizationSpecItem(ctx context.Context, xml string) (*types.CustomizationSpecItem, error) {
- req := types.XmlToCustomizationSpecItem{
- This: cs.Reference(),
- SpecItemXml: xml,
- }
- res, err := methods.XmlToCustomizationSpecItem(ctx, cs.c, &req)
- if err != nil {
- return nil, err
- }
- return &res.Returnval, nil
- }
|