profile
viewpoint

DRuggeri/OSSClass 19

An Open Open source class

DRuggeri/netgear_exporter 11

A Prometheus exporter for Netgear consumer routers

DRuggeri/bind_query_exporter 6

A Prometheus exporter for BIND queries

DRuggeri/nut_exporter 6

Network UPS Tools Prometheus Exporter

DRuggeri/alertmanager_gotify_bridge 5

A bridge between Prometheus AlertManager and a Gotify server

DRuggeri/netgear_client 5

A go client for netgear routers

DRuggeri/dhcpd_leases_exporter 3

A Prometheus exporter for the ISC dhcpd daemon's dhcpd.leases file

DRuggeri/crystalfontz-lcd-cmd 1

A small, simple command line tool to set/clear CrystalFontz LCD screens

DRuggeri/dhcpdleasesreader 1

A golang wrapper around dhcpd.leases

Mastercard/direct-services-access-reference 1

This is a reference application to demonstrate how the Mastercard Direct Services Access API can be used for the supported operations for directly calling specific Mastercard value-added services.

issue openedMastercard/terraform-provider-restapi

pass headers in a restapi_object

Hi, I'm looking for a way to pass additionnal headers to a restapi_object , on top of the ones set in the provider section.

Is this possible?

created time in 4 days

issue commentMastercard/terraform-provider-restapi

Support query_string in resource provider

Thanks for getting back to me @abelal83, in the meantime I have come up with a simple Powershell for it:

[CmdletBinding()]
param(
  [Parameter(Mandatory = $true)]
  [string] $TenantId,

  [Parameter(Mandatory = $true)]
  [string] $ClientId,

  [Parameter(Mandatory = $true)]
  [SecureString] $ClientSecret
)

$secret = $ClientSecret | ConvertFrom-SecureString -AsPlainText

$request = @{
  grant_type    = "client_credentials"
  client_id     = $ClientId
  client_secret = $secret
  resource      = "https://management.azure.com/"
}

$response = Invoke-RestMethod "https://login.microsoftonline.com/${TenantId}/oauth2/token?" `
  -Method POST `
  -Form $request

$response
abelal83

comment created time in 5 days

issue commentMastercard/terraform-provider-restapi

Support query_string in resource provider

Hi @sponte unfortunately I've not had time to work on this yet but my thinking was to use to use az cli and get its token. Once I get a chance to work on it will happily share here!

abelal83

comment created time in 5 days

issue commentMastercard/terraform-provider-restapi

Support query_string in resource provider

Hey @abelal83, out of interest, how do you authenticate to AzureRM from restapi provider? Did you extract the token from ~/.azure?

abelal83

comment created time in 5 days

startedDRuggeri/nut_exporter

started time in 11 days

fork boobboo/netgear_exporter

A Prometheus exporter for Netgear consumer routers

fork in 11 days

PR opened Mastercard/terraform-provider-restapi

added path_query_string parameter

Issue : #103

Helps the user add a query string to API requests.

+105 -50

0 comment

2 changed files

pr created time in 11 days

issue commentMastercard/terraform-provider-restapi

Unable to perform DELETE: ID is not expanding, being seen as literal and getting Invalid resource

This was an issue with the id_attribute, needed "result/_ref" and it worked as expected. Woohoo!

TryTryAgain

comment created time in 13 days

issue closedMastercard/terraform-provider-restapi

Unable to perform DELETE: ID is not expanding, being seen as literal and getting Invalid resource

I've seen some related issues but nothing specifically talking about ID being seen as a literal string which appears to be what's happening to me...

From the terraform side: state, output are both good (other than being the string "_ref" rather than the results; "id": "_ref"): tfstate (sample):

      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "api_data": {
              "result": "map[_ref:networkcontainer/ZG5zLm5l...]"
            },
          "api_response": "{\n    \"result\": {\n        \"_ref\": \"networkcontainer/ZG5zLm5l...]"

I'm able to use the following to output and/or use as input for something else:

output "cidr" {
    value = jsondecode(restapi_object.network_container.create_response).result.network
}

output "raw_data" {
    value = restapi_object.network_container.create_response
}

But I'm not able to DELETE, tried a bunch of different combinations of including and not including a variety of id_attribute/object_id, *_paths, etc., and have seen a bunch of varying errors but say I'm using something like:

resource "restapi_object" "network_container" {
    path = "/networkcontainer"
    create_path = "/networkcontainer?_return_fields%2B=network,comment&_return_as_object=1"
    data = "{\"network\": \"func:nextavailablenetwork:100.100.0.0/15,1234-TEST,23\",\"comment\": \"1234-TEST-VPC\",\"network_view\": \"1234-TEST\"}"
    id_attribute = "_ref"
    object_id = "_ref"
    debug = true
}

