Register request types in a box/module
184614
protected function registerRequestTypes()
    {
        foreach ($this->requests as $key => $requestType) {
            $contract = is_string($key) ? $key : $this->convention->contractForRequest($requestType);
            $this->concord->registerRequest($contract, $requestType);
        }
    }
44074
function(type) {

	var items = _.filter(process.env, function(value, key) {

		var pattern = new RegExp('CORS\_ALLOWED\_' + type.toUpperCase(), 'i')

		return key.match(pattern);

	});

	return items.join(', ') || '*';

}
89696
protected function _loadContentType()
    {
        $this->_loadRawHeaders();

        if(key_exists('Content-Type', $this->_rawHeaders))
            $this->_requestContentType = $this->_rawHeaders['Content-Type'];
    }
415284
function(request, data){
  request.source_endpoint = data[1];
  request.type = data[2];
  parseType(request, data);
}
477900
function validateResponseType (type) {
  if (validTypes.indexOf(type) < 0)
    return option.some(`Response content type ${type} is not supported`)
  return option.none
}
707370
function Types() {
 
  var self = this
    , types = {};

  this.register = function (typeInfo) {

    if (!typeInfo) { throw new Error("Type information is required"); }

    var type = typeInfo.type;

    if (!typeInfo.name) {
      throw new Error("Type name is missing");
    }
    if (!typeInfo.version) {
      throw new Error("Type version is missing");
    }

    typeInfo.create = typeInfo.create || function create(values) {
      var instance = {
        "type": typeInfo.name,
        "version": typeInfo.version
      };

      if (type) {
        Object.keys(type).forEach(function (name) {
          instance[name] = type[name];
        });
      }
      if (values) {
        Object.keys(values).forEach(function (name) {
          instance[name] = values[name];
        });
      }

      return instance;
    };

    typeInfo.validate = (function (validation) {
      return function validate(instance) {
        var results = [];
        if (!instance) {
          results.push("Instance of type '" + typeInfo.name + "' can not be null or undefined");
        } else {
          if (!instance.type) {
            results.push("Instance of type '" + typeInfo.name + "' must have a type property");
          } else if (instance.type !== typeInfo.name) {
            results.push("Instance is of type '" + instance.type + "' and not of '" + typeInfo.name + "'");
          }
          if (!instance.version) {
            results.push("Instance of type '" + typeInfo.name + "' does not have a version");
          } else if (instance.version !== typeInfo.version) {
            results.push("Instance is version '" + instance.type + "' and not version '" + typeInfo.name + "'");
          }
          if (validation) {
            results = results.concat(validation(instance));
          }
        }
        return results;
      };
    }(typeInfo.validate));

    if (types[typeInfo.name] && types[typeInfo.name][typeInfo.version]) {
      throw new Error("Type '" + typeInfo.name + "' with version '" +
        typeInfo.version + "' is already registered.");
    }

    types[typeInfo.name] = types[typeInfo.name] || {};
    types[typeInfo.name][typeInfo.version] = typeInfo;

    if (typeInfo.version > (types[typeInfo.name].latestVersion || -1)) {
      types[typeInfo.name].latestVersion = typeInfo.version;
    }
  };

  this.validate = function (item) {
    return item && item.type && item.version &&
      types[item.type] && types[item.type][item.version]
      && types[item.type][item.version].validate(item);
  };

  this.get = function (name, version) {

    if (typeof name !== 'string' && typeof version !== 'number') {
      if (typeof name === 'object' && name.name && name.version) {
        version = name.version;
        name = name.name;
      } else if (typeof name === 'object' && name.type && name.version) {
        version = name.version;
        name = name.type;
      }
    }

    if (!types[name]) {
      throw new Error("Type '" + name + "' is not registered.");
    }
    version = version || types[name].latestVersion;
    if (!types[name][version]) {
      throw new Error("Type '" + name + "' with version '" +
        version + "' is not registered.");
    }
    return types[name][version];
  };

  this.getAll = function () {
    return Object.keys(types).map(function (name) {
      return types[name];
    });
  };

  this.create = function (name, version, values) {

    if (typeof name === 'string' && typeof version === 'object' && !values) {
      values = version;
      version = undefined;
    } else if (typeof name !== 'string' && typeof version !== 'number') {
      if (typeof name === 'object' && (name.type || name.name) && name.version) {
        values = name;
        version = name.version;
        name = name.type || name.name;
      }
    }

    return self.get(name, version).create(values);
  };
}
1061732
private void loadAuthenticationMethodTypes(ExtensionHook hook) {
		this.authenticationMethodTypes = new ArrayList<>();
		this.authenticationMethodTypes.add(new FormBasedAuthenticationMethodType());
		this.authenticationMethodTypes.add(new HttpAuthenticationMethodType());
		this.authenticationMethodTypes.add(new ManualAuthenticationMethodType());
		this.authenticationMethodTypes.add(new ScriptBasedAuthenticationMethodType());
		this.authenticationMethodTypes.add(new JsonBasedAuthenticationMethodType());

		for (AuthenticationMethodType a : authenticationMethodTypes) {
			a.hook(hook);
		}

		if (log.isInfoEnabled()) {
			log.info("Loaded authentication method types: " + authenticationMethodTypes);
		}
	}
