2
Copyright (c) 2014 VMware, Inc. All Rights Reserved.
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
8
http://www.apache.org/licenses/LICENSE-2.0
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.
23
"github.com/juju/govmomi/property"
24
"github.com/juju/govmomi/vim25"
25
"github.com/juju/govmomi/vim25/methods"
26
"github.com/juju/govmomi/vim25/mo"
27
"github.com/juju/govmomi/vim25/types"
28
"golang.org/x/net/context"
31
type HttpNfcLease struct {
35
func NewHttpNfcLease(c *vim25.Client, ref types.ManagedObjectReference) *HttpNfcLease {
37
Common: NewCommon(c, ref),
41
// HttpNfcLeaseAbort wraps methods.HttpNfcLeaseAbort
42
func (o HttpNfcLease) HttpNfcLeaseAbort(ctx context.Context, fault *types.LocalizedMethodFault) error {
43
req := types.HttpNfcLeaseAbort{
48
_, err := methods.HttpNfcLeaseAbort(ctx, o.c, &req)
56
// HttpNfcLeaseComplete wraps methods.HttpNfcLeaseComplete
57
func (o HttpNfcLease) HttpNfcLeaseComplete(ctx context.Context) error {
58
req := types.HttpNfcLeaseComplete{
62
_, err := methods.HttpNfcLeaseComplete(ctx, o.c, &req)
70
// HttpNfcLeaseGetManifest wraps methods.HttpNfcLeaseGetManifest
71
func (o HttpNfcLease) HttpNfcLeaseGetManifest(ctx context.Context) error {
72
req := types.HttpNfcLeaseGetManifest{
76
_, err := methods.HttpNfcLeaseGetManifest(ctx, o.c, &req)
84
// HttpNfcLeaseProgress wraps methods.HttpNfcLeaseProgress
85
func (o HttpNfcLease) HttpNfcLeaseProgress(ctx context.Context, percent int) error {
86
req := types.HttpNfcLeaseProgress{
91
_, err := methods.HttpNfcLeaseProgress(ctx, o.c, &req)
99
func (o HttpNfcLease) Wait(ctx context.Context) (*types.HttpNfcLeaseInfo, error) {
100
var lease mo.HttpNfcLease
102
pc := property.DefaultCollector(o.c)
103
err := property.Wait(ctx, pc, o.Reference(), []string{"state", "info", "error"}, func(pc []types.PropertyChange) bool {
106
for _, c := range pc {
113
val := c.Val.(types.LocalizedMethodFault)
117
val := c.Val.(types.HttpNfcLeaseInfo)
120
lease.State = c.Val.(types.HttpNfcLeaseState)
121
if lease.State != types.HttpNfcLeaseStateInitializing {
134
if lease.State == types.HttpNfcLeaseStateReady {
135
return lease.Info, nil
138
if lease.Error != nil {
139
return nil, errors.New(lease.Error.LocalizedMessage)
142
return nil, fmt.Errorf("unexpected nfc lease state: %s", lease.State)