if then issuing a terraform destroy I'll get back:

restapi_object.network_container: Refreshing state... [id=_ref]

Error: Unexpected response code '400': { "Error": "AdmConProtoError: Invalid reference: networkcontainer/_ref", 
  "code": "Client.Ibap.Proto", 
  "text": "Invalid reference: networkcontainer/_ref"
}

...where I would assume it would be what it should be networkcontainer/ZG5zLm5l... but for some reason, it would appear the ID is being seen as the literal string rather than the generated return data.

Similar to other related issues, if I don't include object_id I get an error Internal validation failed error.

Any help would be appreciated.

closed time in 13 days

TryTryAgain

issue openedMastercard/terraform-provider-restapi

Unable to perform DELETE: ID is not expanding, being seen as literal and getting Invalid resource

I've seen some related issues but nothing specifically talking about ID being seen as a literal string which appears to be what's happening to me...

From the terraform side: state, output are both good (other than being the string "_ref" rather than the results; "id": "_ref"): tfstate (sample):

      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "api_data": {
              "result": "map[_ref:networkcontainer/ZG5zLm5l...]"
            },
          "api_response": "{\n    \"result\": {\n        \"_ref\": \"networkcontainer/ZG5zLm5l...]"

I'm able to use the following to output and/or use as input for something else:

output "cidr" {
    value = jsondecode(restapi_object.network_container.create_response).result.network
}

output "raw_data" {
    value = restapi_object.network_container.create_response
}

But I'm not able to DELETE, tried a bunch of different combinations of including and not including a variety of id_attribute/object_id, *_paths, etc., and have seen a bunch of varying errors but say I'm using something like:

resource "restapi_object" "network_container" {
    path = "/networkcontainer"
    create_path = "/networkcontainer?_return_fields%2B=network,comment&_return_as_object=1"
    data = "{\"network\": \"func:nextavailablenetwork:100.100.0.0/15,1234-TEST,23\",\"comment\": \"1234-TEST-VPC\",\"network_view\": \"1234-TEST\"}"
    id_attribute = "_ref"
    object_id = "_ref"
    debug = true
}

if then issuing a terraform destroy I'll get back:

restapi_object.network_container: Refreshing state... [id=_ref]

Error: Unexpected response code '400': { "Error": "AdmConProtoError: Invalid reference: networkcontainer/_ref", 
  "code": "Client.Ibap.Proto", 
  "text": "Invalid reference: networkcontainer/_ref"
}

...where I would assume it would be what it should be networkcontainer/ZG5zLm5l... but for some reason, it would appear the ID is being seen as the literal string rather than the generated return data.

Similar to other related issues, if I don't include object_id I get an error Internal validation failed error.

Any help would be appreciated.

created time in 13 days

issue commentDRuggeri/netgear_exporter

Rate limits

I am using version 1.0.1 according to the output of the command.

bwees

comment created time in 13 days

issue closedMastercard/terraform-provider-restapi

ID in Location Header

Hi there,

I want to create QBoxMail inboxes via terraform and the API looks like this

/**
 * Create a new email account (info@hello2.com)
 */

curl -v \
    -H "Content-Type: application/json" \
    -H "X-Api-Token: 3u2eIGWX2oN_Z2TRxZOp5Si8hzrDF6vpyxYcdWAX-WUnbBroqNmphw9PUBbGNolP" \
    -X POST -d '{
        "name":"info",
        "firstname": "info",
        "password":"Qwertyuiop0",
        "password_confirmation":"Qwertyuiop0" }' \
    https://api.qboxmail.com/api/domains/D727264119/email_accounts

