private static String createImageStreamRequest(String name, String version, String image, boolean insecure) {
        JSONObject imageStream = new JSONObject();
        JSONObject metadata = new JSONObject();
        JSONObject annotations = new JSONObject();

        metadata.put("name", name);
        annotations.put("openshift.io/image.insecureRepository", insecure);
        metadata.put("annotations", annotations);

        // Definition of the image
        JSONObject from = new JSONObject();
        from.put("kind", "DockerImage");
        from.put("name", image);

        JSONObject importPolicy = new JSONObject();
        importPolicy.put("insecure", insecure);

        JSONObject tag = new JSONObject();
        tag.put("name", version);
        tag.put("from", from);
        tag.put("importPolicy", importPolicy);

        JSONObject tagAnnotations = new JSONObject();
        tagAnnotations.put("version", version);
        tag.put("annotations", tagAnnotations);

        JSONArray tags = new JSONArray();
        tags.add(tag);

        // Add image definition to image stream
        JSONObject spec = new JSONObject();
        spec.put("tags", tags);

        imageStream.put("kind", "ImageStream");
        imageStream.put("apiVersion", "v1");
        imageStream.put("metadata", metadata);
        imageStream.put("spec", spec);

        return imageStream.toJSONString();
    }
private static String createImageStreamRequest ( String name , String version , String image , boolean insecure ) { JSONObject imageStream = new JSONObject ( ) ; JSONObject metadata = new JSONObject ( ) ; JSONObject annotations = new JSONObject ( ) ; metadata . put ( "name" , name ) ; annotations . put ( "openshift.io/image.insecureRepository" , insecure ) ; metadata . put ( "annotations" , annotations ) ; JSONObject from = new JSONObject ( ) ; from . put ( "kind" , "DockerImage" ) ; from . put ( "name" , image ) ; JSONObject importPolicy = new JSONObject ( ) ; importPolicy . put ( "insecure" , insecure ) ; JSONObject tag = new JSONObject ( ) ; tag . put ( "name" , version ) ; tag . put ( "from" , from ) ; tag . put ( "importPolicy" , importPolicy ) ; JSONObject tagAnnotations = new JSONObject ( ) ; tagAnnotations . put ( "version" , version ) ; tag . put ( "annotations" , tagAnnotations ) ; JSONArray tags = new JSONArray ( ) ; tags . add ( tag ) ; JSONObject spec = new JSONObject ( ) ; spec . put ( "tags" , tags ) ; imageStream . put ( "kind" , "ImageStream" ) ; imageStream . put ( "apiVersion" , "v1" ) ; imageStream . put ( "metadata" , metadata ) ; imageStream . put ( "spec" , spec ) ; return imageStream . toJSONString ( ) ; }
Creates image stream request and returns it in JSON formatted string.

@param name     Name of the image stream
@param insecure If the registry where the image is stored is insecure
@param image    Image name, includes registry information and tag
@param version  Image stream version.
@return JSON formatted string