Creates a remote link.

@param string $issue_key    Issue key.
@param array  $object       Object.
@param string $relationship Relationship.
@param string $global_id    Global ID.
@param array  $application  Application.

@return array|false
@since  2.0.0
348260
public function createRemoteLink(
		$issue_key,
		array $object = array(),
		$relationship = null,
		$global_id = null,
		array $application = null
	) {
		$options = array(
						'globalId' => $global_id,
						'relationship' => $relationship,
						'object' => $object,
					);

		if ( !is_null($application) ) {
			$options['application'] = $application;
		}

		return $this->api(self::REQUEST_POST, sprintf('/rest/api/2/issue/%s/remotelink', $issue_key), $options, true);
	}
451090
public function reportIssueInFile($issue_type, $file_path)
    {
        if (!$this->totally_typed && in_array($issue_type, self::MIXED_ISSUES, true)) {
            return false;
        }

        if ($this->hide_external_errors) {
            if ($this->mustBeIgnored($file_path)) {
                return false;
            }

            $project_analyzer = ProjectAnalyzer::getInstance();

            $codebase = $project_analyzer->getCodebase();

            $dependent_files = [strtolower($file_path) => $file_path];

            try {
                $file_storage = $codebase->file_storage_provider->get($file_path);
                $dependent_files += $file_storage->required_by_file_paths;
            } catch (\InvalidArgumentException $e) {
                // do nothing
            }

            $any_file_path_matched = false;

            foreach ($dependent_files as $dependent_file_path) {
                if (($codebase->analyzer->canReportIssues($dependent_file_path)
                        || $project_analyzer->canReportIssues($dependent_file_path))
                    && !$this->mustBeIgnored($dependent_file_path)
                ) {
                    $any_file_path_matched = true;
                    break;
                }
            }

            if (!$any_file_path_matched) {
                return false;
            }
        }

        if ($this->getReportingLevelForFile($issue_type, $file_path) === self::REPORT_SUPPRESS) {
            return false;
        }

        return true;
    }
742841
public function setWatchers($issue_key, array $watchers)
	{
		$result = array();

		foreach ( $watchers as $watcher ) {
			$result[] = $this->api(self::REQUEST_POST, sprintf('/rest/api/2/issue/%s/watchers', $issue_key), $watcher);
		}

		return $result;
	}
1199071
protected function getGitHubIssueLabels(Issue $issue_api, $github_issue_number) {
    $issue = $issue_api->show('acquia', 'blt', $github_issue_number);
    $labels = isset($issue['labels']) ? $issue['labels'] : [];

    return $labels;
  }
914036
function getAssociation($server_url, $handle = null)
    {
        // simple case: handle given
        if ($handle !== null) {
            // get association, return null if failed
            $association = $this->connection->get(
                $this->associationKey($server_url, $handle));
            return $association ? $association : null;
        }

        // no handle given, working with list
        // create key for list of associations
        $serverKey = $this->associationServerKey($server_url);

        // get list of associations
        $serverAssociations = $this->connection->get($serverKey);
        // return null if failed or got empty list
        if (!$serverAssociations) {
            return null;
        }

        // get key of most recently issued association
        $keys = array_keys($serverAssociations);
        sort($keys);
        $lastKey = $serverAssociations[array_pop($keys)];

        // get association, return null if failed
        $association = $this->connection->get($lastKey);
        return $association ? $association : null;
    }
