instance.go
author Mikael Berthe <mikael@lilotux.net>
Sat, 29 Apr 2017 17:27:15 +0200
changeset 156 70aadba26338
parent 155 0c581e0108da
child 207 301d5b94be3f
permissions -rw-r--r--
Add field "All" to LimitParams, change Limit behaviour If All is true, the library will send several requests (if needed) until the API server has sent all the results. If not, and if a Limit is set, the library will try to fetch at least this number of results.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
130
c450bb73f59a Update credits
Mikael Berthe <mikael@lilotux.net>
parents: 120
diff changeset
     1
/*
c450bb73f59a Update credits
Mikael Berthe <mikael@lilotux.net>
parents: 120
diff changeset
     2
Copyright 2017 Mikael Berthe
c450bb73f59a Update credits
Mikael Berthe <mikael@lilotux.net>
parents: 120
diff changeset
     3
c450bb73f59a Update credits
Mikael Berthe <mikael@lilotux.net>
parents: 120
diff changeset
     4
Licensed under the MIT license.  Please see the LICENSE file is this directory.
c450bb73f59a Update credits
Mikael Berthe <mikael@lilotux.net>
parents: 120
diff changeset
     5
*/
c450bb73f59a Update credits
Mikael Berthe <mikael@lilotux.net>
parents: 120
diff changeset
     6
138
23d3a518d0ad Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents: 130
diff changeset
     7
package madon
112
467dd91bf1f9 Add GetCurrentInstance()
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     8
467dd91bf1f9 Add GetCurrentInstance()
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
     9
import (
467dd91bf1f9 Add GetCurrentInstance()
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    10
	"github.com/sendgrid/rest"
467dd91bf1f9 Add GetCurrentInstance()
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    11
)
467dd91bf1f9 Add GetCurrentInstance()
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    12
467dd91bf1f9 Add GetCurrentInstance()
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    13
// GetCurrentInstance returns current instance information
138
23d3a518d0ad Update package name in source files
Mikael Berthe <mikael@lilotux.net>
parents: 130
diff changeset
    14
func (mc *Client) GetCurrentInstance() (*Instance, error) {
112
467dd91bf1f9 Add GetCurrentInstance()
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    15
	var i Instance
155
0c581e0108da Use links from headers
Mikael Berthe <mikael@lilotux.net>
parents: 149
diff changeset
    16
	if err := mc.apiCall("instance", rest.Get, nil, nil, nil, &i); err != nil {
120
579912e9d0ef Refactor API calls
Mikael Berthe <mikael@lilotux.net>
parents: 112
diff changeset
    17
		return nil, err
112
467dd91bf1f9 Add GetCurrentInstance()
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    18
	}
467dd91bf1f9 Add GetCurrentInstance()
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    19
	return &i, nil
467dd91bf1f9 Add GetCurrentInstance()
Mikael Berthe <mikael@lilotux.net>
parents:
diff changeset
    20
}