terraform/vendor/github.com/sethvargo/go-fastly
zimbatm 01876ef415
provider/fastly: add ssl_hostname option
Fastly will fail if the user sets the port to 443, ssl_check_cert is set
to true and the ssl_hostname is not provided.
2016-12-06 08:28:37 +00:00
..
LICENSE
Makefile provider/fastly: Update go-fastly SDK (#7747) 2016-07-21 14:10:33 -05:00
README.md
backend.go provider/fastly: add ssl_hostname option 2016-12-06 08:28:37 +00:00
billing.go provider/fastly: Add Gzip rule support (#6247) 2016-04-20 13:43:54 -05:00
cache_setting.go provider/fastly: Update go-fastly SDK (#7747) 2016-07-21 14:10:33 -05:00
client.go provider/fastly: Update go-fastly SDK (#7747) 2016-07-21 14:10:33 -05:00
condition.go provider/fastly: Add Gzip rule support (#6247) 2016-04-20 13:43:54 -05:00
content.go provider/fastly: Add Gzip rule support (#6247) 2016-04-20 13:43:54 -05:00
decode_hooks.go provider/fastly: Add Gzip rule support (#6247) 2016-04-20 13:43:54 -05:00
dictionary.go provider/fastly: add ssl_hostname option 2016-12-06 08:28:37 +00:00
dictionary_item.go provider/fastly: add ssl_hostname option 2016-12-06 08:28:37 +00:00
diff.go provider/fastly: Add Gzip rule support (#6247) 2016-04-20 13:43:54 -05:00
director.go provider/fastly: Add Gzip rule support (#6247) 2016-04-20 13:43:54 -05:00
director_backend.go provider/fastly: Add Gzip rule support (#6247) 2016-04-20 13:43:54 -05:00
domain.go provider/fastly: Add Gzip rule support (#6247) 2016-04-20 13:43:54 -05:00
errors.go provider/fastly: Update go-fastly SDK (#7747) 2016-07-21 14:10:33 -05:00
fastly.go provider/fastly: add ssl_hostname option 2016-12-06 08:28:37 +00:00
ftp.go provider/fastly: Add Gzip rule support (#6247) 2016-04-20 13:43:54 -05:00
gcs.go provider/fastly: Add Gzip rule support (#6247) 2016-04-20 13:43:54 -05:00
gzip.go provider/fastly: Update Gzip handling with new go-fastly (#6334) 2016-04-27 10:46:20 -05:00
header.go provider/fastly: add ssl_hostname option 2016-12-06 08:28:37 +00:00
health_check.go provider/fastly: Add Gzip rule support (#6247) 2016-04-20 13:43:54 -05:00
ip.go provider/fastly: Add Gzip rule support (#6247) 2016-04-20 13:43:54 -05:00
logentries.go provider/fastly: add ssl_hostname option 2016-12-06 08:28:37 +00:00
papertrail.go provider/fastly: Add Gzip rule support (#6247) 2016-04-20 13:43:54 -05:00
purge.go provider/fastly: Add Gzip rule support (#6247) 2016-04-20 13:43:54 -05:00
request.go provider/fastly: Add Gzip rule support (#6247) 2016-04-20 13:43:54 -05:00
request_setting.go provider/fastly: add ssl_hostname option 2016-12-06 08:28:37 +00:00
response_object.go provider/fastly: Add Gzip rule support (#6247) 2016-04-20 13:43:54 -05:00
s3.go provider/fastly: Update go-fastly SDK (#7747) 2016-07-21 14:10:33 -05:00
service.go provider/fastly: Add Gzip rule support (#6247) 2016-04-20 13:43:54 -05:00
settings.go provider/fastly: Add Gzip rule support (#6247) 2016-04-20 13:43:54 -05:00
sumologic.go provider/fastly: Add Gzip rule support (#6247) 2016-04-20 13:43:54 -05:00
syslog.go provider/fastly: add ssl_hostname option 2016-12-06 08:28:37 +00:00
vcl.go provider/fastly: Add Gzip rule support (#6247) 2016-04-20 13:43:54 -05:00
version.go provider/fastly: Update go-fastly SDK (#7747) 2016-07-21 14:10:33 -05:00
wordpress.go provider/fastly: Add Gzip rule support (#6247) 2016-04-20 13:43:54 -05:00

README.md

Go Fastly

Build Status Go Documentation

Go Fastly is a Golang API client for interacting with most facets of the Fastly API.

Installation

This is a client library, so there is nothing to install.

Usage

Download the library into your $GOPATH:

$ go get github.com/sethvargo/go-fastly

Import the library into your tool:

import "github.com/sethvargo/go-fastly"

Examples

Fastly's API is designed to work in the following manner:

  1. Create (or clone) a new configuration version for the service
  2. Make any changes to the version
  3. Validate the version
  4. Activate the version

This flow using the Golang client looks like this:

// Create a client object. The client has no state, so it can be persisted
// and re-used. It is also safe to use concurrently due to its lack of state.
// There is also a DefaultClient() method that reads an environment variable.
// Please see the documentation for more information and details.
client, err := fastly.NewClient("YOUR_FASTLY_API_KEY")
if err != nil {
  log.Fatal(err)
}

// You can find the service ID in the Fastly web console.
var serviceID = "SU1Z0isxPaozGVKXdv0eY"

// Get the latest active version
latest, err := client.LatestVersion(&fastly.LatestVersionInput{
  Service: serviceID,
})
if err != nil {
  log.Fatal(err)
}

// Clone the latest version so we can make changes without affecting the
// active configuration.
version, err := client.CloneVersion(&fastly.CloneVersionInput{
  Service: serviceID,
  Version: latest.Number,
})
if err != nil {
  log.Fatal(err)
}

// Now you can make any changes to the new version. In this example, we will add
// a new domain.
domain, err := client.CreateDomain(&fastly.CreateDomainInput{
  Service: serviceID,
  Version: version.Number,
  Name: "example.com",
})
if err != nil {
  log.Fatal(err)
}

// Output: "example.com"
fmt.Println(domain.Name)

// Now we can validate that our version is valid.
valid, err := client.ValidateVersion(&fastly.ValidateVersionInput{
  Service: serviceID,
  Version: version.Number,
})
if err != nil {
  log.Fatal(err)
}
if !valid {
  log.Fatal("not valid version")
}

// Finally, activate this new version.
activeVersion, err := client.ActivateVersion(&fastly.ActivateVersionInput{
  Service: serviceID,
  Version: version.Number,
})
if err != nil {
  log.Fatal(err)
}

// Output: true
fmt.Printf("%b", activeVersion.Locked)

More information can be found in the Fastly Godoc.

License

Copyright 2015 Seth Vargo

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.