188579
function askForRelationship(done) {
    const context = this.context;
    const name = context.name;
    this.log(chalk.green('\nGenerating relationships to other entities\n'));
    const fieldNamesUnderscored = context.fieldNamesUnderscored;
    const prompts = [
        {
            type: 'confirm',
            name: 'relationshipAdd',
            message: 'Do you want to add a relationship to another entity?',
            default: true
        },
        {
            when: response => response.relationshipAdd === true,
            type: 'input',
            name: 'otherEntityName',
            validate: input => {
                if (!/^([a-zA-Z0-9_]*)$/.test(input)) {
                    return 'Your other entity name cannot contain special characters';
                }
                if (input === '') {
                    return 'Your other entity name cannot be empty';
                }
                if (jhiCore.isReservedKeyword(input, 'JAVA')) {
                    return 'Your other entity name cannot contain a Java reserved keyword';
                }
                if (input.toLowerCase() === 'user' && context.applicationType === 'microservice') {
                    return "Your entity cannot have a relationship with User because it's a gateway entity";
                }
                return true;
            },
            message: 'What is the name of the other entity?'
        },
        {
            when: response => response.relationshipAdd === true,
            type: 'input',
            name: 'relationshipName',
            validate: input => {
                if (!/^([a-zA-Z0-9_]*)$/.test(input)) {
                    return 'Your relationship cannot contain special characters';
                }
                if (input === '') {
                    return 'Your relationship cannot be empty';
                }
                if (input.charAt(0) === input.charAt(0).toUpperCase()) {
                    return 'Your relationship cannot start with an upper case letter';
                }
                if (input === 'id' || fieldNamesUnderscored.includes(_.snakeCase(input))) {
                    return 'Your relationship cannot use an already existing field name';
                }
                if (jhiCore.isReservedKeyword(input, 'JAVA')) {
                    return 'Your relationship cannot contain a Java reserved keyword';
                }
                return true;
            },
            message: 'What is the name of the relationship?',
            default: response => _.lowerFirst(response.otherEntityName)
        },
        {
            when: response => response.relationshipAdd === true,
            type: 'list',
            name: 'relationshipType',
            message: 'What is the type of the relationship?',
            choices: response => {
                const opts = [
                    {
                        value: 'many-to-one',
                        name: 'many-to-one'
                    },
                    {
                        value: 'many-to-many',
                        name: 'many-to-many'
                    },
                    {
                        value: 'one-to-one',
                        name: 'one-to-one'
                    }
                ];
                if (response.otherEntityName.toLowerCase() !== 'user') {
                    opts.unshift({
                        value: 'one-to-many',
                        name: 'one-to-many'
                    });
                }
                return opts;
            },
            default: 0
        },
        {
            when: response =>
                response.relationshipAdd === true &&
                response.otherEntityName.toLowerCase() !== 'user' &&
                (response.relationshipType === 'many-to-many' || response.relationshipType === 'one-to-one'),
            type: 'confirm',
            name: 'ownerSide',
            message: 'Is this entity the owner of the relationship?',
            default: false
        },
        {
            when: response =>
                context.databaseType === 'sql' &&
                response.relationshipAdd === true &&
                response.relationshipType === 'one-to-one' &&
                (response.ownerSide === true || response.otherEntityName.toLowerCase() === 'user'),
            type: 'confirm',
            name: 'useJPADerivedIdentifier',
            message: 'Do you want to use JPA Derived Identifier - @MapsId?',
            default: false
        },
        {
            when: response =>
                response.relationshipAdd === true &&
                (response.relationshipType === 'one-to-many' ||
                    ((response.relationshipType === 'many-to-many' || response.relationshipType === 'one-to-one') &&
                        response.otherEntityName.toLowerCase() !== 'user')),
            type: 'input',
            name: 'otherEntityRelationshipName',
            message: 'What is the name of this relationship in the other entity?',
            default: response => _.lowerFirst(name)
        },
        {
            when: response =>
                response.relationshipAdd === true &&
                (response.relationshipType === 'many-to-one' ||
                    (response.relationshipType === 'many-to-many' && response.ownerSide === true) ||
                    (response.relationshipType === 'one-to-one' && response.ownerSide === true)),
            type: 'input',
            name: 'otherEntityField',
            message: response =>
                `When you display this relationship on client-side, which field from '${
                    response.otherEntityName
                }' do you want to use? This field will be displayed as a String, so it cannot be a Blob`,
            default: 'id'
        },
        {
            when: response =>
                response.relationshipAdd === true &&
                response.otherEntityName.toLowerCase() !== context.name.toLowerCase() &&
                (response.relationshipType === 'many-to-one' ||
                    (response.relationshipType === 'many-to-many' &&
                        (response.ownerSide === true || response.otherEntityName.toLowerCase() === 'user')) ||
                    (response.relationshipType === 'one-to-one' &&
                        (response.ownerSide === true || response.otherEntityName.toLowerCase() === 'user'))),
            type: 'confirm',
            name: 'relationshipValidate',
            message: 'Do you want to add any validation rules to this relationship?',
            default: false
        },
        {
            when: response => response.relationshipValidate === true,
            type: 'checkbox',
            name: 'relationshipValidateRules',
            message: 'Which validation rules do you want to add?',
            choices: [
                {
                    name: 'Required',
                    value: 'required'
                }
            ],
            default: 0
        }
    ];
    this.prompt(prompts).then(props => {
        if (props.relationshipAdd) {
            const relationship = {
                relationshipName: props.relationshipName,
                otherEntityName: _.lowerFirst(props.otherEntityName),
                relationshipType: props.relationshipType,
                relationshipValidateRules: props.relationshipValidateRules,
                otherEntityField: props.otherEntityField,
                ownerSide: props.ownerSide,
                useJPADerivedIdentifier: props.useJPADerivedIdentifier,
                otherEntityRelationshipName: props.otherEntityRelationshipName
            };

            if (props.otherEntityName.toLowerCase() === 'user') {
                relationship.ownerSide = true;
                relationship.otherEntityField = 'login';
                relationship.otherEntityRelationshipName = _.lowerFirst(name);
            }

            fieldNamesUnderscored.push(_.snakeCase(props.relationshipName));
            context.relationships.push(relationship);
        }
        logFieldsAndRelationships.call(this);
        if (props.relationshipAdd) {
            askForRelationship.call(this, done);
        } else {
            this.log('\n');
            done();
        }
    });
}
428873
public function delete_object_from_relationships( $id, $object, $name = null ) {

		/**
		 * @var $pods_init \PodsInit
		 */
		global $pods_init;

		$pod = false;

		// Run any bidirectional delete operations
		if ( is_array( $object ) ) {
			$pod = $object;
		} elseif ( is_object( $pods_init ) ) {
			$pod = PodsInit::$meta->get_object( $object, $name );
		}

		if ( ! empty( $pod ) ) {
			$object = $pod['type'];
			$name   = $pod['name'];

			foreach ( $pod['fields'] as $field ) {
				PodsForm::delete( $field['type'], $id, $field['name'], array_merge( $field, $field['options'] ), $pod );
			}
		}

		// Lookup related fields (non-bidirectional)
		$params = array(
			'where' => array(
				array(
					'key'   => 'type',
					'value' => 'pick'
				),
				array(
					'key'   => 'pick_object',
					'value' => $object
				)
			)
		);

		if ( ! empty( $name ) && $name !== $object ) {
			$params['where'][] = array(
				'key'   => 'pick_val',
				'value' => $name
			);
		}

		$fields = $this->load_fields( $params, false );

		if ( ! empty( $pod ) && 'media' === $pod['type'] ) {
			$params['where'] = array(
				array(
					'key'   => 'type',
					'value' => 'file'
				)
			);

			$fields = array_merge( $fields, $this->load_fields( $params, false ) );
		}

		if ( is_array( $fields ) && ! empty( $fields ) ) {
			foreach ( $fields as $related_field ) {
				$related_pod = $this->load_pod( array( 'id' => $related_field['pod_id'], 'fields' => false ), false );

				if ( empty( $related_pod ) ) {
					continue;
				}

				$related_from = $this->lookup_related_items_from( $related_field['id'], $related_pod['id'], $id, $related_field, $related_pod );

				$this->delete_relationships( $related_from, $id, $related_pod, $related_field );
			}
		}

		if ( ! empty( $pod ) && ! pods_tableless() ) {
			pods_query( "
				DELETE FROM `@wp_podsrel`
				WHERE
				(
					`pod_id` = %d
					AND `item_id` = %d
				)
				OR (
					`related_pod_id` = %d
					AND `related_item_id` = %d
				)
			", array(
				$pod['id'],
				$id,

				$pod['id'],
				$id
			) );
		}

		return true;
	}
