Created
August 21, 2017 22:17
-
-
Save broady/b5bd067449cb0ac3c2a553b93e0e77bf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"log" | |
"golang.org/x/oauth2/google" | |
compute "google.golang.org/api/compute/v1" | |
) | |
func main() { | |
ctx := context.Background() | |
client, err := google.DefaultClient(ctx, compute.ComputeScope) | |
if err != nil { | |
log.Fatal(err) | |
} | |
computeService, err := compute.New(client) | |
if err != nil { | |
log.Fatal(err) | |
} | |
snapshot := &compute.Snapshot{ | |
Description: "Snapshot of my-disk", | |
Name: "my-disk-snapshot", | |
} | |
resp, err := computeService.Disks.CreateSnapshot("my-project", "us-central1-a", "my-disk", snapshot).Do() | |
if err != nil { | |
log.Fatal(err) | |
} | |
log.Printf("Operation: %s", resp.SelfLink) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment