Categorygithub.com/apiheat/go-edgegrid
modulepackage
0.0.1
Repository: https://github.com/apiheat/go-edgegrid.git
Documentation: pkg.go.dev

# README

go-edgegrid

An Akamai API client enabling Go programs to interact with Akamai in a simple and uniform way

NOTE

n.v.t

Coverage

This API client package covers most used parts the existing akamai API calls and is updated regularly. Currently the following services are supported:

  • Network Lists
  • Firewall Rule notifications
  • Siteshield
  • Netstorage
  • Certificate management

To add new/update existing features create a new PR

Usage

import "github.com/RafPe/go-edgegrid"

Construct a new Akamai client, then use the various services on the client to access different parts of the akamai API.

apiClientOpts := &edgegrid.ClientOptions{}
apiClientOpts.ConfigPath =  "/path/to/.edgerc/"
apiClientOpts.ConfigSection = "default"

// create new Akamai API client
akamaiApi := edgegrid.NewClient(nil, apiClientOpts)

Passing nil into client options will cause it to try and initiate using ENV VARS

Some API methods have optional parameters that can be passed.



// create new API client - using ENV VARS
// * AKAMAI_EDGERC_CONFIG
// * AKAMAI_EDGERC_SECTION
akamaiApi := edgegrid.NewClient(nil,nil)

// Set options for working with network lists
opt := edgegrid.ListNetworkListsOptions{
	TypeOflist:        "IP",
	Extended:          true,
	IncludeDeprecated: false,
	IncludeElements:   false,
}

// List all network lists
netLists, resp, err := apiClient.NetworkLists.ListNetworkLists(opt)

if err != nil {
	return err
}

Examples

The examples directory contains a couple for clear examples.

package main

import (
	"log"

	"github.com/RafPe/go-edgegrid"
)

func main() {

	// create new Akamai API client
	akamaiApi := edgegrid.NewClient(nil, "/path/to/.edgerc/", "section-name")

	// create options for new list creation
	newListItems := []string{"1.2.3.4/32", "5.6.7.8/32"}
	newListOpts := edgegrid.CreateNetworkListsOptions{
		Name:        "dummy_delete_1",
		Type:        "IP",
		Description: "",
		List:        newListItems,
	}
	
	newList, err := api.NetworkLists.CreateNetworkList(newListOpts)
	if err != nil {
		log.Fatal(err)
	}
}

ToDo

  • The biggest thing this package still needs is tests :disappointed:

Issues

Author

License

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

Inspired by

# Packages

No description provided by the author

# Functions

AuthString takes prm and returns a string that can be used as the `Authorization` header in making Akamai API requests.
CheckResponse checks the API response for errors, and returns them if present.
Init initializes using a configuration file in standard INI format.
NewClient returns a new edgegrid.Client for API.

# Constants

AkamaiEnvironmentVar const represents Akamai's env variables to be used.
AkamaiEnvironmentVar const represents Akamai's env variables to be used.
AkamaiEnvironment const represents Akamai's target environment to be used in calls.
AkamaiEnvironment const represents Akamai's target environment to be used in calls.

# Structs

ActivateNetworkListOptions represents options for network list activation Akamai API docs: https://developer.akamai.com/api/luna/network-list.
ActivateNetworkListStatus represents status of network list activation Akamai API docs: https://developer.akamai.com/api/luna/network-list.
AkamaiNetworkList represents the network list structure Akamai API docs: https://developer.akamai.com/api/luna/network-list.
AkamaiNetworkLists represents array of network lists Akamai API docs: https://developer.akamai.com/api/luna/network-list.
Akamai {OPEN} EdgeGrid Authentication Service.
Client represents Akamai's API client for communicating with service client.
ClientOptions represents options we can pass during client creation client.
ClientResponse represents response from our API call client.
CreateNetworkListOptions represents the available options for network list creation Akamai API docs: https://developer.akamai.com/api/luna/network-list.
EdgercCredentials are items from config file.
An ErrorResponse reports one or more errors caused by an API request.
ListNetworkListsOptions represents the available options for listing network lists Akamai API docs: https://developer.akamai.com/api/luna/network-list.
NetworkListResponse represents the response from network list creation Akamai API docs: https://developer.akamai.com/api/luna/network-list.
NetworkListService represents exposed services to manage network lists Akamai API docs: https://developer.akamai.com/api/luna/network-list.

# Type aliases

AkamaiEnvironment represents Akamai's target environment type.
AkamaiEnvironmentVar represents Akamai's env variables used client.