Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/main/java/com/auth0/client/mgmt/ManagementAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,14 @@ public SelfServiceProfilesEntity selfServiceProfiles() {
return new SelfServiceProfilesEntity(client, baseUrl, tokenProvider);
}

/**
* Getter for the Network Acls Entity
* @return the Network Acls Entity
*/
public NetworkAclsEntity networkAcls() {
return new NetworkAclsEntity(client, baseUrl, tokenProvider);
}

/**
* Builder for {@link ManagementAPI} API client instances.
*/
Expand Down
152 changes: 152 additions & 0 deletions src/main/java/com/auth0/client/mgmt/NetworkAclsEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
package com.auth0.client.mgmt;

import com.auth0.client.mgmt.filter.NetworkAclsFilter;
import com.auth0.json.mgmt.networkacls.NetworkAcls;
import com.auth0.json.mgmt.networkacls.NetworkAclsPage;
import com.auth0.net.BaseRequest;
import com.auth0.net.Request;
import com.auth0.net.VoidRequest;
import com.auth0.net.client.Auth0HttpClient;
import com.auth0.net.client.HttpMethod;
import com.auth0.utils.Asserts;
import com.fasterxml.jackson.core.type.TypeReference;
import okhttp3.HttpUrl;

import java.util.Map;

public class NetworkAclsEntity extends BaseManagementEntity {

private final static String ORGS_PATH = "api/v2/network-acls";

NetworkAclsEntity(Auth0HttpClient client, HttpUrl baseUrl, TokenProvider tokenProvider) {
super(client, baseUrl, tokenProvider);
}

/**
* Lists all Network ACLs for the Auth0 tenant.
* This method allows you to filter the results using the provided {@link NetworkAclsFilter}.
* A token with scope read:network_acls is needed.
*
* @see <a href="https://auth0.com/docs/api/management/v2#!/network-acls/get-network-acls">https://auth0.com/docs/api/management/v2#!/network-acls/get-network-acls</a>
* @param filter the filter to apply to the request, can be null.
* @return a Request that can be executed to retrieve a page of Network ACLs.
*/
public Request<NetworkAclsPage> list(NetworkAclsFilter filter) {
HttpUrl.Builder builder = baseUrl.newBuilder()
.addPathSegments(ORGS_PATH);

if (filter != null) {
for (Map.Entry<String, Object> e : filter.getAsMap().entrySet()) {
builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue()));
}
}

String url = builder.build().toString();
return new BaseRequest<>(client, tokenProvider, url, HttpMethod.GET, new TypeReference<NetworkAclsPage>(){
});
}

/**
* Creates a new Network ACL for the Auth0 tenant.
* A token with scope create:network_acls is needed.
*
* @see <a href="https://auth0.com/docs/api/management/v2#!/network-acls/post-network-acls">https://auth0.com/docs/api/management/v2#!/network-acls/post-network-acls</a>
* @param networkAcls the Network ACL to create.
* @return a Request that can be executed to create the Network ACL.
*/
public Request<NetworkAcls> create(NetworkAcls networkAcls) {
Asserts.assertNotNull(networkAcls, "network acls");
String url = baseUrl.newBuilder()
.addPathSegments(ORGS_PATH)
.build().toString();
BaseRequest<NetworkAcls> request = new BaseRequest<>(client, tokenProvider, url, HttpMethod.POST, new TypeReference<NetworkAcls>(){});
request.setBody(networkAcls);
return request;
}

/**
* Get a Network ACL by its ID.
* A token with scope read:network_acls is needed.
*
* @see <a href="https://auth0.com/docs/api/management/v2#!/network-acls/get-network-acls-by-id">https://auth0.com/docs/api/management/v2#!/network-acls/get-network-acls-by-id</a>
* @param id the ID of the Network ACL to delete.
* @return a Request that can be executed to delete the Network ACL.
*/
public Request<NetworkAcls> get(String id) {
Asserts.assertNotNull(id, "id");

String url = baseUrl.newBuilder()
.addPathSegments(ORGS_PATH)
.addPathSegment(id)
.build().toString();

return new BaseRequest<>(client, tokenProvider, url, HttpMethod.GET, new TypeReference<NetworkAcls>(){});
}

/**
* Deletes a Network ACL by its ID.
* A token with scope delete:network_acls is needed.
*
* @see <a href="https://auth0.com/docs/api/management/v2#!/network-acls/delete-network-acls-by-id">https://auth0.com/docs/api/management/v2#!/network-acls/delete-network-acls-by-id</a>
* @param id the ID of the Network ACL to delete.
* @return a Request that can be executed to delete the Network ACL.
*/
public Request<Void> delete(String id) {
Asserts.assertNotNull(id, "id");

String url = baseUrl.newBuilder()
.addPathSegments(ORGS_PATH)
.addPathSegment(id)
.build().toString();

return new VoidRequest(client, tokenProvider, url, HttpMethod.DELETE);
}

/**
* Updates a Network ACL by its ID.
* A token with scope update:network_acls is needed.
*
* @see <a href="https://auth0.com/docs/api/management/v2#!/network-acls/put-network-acls-by-id">https://auth0.com/docs/api/management/v2#!/network-acls/put-network-acls-by-id</a>
* @param id the ID of the Network ACL to update.
* @param networkAcls the Network ACL to update.
* @return a Request that can be executed to update the Network ACL.
*/
public Request<NetworkAcls> update(String id, NetworkAcls networkAcls) {
Asserts.assertNotNull(id, "id");
Asserts.assertNotNull(networkAcls, "network acls");

String url = baseUrl.newBuilder()
.addPathSegments(ORGS_PATH)
.addPathSegment(id)
.build().toString();

BaseRequest<NetworkAcls> request = new BaseRequest<>(client, tokenProvider, url, HttpMethod.PUT, new TypeReference<NetworkAcls>() {
});
request.setBody(networkAcls);
return request;
}

/**
* Partially updates a Network ACL by its ID.
* A token with scope update:network_acls is needed.
*
* @see <a href="https://auth0.com/docs/api/management/v2#!/network-acls/patch-network-acls-by-id">https://auth0.com/docs/api/management/v2#!/network-acls/patch-network-acls-by-id</a>
* @param id the ID of the Network ACL to update.
* @param networkAcls the Network ACL to update.
* @return a Request that can be executed to partially update the Network ACL.
*/
public Request<NetworkAcls> patch(String id, NetworkAcls networkAcls) {
Asserts.assertNotNull(id, "id");

String url = baseUrl.newBuilder()
.addPathSegments(ORGS_PATH)
.addPathSegment(id)
.build().toString();

BaseRequest<NetworkAcls> request = new BaseRequest<>(client, tokenProvider, url, HttpMethod.PATCH, new TypeReference<NetworkAcls>() {
});
request.setBody(networkAcls);
return request;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.auth0.client.mgmt.filter;

public class NetworkAclsFilter extends BaseFilter {

/**
* Filter by page
*
* @param pageNumber the page number to retrieve.
* @param amountPerPage the amount of items per page to retrieve.
* @return this filter instance
*/
public NetworkAclsFilter withPage(int pageNumber, int amountPerPage) {
parameters.put("page", pageNumber);
parameters.put("per_page", amountPerPage);
return this;
}

/**
* Include the query summary
*
* @param includeTotals whether to include or not the query summary.
* @return this filter instance
*/
public NetworkAclsFilter withTotals(boolean includeTotals) {
parameters.put("include_totals", includeTotals);
return this;
}
}
108 changes: 108 additions & 0 deletions src/main/java/com/auth0/json/mgmt/networkacls/Action.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package com.auth0.json.mgmt.networkacls;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Action {
@JsonProperty("block")
private Boolean block;
@JsonProperty("allow")
private Boolean allow;
@JsonProperty("log")
private Boolean log;
@JsonProperty("redirect")
private Boolean redirect;
@JsonProperty("redirect_uri")
private String redirectUri;

/**
* Getter for the block action.
* @return true if the action is to block.
*/
@JsonProperty("block")
public Boolean isBlock() {
return block;
}

/**
* Setter for the block action.
* @param block true to set the action as block, false otherwise.
*/
@JsonProperty("block")
public void setBlock(Boolean block) {
this.block = block;
}

/**
* Getter for the allow action.
* @return true if the action is to allow.
*/
@JsonProperty("allow")
public Boolean isAllow() {
return allow;
}

/**
* Setter for the allow action.
* @param allow true to set the action as allow, false otherwise.
*/
@JsonProperty("allow")
public void setAllow(Boolean allow) {
this.allow = allow;
}

/**
* Getter for the log action.
* @return true if the action is to log.
*/
@JsonProperty("log")
public Boolean isLog() {
return log;
}

/**
* Setter for the log action.
* @param log true to set the action as log, false otherwise.
*/
@JsonProperty("log")
public void setLog(Boolean log) {
this.log = log;
}

/**
* Getter for the redirect action.
* @return true if the action is to redirect.
*/
@JsonProperty("redirect")
public Boolean isRedirect() {
return redirect;
}

/**
* Setter for the redirect action.
* @param redirect true to set the action as redirect, false otherwise.
*/
@JsonProperty("redirect")
public void setRedirect(Boolean redirect) {
this.redirect = redirect;
}

/**
* Getter for the redirect URI.
* @return the redirect URI if set, null otherwise.
*/
public String getRedrectUri() {
return redirectUri;
}

/**
* Setter for the redirect URI.
* @param redrectUri the URI to set for redirection.
*/
public void setRedrectUri(String redrectUri) {
this.redirectUri = redrectUri;
}
}
Loading