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

Create an ObjectID type for dealing with partition and object name #19

Open
gilliek opened this issue Dec 26, 2019 · 0 comments
Open

Create an ObjectID type for dealing with partition and object name #19

gilliek opened this issue Dec 26, 2019 · 0 comments
Labels
Milestone

Comments

@gilliek
Copy link
Member

gilliek commented Dec 26, 2019

A lot of method are using an id, which references an object on the BIG-IP (e.g. /Common/foobar). Such id is composed of a partition name and the actual object name. iControl REST are using ~Common~foobar to create such a reference and just using a plain string is not necessarily the best.

A structure like ObjectID would make things a lot easier:

type ObjectID string

func NewObjectID(partition, name string) ObjectID {
	if partition == "" {
		partition = "Common"
	}
	return ObjectID("~" + partition + "~" + name)
}

func ParseObjectID(fullname string) ObjectID {
	return ObjectID(strings.Replace(fullname, "/", "~", -1))
}

func (oid ObjectID) Partition() string {
	idx := strings.LastIndex(string(oid), "~")
	if idx == -1 {
		return ""
	}
	return string(oid)[1:idx]
}

func (oid ObjectID) Name() string {
	idx := strings.LastIndex(string(oid), "~")
	if idx == -1 {
		return ""
	}
	return string(oid)[idx+1:]
}

func (oid ObjectID) String() string {
	return strings.Replace(string(oid), "~", "/", -1)
}

(note that this is just a prototype, not the final implementation)

This feature should be implemented in the next release (v1.0.0) in order not to break any existing implementation using the f5-rest-client.

@gilliek gilliek added this to the v1.0.0 milestone Dec 26, 2019
@gilliek gilliek added the priority/low Low priority label Apr 28, 2022
@gilliek gilliek modified the milestones: 1.0.0, 2.0.0 Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant