Unable to assign profile to project via API?

I can do incus profile create foo --project bar.

However, I can’t seem to assign a project anywhere on profile creation using the API.

For example, in Go:

	profileReq := api.ProfilesPost{
		Name: opts.Username,
		ProfilePut: api.ProfilePut{
			Description: "...",
			Devices: map[string]map[string]string{
				"root": {
					"type": "disk",
					"pool": "foo",
					"path": "/",
				},
				"eth0": {
					"name":    "eth0",
					"type":    "nic",
					"network": "baz",
				},
			},
		},
	}
	if err := conn.CreateProfile(profileReq); err != nil {
		return conn, err
	}

api.ProfilesPost does not expose a Project: ...?

Got it, I think :sweat_smile:

projectConn := conn.UseProject(projectName)

Yep, we first introduced UseTarget when we added clustering as that provided a convenient way to get a copy of the client that’d target a specific server without having to modify the entire Go API to take an extra argument or expand all the structs to have an extra field.

When we added projects, we repeated that pattern with UseProject which similarly let us roll out the feature without having to break the Go API or extend all the structs.

1 Like