AkamaiOPEN-edgegrid-golang
AkamaiOPEN-edgegrid-golang copied to clipboard
Too many requests while working via papi-v1
Hi, I'm trying to interact with Akamai Property API via papi-v1 module, but I've faced the problem with blocking me while I was trying to get a list of hostnames. Error: "API Error: 400 Bad Request WAF deny rule IPBLOCK-BURST4-54013".
The example:
config, _ := edgegrid.Init("~/.edgerc", "papi")
papi.Init(config)
contracts := papi.NewContracts()
err := contracts.GetContracts()
if err != nil {
log.Fatal(err)
}
contract, err := contracts.FindContract(contractName)
if err != nil {
log.Fatal(err)
}
groups := papi.NewGroups()
err = groups.GetGroups()
if err != nil {
log.Fatal(err)
}
group, err := groups.FindGroup(groupName)
if err != nil {
log.Fatal(err)
}
properties := papi.NewProperties()
err = properties.GetProperties(contract, group)
if err != nil {
log.Fatal(err)
}
property, err := properties.FindProperty(propertyID)
if err != nil {
log.Fatal(err)
}
v, err := property.GetLatestVersion("")
if err != nil {
log.Fatal(err)
}
hostnames := papi.NewHostnames()
err = hostnames.GetHostnames(v)
if err != nil {
log.Fatal(err)
}
for _, h := range hostnames.Hostnames.Items {
fmt.Printf("%+v\n", h)
}
UPD:
Debug helped me to find out that the client does a hell of a lot of requests during execution of properties.GetProperties(contract, group). That's because of post unmarshall hook that's defined here: https://github.com/akamai/AkamaiOPEN-edgegrid-golang/blob/master/papi-v1/properties.go#L342
So because of that I exceed the limit of requests and the Akamai API blocks me. Is there any chance to fix/get rid of that post unmarshall hook in the package? I'd be glad to help.
@dstdfx Fixed in v0.9.9 add caching to contract group cpcode
I'm getting this frequently in v1.0.1 while using no concurrency. To make matters worse, the debug logging shows that not every method propagates the 400 responses back as error values so my code keeps sending requests when already rate limited.
@dstdfx , @jasonmf - Sorry for not looking at this earlier. Plesae check it with most up to date version of Edgegtid library. I will close this ticket for now, feel free to open a new one.