Create order

REST: POST /order/dedicated/nasha/new/{duration}
@param datacenter [required] Nas HA localization
@param model [required] Capacity of Nas HA offer
@param duration [required] Duration
481925
public OvhOrder dedicated_nasha_new_duration_POST(String duration, OvhNasHAZoneEnum datacenter, OvhNasHAOfferEnum model) throws IOException {
		String qPath = "/order/dedicated/nasha/new/{duration}";
		StringBuilder sb = path(qPath, duration);
		HashMap<String, Object>o = new HashMap<String, Object>();
		addBody(o, "datacenter", datacenter);
		addBody(o, "model", model);
		String resp = exec(qPath, "POST", sb.toString(), o);
		return convertTo(resp, OvhOrder.class);
	}
1317853
@Override
    public CompletableFuture<Void> initialize(Duration timeout) {
        Preconditions.checkState(!this.initialized.get(), "TableMetadataStore is already initialized.");

        // Invoke submitAssignment(), which will ensure that the Metadata Segment is mapped in memory and pinned.
        // If this is the first time we initialize the TableMetadataStore for this SegmentContainer, a new id will be
        // assigned to it.
        val attributes = TableAttributes.DEFAULT_VALUES
                .entrySet().stream()
                .map(e -> new AttributeUpdate(e.getKey(), AttributeUpdateType.None, e.getValue()))
                .collect(Collectors.toList());
        return submitAssignment(SegmentInfo.newSegment(this.metadataSegmentName, attributes), true, timeout)
                .thenAccept(segmentId -> {
                    this.initialized.set(true);
                    log.info("{}: Metadata Segment pinned. Name = '{}', Id = '{}'", this.metadataSegmentName, segmentId);
                });
    }
962833
private function createModel(array $model, $location)
    {
        $name = null;
        if (isset($model['id']) === true) {
            // if model id is set, us it as a name
            $name = trim($model['id']);
        } elseif (isset($model['nickname'], $this->responseClasses[$model['nickname']])) {
            // if custom response class is defined with model nickname, use nickname
            $name = $model['nickname'];
        } elseif (isset($model['type']) === true && $model['type'] === 'array') {
            // if model is of array type
            if (isset($model['items']['$ref']) === true) {
                // E. g. if it's an array of 'Tag' models, call this model 'TagList'.
                $name = $model['items']['$ref'].'List';
            } elseif (isset($model['nickname']) === true) {
                // Fallback generate name from operation nickname (e.g. getTags -> TagList)
                $found = preg_match('/[A-Z]/', $model['nickname'], $matches, PREG_OFFSET_CAPTURE);
                if ($found === 1) {
                    $name = rtrim(substr($model['nickname'], $matches[0][1]), 's').'List';
                }
            }
        }
        // if none of above worked to create a model name, hash model array
        if ($name === null) {
            $name = $model['id'] = 'anon_'.self::hashArray($model);
        }

        // a model is basically a parameter, but has name property added
        $defaults = [
            'name' => $name,
            'type' => 'object',
        ];
        /** @noinspection AdditionOperationOnArraysInspection */
        $data = $this->transformSchema($model + $defaults);
        if ('object' === $data['type']) {
            $data['additionalProperties'] = false;
            // model must have top level properties specified as serialized response type, but no response type itself
            foreach ($data['properties'] as $key => $property) {
                $data['properties'][$key]['location'] = $location;
            }
        } elseif ('array' === $data['type']) {
            $data['location'] = $location;
        }

        // allow result class override
        if (isset($this->responseClasses[$name])) {
            $class = $this->responseClasses[$name];
            $data['class'] = $class;

            if (is_subclass_of($class, ResultInterface::class)) {
                $data['type'] = 'object';
                if (is_array($data['additionalProperties']) === false) {
                    $data['additionalProperties'] = [];
                }
                $data['additionalProperties']['location'] = $location;
            } else {
                $data['type'] = 'class';
            }
        }

        // required makes no sense at root of model
        unset($data['required']);

        return new Parameter($data, ['description' => $this->getServiceDescription()]);
    }
