golang.org/x/build@v0.0.0-20240506185731-218518f32b70/internal/macservice/leases.go (about)

     1  // Copyright 2023 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package macservice
     6  
     7  import (
     8  	"time"
     9  )
    10  
    11  // These are minimal definitions. Many fields have been omitted since we don't
    12  // need them yet.
    13  
    14  type LeaseRequest struct {
    15  	VMResourceNamespace Namespace `json:"vmResourceNamespace"`
    16  
    17  	InstanceSpecification InstanceSpecification `json:"instanceSpecification"`
    18  
    19  	// Duration is ultimately a Duration protobuf message.
    20  	//
    21  	// https://pkg.go.dev/google.golang.org/protobuf@v1.31.0/types/known/durationpb#hdr-JSON_Mapping:
    22  	// "In JSON format, the Duration type is encoded as a string rather
    23  	// than an object, where the string ends in the suffix "s" (indicating
    24  	// seconds) and is preceded by the number of seconds, with nanoseconds
    25  	// expressed as fractional seconds."
    26  	Duration string `json:"duration"`
    27  }
    28  
    29  type LeaseResponse struct {
    30  	PendingLease Lease `json:"pendingLease"`
    31  }
    32  
    33  type RenewRequest struct {
    34  	LeaseID string `json:"leaseId"`
    35  
    36  	// Duration is ultimately a Duration protobuf message.
    37  	//
    38  	// https://pkg.go.dev/google.golang.org/protobuf@v1.31.0/types/known/durationpb#hdr-JSON_Mapping:
    39  	// "In JSON format, the Duration type is encoded as a string rather
    40  	// than an object, where the string ends in the suffix "s" (indicating
    41  	// seconds) and is preceded by the number of seconds, with nanoseconds
    42  	// expressed as fractional seconds."
    43  	Duration string `json:"duration"`
    44  }
    45  
    46  type RenewResponse struct {
    47  	Expires time.Time `json:"expires"`
    48  }
    49  
    50  type VacateRequest struct {
    51  	LeaseID string `json:"leaseId"`
    52  }
    53  
    54  type FindRequest struct {
    55  	VMResourceNamespace Namespace `json:"vmResourceNamespace"`
    56  }
    57  
    58  type FindResponse struct {
    59  	Instances []Instance `json:"instances"`
    60  }
    61  
    62  type Namespace struct {
    63  	CustomerName    string `json:"customerName"`
    64  	ProjectName     string `json:"projectName"`
    65  	SubCustomerName string `json:"subCustomerName"`
    66  }
    67  
    68  type Instance struct {
    69  	Lease Lease `json:"lease"`
    70  
    71  	InstanceSpecification InstanceSpecification `json:"instanceSpecification"`
    72  }
    73  
    74  type Lease struct {
    75  	LeaseID string `json:"leaseId"`
    76  
    77  	VMResourceNamespace Namespace `json:"vmResourceNamespace"`
    78  
    79  	Expires time.Time `json:"expires"`
    80  }
    81  
    82  type InstanceSpecification struct {
    83  	Profile     MachineProfile     `json:"profile"`
    84  	AccessLevel NetworkAccessLevel `json:"accessLevel"`
    85  
    86  	Metadata []MetadataEntry `json:"metadata"`
    87  
    88  	DiskSelection DiskSelection `json:"diskSelection"`
    89  }
    90  
    91  type DiskSelection struct {
    92  	ImageHashes ImageHashes `json:"imageHashes"`
    93  }
    94  
    95  type ImageHashes struct {
    96  	BootSHA256 string `json:"bootSha256"`
    97  }
    98  
    99  type MachineProfile string
   100  
   101  const (
   102  	V1_MEDIUM_VM MachineProfile = "V1_MEDIUM_VM"
   103  )
   104  
   105  type NetworkAccessLevel string
   106  
   107  const (
   108  	GOLANG_OSS NetworkAccessLevel = "GOLANG_OSS"
   109  )
   110  
   111  type MetadataEntry struct {
   112  	Key   string `json:"key"`
   113  	Value string `json:"value"`
   114  }