Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EmailList to Access Group objects #1445

Merged
merged 2 commits into from
Dec 6, 2023

Conversation

tv
Copy link
Contributor

@tv tv commented Nov 20, 2023

Description

Add missing Email List to Access Group objects. While the UI already adds and supports these, the official API docs are completely out of date.

Has your change been tested?

Yes. This change has both unit tests and I also tested it with a short app:

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/cloudflare/cloudflare-go"
)

func main() {
	api, err := cloudflare.NewWithAPIToken(
		os.Getenv("CF_API_TOKEN"),
		cloudflare.Debug(true),
	)
	accountID := os.Getenv("CF_ACCOUNT_ID")
	rc := cloudflare.AccountIdentifier(accountID)
	ctx := context.Background()

	newAg := cloudflare.CreateAccessGroupParams{
		Name: "test",
		Include: []interface{}{
			cloudflare.AccessGroupEmailDomain{
				EmailDomain: struct {
					Domain string `json:"domain"`
				}{
					Domain: "example.com",
				},
			},
		},
		Require: []interface{}{
			cloudflare.AccessGroupEmailList{
				EmailList: struct {
					ID string `json:"id"`
				}{
					ID: "110c0d2a-cda2-4d25-8451-3cd70c60b8b3",
				},
			},
		},
	}

	_, err = api.CreateAccessGroup(ctx, rc, newAg)
	if err != nil {
		fmt.Println(err)
		return
	}

	ags, _, err := api.ListAccessGroups(ctx, rc, cloudflare.ListAccessGroupsParams{})
	if err != nil {
		fmt.Println(err)
		return
	}

	for _, ag := range ags {
		fmt.Println(ag.ID, ag.Name, ag.Require)
	}
}

This outputs (a bit redacted) the following which indicates that it marshals the email_list correctly.

POST /client/v4/accounts/xyz/access/groups HTTP/1.1

{"name":"test","include":[{"email_domain":{"domain":"example.com"}}],"exclude":null,"require":[{"email_list":{"id":"110c0d2a-cda2-4d25-8451-3cd70c60b8b3"}}]}
2023/11/20 15:27:55
HTTP/2.0 201 Created

{
  "result": {
    "id": "e1db6929-641f-4996-852a-d9d8a7efa1c1",
    "name": "test",
    "uid": "e1db6929-641f-4996-852a-d9d8a7efa1c1",
    "include": [
      {
        "email_domain": {
          "domain": "example.com"
        }
      }
    ],
    "require": [
      {
        "email_list": {
          "id": "110c0d2a-cda2-4d25-8451-3cd70c60b8b3"
        }
      }
    ],
    "exclude": [],
    "created_at": "2023-11-20T13:27:55Z",
    "updated_at": "2023-11-20T13:27:55Z"
  },
  "success": true,
  "errors": [],
  "messages": []
}
2023/11/20 15:27:55
GET /client/v4/accounts/xyz/access/groups?page=1&per_page=25 HTTP/1.1

2023/11/20 15:27:55
HTTP/2.0 200 OK

{
  "result": [
    {
      "id": "e1db6929-641f-4996-852a-d9d8a7efa1c1",
      "name": "test",
      "uid": "e1db6929-641f-4996-852a-d9d8a7efa1c1",
      "include": [
        {
          "email_domain": {
            "domain": "example.com"
          }
        }
      ],
      "require": [
        {
          "email_list": {
            "id": "110c0d2a-cda2-4d25-8451-3cd70c60b8b3"
          }
        }
      ],
      "exclude": [],
      "created_at": "2023-11-20T13:27:55Z",
      "updated_at": "2023-11-20T13:27:55Z"
    }
  ],
  "success": true,
  "errors": [],
  "messages": []
}
e1db6929-641f-4996-852a-d9d8a7efa1c1 test [map[email_list:map[id:110c0d2a-cda2-4d25-8451-3cd70c60b8b3]]]


Types of changes

What sort of change does your code introduce/modify?

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • This change is using publicly documented in cloudflare/api-schemas
    and relies on stable APIs.

Copy link
Contributor

github-actions bot commented Nov 20, 2023

changelog detected ✅

@jacobbednarz
Copy link
Member

the official API docs are completely out of date.

the docs only seem to be missing the email list (which may not yet be ready for public consumption). what else are you seeing missing?

@jroyal should email list be publicly documented yet?

@tv
Copy link
Contributor Author

tv commented Nov 21, 2023

To me it looks like the following ones are missing:

  • Email List
  • External Evaluation
  • Country
  • Service Token (and any service token)

@jroyal
Copy link
Contributor

jroyal commented Nov 21, 2023

All of the things that @tv has on their list are officially supported. I'll get a PR open once thanksgiving is over to update the API docs.

@jacobbednarz
Copy link
Member

awesome, thanks @jroyal! marking this as pending docs while we get those sorted.

@jroyal
Copy link
Contributor

jroyal commented Dec 5, 2023

@jacobbednarz those docs exist now.

@jacobbednarz jacobbednarz merged commit f62ad72 into cloudflare:master Dec 6, 2023
11 checks passed
@github-actions github-actions bot added this to the v0.84.0 milestone Dec 6, 2023
github-actions bot pushed a commit that referenced this pull request Dec 6, 2023
Copy link
Contributor

This functionality has been released in v0.84.0.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 19, 2023
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.

3 participants