Skip to content

Latest commit

 

History

History
550 lines (352 loc) · 15.5 KB

ServiceAPI.md

File metadata and controls

550 lines (352 loc) · 15.5 KB

ServiceAPI

Note

All URIs are relative to https://api.fastly.com

Method HTTP request Description
CreateService POST /service Create a service
DeleteService DELETE /service/{service_id} Delete a service
GetService GET /service/{service_id} Get a service
GetServiceDetail GET /service/{service_id}/details Get service details
ListServiceDomains GET /service/{service_id}/domain List the domains within a service
ListServices GET /service List services
SearchService GET /service/search Search for a service by name
UpdateService PUT /service/{service_id} Update a service

CreateService

Create a service

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    comment := "comment_example" // string | A freeform descriptive note. (optional)
    name := "name_example" // string | The name of the service. (optional)
    customerID := "customerId_example" // string | Alphanumeric string identifying the customer. (optional)
    resourceType := "resourceType_example" // string | The type of this service. (optional)

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.ServiceAPI.CreateService(ctx).Comment(comment).Name(name).CustomerID(customerID).ResourceType(resourceType).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `ServiceAPI.CreateService`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `CreateService`: ServiceResponse
    fmt.Fprintf(os.Stdout, "Response from `ServiceAPI.CreateService`: %v\n", resp)
}

Path Parameters

Other Parameters

Other parameters are passed through a pointer to a apiCreateServiceRequest struct via the builder pattern

Name Type Description Notes
comment string A freeform descriptive note. name

Return type

ServiceResponse

Authorization

API Token

HTTP request headers

  • Content-Type: application/x-www-form-urlencoded
  • Accept: application/json

Back to top | Back to API list | Back to README

DeleteService

Delete a service

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    serviceID := "serviceId_example" // string | Alphanumeric string identifying the service.

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.ServiceAPI.DeleteService(ctx, serviceID).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `ServiceAPI.DeleteService`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `DeleteService`: InlineResponse200
    fmt.Fprintf(os.Stdout, "Response from `ServiceAPI.DeleteService`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
serviceID string Alphanumeric string identifying the service.

Other Parameters

Other parameters are passed through a pointer to a apiDeleteServiceRequest struct via the builder pattern

Name Type Description Notes

Return type

InlineResponse200

Authorization

API Token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

Back to top | Back to API list | Back to README

GetService

Get a service

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    serviceID := "serviceId_example" // string | Alphanumeric string identifying the service.

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.ServiceAPI.GetService(ctx, serviceID).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `ServiceAPI.GetService`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `GetService`: ServiceResponse
    fmt.Fprintf(os.Stdout, "Response from `ServiceAPI.GetService`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
serviceID string Alphanumeric string identifying the service.

Other Parameters

Other parameters are passed through a pointer to a apiGetServiceRequest struct via the builder pattern

Name Type Description Notes

Return type

ServiceResponse

Authorization

API Token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

Back to top | Back to API list | Back to README

GetServiceDetail

Get service details

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    serviceID := "serviceId_example" // string | Alphanumeric string identifying the service.
    version := int32(56) // int32 | Number identifying a version of the service. (optional)

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.ServiceAPI.GetServiceDetail(ctx, serviceID).Version(version).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `ServiceAPI.GetServiceDetail`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `GetServiceDetail`: ServiceDetail
    fmt.Fprintf(os.Stdout, "Response from `ServiceAPI.GetServiceDetail`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
serviceID string Alphanumeric string identifying the service.

Other Parameters

Other parameters are passed through a pointer to a apiGetServiceDetailRequest struct via the builder pattern

Name Type Description Notes
version int32 Number identifying a version of the service.

Return type

ServiceDetail

Authorization

API Token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

Back to top | Back to API list | Back to README

ListServiceDomains

List the domains within a service

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    serviceID := "serviceId_example" // string | Alphanumeric string identifying the service.

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.ServiceAPI.ListServiceDomains(ctx, serviceID).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `ServiceAPI.ListServiceDomains`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `ListServiceDomains`: []DomainResponse
    fmt.Fprintf(os.Stdout, "Response from `ServiceAPI.ListServiceDomains`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
serviceID string Alphanumeric string identifying the service.

Other Parameters

Other parameters are passed through a pointer to a apiListServiceDomainsRequest struct via the builder pattern

Name Type Description Notes

Return type

[]DomainResponse

Authorization

API Token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

Back to top | Back to API list | Back to README

ListServices

List services

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    page := int32(1) // int32 | Current page. (optional)
    perPage := int32(20) // int32 | Number of records per page. (optional) (default to 20)
    sort := "created" // string | Field on which to sort. (optional) (default to "created")
    direction := "ascend" // string | Direction in which to sort results. (optional) (default to "ascend")

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.ServiceAPI.ListServices(ctx).Page(page).PerPage(perPage).Sort(sort).Direction(direction).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `ServiceAPI.ListServices`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `ListServices`: []ServiceListResponse
    fmt.Fprintf(os.Stdout, "Response from `ServiceAPI.ListServices`: %v\n", resp)
}

Path Parameters

Other Parameters

Other parameters are passed through a pointer to a apiListServicesRequest struct via the builder pattern

Name Type Description Notes
page int32 Current page. perPage

Return type

[]ServiceListResponse

Authorization

API Token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

Back to top | Back to API list | Back to README

SearchService

Search for a service by name

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    name := "name_example" // string | The name of the service.

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.ServiceAPI.SearchService(ctx).Name(name).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `ServiceAPI.SearchService`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `SearchService`: ServiceResponse
    fmt.Fprintf(os.Stdout, "Response from `ServiceAPI.SearchService`: %v\n", resp)
}

Path Parameters

Other Parameters

Other parameters are passed through a pointer to a apiSearchServiceRequest struct via the builder pattern

Name Type Description Notes
name string The name of the service.

Return type

ServiceResponse

Authorization

API Token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

Back to top | Back to API list | Back to README

UpdateService

Update a service

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    serviceID := "serviceId_example" // string | Alphanumeric string identifying the service.
    comment := "comment_example" // string | A freeform descriptive note. (optional)
    name := "name_example" // string | The name of the service. (optional)
    customerID := "customerId_example" // string | Alphanumeric string identifying the customer. (optional)

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.ServiceAPI.UpdateService(ctx, serviceID).Comment(comment).Name(name).CustomerID(customerID).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `ServiceAPI.UpdateService`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `UpdateService`: ServiceResponse
    fmt.Fprintf(os.Stdout, "Response from `ServiceAPI.UpdateService`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
serviceID string Alphanumeric string identifying the service.

Other Parameters

Other parameters are passed through a pointer to a apiUpdateServiceRequest struct via the builder pattern

Name Type Description Notes
comment string A freeform descriptive note. name

Return type

ServiceResponse

Authorization

API Token

HTTP request headers

  • Content-Type: application/x-www-form-urlencoded
  • Accept: application/json

Back to top | Back to API list | Back to README