X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=policy-agent%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fpolicyagent%2Fclients%2FA1ClientImpl.java;h=f621566e70aeebbf9aad0bcb51ffc553b26a060e;hb=a76d95e9292f99dfb5cd5782ef6d7bb2ec293fd7;hp=7bbb4990ce3135672dd0be5a9fdd94bc210731b5;hpb=35e7ea7bb7a6e2890542f3535aa09b11b2f079a1;p=nonrtric.git diff --git a/policy-agent/src/main/java/org/oransc/policyagent/clients/A1ClientImpl.java b/policy-agent/src/main/java/org/oransc/policyagent/clients/A1ClientImpl.java index 7bbb4990..f621566e 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/clients/A1ClientImpl.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/clients/A1ClientImpl.java @@ -40,10 +40,14 @@ public class A1ClientImpl implements A1Client { return nearRtRicUrl + "/A1-P/v1"; } + public AsyncRestClient createClient(final String nearRtRicUrl) { + return new AsyncRestClient(getBaseUrl(nearRtRicUrl)); + } + @Override public Flux getPolicyTypeIdentities(String nearRtRicUrl) { logger.debug("getPolicyTypeIdentities nearRtRicUrl = {}", nearRtRicUrl); - AsyncRestClient client = new AsyncRestClient(getBaseUrl(nearRtRicUrl)); + AsyncRestClient client = createClient(nearRtRicUrl); Mono response = client.get("/policytypes/identities"); return response.flatMapMany(this::createFlux); } @@ -51,7 +55,7 @@ public class A1ClientImpl implements A1Client { @Override public Flux getPolicyIdentities(String nearRtRicUrl) { logger.debug("getPolicyIdentities nearRtRicUrl = {}", nearRtRicUrl); - AsyncRestClient client = new AsyncRestClient(getBaseUrl(nearRtRicUrl)); + AsyncRestClient client = createClient(nearRtRicUrl); Mono response = client.get("/policies/identities"); return response.flatMapMany(this::createFlux); } @@ -59,7 +63,7 @@ public class A1ClientImpl implements A1Client { @Override public Mono getPolicyType(String nearRtRicUrl, String policyTypeId) { logger.debug("getPolicyType nearRtRicUrl = {}, policyTypeId = {}", nearRtRicUrl, policyTypeId); - AsyncRestClient client = new AsyncRestClient(getBaseUrl(nearRtRicUrl)); + AsyncRestClient client = createClient(nearRtRicUrl); Mono response = client.get("/policytypes/" + policyTypeId); return response.flatMap(this::createMono); } @@ -68,15 +72,15 @@ public class A1ClientImpl implements A1Client { public Mono putPolicy(String nearRtRicUrl, String policyId, String policyString) { logger.debug("putPolicy nearRtRicUrl = {}, policyId = {}, policyString = {}", nearRtRicUrl, policyId, policyString); - AsyncRestClient client = new AsyncRestClient(getBaseUrl(nearRtRicUrl)); + AsyncRestClient client = createClient(nearRtRicUrl); Mono response = client.put("/policies/" + policyId, policyString); return response.flatMap(this::createMono); } @Override - public Mono deletePolicy(String nearRtRicUrl, String policyId) { + public Mono deletePolicy(String nearRtRicUrl, String policyId) { logger.debug("deletePolicy nearRtRicUrl = {}, policyId = {}", nearRtRicUrl, policyId); - AsyncRestClient client = new AsyncRestClient(getBaseUrl(nearRtRicUrl)); + AsyncRestClient client = createClient(nearRtRicUrl); return client.delete("/policies/" + policyId); }