> POST /api/domains/D727264119/email_accounts HTTP/1.1
> Host: api.qboxmail.com
> User-Agent: curl/7.51.0
> Accept: */*
> Content-Type: application/json
> X-Api-Token: 3u2eIGWX2oN_Z2TRxZOp5Si8hzrDF6vpyxYcdWAX-WUnbBroqNmphw9PUBbGNolP
> Content-Length: 108

< HTTP/1.1 201 Created
< Location: https://api.qboxmail.com/domains/D727264119/email_accounts/EA03350967
< Content-Type: application/json
< Content-Length: 28
< Etag: W/"a0d00fe50a65a8b47780d2dce5029fb4"
< Cache-Control: max-age=0, private, must-revalidate
< X-Request-Id: e9032d55-3d8a-4c5f-99d9-af18bb44c015
< X-Runtime: 0.775738
< Vary: Origin
< Server: WEBrick/1.3.1 (Ruby/2.3.3/2016-11-21)
< Date: Tue, 29 Nov 2016 08:38:30 GMT
< Connection: Keep-Alive

Body:
{
    "message": "risorsa creata"
}

The created id EA03350967 can be found in the Location header, not the body

Location: https://api.qboxmail.com/domains/D727264119/email_accounts/EA03350967

Is it possible with the current provider to extract this id?

Cheers, Dennis

PS: QBoxMail API https://www.qboxmail.com/api-doc/#api-Emails-PostEmails

closed time in 13 days

dennis-tra

issue commentMastercard/terraform-provider-restapi

ID in Location Header

Turns out the documentation is out of date and the API indeed returns a field resource_created that contains an ID.

dennis-tra

comment created time in 13 days

issue commentMastercard/terraform-provider-restapi

How to set object ID correctly based on response ?

Described it here , basically making infoblox return object (?_return_as_object=1)

irom77

comment created time in 13 days

issue openedMastercard/terraform-provider-restapi

ID in Location Header

Hi there,

I want to create QBoxMail inboxes via terraform and the API looks like this

/**
 * Create a new email account (info@hello2.com)
 */

curl -v \
    -H "Content-Type: application/json" \
    -H "X-Api-Token: 3u2eIGWX2oN_Z2TRxZOp5Si8hzrDF6vpyxYcdWAX-WUnbBroqNmphw9PUBbGNolP" \
    -X POST -d '{
        "name":"info",
        "firstname": "info",
        "password":"Qwertyuiop0",
        "password_confirmation":"Qwertyuiop0" }' \
    https://api.qboxmail.com/api/domains/D727264119/email_accounts

