|
24 | 24 | import com.microsoft.windowsazure.services.media.entityoperations.EntityCreateOperation;
|
25 | 25 | import com.microsoft.windowsazure.services.media.entityoperations.EntityDeleteOperation;
|
26 | 26 | import com.microsoft.windowsazure.services.media.entityoperations.EntityGetOperation;
|
| 27 | +import com.microsoft.windowsazure.services.media.entityoperations.EntityOperationBase; |
27 | 28 | import com.microsoft.windowsazure.services.media.entityoperations.EntityOperationSingleResultBase;
|
| 29 | +import com.microsoft.windowsazure.services.media.entityoperations.EntityUpdateOperation; |
28 | 30 | import com.microsoft.windowsazure.services.media.implementation.content.ContentKeyAuthorizationPolicyOptionType;
|
29 | 31 | import com.microsoft.windowsazure.services.media.implementation.content.ContentKeyAuthorizationPolicyRestrictionType;
|
30 | 32 | import com.sun.jersey.api.client.GenericType;
|
@@ -149,4 +151,72 @@ public static DefaultListOperation<ContentKeyAuthorizationPolicyOptionInfo> list
|
149 | 151 | public static EntityDeleteOperation delete(String contentKeyAuthorizationPolicyOptionId) {
|
150 | 152 | return new DefaultDeleteOperation(ENTITY_SET, contentKeyAuthorizationPolicyOptionId);
|
151 | 153 | }
|
| 154 | + |
| 155 | + public static Updater update(String contentKeyAuthorizationPolicyOptionId) { |
| 156 | + return new Updater(contentKeyAuthorizationPolicyOptionId); |
| 157 | + } |
| 158 | + |
| 159 | + public static class Updater extends EntityOperationBase implements EntityUpdateOperation { |
| 160 | + |
| 161 | + private int keyDeliveryType; |
| 162 | + private String keyDeliveryConfiguration; |
| 163 | + private List<ContentKeyAuthorizationPolicyRestrictionType> restrictions; |
| 164 | + |
| 165 | + protected Updater(String contentKeyAuthorizationPolicyOptionId) { |
| 166 | + super(new EntityOperationBase.EntityIdUriBuilder(ENTITY_SET, |
| 167 | + contentKeyAuthorizationPolicyOptionId)); |
| 168 | + |
| 169 | + } |
| 170 | + |
| 171 | + @Override |
| 172 | + public Object getRequestContents() { |
| 173 | + return new ContentKeyAuthorizationPolicyOptionType().setKeyDeliveryType(keyDeliveryType) |
| 174 | + .setKeyDeliveryConfiguration(keyDeliveryConfiguration).setRestrictions(restrictions); |
| 175 | + |
| 176 | + } |
| 177 | + |
| 178 | + /** |
| 179 | + * Set the protocol of the Asset Delivery Policy to be created. |
| 180 | + * |
| 181 | + * @param assetDeliveryProtocol |
| 182 | + * The protocol |
| 183 | + * @return The creator object (for call chaining) |
| 184 | + */ |
| 185 | + public Updater setKeyDeliveryType(int keyDeliveryType) { |
| 186 | + this.keyDeliveryType = keyDeliveryType; |
| 187 | + return this; |
| 188 | + } |
| 189 | + |
| 190 | + /** |
| 191 | + * Set the type of the Asset Delivery Policy to be created. |
| 192 | + * |
| 193 | + * @param assetDeliveryPolicyType |
| 194 | + * The type |
| 195 | + * @return The creator object (for call chaining) |
| 196 | + */ |
| 197 | + public Updater setKeyDeliveryConfiguration(String keyDeliveryConfiguration) { |
| 198 | + this.keyDeliveryConfiguration = keyDeliveryConfiguration; |
| 199 | + return this; |
| 200 | + } |
| 201 | + |
| 202 | + /** |
| 203 | + * Set the configuration of the Asset Delivery Policy to be created. |
| 204 | + * |
| 205 | + * @param assetDeliveryPolicyConfiguration |
| 206 | + * The configuration |
| 207 | + * @return The creator object (for call chaining) |
| 208 | + */ |
| 209 | + public Updater setRestrictions( |
| 210 | + List<ContentKeyAuthorizationPolicyRestriction> restrictions) { |
| 211 | + |
| 212 | + this.restrictions = new ArrayList<ContentKeyAuthorizationPolicyRestrictionType>(); |
| 213 | + for (ContentKeyAuthorizationPolicyRestriction restriction : restrictions) { |
| 214 | + this.restrictions.add(new ContentKeyAuthorizationPolicyRestrictionType() |
| 215 | + .setName(restriction.getName()) |
| 216 | + .setKeyRestrictionType(restriction.getKeyRestrictionType()) |
| 217 | + .setRequirements(restriction.getRequirements())); |
| 218 | + } |
| 219 | + return this; |
| 220 | + } |
| 221 | + } |
152 | 222 | }
|
0 commit comments