Link delivery policy

@param assetId
the asset id
@param deliveryPolicyId
the content key id
@return the entity action operation
189219
public static EntityLinkOperation linkDeliveryPolicy(String assetId,
            String deliveryPolicyId) {
        String escapedContentKeyId = null;
        try {
            escapedContentKeyId = URLEncoder.encode(deliveryPolicyId, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            throw new InvalidParameterException("deliveryPolicyId");
        }
        URI contentKeyUri = URI.create(String.format("AssetDeliveryPolicies('%s')",
                escapedContentKeyId));
        return new EntityLinkOperation(ENTITY_SET, assetId, "DeliveryPolicies",
                contentKeyUri);
    }
164150
function loadPolicy(documentPath, name) {
  return plugin.myrmex.fire('beforePolicyLoad', documentPath, name)
  .spread((documentPath, name) => {
    // Because we use require() to get the document, it could either be a JSON file
    // or the content exported by a node module
    // But because require() caches the content it loads, we clone the result to avoid bugs
    // if the function is called twice
    const document = _.cloneDeep(require(documentPath));
    const Policy = require('./policy');
    const policy = new Policy(document, name);

    // This event allows to inject code to alter the Lambda configuration
    return plugin.myrmex.fire('afterPolicyLoad', policy);
  })
  .spread((policy) => {
    return Promise.resolve(policy);
  });
}
452108
public static EntityGetOperation<ContentKeyAuthorizationPolicyInfo> get(String contentKeyAuthorizationPolicyId) {
        return new DefaultGetOperation<ContentKeyAuthorizationPolicyInfo>(ENTITY_SET, contentKeyAuthorizationPolicyId,
                ContentKeyAuthorizationPolicyInfo.class);
    }
867050
public static void addTargetLinks(final MgmtTarget response) {
        response.add(linkTo(methodOn(MgmtTargetRestApi.class).getAssignedDistributionSet(response.getControllerId()))
                .withRel(MgmtRestConstants.TARGET_V1_ASSIGNED_DISTRIBUTION_SET));
        response.add(linkTo(methodOn(MgmtTargetRestApi.class).getInstalledDistributionSet(response.getControllerId()))
                .withRel(MgmtRestConstants.TARGET_V1_INSTALLED_DISTRIBUTION_SET));
        response.add(linkTo(methodOn(MgmtTargetRestApi.class).getAttributes(response.getControllerId()))
                .withRel(MgmtRestConstants.TARGET_V1_ATTRIBUTES));
        response.add(linkTo(methodOn(MgmtTargetRestApi.class).getActionHistory(response.getControllerId(), 0,
                MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE,
                ActionFields.ID.getFieldName() + ":" + SortDirection.DESC, null))
                        .withRel(MgmtRestConstants.TARGET_V1_ACTIONS).expand());
        response.add(linkTo(methodOn(MgmtTargetRestApi.class).getMetadata(response.getControllerId(),
                MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE,
                MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, null, null)).withRel("metadata"));
    }
1129647
public static String buildCustomPolicy(String resourcePath,
            Date expiresOn, Date activeFrom, String ipAddress) {
        return "{\"Statement\": [{"
                + "\"Resource\":\""
                + resourcePath
                + "\""
                + ",\"Condition\":{"
                + "\"DateLessThan\":{\"AWS:EpochTime\":"
                + MILLISECONDS.toSeconds(expiresOn.getTime())
                + "}"
                + (ipAddress == null
                  ? ""
                  : ",\"IpAddress\":{\"AWS:SourceIp\":\""
                    + ipAddress + "\"}"
                  )
                + (activeFrom == null
                   ? ""
                   : ",\"DateGreaterThan\":{\"AWS:EpochTime\":"
                     + MILLISECONDS.toSeconds(activeFrom.getTime()) + "}"
                  )
                + "}}]}";
    }
1166842
public void addPolicy(Policy policy) throws PolicyException {

        // Add BlueprintPolicy
        if (policy instanceof BlueprintPolicy) {
            if (erectors.get(policy.getTarget()) == null) {
                throw new PolicyException("Blueprint does not exist for BlueprintPolicy target: " + policy.getTarget());
            }

            List<BlueprintPolicy> policies = blueprintPolicies.get(policy.getTarget());
            if (policies == null) {
                policies = new ArrayList<BlueprintPolicy>();
            }

            policies.add((BlueprintPolicy) policy);

            logger.info("Setting BlueprintPolicy {} for {}", policy, policy.getTarget());

            blueprintPolicies.put(policy.getTarget(), policies);

            // Add FieldPolicy
        } else if (policy instanceof FieldPolicy) {

            // XXX: force FieldPolicy's to be mapped to a blueprint? Limits their scope, but enables validation
            if (erectors.get(policy.getTarget()) == null) {
                throw new PolicyException("Blueprint does not exist for FieldPolicy target: " + policy.getTarget());
            }

            List<FieldPolicy> policies = fieldPolicies.get(policy.getTarget());
            if (policies == null) {
                policies = new ArrayList<FieldPolicy>();
            }

            policies.add((FieldPolicy) policy);

            logger.info("Setting FieldPolicy {} for {}", policy, policy.getTarget());

            fieldPolicies.put(policy.getTarget(), policies);
        }
    }
1022958
public function getLinkedDeliveryExecutions(core_kernel_classes_Resource $delivery, core_kernel_classes_Resource $link, $userId) {
        /** @var LtiDeliveryExecutionService $deliveryExecutionService */
	    $deliveryExecutionService = $this->getServiceLocator()->get(LtiDeliveryExecutionService::SERVICE_ID);
        $executions = $deliveryExecutionService->getLinkedDeliveryExecutions($delivery, $link, $userId);
        return $executions;
    }
728668
def create_asset_delivery_policy(access_token, ams_account, key_delivery_url):
    '''
    '''
    path = '/AssetDeliveryPolicies'
    endpoint = ''.join([ams_rest_endpoint, path])
    body = '{ \
		"Name":"AssetDeliveryPolicy", \
		"AssetDeliveryProtocol":"4", \
		"AssetDeliveryPolicyType":"3", \
		"AssetDeliveryConfiguration":"[{ \
			\\"Key\\":\\"2\\", \
			\\"Value\\":\\"' + key_delivery_url + '\\"}]" \
	}'
    return do_ams_post(endpoint, path, body, access_token)
958857
public function removeDeliveryPolicyFromAsset($asset, $policy)
    {
        $assetId = Utilities::getEntityId(
            $asset,
            'WindowsAzure\MediaServices\Models\Asset'
        );

        $policyId = Utilities::getEntityId(
            $policy,
            'WindowsAzure\MediaServices\Models\AssetDeliveryPolicy'
        );

        $method = Resources::HTTP_DELETE;
        $path = "Assets('{$assetId}')/\$links/DeliveryPolicies('{$policyId}')";
        $headers = [];
        $postParams = [];
        $queryParams = [];
        $statusCode = Resources::STATUS_NO_CONTENT;

        $this->sendHttp(
            $method,
            $headers,
            $queryParams,
            $postParams,
            $path,
            $statusCode
        );
    }
554380
public static Package getAssetPackage(Long assetId) throws CachingException {
        for (Package pkg : getPackageList()) {
            if (pkg.containsAsset(assetId))
                return pkg;
        }
        return null;
    }
31998
@RequestMapping(value = "builds/{buildId}/links/{targetBuildId}", method = RequestMethod.PUT)
    public Build addBuildLink(@PathVariable ID buildId, @PathVariable ID targetBuildId) {
        Build build = structureService.getBuild(buildId);
        Build targetBuild = structureService.getBuild(targetBuildId);
        structureService.addBuildLink(build, targetBuild);
        return build;
    }
1093783
public static EntityGetOperation<AssetFileInfo> get(String assetFileId) {
        return new DefaultGetOperation<AssetFileInfo>(ENTITY_SET, assetFileId,
                AssetFileInfo.class);
    }
503788
public TransportApiResult<Agency> getAgency(String agencyId)
    {
    	if (Extensions.isNullOrWhiteSpace(agencyId))
    	{
    		throw new IllegalArgumentException("AgencyId is required.");
    	}

    	return TransportApiClientCalls.getAgency(tokenComponent, settings, agencyId);
    }
1292268
public static DefaultListOperation<AssetDeliveryPolicyInfo> list(LinkInfo<AssetDeliveryPolicyInfo> link) {
        return new DefaultListOperation<AssetDeliveryPolicyInfo>(link.getHref(),
                new GenericType<ListResult<AssetDeliveryPolicyInfo>>() {
                });
    }
568032
public Policy replaceTopicPolicy(String topicId) throws Exception {
    // [START pubsub_set_topic_policy]
    try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
      String topicName = ProjectTopicName.format(projectId, topicId);
      Policy policy = topicAdminClient.getIamPolicy(topicName);
      // add role -> members binding
      Binding binding =
          Binding.newBuilder()
              .setRole(Role.viewer().toString())
              .addMembers(Identity.allAuthenticatedUsers().toString())
              .build();
      // create updated policy
      Policy updatedPolicy = Policy.newBuilder(policy).addBindings(binding).build();
      updatedPolicy = topicAdminClient.setIamPolicy(topicName, updatedPolicy);
      return updatedPolicy;
    }
    // [END pubsub_set_topic_policy]
  }
174959
public function spawnDeliveryExecution($label, $deliveryId, $userId, $status)
    {
        $identifier = self::DELIVERY_EXECUTION_PREFIX . \common_Utils::getNewUri();
        $data = array(
            OntologyRdfs::RDFS_LABEL => $label,
            OntologyDeliveryExecution::PROPERTY_DELIVERY  => $deliveryId,
            OntologyDeliveryExecution::PROPERTY_SUBJECT => $userId,
            OntologyDeliveryExecution::PROPERTY_TIME_START => microtime(),
            OntologyDeliveryExecution::PROPERTY_STATUS => $status
        );
        $kvDe = new KVDeliveryExecution($this, $identifier, $data);
        $this->updateDeliveryExecutionStatus($kvDe, null, $status);
        $this->addDeliveryToUserExecutionList($userId, $deliveryId, $kvDe->getIdentifier());
        return $this->propagate(new DeliveryExecutionWrapper($kvDe));
    }
158730
public Optional<AlertPolicy> update(AlertPolicy policy)
    {
        return HTTP.PUT(String.format("/v2/alerts_policies/%d.json", policy.getId()), policy, ALERT_POLICY);
    }