@@ -233,6 +233,13 @@ An object containing a list of "key": value pairs. Example: { "name": "wrench",
233233 Description : `The name of the VPC that this instance is in.
234234Format: projects/{project_id}/global/networks/{network_id}` ,
235235 },
236+ "nic_type" : {
237+ Type : schema .TypeString ,
238+ Optional : true ,
239+ ForceNew : true ,
240+ ValidateFunc : validation .StringInSlice ([]string {"UNSPECIFIED_NIC_TYPE" , "VIRTIO_NET" , "GVNIC" , "" }, false ),
241+ Description : `The type of vNIC driver. Possible values: ["UNSPECIFIED_NIC_TYPE", "VIRTIO_NET", "GVNIC"]` ,
242+ },
236243 "no_proxy_access" : {
237244 Type : schema .TypeBool ,
238245 Optional : true ,
@@ -259,6 +266,39 @@ Format: projects/{project_id}/global/networks/{network_id}`,
259266notebook instance fully boots up. The path must be a URL
260267or Cloud Storage path (gs://path-to-file/file-name).` ,
261268 },
269+ "reservation_affinity" : {
270+ Type : schema .TypeList ,
271+ Optional : true ,
272+ ForceNew : true ,
273+ Description : `Reservation Affinity for consuming Zonal reservation.` ,
274+ MaxItems : 1 ,
275+ Elem : & schema.Resource {
276+ Schema : map [string ]* schema.Schema {
277+ "consume_reservation_type" : {
278+ Type : schema .TypeString ,
279+ Required : true ,
280+ ForceNew : true ,
281+ ValidateFunc : validation .StringInSlice ([]string {"NO_RESERVATION" , "ANY_RESERVATION" , "SPECIFIC_RESERVATION" }, false ),
282+ Description : `The type of Compute Reservation. Possible values: ["NO_RESERVATION", "ANY_RESERVATION", "SPECIFIC_RESERVATION"]` ,
283+ },
284+ "key" : {
285+ Type : schema .TypeString ,
286+ Optional : true ,
287+ ForceNew : true ,
288+ Description : `Corresponds to the label key of reservation resource.` ,
289+ },
290+ "values" : {
291+ Type : schema .TypeList ,
292+ Optional : true ,
293+ ForceNew : true ,
294+ Description : `Corresponds to the label values of reservation resource.` ,
295+ Elem : & schema.Schema {
296+ Type : schema .TypeString ,
297+ },
298+ },
299+ },
300+ },
301+ },
262302 "service_account" : {
263303 Type : schema .TypeString ,
264304 Computed : true ,
@@ -454,6 +494,18 @@ func resourceNotebooksInstanceCreate(d *schema.ResourceData, meta interface{}) e
454494 } else if v , ok := d .GetOkExists ("shielded_instance_config" ); ! isEmptyValue (reflect .ValueOf (shieldedInstanceConfigProp )) && (ok || ! reflect .DeepEqual (v , shieldedInstanceConfigProp )) {
455495 obj ["shieldedInstanceConfig" ] = shieldedInstanceConfigProp
456496 }
497+ nicTypeProp , err := expandNotebooksInstanceNicType (d .Get ("nic_type" ), d , config )
498+ if err != nil {
499+ return err
500+ } else if v , ok := d .GetOkExists ("nic_type" ); ! isEmptyValue (reflect .ValueOf (nicTypeProp )) && (ok || ! reflect .DeepEqual (v , nicTypeProp )) {
501+ obj ["nicType" ] = nicTypeProp
502+ }
503+ reservationAffinityProp , err := expandNotebooksInstanceReservationAffinity (d .Get ("reservation_affinity" ), d , config )
504+ if err != nil {
505+ return err
506+ } else if v , ok := d .GetOkExists ("reservation_affinity" ); ! isEmptyValue (reflect .ValueOf (reservationAffinityProp )) && (ok || ! reflect .DeepEqual (v , reservationAffinityProp )) {
507+ obj ["reservationAffinity" ] = reservationAffinityProp
508+ }
457509 installGpuDriverProp , err := expandNotebooksInstanceInstallGpuDriver (d .Get ("install_gpu_driver" ), d , config )
458510 if err != nil {
459511 return err
@@ -673,6 +725,12 @@ func resourceNotebooksInstanceRead(d *schema.ResourceData, meta interface{}) err
673725 if err := d .Set ("shielded_instance_config" , flattenNotebooksInstanceShieldedInstanceConfig (res ["shieldedInstanceConfig" ], d , config )); err != nil {
674726 return fmt .Errorf ("Error reading Instance: %s" , err )
675727 }
728+ if err := d .Set ("nic_type" , flattenNotebooksInstanceNicType (res ["nicType" ], d , config )); err != nil {
729+ return fmt .Errorf ("Error reading Instance: %s" , err )
730+ }
731+ if err := d .Set ("reservation_affinity" , flattenNotebooksInstanceReservationAffinity (res ["reservationAffinity" ], d , config )); err != nil {
732+ return fmt .Errorf ("Error reading Instance: %s" , err )
733+ }
676734 if err := d .Set ("state" , flattenNotebooksInstanceState (res ["state" ], d , config )); err != nil {
677735 return fmt .Errorf ("Error reading Instance: %s" , err )
678736 }
@@ -929,6 +987,39 @@ func flattenNotebooksInstanceShieldedInstanceConfigEnableVtpm(v interface{}, d *
929987 return v
930988}
931989
990+ func flattenNotebooksInstanceNicType (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
991+ return v
992+ }
993+
994+ func flattenNotebooksInstanceReservationAffinity (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
995+ if v == nil {
996+ return nil
997+ }
998+ original := v .(map [string ]interface {})
999+ if len (original ) == 0 {
1000+ return nil
1001+ }
1002+ transformed := make (map [string ]interface {})
1003+ transformed ["consume_reservation_type" ] =
1004+ flattenNotebooksInstanceReservationAffinityConsumeReservationType (original ["consumeReservationType" ], d , config )
1005+ transformed ["key" ] =
1006+ flattenNotebooksInstanceReservationAffinityKey (original ["key" ], d , config )
1007+ transformed ["values" ] =
1008+ flattenNotebooksInstanceReservationAffinityValues (original ["values" ], d , config )
1009+ return []interface {}{transformed }
1010+ }
1011+ func flattenNotebooksInstanceReservationAffinityConsumeReservationType (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1012+ return v
1013+ }
1014+
1015+ func flattenNotebooksInstanceReservationAffinityKey (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1016+ return v
1017+ }
1018+
1019+ func flattenNotebooksInstanceReservationAffinityValues (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
1020+ return v
1021+ }
1022+
9321023func flattenNotebooksInstanceState (v interface {}, d * schema.ResourceData , config * Config ) interface {} {
9331024 return v
9341025}
@@ -1084,6 +1175,55 @@ func expandNotebooksInstanceShieldedInstanceConfigEnableVtpm(v interface{}, d Te
10841175 return v , nil
10851176}
10861177
1178+ func expandNotebooksInstanceNicType (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
1179+ return v , nil
1180+ }
1181+
1182+ func expandNotebooksInstanceReservationAffinity (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
1183+ l := v .([]interface {})
1184+ if len (l ) == 0 || l [0 ] == nil {
1185+ return nil , nil
1186+ }
1187+ raw := l [0 ]
1188+ original := raw .(map [string ]interface {})
1189+ transformed := make (map [string ]interface {})
1190+
1191+ transformedConsumeReservationType , err := expandNotebooksInstanceReservationAffinityConsumeReservationType (original ["consume_reservation_type" ], d , config )
1192+ if err != nil {
1193+ return nil , err
1194+ } else if val := reflect .ValueOf (transformedConsumeReservationType ); val .IsValid () && ! isEmptyValue (val ) {
1195+ transformed ["consumeReservationType" ] = transformedConsumeReservationType
1196+ }
1197+
1198+ transformedKey , err := expandNotebooksInstanceReservationAffinityKey (original ["key" ], d , config )
1199+ if err != nil {
1200+ return nil , err
1201+ } else if val := reflect .ValueOf (transformedKey ); val .IsValid () && ! isEmptyValue (val ) {
1202+ transformed ["key" ] = transformedKey
1203+ }
1204+
1205+ transformedValues , err := expandNotebooksInstanceReservationAffinityValues (original ["values" ], d , config )
1206+ if err != nil {
1207+ return nil , err
1208+ } else if val := reflect .ValueOf (transformedValues ); val .IsValid () && ! isEmptyValue (val ) {
1209+ transformed ["values" ] = transformedValues
1210+ }
1211+
1212+ return transformed , nil
1213+ }
1214+
1215+ func expandNotebooksInstanceReservationAffinityConsumeReservationType (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
1216+ return v , nil
1217+ }
1218+
1219+ func expandNotebooksInstanceReservationAffinityKey (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
1220+ return v , nil
1221+ }
1222+
1223+ func expandNotebooksInstanceReservationAffinityValues (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
1224+ return v , nil
1225+ }
1226+
10871227func expandNotebooksInstanceInstallGpuDriver (v interface {}, d TerraformResourceData , config * Config ) (interface {}, error ) {
10881228 return v , nil
10891229}
0 commit comments