> POST /api/domains/D727264119/email_accounts HTTP/1.1
> Host: api.qboxmail.com
> User-Agent: curl/7.51.0
> Accept: */*
> Content-Type: application/json
> X-Api-Token: 3u2eIGWX2oN_Z2TRxZOp5Si8hzrDF6vpyxYcdWAX-WUnbBroqNmphw9PUBbGNolP
> Content-Length: 108

< HTTP/1.1 201 Created
< Location: https://api.qboxmail.com/domains/D727264119/email_accounts/EA03350967
< Content-Type: application/json
< Content-Length: 28
< Etag: W/"a0d00fe50a65a8b47780d2dce5029fb4"
< Cache-Control: max-age=0, private, must-revalidate
< X-Request-Id: e9032d55-3d8a-4c5f-99d9-af18bb44c015
< X-Runtime: 0.775738
< Vary: Origin
< Server: WEBrick/1.3.1 (Ruby/2.3.3/2016-11-21)
< Date: Tue, 29 Nov 2016 08:38:30 GMT
< Connection: Keep-Alive

Body:
{
    "message": "risorsa creata"
}

The created id EA03350967 can be found in the Location header, not the body

Location: https://api.qboxmail.com/domains/D727264119/email_accounts/EA03350967

Is it possible with the current provider to extract this id?

Cheers, Dennis

PS: QBoxMail API https://www.qboxmail.com/api-doc/#api-Emails-PostEmails

created time in 14 days

issue commentMastercard/terraform-provider-restapi

How to set object ID correctly based on response ?

@irom77 ...what was your solution?

irom77

comment created time in 14 days

issue commentMastercard/terraform-provider-restapi

Getting 401 even though credentials are provided

Ok I think the problem is that on http I'm getting redirect to https and then the basic auth header won't be propagated? Would that be a possible root cause?

nadworny

comment created time in 15 days

issue commentMastercard/terraform-provider-restapi

Unable to view any output

So, when the problem is that I am unable to print any output. I was able to see the results array in my debug terraform output which confirms that the config is right and the only problem I have is while printing output.

niraj8241

comment created time in 15 days

issue openedMastercard/terraform-provider-restapi

EvalRefresh Error - err: json: cannot unmarshal array into Go value

I receive the following error when applying my tf config:

... _account_plan: Refreshing state... [id=0a32584d-6abc-4cdc-a827-b552683b5999] 2020/11/13 14:26:40 [ERROR] eval: *terraform.EvalRefresh, err: json: cannot unmarshal array into Go value of type map[string]interface {}

This resource was created successfully. However, on subsequent apply runs, it fails. Not sure where to go from here...

Here is what state looks like:

restapi_object.demo_account_plan:

resource "restapi_object" "demo_account_plan" { api_data = { "ApiIds" = "map[results:[]]" "DefaultPlan" = "false" "Description" = "The test plan" "Name" = "TF Account Plan" "OrganizationUsage" = "0" "Quota" = "100" "QuotaInterval" = "DAY" "RateLimit" = "1" "Uuid" = "0a32584d-6abc-4cdc-a827-b552683b5999" "__metadata" = "map[uri:https://apim-ssg.test.foo.com:9443/developersdev/AccountPlans('0a32584d-6abc-4cdc-a827-b552683b5999')]" } api_response = jsonencode( { ApiIds = { results = [] } DefaultPlan = false Description = "The test plan" Name = "TF Account Plan" OrganizationUsage = "0" Quota = 100 QuotaInterval = "DAY" RateLimit = 1 Uuid = "0a32584d-6abc-4cdc-a827-b552683b5999" __metadata = { uri = "https://apim-ssg.apimdev.test.com:9443/developersdev/AccountPlans('0a32584d-6abc-4cdc-a827-b552683b5999')" } } )

created time in 17 days

issue closedMastercard/terraform-provider-restapi

Support single quotes in path

Hello,

I have an unconventional endpoint path, from a commercial 3rd party API, that requires the use of single quotes when addressing an object by id.

Example - destroy_path = "/Organizations('{id}')"

The full URL ends up being - .../Organizations(99999999-9999-9999-9999-999999999999)

This provider seems to strip off single quotes when it constructs the full URL. Is there a way to preserve the single quote?

Thanks,

Alejandro

closed time in 18 days

acalbazana

issue commentMastercard/terraform-provider-restapi

Support single quotes in path

please disregard. issue was on my end. thanks!

acalbazana

comment created time in 18 days

issue openedMastercard/terraform-provider-restapi

Support single quotes in path

Hello,

I have an unconventional endpoint path, from a commercial 3rd party API, that requires the use of single quotes when addressing an object by id.

Example - destroy_path = "/Organizations('{id}')"

The full URL ends up being - .../Organizations(99999999-9999-9999-9999-999999999999)

This provider seems to strip off single quotes when it constructs the full URL. Is there a way to preserve the single quote?

Thanks,

Alejandro

created time in 18 days

issue commentMastercard/terraform-provider-restapi

Planned support for refreshing state against the remote state?

@DRuggeri we could just use a string input where the user can copy the json layout they want to have in the state (just let them remove the things they don't want) create a dynamic struct https://github.com/Ompluscator/dynamic-struct by iterating over the json object and save this to the state, on plan compare by hash

davidronk

comment created time in 19 days

PR closed Mastercard/terraform-provider-restapi

Oauth support

added some documentation, preferred changes

+156 -0

0 comment

7 changed files

SvenHamers

pr closed time in 19 days

PR opened Mastercard/terraform-provider-restapi

Oauth support

added some documentation, preferred changes

+156 -0

0 comment

7 changed files

pr created time in 19 days

Pull request review commentMastercard/terraform-provider-restapi

Add http client oauth authentication

+provider "restapi" {

@DRuggeri Maybe we need some automatic doc generator ? as we are using this provider quite a lot at the moment i am happy to contribute. For now i will update the docs manual

SvenHamers

comment created time in 19 days

Pull request review commentMastercard/terraform-provider-restapi

Add http client oauth authentication

 func NewAPIClient(opt *apiClientOpt) (*api_client, error) { 		debug:                 opt.debug, 	} +	if opt.use_oauth_client_credentials {

👍

SvenHamers

comment created time in 19 days

Pull request review commentMastercard/terraform-provider-restapi

Add http client oauth authentication

 func configureProvider(d *schema.ResourceData) (interface{}, error) { 	if v, ok := d.GetOk("destroy_method"); ok { 		opt.destroy_method = v.(string) 	}+	if _, ok := d.GetOk("oauth_client_credentials"); ok {+		opt.use_oauth_client_credentials = true+	}+	if v, ok := d.GetOk("oauth_client_credentials"); ok {+		opt.use_oauth_client_credentials = true

👍

SvenHamers

comment created time in 19 days

Pull request review commentMastercard/terraform-provider-restapi

Add http client oauth authentication

 func configureProvider(d *schema.ResourceData) (interface{}, error) { 	if v, ok := d.GetOk("destroy_method"); ok { 		opt.destroy_method = v.(string) 	}+	if _, ok := d.GetOk("oauth_client_credentials"); ok {

whoops yes something went wrong there :)

SvenHamers

comment created time in 19 days

issue commentMastercard/terraform-provider-restapi

Getting 401 even though credentials are provided

Hey, yeah I copy pasted the header from this working curl so not sure why it's not working:

curl --location --request POST 'http://xxx.elastic.com/_template/template_xxx' \
--header 'Authorization: Basic xxx' \
--header 'Content-Type: application/json' \
nadworny

comment created time in 19 days

more