832254
public function addRelationshipObject($key, RelationshipObject $relationshipObject) {
		Validator::checkMemberName($key);
		
		if (isset($this->relationships[$key])) {
			throw new DuplicateException('relationship with key "'.$key.'" already set');
		}
		
		$this->relationships[$key] = $relationshipObject;
	}
851134
public static function selectPrimaryKey(Connection $connection, $primary_key)
    {
        return static::selectOne($connection)
            ->where(static::$primary_key, $primary_key)
            ->execute();
    }
894635
protected function fixInputRelations(eZContentObject $object, $versionNo)
    {
        $validRelationTypes = array(1, 2, 4, 8, 16, 32, 64, 128);

        $db = eZDB::instance();
        $rows = $db->arrayQuery(
            "SELECT * FROM ezcontentobject_link
            WHERE from_contentobject_id={$object->attribute('id')}
            AND from_contentobject_version={$versionNo}"
        );

        foreach ($rows as $row) {
            $relationType = (int)$row['relation_type'];

            if (!in_array($relationType, $validRelationTypes)) {
                foreach ($validRelationTypes as $validRelationType) {
                    if ($relationType & $validRelationType) {
                        $db->query(
                            "INSERT INTO ezcontentobject_link (
                                from_contentobject_id,
                                from_contentobject_version,
                                to_contentobject_id,
                                contentclassattribute_id,
                                relation_type
                            ) VALUES (
                                {$row['from_contentobject_id']},
                                {$row['from_contentobject_version']},
                                {$row['to_contentobject_id']},
                                {$row['contentclassattribute_id']},
                                {$validRelationType}
                            )
                        ");
                    }
                }

                $db->query("DELETE FROM ezcontentobject_link WHERE id = {$row['id']}");
            }
        }
    }