337434
def request_types(self, service_desk):
        
        if hasattr(service_desk, 'id'):
            service_desk = service_desk.id
        url = (self._options['server'] +
               '/rest/servicedeskapi/servicedesk/%s/requesttype'
               % service_desk)
        headers = {'X-ExperimentalApi': 'opt-in'}
        r_json = json_loads(self._session.get(url, headers=headers))
        request_types = [
            RequestType(self._options, self._session, raw_type_json)
            for raw_type_json in r_json['values']]
        return request_types
1223115
def request(method, url, **kwargs):
    """"""
    _set_content_type(kwargs)
    if _content_type_is_json(kwargs) and kwargs.get('data') is not None:
        kwargs['data'] = dumps(kwargs['data'])
    _log_request(method, url, kwargs)
    response = requests.request(method, url, **kwargs)
    _log_response(response)
    return response
1160903
public function register( $post_types = [] ) {
		foreach ( $post_types as $post_type => $callback ) {
			$this->post_types[ $post_type ] = [
				'callback' => $callback,
			];
		}
	}
449181
function register_post_type() {

        // Friendly post type names.
        $plural   = $this->plural;
        $singular = $this->singular;
        $slug     = $this->slug;

        // Default labels.
        $labels = array(
            'name'               => sprintf( __( '%s', $this->textdomain ), $plural ),
            'singular_name'      => sprintf( __( '%s', $this->textdomain ), $singular ),
            'menu_name'          => sprintf( __( '%s', $this->textdomain ), $plural ),
            'all_items'          => sprintf( __( '%s', $this->textdomain ), $plural ),
            'add_new'            => __( 'Add New', $this->textdomain ),
            'add_new_item'       => sprintf( __( 'Add New %s', $this->textdomain ), $singular ),
            'edit_item'          => sprintf( __( 'Edit %s', $this->textdomain ), $singular ),
            'new_item'           => sprintf( __( 'New %s', $this->textdomain ), $singular ),
            'view_item'          => sprintf( __( 'View %s', $this->textdomain ), $singular ),
            'search_items'       => sprintf( __( 'Search %s', $this->textdomain ), $plural ),
            'not_found'          => sprintf( __( 'No %s found', $this->textdomain ), $plural ),
            'not_found_in_trash' => sprintf( __( 'No %s found in Trash', $this->textdomain ), $plural ),
            'parent_item_colon'  => sprintf( __( 'Parent %s:', $this->textdomain ), $singular )
        );

        // Default options.
        $defaults = array(
            'labels' => $labels,
            'public' => true,
            'rewrite' => array(
                'slug' => $slug,
            )
        );

        // Merge user submitted options with defaults.
        $options = array_replace_recursive( $defaults, $this->options );

        // Set the object options as full options passed.
        $this->options = $options;

        // Check that the post type doesn't already exist.
        if ( ! post_type_exists( $this->post_type_name ) ) {

            // Register the post type.
            register_post_type( $this->post_type_name, $options );
        }
    }
