github.com/vmware/govmomi@v0.37.1/vapi/internal/internal.go (about)

     1  /*
     2  Copyright (c) 2018-2023 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 internal
    18  
    19  import (
    20  	"github.com/vmware/govmomi/vim25/mo"
    21  	"github.com/vmware/govmomi/vim25/types"
    22  )
    23  
    24  // VAPI REST Paths
    25  const (
    26  	SessionPath                    = "/com/vmware/cis/session"
    27  	CategoryPath                   = "/com/vmware/cis/tagging/category"
    28  	TagPath                        = "/com/vmware/cis/tagging/tag"
    29  	AssociationPath                = "/com/vmware/cis/tagging/tag-association"
    30  	LibraryPath                    = "/com/vmware/content/library"
    31  	LibraryItemFileData            = "/com/vmware/cis/data"
    32  	LibraryItemPath                = "/com/vmware/content/library/item"
    33  	LibraryItemFilePath            = "/com/vmware/content/library/item/file"
    34  	LibraryItemUpdateSession       = "/com/vmware/content/library/item/update-session"
    35  	LibraryItemUpdateSessionFile   = "/com/vmware/content/library/item/updatesession/file"
    36  	LibraryItemDownloadSession     = "/com/vmware/content/library/item/download-session"
    37  	LibraryItemDownloadSessionFile = "/com/vmware/content/library/item/downloadsession/file"
    38  	LocalLibraryPath               = "/com/vmware/content/local-library"
    39  	SubscribedLibraryPath          = "/com/vmware/content/subscribed-library"
    40  	SecurityPoliciesPath           = "/api/content/security-policies"
    41  	SubscribedLibraryItem          = "/com/vmware/content/library/subscribed-item"
    42  	Subscriptions                  = "/com/vmware/content/library/subscriptions"
    43  	TrustedCertificatesPath        = "/api/content/trusted-certificates"
    44  	VCenterOVFLibraryItem          = "/com/vmware/vcenter/ovf/library-item"
    45  	VCenterVMTXLibraryItem         = "/vcenter/vm-template/library-items"
    46  	SessionCookieName              = "vmware-api-session-id"
    47  	UseHeaderAuthn                 = "vmware-use-header-authn"
    48  	DebugEcho                      = "/vc-sim/debug/echo"
    49  )
    50  
    51  // AssociatedObject is the same structure as types.ManagedObjectReference,
    52  // just with a different field name (ID instead of Value).
    53  // In the API we use mo.Reference, this type is only used for wire transfer.
    54  type AssociatedObject struct {
    55  	Type  string `json:"type"`
    56  	Value string `json:"id"`
    57  }
    58  
    59  // Reference implements mo.Reference
    60  func (o AssociatedObject) Reference() types.ManagedObjectReference {
    61  	return types.ManagedObjectReference{
    62  		Type:  o.Type,
    63  		Value: o.Value,
    64  	}
    65  }
    66  
    67  // Association for tag-association requests.
    68  type Association struct {
    69  	ObjectID *AssociatedObject `json:"object_id,omitempty"`
    70  }
    71  
    72  // NewAssociation returns an Association, converting ref to an AssociatedObject.
    73  func NewAssociation(ref mo.Reference) Association {
    74  	return Association{
    75  		ObjectID: &AssociatedObject{
    76  			Type:  ref.Reference().Type,
    77  			Value: ref.Reference().Value,
    78  		},
    79  	}
    80  }
    81  
    82  type SubscriptionDestination struct {
    83  	ID string `json:"subscription"`
    84  }
    85  
    86  type SubscriptionDestinationSpec struct {
    87  	Subscriptions []SubscriptionDestination `json:"subscriptions,omitempty"`
    88  }
    89  
    90  type SubscriptionItemDestinationSpec struct {
    91  	Force         bool                      `json:"force_sync_content"`
    92  	Subscriptions []SubscriptionDestination `json:"subscriptions,omitempty"`
    93  }