Skip to content

Commit

Permalink
review changes
Browse files Browse the repository at this point in the history
Signed-off-by: rajeshal <rajeshal@yahooinc.com>
  • Loading branch information
rajeshal committed Jul 29, 2024
1 parent 39e1c18 commit b2c985c
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 81 deletions.
6 changes: 3 additions & 3 deletions clients/go/msd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ func (client MSDClient) GetWorkloadsByDomainAndService(request *BulkWorkloadRequ
}
}

func (client MSDClient) PostCompositeInstance(domainName DomainName, serviceName EntityName, instance *CompositeInstance) error {
func (client MSDClient) PutCompositeInstance(domainName DomainName, serviceName EntityName, instance *CompositeInstance) error {
url := client.URL + "/domain/" + fmt.Sprint(domainName) + "/service/" + fmt.Sprint(serviceName) + "/workload/discover/instance"
contentBytes, err := json.Marshal(instance)
if err != nil {
Expand Down Expand Up @@ -882,8 +882,8 @@ func (client MSDClient) PostCompositeInstance(domainName DomainName, serviceName
}
}

func (client MSDClient) DeleteCompositeInstance(domainName DomainName, serviceName EntityName, instance *CompositeInstance) error {
url := client.URL + "/domain/" + fmt.Sprint(domainName) + "/service/" + fmt.Sprint(serviceName) + "/workload/discover/instance"
func (client MSDClient) DeleteCompositeInstance(domainName DomainName, serviceName EntityName, instance SimpleName) error {
url := client.URL + "/domain/" + fmt.Sprint(domainName) + "/service/" + fmt.Sprint(serviceName) + "/workload/discover/instance/$" + fmt.Sprint(instance)
resp, err := client.httpDelete(url, nil)
if err != nil {
return err
Expand Down
12 changes: 5 additions & 7 deletions clients/go/msd/model.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 19 additions & 19 deletions clients/go/msd/msd_schema.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ public BulkWorkloadResponse getWorkloadsByDomainAndService(BulkWorkloadRequest r
}
}

public Workloads postCompositeInstance(String domainName, String serviceName, CompositeInstance instance) throws URISyntaxException, IOException {
public Workloads putCompositeInstance(String domainName, String serviceName, CompositeInstance instance) throws URISyntaxException, IOException {
UriTemplateBuilder uriTemplateBuilder = new UriTemplateBuilder(baseUrl, "/domain/{domainName}/service/{serviceName}/workload/discover/instance")
.resolveTemplate("domainName", domainName)
.resolveTemplate("serviceName", serviceName);
Expand Down Expand Up @@ -703,10 +703,11 @@ public Workloads postCompositeInstance(String domainName, String serviceName, Co
}
}

public Workloads deleteCompositeInstance(String domainName, String serviceName, CompositeInstance instance) throws URISyntaxException, IOException {
UriTemplateBuilder uriTemplateBuilder = new UriTemplateBuilder(baseUrl, "/domain/{domainName}/service/{serviceName}/workload/discover/instance")
public Workloads deleteCompositeInstance(String domainName, String serviceName, String instance) throws URISyntaxException, IOException {
UriTemplateBuilder uriTemplateBuilder = new UriTemplateBuilder(baseUrl, "/domain/{domainName}/service/{serviceName}/workload/discover/instance/${instance}")
.resolveTemplate("domainName", domainName)
.resolveTemplate("serviceName", serviceName);
.resolveTemplate("serviceName", serviceName)
.resolveTemplate("instance", instance);
URIBuilder uriBuilder = new URIBuilder(uriTemplateBuilder.getUri());
HttpUriRequest httpUriRequest = RequestBuilder.delete()
.setUri(uriBuilder.build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class CompositeInstance {
public String domainName;
public String serviceName;
public String instance;
@RdlOptional
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public String instanceType;
@RdlOptional
@JsonInclude(JsonInclude.Include.NON_EMPTY)
Expand Down
10 changes: 5 additions & 5 deletions core/msd/src/main/java/com/yahoo/athenz/msd/MSDSchema.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ private static Schema build() {
.comment("generic instance")
.field("domainName", "DomainName", false, "name of the domain")
.field("serviceName", "EntityName", false, "name of the service")
.field("instance", "EntityName", false, "instance name/id")
.field("instanceType", "String", false, "instance type")
.field("instance", "SimpleName", false, "instance name/id")
.field("instanceType", "String", true, "instance type")
.field("provider", "String", true, "name of the instance provider, for example aws/gcp")
.field("certExpiryTime", "Timestamp", true, "certificate expiry time (ex: getNotAfter), if applicable")
.field("certIssueTime", "Timestamp", true, "certificate issue time (ex: getNotBefore), if applicable");
Expand Down Expand Up @@ -881,7 +881,7 @@ private static Schema build() {

sb.resource("CompositeInstance", "PUT", "/domain/{domainName}/service/{serviceName}/workload/discover/instance")
.comment("Api to discover an additional instance which can have static or dynamic or both IPs")
.name("postCompositeInstance")
.name("putCompositeInstance")
.pathParam("domainName", "DomainName", "name of the domain")
.pathParam("serviceName", "EntityName", "name of the service")
.input("instance", "CompositeInstance", "Generic instance")
Expand All @@ -898,12 +898,12 @@ private static Schema build() {
.exception("UNAUTHORIZED", "ResourceError", "")
;

sb.resource("Workloads", "DELETE", "/domain/{domainName}/service/{serviceName}/workload/discover/instance")
sb.resource("Workloads", "DELETE", "/domain/{domainName}/service/{serviceName}/workload/discover/instance/${instance}")
.comment("Api to delete an additional instance which can have static or dynamic or both IPs")
.name("deleteCompositeInstance")
.pathParam("domainName", "DomainName", "name of the domain")
.pathParam("serviceName", "EntityName", "name of the service")
.input("instance", "CompositeInstance", "Generic instance")
.pathParam("instance", "SimpleName", "instance name/id/key")
.auth("update", "{domainName}:service.{serviceName}")
.expected("NO_CONTENT")
.exception("BAD_REQUEST", "ResourceError", "")
Expand Down
6 changes: 3 additions & 3 deletions core/msd/src/main/rdl/Workload.rdli
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ resource BulkWorkloadResponse POST "/workloads" (name=getWorkloadsByDomainAndSer
}

// Api to discover an additional instance which can have static or dynamic or both IPs
resource Workloads PUT "/domain/{domainName}/service/{serviceName}/workload/discover/instance" (name=postCompositeInstance) {
resource Workloads PUT "/domain/{domainName}/service/{serviceName}/workload/discover/instance" (name=putCompositeInstance) {
DomainName domainName; // name of the domain
EntityName serviceName; // name of the service
CompositeInstance instance; // Generic instance
Expand All @@ -164,10 +164,10 @@ resource Workloads PUT "/domain/{domainName}/service/{serviceName}/workload/disc
}

// Api to delete an additional instance which can have static or dynamic or both IPs
resource Workloads DELETE "/domain/{domainName}/service/{serviceName}/workload/discover/instance" (name=deleteCompositeInstance) {
resource Workloads DELETE "/domain/{domainName}/service/{serviceName}/workload/discover/instance/${instance}" (name=deleteCompositeInstance) {
DomainName domainName; // name of the domain
EntityName serviceName; // name of the service
CompositeInstance instance; // Generic instance
SimpleName instance; // instance name/id/key
authorize ("update", "{domainName}:service.{serviceName}");
expected NO_CONTENT;
exceptions {
Expand Down
4 changes: 2 additions & 2 deletions core/msd/src/main/rdl/Workload.tdl
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ type BulkWorkloadResponse Struct {
type CompositeInstance Struct {
DomainName domainName; // name of the domain
EntityName serviceName; // name of the service
EntityName instance; // instance name/id
String instanceType; // instance type
SimpleName instance; // instance name/id
String instanceType (optional); // instance type
String provider (optional); // name of the instance provider, for example aws/gcp
Timestamp certExpiryTime (optional); // certificate expiry time (ex: getNotAfter), if applicable
Timestamp certIssueTime (optional); // certificate issue time (ex: getNotBefore), if applicable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,43 +114,5 @@ public void testCompositeInstanceFields() {
assertNotEquals(instance, "mystring");

assertEquals(instance, instance);

}
//
// @Test (dataProvider = "staticWorkloadNameProvider")
// public void testStaticWorkloadName(String name, boolean expected) {
//
// Schema schema = MSDSchema.instance();
// Validator validator = new Validator(schema);
//
// StaticWorkload wl1 = new StaticWorkload();
// wl1.setDomainName("athenz")
// .setServiceName("api")
// .setName(name)
// .setType(StaticWorkloadType.CLOUD_LB);
//
// Validator.Result result = validator.validate(wl1, "StaticWorkload");
// assertEquals(result.valid, expected);
// }
//
// @DataProvider
// private Object[][] staticWorkloadNameProvider() {
// return new Object[][] {
// {"10.10.20.30", true},
// {"10.10.20.30/24", true},
// {"172.30.255.255", true},
// {"2001:db8:abcd:12::ffff", true},
// {"2001:db8:abcd:12::ffff/24", true},
// {"2001:db8:abcd:12::ffff/128", true},
// {"myhostname", true},
// {"ABC::AA012_113_3332_11344", true},
// {"myhostname.subdomain.domain.com", true},
// {"avc/dd", false},
// {"avc/12/11", false},
// {"*ddw$%#", false},
// {"/", false},
// {"/etc/passwd", false},
// };
// }

}

0 comments on commit b2c985c

Please sign in to comment.