527452
def __NeedRequestType(self, method_description, request_type):
        """"""
        if not request_type:
            return True
        method_id = method_description.get('id', '')
        if method_id in self.__unelidable_request_methods:
            return True
        message = self.__message_registry.LookupDescriptorOrDie(request_type)
        if message is None:
            return True
        field_names = [x.name for x in message.fields]
        parameters = method_description.get('parameters', {})
        for param_name, param_info in parameters.items():
            if (param_info.get('location') != 'path' or
                    self.__names.CleanName(param_name) not in field_names):
                break
        else:
            return False
        return True
1085557
def register(name=''):
    ""
    def reg(widget):
        """A decorator registering a widget class in the widget registry."""
        w = widget.class_traits()
        Widget.widget_types.register(w['_model_module'].default_value,
                                    w['_model_module_version'].default_value,
                                    w['_model_name'].default_value,
                                    w['_view_module'].default_value,
                                    w['_view_module_version'].default_value,
                                    w['_view_name'].default_value,
                                    widget)
        return widget
    if isinstance(name, string_types):
        import warnings
        warnings.warn("Widget registration using a string name has been deprecated. Widget registration now uses a plain `@register` decorator.", DeprecationWarning)
        return reg
    else:
        return reg(name)
1251685
function(request, parameters) {
	if (!parameters) {
		return;
	}

	var keys = Object.keys(parameters);
	var type = false;
	var value = null;
	var options = null;
	for (var i = keys.length - 1; i >= 0; i--) {
		value = parameters[keys[i]];
		options = null;

		if (value instanceof Object && value.type && value.hasOwnProperty('value')) {
			if (value.hasOwnProperty('options')) {
				options = value.options;
			}
			type = value.type;
			value = value.value;
		}
		else {
			type = exports.detectParameterType(value);
		}

		if (!(value instanceof Array)) {
			request.addParameter(keys[i], type, value, options);
			continue;
		}
	}
}
28202
def register_type(*args)
      if types_list.respond_to?(:add)
        types_list.add self, *args
      else
        types_list << self
      end
      if types_tracker_base.respond_to?(:scope) &&
          !types_tracker_base.respond_to?(model_name.element)
        type_name = name
        types_tracker_base.scope model_name.element, -> { where(type: type_name) }
      end
    end
860050
def edit_request_type_view(request, typeName):
    ''' 
    '''
    requestType = get_object_or_404(RequestType, url_name=typeName)
    form = RequestTypeForm(
        request.POST or None,
        instance=requestType,
        )
    if form.is_valid():
        rtype = form.save()
        messages.add_message(request, messages.SUCCESS,
                             MESSAGES['REQUEST_TYPE_SAVED'].format(typeName=rtype.name))
        return HttpResponseRedirect(reverse('managers:manage_request_types'))
    return render_to_response('edit_request_type.html', {
        'page_name': "Admin - Edit Request Type",
        'request_types': RequestType.objects.all(),
        'form': form,
        'requestType': requestType,
        }, context_instance=RequestContext(request))
680863
public function register_post_type() {

		if ( ! isset( $this->args['query_var'] ) || ( true === $this->args['query_var'] ) ) {
			$query_var = $this->post_type;
		} else {
			$query_var = $this->args['query_var'];
		}

		$existing = get_post_type_object( $this->post_type );
		$taxonomies = get_taxonomies( [
			'query_var' => $query_var,
		], 'objects' );

		if ( $query_var && count( $taxonomies ) ) {
			// https://core.trac.wordpress.org/ticket/35089
			foreach ( $taxonomies as $tax ) {
				if ( $tax->query_var === $query_var ) {
					trigger_error( esc_html( sprintf(
						/* translators: %s: Post type query variable name */
						__( 'Post type query var "%s" clashes with a taxonomy query var of the same name', 'extended-cpts' ),
						$query_var
					) ), E_USER_ERROR );
				}
			}
		}

		if ( empty( $existing ) ) {

			$cpt = register_post_type( $this->post_type, $this->args );

			if ( is_wp_error( $cpt ) ) {
				trigger_error( esc_html( $cpt->get_error_message() ), E_USER_ERROR );
			}
		} else {

			# This allows us to call `register_extended_post_type()` on an existing post type to add custom functionality
			# to the post type.
			$this->extend( $existing );

		}

	}