1074127
public function setCustomErrorLevel($issue_key, $error_level)
    {
        $this->issue_handlers[$issue_key] = new IssueHandler();
        $this->issue_handlers[$issue_key]->setErrorLevel($error_level);
    }
763164
def get_issue_labels(self, issue_key):
        
        url = 'rest/api/2/issue/{issue_key}?fields=labels'.format(issue_key=issue_key)
        return (self.get(url) or {}).get('fields').get('labels')
168259
def issue(ctx, accountable, issue_key):
    
    accountable.issue_key = issue_key
    if not ctx.invoked_subcommand:
        issue = accountable.issue_meta()
        headers = issue.keys()
        rows = [headers, [v for k, v in issue.items()]]
        print_table(SingleTable(rows))
1089747
def attach_issue(context, id, url):
    

    result = job.attach_issue(context, id=id, url=url)
    utils.format_output(result, context.format)
1117524
def remote_links(self, issue):
        
        r_json = self._get_json('issue/' + str(issue) + '/remotelink')
        remote_links = [RemoteLink(
            self._options, self._session, raw_remotelink_json) for raw_remotelink_json in r_json]
        return remote_links
408546
protected void sendAuthFailure(IPolicyContext context, IPolicyChain<?> chain, BasicAuthenticationConfig config, int reason) {
        IPolicyFailureFactoryComponent pff = context.getComponent(IPolicyFailureFactoryComponent.class);
        PolicyFailure failure = pff.createFailure(PolicyFailureType.Authentication, reason, Messages.i18n.format("BasicAuthenticationPolicy.AuthenticationFailed")); //$NON-NLS-1$
        String realm = config.getRealm();
        if (realm == null || realm.trim().isEmpty()) {
            realm = "Apiman"; //$NON-NLS-1$
        }
        failure.getHeaders().put("WWW-Authenticate", String.format("Basic realm=\"%1$s\"", realm)); //$NON-NLS-1$ //$NON-NLS-2$
        chain.doFailure(failure);
    }
230309
public static function confirm_link_login($userid, $username, $issuerid, $token) {
        if (empty($token) || empty($userid) || empty($issuerid) || empty($username)) {
            return false;
        }
        $params = [
            'userid' => $userid,
            'username' => $username,
            'issuerid' => $issuerid,
            'confirmtoken' => $token,
        ];

        $login = linked_login::get_record($params);
        if (empty($login)) {
            return false;
        }
        $expires = $login->get('confirmtokenexpires');
        if (time() > $expires) {
            $login->delete();
            return;
        }
        $login->set('confirmtokenexpires', 0);
        $login->set('confirmtoken', '');
        $login->update();
        return true;
    }