Repository: google/go-github (go)

Issue:
Add support for deleting an organization.
A new REST endpoint was added to delete an organization at `/orgs/{org}'`. The documentation doesn't seem to have gone live quite yet but I'll update the issue as soon as I see it. In the meantime the endpoint can be evoked like:

`curl -X DELETE https://api.github.com/orgs/:org`

Now with [documentation](https://docs.github.com/en/rest/orgs/orgs?apiVersion=2022-11-28#delete-an-organization)!



Pull request description:
Add support for deleting an org
Fixes: #2726.

Patch:
diff --git a/github/orgs.go b/github/orgs.go
index 48740577..837dda89 100644
--- a/github/orgs.go
+++ b/github/orgs.go
@@ -262,6 +262,19 @@ func (s *OrganizationsService) Edit(ctx context.Context, name string, org *Organ
 	return o, resp, nil
 }
 
+// Delete an organization by name.
+//
+// GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#delete-an-organization
+func (s *OrganizationsService) Delete(ctx context.Context, org string) (*Response, error) {
+	u := fmt.Sprintf("orgs/%v", org)
+	req, err := s.client.NewRequest("DELETE", u, nil)
+	if err != nil {
+		return nil, err
+	}
+
+	return s.client.Do(ctx, req, nil)
+}
+
 // ListInstallations lists installations for an organization.
 //
 // GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#list-app-installations-for-an-organization
diff --git a/github/users_emails.go b/github/users_emails.go
index be7e0f81..67bd210e 100644
--- a/github/users_emails.go
+++ b/github/users_emails.go
@@ -70,3 +70,28 @@ func (s *UsersService) DeleteEmails(ctx context.Context, emails []string) (*Resp
 
 	return s.client.Do(ctx, req, nil)
 }
+
+// SetEmailVisibility sets the visibility for the primary email address of the authenticated user.
+// `visibility` can be "private" or "public".
+//
+// GitHub API docs: https://docs.github.com/en/rest/users/emails#set-primary-email-visibility-for-the-authenticated-user
+func (s *UsersService) SetEmailVisibility(ctx context.Context, visibility string) ([]*UserEmail, *Response, error) {
+	u := "user/email/visibility"
+
+	updateVisiblilityReq := &UserEmail{
+		Visibility: &visibility,
+	}
+
+	req, err := s.client.NewRequest("PATCH", u, updateVisiblilityReq)
+	if err != nil {
+		return nil, nil, err
+	}
+
+	var e []*UserEmail
+	resp, err := s.client.Do(ctx, req, &e)
+	if err != nil {
+		return nil, resp, err
+	}
+
+	return e, resp, nil
+}


Test patch:
diff --git a/github/orgs_test.go b/github/orgs_test.go
index b30c48f1..1205ad00 100644
--- a/github/orgs_test.go
+++ b/github/orgs_test.go
@@ -315,6 +315,31 @@ func TestOrganizationsService_Edit_invalidOrg(t *testing.T) {
 	testURLParseError(t, err)
 }
 
+func TestOrganizationsService_Delete(t *testing.T) {
+	client, mux, _, teardown := setup()
+	defer teardown()
+
+	mux.HandleFunc("/orgs/o", func(w http.ResponseWriter, r *http.Request) {
+		testMethod(t, r, "DELETE")
+	})
+
+	ctx := context.Background()
+	_, err := client.Organizations.Delete(ctx, "o")
+	if err != nil {
+		t.Errorf("Organizations.Delete returned error: %v", err)
+	}
+
+	const methodName = "Delete"
+	testBadOptions(t, methodName, func() (err error) {
+		_, err = client.Organizations.Delete(ctx, "\n")
+		return err
+	})
+
+	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+		return client.Organizations.Delete(ctx, "o")
+	})
+}
+
 func TestOrganizationsService_ListInstallations(t *testing.T) {
 	client, mux, _, teardown := setup()
 	defer teardown()
diff --git a/github/users_emails_test.go b/github/users_emails_test.go
index d40356d8..ad9d32e9 100644
--- a/github/users_emails_test.go
+++ b/github/users_emails_test.go
@@ -140,3 +140,47 @@ func TestUserEmail_Marshal(t *testing.T) {
 
 	testJSONMarshal(t, u, want)
 }
+
+func TestUsersService_SetEmailVisibility(t *testing.T) {
+	client, mux, _, teardown := setup()
+	defer teardown()
+
+	input := &UserEmail{Visibility: String("private")}
+
+	mux.HandleFunc("/user/email/visibility", func(w http.ResponseWriter, r *http.Request) {
+		v := new(UserEmail)
+		json.NewDecoder(r.Body).Decode(&v)
+
+		testMethod(t, r, "PATCH")
+		if !cmp.Equal(v, input) {
+			t.Errorf("Request body = %+v, want %+v", v, input)
+		}
+
+		fmt.Fprint(w, `[{
+			"email": "user@example.com",
+			"verified": false,
+			"primary": true,
+			"visibility": "private"
+		}]`)
+	})
+
+	ctx := context.Background()
+	emails, _, err := client.Users.SetEmailVisibility(ctx, "private")
+	if err != nil {
+		t.Errorf("Users.SetEmailVisibility returned error: %v", err)
+	}
+
+	want := []*UserEmail{{Email: String("user@example.com"), Verified: Bool(false), Primary: Bool(true), Visibility: String("private")}}
+	if !cmp.Equal(emails, want) {
+		t.Errorf("Users.SetEmailVisibility returned %+v, want %+v", emails, want)
+	}
+
+	const methodName = "SetEmailVisibility"
+	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
+		got, resp, err := client.Users.SetEmailVisibility(ctx, "private")
+		if got != nil {
+			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
+		}
+		return resp, err
+	})
+}