638680
def create(name, region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    conn.create_topic(name)
    log.info('Created SNS topic %s', name)
    _invalidate_cache()
    return True
1196207
public OvhOrder router_new_duration_POST(String duration, String vrack) throws IOException {
		String qPath = "/order/router/new/{duration}";
		StringBuilder sb = path(qPath, duration);
		HashMap<String, Object>o = new HashMap<String, Object>();
		addBody(o, "vrack", vrack);
		String resp = exec(qPath, "POST", sb.toString(), o);
		return convertTo(resp, OvhOrder.class);
	}
626727
public void addMetadata( final Model model )
    {
        final Resource datasetId = model.createResource( getDatasetURI() );
        final Resource fragmentId = model.createResource( fragmentURL );

        datasetId.addProperty( CommonResources.RDF_TYPE, CommonResources.VOID_DATASET );
        datasetId.addProperty( CommonResources.RDF_TYPE, CommonResources.HYDRA_COLLECTION );
        datasetId.addProperty( CommonResources.VOID_SUBSET, fragmentId );
        
        Literal itemsPerPage = model.createTypedLiteral(this.getMaxPageSize());
        datasetId.addProperty( CommonResources.HYDRA_ITEMSPERPAGE, itemsPerPage);

        fragmentId.addProperty( CommonResources.RDF_TYPE, CommonResources.HYDRA_COLLECTION );
        fragmentId.addProperty( CommonResources.RDF_TYPE, CommonResources.HYDRA_PAGEDCOLLECTION );
    }
863512
public OvhOrder vps_serviceName_additionalDisk_duration_POST(String serviceName, String duration, OvhAdditionalDiskSizeEnum additionalDiskSize) throws IOException {
		String qPath = "/order/vps/{serviceName}/additionalDisk/{duration}";
		StringBuilder sb = path(qPath, serviceName, duration);
		HashMap<String, Object>o = new HashMap<String, Object>();
		addBody(o, "additionalDiskSize", additionalDiskSize);
		String resp = exec(qPath, "POST", sb.toString(), o);
		return convertTo(resp, OvhOrder.class);
	}
1243471
def create(gandi, name, vm, size, snapshotprofile, datacenter, source,
           background):
    
    try:
        gandi.datacenter.is_opened(datacenter, 'iaas')
    except DatacenterLimited as exc:
        gandi.echo('/!\ Datacenter %s will be closed on %s, '
                   'please consider using another datacenter.' %
                   (datacenter, exc.date))

    if vm:
        vm_dc = gandi.iaas.info(vm)
        vm_dc_id = vm_dc['datacenter_id']
        dc_id = int(gandi.datacenter.usable_id(datacenter))
        if vm_dc_id != dc_id:
            gandi.echo('/!\ VM %s datacenter will be used instead of %s.'
                       % (vm, datacenter))
        datacenter = vm_dc_id

    output_keys = ['id', 'type', 'step']
    name = name or randomstring('vdi')

    disk_type = 'data'
    oper = gandi.disk.create(name, vm, size, snapshotprofile, datacenter,
                             source, disk_type, background)

    if background:
        output_generic(gandi, oper, output_keys)

    return oper
1206538
def placeOrder(self, contract, order, orderId=None, account=None):
        

        # get latest order id before submitting an order
        self.requestOrderIds()

        # continue...
        useOrderId = self.orderId if orderId == None else orderId
        if account:
            order.m_account = account
        self.ibConn.placeOrder(useOrderId, contract, order)

        account_key = order.m_account
        self.orders[useOrderId] = {
            "id":       useOrderId,
            "symbol":   self.contractString(contract),
            "contract": contract,
            "status":   "SENT",
            "reason":   None,
            "avgFillPrice": 0.,
            "parentId": 0,
            "time": datetime.fromtimestamp(int(self.time)),
            "account": None
        }
        if hasattr(order, "m_account"):
            self.orders[useOrderId]["account"] = order.m_account

        # return order id
        return useOrderId
912221
public OvhOrder cdn_webstorage_serviceName_storage_duration_POST(String serviceName, String duration, OvhOrderStorageEnum storage) throws IOException {
		String qPath = "/order/cdn/webstorage/{serviceName}/storage/{duration}";
		StringBuilder sb = path(qPath, serviceName, duration);
		HashMap<String, Object>o = new HashMap<String, Object>();
		addBody(o, "storage", storage);
		String resp = exec(qPath, "POST", sb.toString(), o);
		return convertTo(resp, OvhOrder.class);
	}
578290
public void createTransaction(String scope, String streamName, Duration latency) {
        DYNAMIC_LOGGER.incCounterValue(globalMetricName(CREATE_TRANSACTION), 1);
        DYNAMIC_LOGGER.incCounterValue(CREATE_TRANSACTION, 1, streamTags(scope, streamName));
        createTransactionLatency.reportSuccessValue(latency.toMillis());
    }
793952
public void add(DnsQuery query, DnsResponse response) {
		assert eventloop.inEventloopThread() : "Concurrent cache adds are not allowed";
		long expirationTime = now.currentTimeMillis();
		if (response.isSuccessful()) {
			assert response.getRecord() != null; // where are my advanced contracts so that Intellj would know it's true here without an assert?
			long minTtl = response.getRecord().getMinTtl() * 1000;
			if (minTtl == 0) {
				return;
			}
			expirationTime += Math.min(minTtl, maxTtl);
		} else {
			expirationTime += response.getErrorCode() == ResponseErrorCode.TIMED_OUT ?
					timedOutExceptionTtl :
					errorCacheExpiration;
		}
		CachedDnsQueryResult cachedResult = new CachedDnsQueryResult(response, expirationTime);
		CachedDnsQueryResult old = cache.put(query, cachedResult);
		expirations.add(cachedResult);

		if (old != null) {
			old.response = null; // mark old cache response as refreshed (see performCleanup)
			logger.trace("Refreshed cache entry for {}", query);
		} else {
			logger.trace("Added cache entry for {}", query);
		}
	}
1160203
CompletableFuture<Void> initialize(Duration timeout) {
        TimeoutTimer timer = new TimeoutTimer(timeout);
        Preconditions.checkState(!this.index.isInitialized(), "SegmentAttributeIndex is already initialized.");
        String attributeSegmentName = StreamSegmentNameUtils.getAttributeSegmentName(this.segmentMetadata.getName());

        // Attempt to open the Attribute Segment; if it does not exist yet then create it.
        return Futures
                .exceptionallyComposeExpecting(
                        this.storage.openWrite(attributeSegmentName).thenAccept(this.handle::set),
                        ex -> ex instanceof StreamSegmentNotExistsException,
                        () -> this.storage.create(attributeSegmentName, this.config.getAttributeSegmentRollingPolicy(), timer.getRemaining()).thenAccept(this.handle::set))
                .thenComposeAsync(v -> this.index.initialize(timer.getRemaining()), this.executor)
                .thenRun(() -> log.debug("{}: Initialized.", this.traceObjectId))
                .exceptionally(this::handleIndexOperationException);
    }
1309552
public OvhOrder hosting_web_serviceName_cdn_duration_POST(String serviceName, String duration, OvhCdnOfferEnum offer) throws IOException {
		String qPath = "/order/hosting/web/{serviceName}/cdn/{duration}";
		StringBuilder sb = path(qPath, serviceName, duration);
		HashMap<String, Object>o = new HashMap<String, Object>();
		addBody(o, "offer", offer);
		String resp = exec(qPath, "POST", sb.toString(), o);
		return convertTo(resp, OvhOrder.class);
	}
1322185
def cli(env, **kwargs):
    

    mgr = SoftLayer.DedicatedHostManager(env.client)
    tables = []

    if not kwargs['flavor'] and not kwargs['datacenter']:
        options = mgr.get_create_options()

        # Datacenters
        dc_table = formatting.Table(['datacenter', 'value'])
        dc_table.sortby = 'value'
        for location in options['locations']:
            dc_table.add_row([location['name'], location['key']])
        tables.append(dc_table)

        dh_table = formatting.Table(['Dedicated Virtual Host Flavor(s)', 'value'])
        dh_table.sortby = 'value'
        for item in options['dedicated_host']:
            dh_table.add_row([item['name'], item['key']])
        tables.append(dh_table)
    else:
        if kwargs['flavor'] is None or kwargs['datacenter'] is None:
            raise exceptions.ArgumentError('Both a flavor and datacenter need '
                                           'to be passed as arguments '
                                           'ex. slcli dh create-options -d '
                                           'ams01 -f '
                                           '56_CORES_X_242_RAM_X_1_4_TB')
        router_opt = mgr.get_router_options(kwargs['datacenter'], kwargs['flavor'])
        br_table = formatting.Table(
            ['Available Backend Routers'])
        for router in router_opt:
            br_table.add_row([router['hostname']])
        tables.append(br_table)

    env.fout(formatting.listing(tables, separator='\n'))
318612
@RequestMapping(path = "", method = RequestMethod.POST)
    public ResponseEntity<Order> createOrder(@RequestBody OrderInfo orderInfo) {
        Order order = orderService.createOrder(orderInfo);
        if(order != null){
            return new ResponseEntity<Order>(order, HttpStatus.CREATED);
        }
        return new ResponseEntity<Order>(HttpStatus.BAD_REQUEST);
    }
558275
public void addServletModel(final ServletModel model) throws NamespaceException, ServletException {
		servletLock.writeLock().lock();
		try {
            associateBundle(model.getContextModel().getVirtualHosts(), model.getContextModel().getBundle());
            for (String virtualHost:resolveVirtualHosts(model)) {
                if (servlets.get(virtualHost) == null) {
                    servlets.put(virtualHost, new HashSet<>());
                }
                if (model.getServlet() != null && servlets.get(virtualHost).contains(model.getServlet())) {
                        throw new ServletException("servlet already registered with a different alias");
                }
                if (model.getAlias() != null) {
                        final String alias = getFullPath(model.getContextModel(), model.getAlias());
                        if (aliasMapping.get(virtualHost) == null) {
                            aliasMapping.put(virtualHost, new HashMap<>());
                        }
                        if (aliasMapping.get(virtualHost).containsKey(alias)) {
                                throw new NamespaceException("alias: '" + alias + "' is already in use in this or another context");
                        }
                        aliasMapping.get(virtualHost).put(alias, model);
                }
                if (model.getServlet() != null) {
                        servlets.get(virtualHost).add(model.getServlet());
                }
                for (String urlPattern : model.getUrlPatterns()) {
                        if (servletUrlPatterns.get(virtualHost) == null) {
                            servletUrlPatterns.put(virtualHost, new HashMap<>());
                        }
                        servletUrlPatterns.get(virtualHost).put(getFullPath(model.getContextModel(), urlPattern),
                                        new UrlPattern(getFullPath(model.getContextModel(), urlPattern), model));
                }
            }
		} finally {
			servletLock.writeLock().unlock();
		}
	}