Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

Add organization ID to client connection using header. #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

medains
Copy link

@medains medains commented Aug 5, 2020

This seems like the right place to do so - the resource API calls that
require an organization ID that are not-quite RESTful also would need
authentication with a user that is an administrator for the
organization. So putting it in at this level works out, and also avoids
adding orgID parameters all over the place.

Co-authored-by: hansnqyr [email protected]

This is a prelude to a PR on terraform-grafana-provider to fix this issue. It is similar to previous work under this PR: https://github.com/terraform-providers/terraform-provider-grafana/pull/60 - though the change in that PR is not what will result (it's far simpler).

This seems like the right place to do so - the resource API calls that
require an organization ID that are not-quite RESTful also would need
authentication with a user that is an administrator for the
organization.  So putting it in at this level works out, and also avoids
adding orgID parameters all over the place.

Co-authored-by: hansnqyr <[email protected]>
medains added a commit to medains/terraform-provider-grafana that referenced this pull request Aug 5, 2020
Use the change in nytm/go-grafana-api#62 to
apply an organization id to the provider.

Usage might look like this:

```hcl
provider "grafana" {
  url = "someurl"
  auth = "adminuser:somepass"
}

resource "grafana_organization" "neworg" {
  name = "neworg"
  admin = "neworgadmin"
}

provider "grafana" {
  alias = "neworg"
  url = "someurl"
  auth = "neworgadmin:somepass"
  org_id = grafana_organization.neworg.org_id
}

resource "grafana_data_source" "neworg_graphite" {
  provider = grafana.neworg
  type = "graphite"
  name = "neworg-graphite"
}
```
medains added a commit to medains/terraform-provider-grafana that referenced this pull request Aug 5, 2020
Use the change in nytm/go-grafana-api#62 to
apply an organization id to the provider.

Usage might look like this:

```hcl
provider "grafana" {
  url = "someurl"
  auth = "adminuser:somepass"
}

resource "grafana_organization" "neworg" {
  name = "neworg"
  admin = "neworgadmin"
}

provider "grafana" {
  alias = "neworg"
  url = "someurl"
  auth = "neworgadmin:somepass"
  org_id = grafana_organization.neworg.org_id
}

resource "grafana_data_source" "neworg_graphite" {
  provider = grafana.neworg
  type = "graphite"
  name = "neworg-graphite"
}
```

Co-authored-by: hansnqyr <[email protected]>
@medains
Copy link
Author

medains commented Oct 7, 2020

@tonglil @mlclmj : Can this get a review please?

medains added a commit to medains/terraform-provider-grafana that referenced this pull request Oct 16, 2020
Use the change in nytm/go-grafana-api#62 to
apply an organization id to the provider.

Usage might look like this:

```hcl
provider "grafana" {
  url = "someurl"
  auth = "adminuser:somepass"
}

resource "grafana_organization" "neworg" {
  name = "neworg"
  admin = "neworgadmin"
}

provider "grafana" {
  alias = "neworg"
  url = "someurl"
  auth = "neworgadmin:somepass"
  org_id = grafana_organization.neworg.org_id
}

resource "grafana_data_source" "neworg_graphite" {
  provider = grafana.neworg
  type = "graphite"
  name = "neworg-graphite"
}
```

Co-authored-by: hansnqyr <[email protected]>
@medains
Copy link
Author

medains commented Oct 16, 2020

Moved PR to grafana/grafana-api-golang-client#9

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant