public void RemoveValuesFromResource(string token, string id, string attributeName, string[] valuesToRemove) { if (string.IsNullOrEmpty(id)) { throw new ArgumentException("id must be specified"); } if (string.IsNullOrEmpty(attributeName)) { throw new ArgumentException("id must be specified"); } if (valuesToRemove == null || valuesToRemove.Length == 0) { throw new ArgumentException("values must be specified"); } ResourceManagementClient client = Utiles.GetClient(repoCache, token); ResourceObject ro = client.GetResource(id, new string[] { attributeName }); foreach (string value in valuesToRemove) { ro.RemoveValue(attributeName, value); } try { ro.Save(); } catch (AuthorizationRequiredException e) { throw new AuthZRequiredException(e.Message); } }
public string RemoveValuesFromResource(string id, string attributeName, string[] valuesToRemove, ResourceOption resourceOption = null) { if (valuesToRemove == null || valuesToRemove.Length == 0) { return(id); } ResourceOption option = resourceOption == null ? new ResourceOption() : resourceOption; ResourceManagementClient client = getClient(option.ConnectionInfo); client.RefreshSchema(); ResourceObject objResource = client.GetResource(id, new string[] { attributeName }); if (objResource == null) { throw new Exception($"No Resource was found with ObjectID: {id}"); } foreach (string value in valuesToRemove) { objResource.RemoveValue(attributeName, value); } try { objResource.Save(); } catch (AuthorizationRequiredException) { return("AuthorizationRequired"); } return(objResource.ObjectID.Value); }