github.com/mmcquillan/packer@v1.1.1-0.20171009221028-c85cf0483a5d/builder/oracle/oci/client/vnic_attachment.go (about)

     1  package oci
     2  
     3  import (
     4  	"time"
     5  )
     6  
     7  // VNICAttachmentService enables communicating with the OCI compute API's VNIC
     8  // attachment endpoint.
     9  type VNICAttachmentService struct {
    10  	client *baseClient
    11  }
    12  
    13  // NewVNICAttachmentService creates a new VNICAttachmentService for communicating with the
    14  // OCI compute API's instance related endpoints.
    15  func NewVNICAttachmentService(s *baseClient) *VNICAttachmentService {
    16  	return &VNICAttachmentService{
    17  		client: s.New().Path("vnicAttachments/"),
    18  	}
    19  }
    20  
    21  // VNICAttachment details the attachment of a VNIC to a OCI instance.
    22  type VNICAttachment struct {
    23  	AvailabilityDomain string    `json:"availabilityDomain"`
    24  	CompartmentID      string    `json:"compartmentId"`
    25  	DisplayName        string    `json:"displayName,omitempty"`
    26  	ID                 string    `json:"id"`
    27  	InstanceID         string    `json:"instanceId"`
    28  	LifecycleState     string    `json:"lifecycleState"`
    29  	SubnetID           string    `json:"subnetId"`
    30  	TimeCreated        time.Time `json:"timeCreated"`
    31  	VNICID             string    `json:"vnicId"`
    32  }
    33  
    34  // ListVnicAttachmentsParams are the paramaters available when communicating
    35  // with the ListVnicAttachments API endpoint.
    36  type ListVnicAttachmentsParams struct {
    37  	AvailabilityDomain string `url:"availabilityDomain,omitempty"`
    38  	CompartmentID      string `url:"compartmentId"`
    39  	InstanceID         string `url:"instanceId,omitempty"`
    40  	VNICID             string `url:"vnicId,omitempty"`
    41  }
    42  
    43  // List returns an array of VNICAttachments.
    44  func (s *VNICAttachmentService) List(params *ListVnicAttachmentsParams) ([]VNICAttachment, error) {
    45  	vnicAttachments := new([]VNICAttachment)
    46  	e := new(APIError)
    47  
    48  	_, err := s.client.New().Get("").QueryStruct(params).Receive(vnicAttachments, e)
    49  	err = firstError(err, e)
    50  
    51  	return *vnicAttachments, err
    52  }