~juju-qa/ubuntu/xenial/juju/2.0.2

« back to all changes in this revision

Viewing changes to src/github.com/vmware/govmomi/object/customization_spec_manager.go

  • Committer: Nicholas Skaggs
  • Date: 2016-12-09 22:31:29 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161209223129-h2wbknpc8ty29zwp
ImportĀ upstreamĀ 2.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (c) 2015 VMware, Inc. All Rights Reserved.
 
3
 
 
4
Licensed under the Apache License, Version 2.0 (the "License");
 
5
you may not use this file except in compliance with the License.
 
6
You may obtain a copy of the License at
 
7
 
 
8
    http://www.apache.org/licenses/LICENSE-2.0
 
9
 
 
10
Unless required by applicable law or agreed to in writing, software
 
11
distributed under the License is distributed on an "AS IS" BASIS,
 
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
See the License for the specific language governing permissions and
 
14
limitations under the License.
 
15
*/
 
16
 
 
17
package object
 
18
 
 
19
import (
 
20
        "github.com/vmware/govmomi/vim25"
 
21
        "github.com/vmware/govmomi/vim25/methods"
 
22
        "github.com/vmware/govmomi/vim25/types"
 
23
        "golang.org/x/net/context"
 
24
)
 
25
 
 
26
type CustomizationSpecManager struct {
 
27
        Common
 
28
}
 
29
 
 
30
func NewCustomizationSpecManager(c *vim25.Client) *CustomizationSpecManager {
 
31
        cs := CustomizationSpecManager{
 
32
                Common: NewCommon(c, *c.ServiceContent.CustomizationSpecManager),
 
33
        }
 
34
 
 
35
        return &cs
 
36
}
 
37
 
 
38
func (cs CustomizationSpecManager) DoesCustomizationSpecExist(ctx context.Context, name string) (bool, error) {
 
39
        req := types.DoesCustomizationSpecExist{
 
40
                This: cs.Reference(),
 
41
                Name: name,
 
42
        }
 
43
 
 
44
        res, err := methods.DoesCustomizationSpecExist(ctx, cs.c, &req)
 
45
 
 
46
        if err != nil {
 
47
                return false, err
 
48
        }
 
49
 
 
50
        return res.Returnval, nil
 
51
}
 
52
 
 
53
func (cs CustomizationSpecManager) GetCustomizationSpec(ctx context.Context, name string) (*types.CustomizationSpecItem, error) {
 
54
        req := types.GetCustomizationSpec{
 
55
                This: cs.Reference(),
 
56
                Name: name,
 
57
        }
 
58
 
 
59
        res, err := methods.GetCustomizationSpec(ctx, cs.c, &req)
 
60
 
 
61
        if err != nil {
 
62
                return nil, err
 
63
        }
 
64
 
 
65
        return &res.Returnval, nil
 
66
}
 
67
 
 
68
func (cs CustomizationSpecManager) CreateCustomizationSpec(ctx context.Context, item types.CustomizationSpecItem) error {
 
69
        req := types.CreateCustomizationSpec{
 
70
                This: cs.Reference(),
 
71
                Item: item,
 
72
        }
 
73
 
 
74
        _, err := methods.CreateCustomizationSpec(ctx, cs.c, &req)
 
75
        if err != nil {
 
76
                return err
 
77
        }
 
78
 
 
79
        return nil
 
80
}
 
81
 
 
82
func (cs CustomizationSpecManager) OverwriteCustomizationSpec(ctx context.Context, item types.CustomizationSpecItem) error {
 
83
        req := types.OverwriteCustomizationSpec{
 
84
                This: cs.Reference(),
 
85
                Item: item,
 
86
        }
 
87
 
 
88
        _, err := methods.OverwriteCustomizationSpec(ctx, cs.c, &req)
 
89
        if err != nil {
 
90
                return err
 
91
        }
 
92
 
 
93
        return nil
 
94
}
 
95
 
 
96
func (cs CustomizationSpecManager) DeleteCustomizationSpec(ctx context.Context, name string) error {
 
97
        req := types.DeleteCustomizationSpec{
 
98
                This: cs.Reference(),
 
99
                Name: name,
 
100
        }
 
101
 
 
102
        _, err := methods.DeleteCustomizationSpec(ctx, cs.c, &req)
 
103
        if err != nil {
 
104
                return err
 
105
        }
 
106
 
 
107
        return nil
 
108
}
 
109
 
 
110
func (cs CustomizationSpecManager) DuplicateCustomizationSpec(ctx context.Context, name string, newName string) error {
 
111
        req := types.DuplicateCustomizationSpec{
 
112
                This:    cs.Reference(),
 
113
                Name:    name,
 
114
                NewName: newName,
 
115
        }
 
116
 
 
117
        _, err := methods.DuplicateCustomizationSpec(ctx, cs.c, &req)
 
118
        if err != nil {
 
119
                return err
 
120
        }
 
121
 
 
122
        return nil
 
123
}
 
124
 
 
125
func (cs CustomizationSpecManager) RenameCustomizationSpec(ctx context.Context, name string, newName string) error {
 
126
        req := types.RenameCustomizationSpec{
 
127
                This:    cs.Reference(),
 
128
                Name:    name,
 
129
                NewName: newName,
 
130
        }
 
131
 
 
132
        _, err := methods.RenameCustomizationSpec(ctx, cs.c, &req)
 
133
        if err != nil {
 
134
                return err
 
135
        }
 
136
 
 
137
        return nil
 
138
}
 
139
 
 
140
func (cs CustomizationSpecManager) CustomizationSpecItemToXml(ctx context.Context, item types.CustomizationSpecItem) (string, error) {
 
141
        req := types.CustomizationSpecItemToXml{
 
142
                This: cs.Reference(),
 
143
                Item: item,
 
144
        }
 
145
 
 
146
        res, err := methods.CustomizationSpecItemToXml(ctx, cs.c, &req)
 
147
        if err != nil {
 
148
                return "", err
 
149
        }
 
150
 
 
151
        return res.Returnval, nil
 
152
}
 
153
 
 
154
func (cs CustomizationSpecManager) XmlToCustomizationSpecItem(ctx context.Context, xml string) (*types.CustomizationSpecItem, error) {
 
155
        req := types.XmlToCustomizationSpecItem{
 
156
                This:        cs.Reference(),
 
157
                SpecItemXml: xml,
 
158
        }
 
159
 
 
160
        res, err := methods.XmlToCustomizationSpecItem(ctx, cs.c, &req)
 
161
        if err != nil {
 
162
                return nil, err
 
163
        }
 
164
        return &res.Returnval, nil
 
165
}