"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PortfoliosApi = exports.PortfoliosApiApiKeys = void 0;
/**
 * LUSID API
 * # Introduction  This page documents the [LUSID APIs](https://www.lusid.com/api/swagger), which allows authorised clients to query and update their data within the LUSID platform.  SDKs to interact with the LUSID APIs are available in the following languages :  * [C#](https://github.com/finbourne/lusid-sdk-csharp) * [Java](https://github.com/finbourne/lusid-sdk-java) * [JavaScript](https://github.com/finbourne/lusid-sdk-js) * [Python](https://github.com/finbourne/lusid-sdk-python)  # Data Model  The LUSID API has a relatively lightweight but extremely powerful data model. One of the goals of LUSID was not to enforce on clients a single rigid data model but rather to provide a flexible foundation onto which clients can map their own data models.  The core entities in LUSID provide a minimal structure and set of relationships, and the data model can be extended using Properties.  The LUSID data model is exposed through the LUSID APIs.  The APIs provide access to both business objects and the meta data used to configure the systems behaviours.   The key business entities are: - * **Portfolios** A portfolio is a container for transactions and holdings (a **Transaction Portfolio**) or constituents (a **Reference Portfolio**). * **Derived Portfolios**. Derived Portfolios allow Portfolios to be created based on other Portfolios, by overriding or adding specific items. * **Holdings** A Holding is a quantity of an Instrument or a balance of cash within a Portfolio.  Holdings can only be adjusted via Transactions. * **Transactions** A Transaction is an economic event that occurs in a Portfolio, causing its holdings to change. * **Corporate Actions** A corporate action is a market event which occurs to an Instrument and thus applies to all portfolios which holding the instrument.  Examples are stock splits or mergers. * **Constituents** A constituent is a record in a Reference Portfolio containing an Instrument and an associated weight. * **Instruments**  An instrument represents a currency, tradable instrument or OTC contract that is attached to a transaction and a holding. * **Properties** All major entities allow additional user defined properties to be associated with them.   For example, a Portfolio manager may be associated with a portfolio.  Meta data includes: - * **Transaction Types** Transactions are booked with a specific transaction type.  The types are client defined and are used to map the Transaction to a series of movements which update the portfolio holdings.  * **Properties Types** Types of user defined properties used within the system.  ## Scope  All data in LUSID is segregated at the client level.  Entities in LUSID are identifiable by a unique code.  Every entity lives within a logical data partition known as a Scope.  Scope is an identity namespace allowing two entities with the same unique code to co-exist within individual address spaces.  For example, prices for equities from different vendors may be uploaded into different scopes such as `client/vendor1` and `client/vendor2`.  A portfolio may then be valued using either of the price sources by referencing the appropriate scope.  LUSID Clients cannot access scopes of other clients.  ## Instruments  LUSID has its own built-in instrument master which you can use to master your own instrument universe.  Every instrument must be created with one or more unique market identifiers, such as [FIGI](https://openfigi.com/). For any non-listed instruments (eg OTCs), you can upload an instrument against a custom ID of your choosing.  In addition, LUSID will allocate each instrument a unique \'LUSID instrument identifier\'. The LUSID instrument identifier is what is used when uploading transactions, holdings, prices, etc. The API exposes an `instrument/lookup` endpoint which can be used to lookup these LUSID identifiers using their market identifiers.  Cash can be referenced using the ISO currency code prefixed with \"`CCY_`\" e.g. `CCY_GBP`  ## Instrument Data  Instrument data can be uploaded to the system using the [Instrument Properties](#tag/InstrumentProperties) endpoint.  | Field|Type|Description | | ---|---|--- | | Key|propertykey|The key of the property. This takes the format {domain}/{scope}/{code} e.g. \'Instrument/system/Name\' or \'Transaction/strategy/quantsignal\'. | | Value|string|The value of the property. | | EffectiveFrom|datetimeoffset|The effective datetime from which the property is valid. |   ## Transaction Portfolios  Portfolios are the top-level entity containers within LUSID, containing transactions, corporate actions and holdings.    The transactions build up the portfolio holdings on which valuations, analytics profit & loss and risk can be calculated.  Properties can be associated with Portfolios to add in additional data.  Portfolio properties can be changed over time, for example to allow a Portfolio Manager to be linked with a Portfolio.  Additionally, portfolios can be securitised and held by other portfolios, allowing LUSID to perform \"drill-through\" into underlying fund holdings  ### Derived Portfolios  LUSID also allows for a portfolio to be composed of another portfolio via derived portfolios.  A derived portfolio can contain its own transactions and also inherits any transactions from its parent portfolio.  Any changes made to the parent portfolio are automatically reflected in derived portfolio.  Derived portfolios in conjunction with scopes are a powerful construct.  For example, to do pre-trade what-if analysis, a derived portfolio could be created a new namespace linked to the underlying live (parent) portfolio.  Analysis can then be undertaken on the derived portfolio without affecting the live portfolio.  ### Transactions  A transaction represents an economic activity against a Portfolio.  Transactions are processed according to a configuration. This will tell the LUSID engine how to interpret the transaction and correctly update the holdings. LUSID comes with a set of transaction types you can use out of the box, or you can configure your own set(s) of transactions.  For more details see the [LUSID Getting Started Guide for transaction configuration.](https://support.lusid.com/configuring-transaction-types)  | Field|Type|Description | | ---|---|--- | | TransactionId|string|The unique identifier for the transaction. | | Type|string|The type of the transaction e.g. \'Buy\', \'Sell\'. The transaction type should have been pre-configured via the System Configuration API endpoint. If it hasn\'t been pre-configured the transaction will still be updated or inserted however you will be unable to generate the resultant holdings for the portfolio that contains this transaction as LUSID does not know how to process it. | | InstrumentIdentifiers|map|A set of instrument identifiers to use to resolve the transaction to a unique instrument. | | TransactionDate|dateorcutlabel|The date of the transaction. | | SettlementDate|dateorcutlabel|The settlement date of the transaction. | | Units|decimal|The number of units transacted in the associated instrument. | | TransactionPrice|transactionprice|The price for each unit of the transacted instrument in the transaction currency. | | TotalConsideration|currencyandamount|The total value of the transaction in the settlement currency. | | ExchangeRate|decimal|The exchange rate between the transaction and settlement currency. For example if the transaction currency is in USD and the settlement currency is in GBP this this the USD/GBP rate. | | TransactionCurrency|currency|The transaction currency. | | Properties|map|Set of unique transaction properties and associated values to store with the transaction. Each property must be from the \'Transaction\' domain. | | CounterpartyId|string|The identifier for the counterparty of the transaction. | | Source|string|The source of the transaction. This is used to look up the appropriate transaction group set in the transaction type configuration. |   From these fields, the following values can be calculated  * **Transaction value in Transaction currency**: TotalConsideration / ExchangeRate  * **Transaction value in Portfolio currency**: Transaction value in Transaction currency * TradeToPortfolioRate  #### Example Transactions  ##### A Common Purchase Example Three example transactions are shown in the table below.   They represent a purchase of USD denominated IBM shares within a Sterling denominated portfolio.   * The first two transactions are for separate buy and fx trades    * Buying 500 IBM shares for $71,480.00    * A spot foreign exchange conversion to fund the IBM purchase. (Buy $71,480.00 for &#163;54,846.60)  * The third transaction is an alternate version of the above trades. Buying 500 IBM shares and settling directly in Sterling.  | Column |  Buy Trade | Fx Trade | Buy Trade with foreign Settlement | | ----- | ----- | ----- | ----- | | TransactionId | FBN00001 | FBN00002 | FBN00003 | | Type | Buy | FxBuy | Buy | | InstrumentIdentifiers | { \"figi\", \"BBG000BLNNH6\" } | { \"CCY\", \"CCY_USD\" } | { \"figi\", \"BBG000BLNNH6\" } | | TransactionDate | 2018-08-02 | 2018-08-02 | 2018-08-02 | | SettlementDate | 2018-08-06 | 2018-08-06 | 2018-08-06 | | Units | 500 | 71480 | 500 | | TransactionPrice | 142.96 | 1 | 142.96 | | TradeCurrency | USD | USD | USD | | ExchangeRate | 1 | 0.7673 | 0.7673 | | TotalConsideration.Amount | 71480.00 | 54846.60 | 54846.60 | | TotalConsideration.Currency | USD | GBP | GBP | | Trade/default/TradeToPortfolioRate&ast; | 0.7673 | 0.7673 | 0.7673 |  [&ast; This is a property field]  ##### A Forward FX Example  LUSID has a flexible transaction modelling system, meaning there are a number of different ways of modelling forward fx trades.  The default LUSID transaction types are FwdFxBuy and FwdFxSell. Using these transaction types, LUSID will generate two holdings for each Forward FX trade, one for each currency in the trade.  An example Forward Fx trade to sell GBP for USD in a JPY-denominated portfolio is shown below:  | Column | Forward \'Sell\' Trade | Notes | | ----- | ----- | ---- | | TransactionId | FBN00004 | | | Type | FwdFxSell | | | InstrumentIdentifiers | { \"Instrument/default/Currency\", \"GBP\" } | | | TransactionDate | 2018-08-02 | | | SettlementDate | 2019-02-06 | Six month forward | | Units | 10000.00 | Units of GBP | | TransactionPrice | 1 | | | TradeCurrency | GBP | Currency being sold | | ExchangeRate | 1.3142 | Agreed rate between GBP and USD | | TotalConsideration.Amount | 13142.00 | Amount in the settlement currency, USD | | TotalConsideration.Currency | USD | Settlement currency | | Trade/default/TradeToPortfolioRate | 142.88 | Rate between trade currency, GBP and portfolio base currency, JPY |  Please note that exactly the same economic behaviour could be modelled using the FwdFxBuy Transaction Type with the amounts and rates reversed.  ### Holdings  A holding represents a position in an instrument or cash on a given date.  | Field|Type|Description | | ---|---|--- | | InstrumentUid|string|The unqiue Lusid Instrument Id (LUID) of the instrument that the holding is in. | | SubHoldingKeys|map|The sub-holding properties which identify the holding. Each property will be from the \'Transaction\' domain. These are configured when a transaction portfolio is created. | | Properties|map|The properties which have been requested to be decorated onto the holding. These will be from the \'Instrument\' or \'Holding\' domain. | | HoldingType|string|The type of the holding e.g. Position, Balance, CashCommitment, Receivable, ForwardFX etc. | | Units|decimal|The total number of units of the holding. | | SettledUnits|decimal|The total number of settled units of the holding. | | Cost|currencyandamount|The total cost of the holding in the transaction currency. | | CostPortfolioCcy|currencyandamount|The total cost of the holding in the portfolio currency. | | Transaction|transaction|The transaction associated with an unsettled holding. |   ## Corporate Actions  Corporate actions are represented within LUSID in terms of a set of instrument-specific \'transitions\'.  These transitions are used to specify the participants of the corporate action, and the effect that the corporate action will have on holdings in those participants.  ### Corporate Action  | Field|Type|Description | | ---|---|--- | | CorporateActionCode|code|The unique identifier of this corporate action | | Description|string|  | | AnnouncementDate|datetimeoffset|The announcement date of the corporate action | | ExDate|datetimeoffset|The ex date of the corporate action | | RecordDate|datetimeoffset|The record date of the corporate action | | PaymentDate|datetimeoffset|The payment date of the corporate action | | Transitions|corporateactiontransition[]|The transitions that result from this corporate action |   ### Transition | Field|Type|Description | | ---|---|--- | | InputTransition|corporateactiontransitioncomponent|Indicating the basis of the corporate action - which security and how many units | | OutputTransitions|corporateactiontransitioncomponent[]|What will be generated relative to the input transition |   ### Example Corporate Action Transitions  #### A Dividend Action Transition  In this example, for each share of IBM, 0.20 units (or 20 pence) of GBP are generated.  | Column |  Input Transition | Output Transition | | ----- | ----- | ----- | | Instrument Identifiers | { \"figi\" : \"BBG000BLNNH6\" } | { \"ccy\" : \"CCY_GBP\" } | | Units Factor | 1 | 0.20 | | Cost Factor | 1 | 0 |  #### A Split Action Transition  In this example, for each share of IBM, we end up with 2 units (2 shares) of IBM, with total value unchanged.  | Column |  Input Transition | Output Transition | | ----- | ----- | ----- | | Instrument Identifiers | { \"figi\" : \"BBG000BLNNH6\" } | { \"figi\" : \"BBG000BLNNH6\" } | | Units Factor | 1 | 2 | | Cost Factor | 1 | 1 |  #### A Spinoff Action Transition  In this example, for each share of IBM, we end up with 1 unit (1 share) of IBM and 3 units (3 shares) of Celestica, with 85% of the value remaining on the IBM share, and 5% in each Celestica share (15% total).  | Column |  Input Transition | Output Transition 1 | Output Transition 2 | | ----- | ----- | ----- | ----- | | Instrument Identifiers | { \"figi\" : \"BBG000BLNNH6\" } | { \"figi\" : \"BBG000BLNNH6\" } | { \"figi\" : \"BBG000HBGRF3\" } | | Units Factor | 1 | 1 | 3 | | Cost Factor | 1 | 0.85 | 0.15 |  ## Reference Portfolios Reference portfolios are portfolios that contain constituents with weights.  They are designed to represent entities such as indices and benchmarks.  ### Constituents | Field|Type|Description | | ---|---|--- | | InstrumentIdentifiers|map|Unique instrument identifiers | | InstrumentUid|string|LUSID\'s internal unique instrument identifier, resolved from the instrument identifiers | | Currency|decimal|  | | Weight|decimal|  | | FloatingWeight|decimal|  |   ## Portfolio Groups Portfolio groups allow the construction of a hierarchy from portfolios and groups.  Portfolio operations on the group are executed on an aggregated set of portfolios in the hierarchy.   For example:   * Global Portfolios _(group)_   * APAC _(group)_     * Hong Kong _(portfolio)_     * Japan _(portfolio)_   * Europe _(group)_     * France _(portfolio)_     * Germany _(portfolio)_   * UK _(portfolio)_   In this example **Global Portfolios** is a group that consists of an aggregate of **Hong Kong**, **Japan**, **France**, **Germany** and **UK** portfolios.  ## Properties  Properties are key-value pairs that can be applied to any entity within a domain (where a domain is `trade`, `portfolio`, `security` etc).  Properties must be defined before use with a `PropertyDefinition` and can then subsequently be added to entities.   ## Schema  A detailed description of the entities used by the API and parameters for endpoints which take a JSON document can be retrieved via the `schema` endpoint.  ## Meta data  The following headers are returned on all responses from LUSID  | Name | Purpose | | --- | --- | | lusid-meta-duration | Duration of the request | | lusid-meta-success | Whether or not LUSID considered the request to be successful | | lusid-meta-requestId | The unique identifier for the request | | lusid-schema-url | Url of the schema for the data being returned | | lusid-property-schema-url | Url of the schema for any properties |   # Error Codes  | Code|Name|Description | | ---|---|--- | | <a name=\"-10\">-10</a>|Server Configuration Error|  | | <a name=\"-1\">-1</a>|Unknown error|An unexpected error was encountered on our side. | | <a name=\"102\">102</a>|Version Not Found|  | | <a name=\"103\">103</a>|Api Rate Limit Violation|  | | <a name=\"104\">104</a>|Instrument Not Found|  | | <a name=\"105\">105</a>|Property Not Found|  | | <a name=\"106\">106</a>|Portfolio Recursion Depth|  | | <a name=\"108\">108</a>|Group Not Found|  | | <a name=\"109\">109</a>|Portfolio Not Found|  | | <a name=\"110\">110</a>|Property Schema Not Found|  | | <a name=\"111\">111</a>|Portfolio Ancestry Not Found|  | | <a name=\"112\">112</a>|Portfolio With Id Already Exists|  | | <a name=\"113\">113</a>|Orphaned Portfolio|  | | <a name=\"119\">119</a>|Missing Base Claims|  | | <a name=\"121\">121</a>|Property Not Defined|  | | <a name=\"122\">122</a>|Cannot Delete System Property|  | | <a name=\"123\">123</a>|Cannot Modify Immutable Property Field|  | | <a name=\"124\">124</a>|Property Already Exists|  | | <a name=\"125\">125</a>|Invalid Property Life Time|  | | <a name=\"126\">126</a>|Property Constraint Style Excludes Properties|  | | <a name=\"127\">127</a>|Cannot Modify Default Data Type|  | | <a name=\"128\">128</a>|Group Already Exists|  | | <a name=\"129\">129</a>|No Such Data Type|  | | <a name=\"130\">130</a>|Undefined Value For Data Type|  | | <a name=\"131\">131</a>|Unsupported Value Type Defined On Data Type|  | | <a name=\"132\">132</a>|Validation Error|  | | <a name=\"133\">133</a>|Loop Detected In Group Hierarchy|  | | <a name=\"134\">134</a>|Undefined Acceptable Values|  | | <a name=\"135\">135</a>|Sub Group Already Exists|  | | <a name=\"138\">138</a>|Price Source Not Found|  | | <a name=\"139\">139</a>|Analytic Store Not Found|  | | <a name=\"141\">141</a>|Analytic Store Already Exists|  | | <a name=\"143\">143</a>|Client Instrument Already Exists|  | | <a name=\"144\">144</a>|Duplicate In Parameter Set|  | | <a name=\"147\">147</a>|Results Not Found|  | | <a name=\"148\">148</a>|Order Field Not In Result Set|  | | <a name=\"149\">149</a>|Operation Failed|  | | <a name=\"150\">150</a>|Elastic Search Error|  | | <a name=\"151\">151</a>|Invalid Parameter Value|  | | <a name=\"153\">153</a>|Command Processing Failure|  | | <a name=\"154\">154</a>|Entity State Construction Failure|  | | <a name=\"155\">155</a>|Entity Timeline Does Not Exist|  | | <a name=\"156\">156</a>|Event Publish Failure|  | | <a name=\"157\">157</a>|Invalid Request|  | | <a name=\"158\">158</a>|Event Publish Unknown|  | | <a name=\"159\">159</a>|Event Query Failure|  | | <a name=\"160\">160</a>|Blob Did Not Exist|  | | <a name=\"162\">162</a>|Sub System Request Failure|  | | <a name=\"163\">163</a>|Sub System Configuration Failure|  | | <a name=\"165\">165</a>|Failed To Delete|  | | <a name=\"166\">166</a>|Upsert Client Instrument Failure|  | | <a name=\"167\">167</a>|Illegal As At Interval|  | | <a name=\"168\">168</a>|Illegal Bitemporal Query|  | | <a name=\"169\">169</a>|Invalid Alternate Id|  | | <a name=\"170\">170</a>|Cannot Add Source Portfolio Property Explicitly|  | | <a name=\"171\">171</a>|Entity Already Exists In Group|  | | <a name=\"173\">173</a>|Entity With Id Already Exists|  | | <a name=\"174\">174</a>|Derived Portfolio Details Do Not Exist|  | | <a name=\"176\">176</a>|Portfolio With Name Already Exists|  | | <a name=\"177\">177</a>|Invalid Transactions|  | | <a name=\"178\">178</a>|Reference Portfolio Not Found|  | | <a name=\"179\">179</a>|Duplicate Id|  | | <a name=\"180\">180</a>|Command Retrieval Failure|  | | <a name=\"181\">181</a>|Data Filter Application Failure|  | | <a name=\"182\">182</a>|Search Failed|  | | <a name=\"183\">183</a>|Movements Engine Configuration Key Failure|  | | <a name=\"184\">184</a>|Fx Rate Source Not Found|  | | <a name=\"185\">185</a>|Accrual Source Not Found|  | | <a name=\"186\">186</a>|Access Denied|  | | <a name=\"187\">187</a>|Invalid Identity Token|  | | <a name=\"188\">188</a>|Invalid Request Headers|  | | <a name=\"189\">189</a>|Price Not Found|  | | <a name=\"190\">190</a>|Invalid Sub Holding Keys Provided|  | | <a name=\"191\">191</a>|Duplicate Sub Holding Keys Provided|  | | <a name=\"192\">192</a>|Cut Definition Not Found|  | | <a name=\"193\">193</a>|Cut Definition Invalid|  | | <a name=\"194\">194</a>|Time Variant Property Deletion Date Unspecified|  | | <a name=\"195\">195</a>|Perpetual Property Deletion Date Specified|  | | <a name=\"196\">196</a>|Time Variant Property Upsert Date Unspecified|  | | <a name=\"197\">197</a>|Perpetual Property Upsert Date Specified|  | | <a name=\"200\">200</a>|Invalid Unit For Data Type|  | | <a name=\"201\">201</a>|Invalid Type For Data Type|  | | <a name=\"202\">202</a>|Invalid Value For Data Type|  | | <a name=\"203\">203</a>|Unit Not Defined For Data Type|  | | <a name=\"204\">204</a>|Units Not Supported On Data Type|  | | <a name=\"205\">205</a>|Cannot Specify Units On Data Type|  | | <a name=\"206\">206</a>|Unit Schema Inconsistent With Data Type|  | | <a name=\"207\">207</a>|Unit Definition Not Specified|  | | <a name=\"208\">208</a>|Duplicate Unit Definitions Specified|  | | <a name=\"209\">209</a>|Invalid Units Definition|  | | <a name=\"210\">210</a>|Invalid Instrument Identifier Unit|  | | <a name=\"211\">211</a>|Holdings Adjustment Does Not Exist|  | | <a name=\"212\">212</a>|Could Not Build Excel Url|  | | <a name=\"213\">213</a>|Could Not Get Excel Version|  | | <a name=\"214\">214</a>|Instrument By Code Not Found|  | | <a name=\"215\">215</a>|Entity Schema Does Not Exist|  | | <a name=\"216\">216</a>|Feature Not Supported On Portfolio Type|  | | <a name=\"217\">217</a>|Quote Not Found|  | | <a name=\"218\">218</a>|Invalid Quote Identifier|  | | <a name=\"219\">219</a>|Invalid Metric For Data Type|  | | <a name=\"220\">220</a>|Invalid Instrument Definition|  | | <a name=\"221\">221</a>|Instrument Upsert Failure|  | | <a name=\"222\">222</a>|Reference Portfolio Request Not Supported|  | | <a name=\"223\">223</a>|Transaction Portfolio Request Not Supported|  | | <a name=\"224\">224</a>|Invalid Property Value Assignment|  | | <a name=\"230\">230</a>|Transaction Type Not Found|  | | <a name=\"231\">231</a>|Transaction Type Duplication|  | | <a name=\"232\">232</a>|Portfolio Does Not Exist At Given Date|  | | <a name=\"233\">233</a>|Query Parser Failure|  | | <a name=\"234\">234</a>|Duplicate Constituent|  | | <a name=\"235\">235</a>|Unresolved Instrument Constituent|  | | <a name=\"236\">236</a>|Unresolved Instrument In Transition|  | | <a name=\"237\">237</a>|Missing Side Definitions|  | | <a name=\"299\">299</a>|Invalid Recipe|  | | <a name=\"300\">300</a>|Missing Recipe|  | | <a name=\"301\">301</a>|Dependencies|  | | <a name=\"304\">304</a>|Portfolio Preprocess Failure|  | | <a name=\"310\">310</a>|Valuation Engine Failure|  | | <a name=\"311\">311</a>|Task Factory Failure|  | | <a name=\"312\">312</a>|Task Evaluation Failure|  | | <a name=\"313\">313</a>|Task Generation Failure|  | | <a name=\"314\">314</a>|Engine Configuration Failure|  | | <a name=\"315\">315</a>|Model Specification Failure|  | | <a name=\"320\">320</a>|Market Data Key Failure|  | | <a name=\"321\">321</a>|Market Resolver Failure|  | | <a name=\"322\">322</a>|Market Data Failure|  | | <a name=\"330\">330</a>|Curve Failure|  | | <a name=\"331\">331</a>|Volatility Surface Failure|  | | <a name=\"332\">332</a>|Volatility Cube Failure|  | | <a name=\"350\">350</a>|Instrument Failure|  | | <a name=\"351\">351</a>|Cash Flows Failure|  | | <a name=\"352\">352</a>|Reference Data Failure|  | | <a name=\"360\">360</a>|Aggregation Failure|  | | <a name=\"361\">361</a>|Aggregation Measure Failure|  | | <a name=\"370\">370</a>|Result Retrieval Failure|  | | <a name=\"371\">371</a>|Result Processing Failure|  | | <a name=\"372\">372</a>|Vendor Result Processing Failure|  | | <a name=\"373\">373</a>|Vendor Result Mapping Failure|  | | <a name=\"374\">374</a>|Vendor Library Unauthorised|  | | <a name=\"375\">375</a>|Vendor Connectivity Error|  | | <a name=\"376\">376</a>|Vendor Interface Error|  | | <a name=\"377\">377</a>|Vendor Pricing Failure|  | | <a name=\"378\">378</a>|Vendor Translation Failure|  | | <a name=\"379\">379</a>|Vendor Key Mapping Failure|  | | <a name=\"380\">380</a>|Vendor Reflection Failure|  | | <a name=\"390\">390</a>|Attempt To Upsert Duplicate Quotes|  | | <a name=\"391\">391</a>|Corporate Action Source Does Not Exist|  | | <a name=\"392\">392</a>|Corporate Action Source Already Exists|  | | <a name=\"393\">393</a>|Instrument Identifier Already In Use|  | | <a name=\"394\">394</a>|Properties Not Found|  | | <a name=\"395\">395</a>|Batch Operation Aborted|  | | <a name=\"400\">400</a>|Invalid Iso4217 Currency Code|  | | <a name=\"401\">401</a>|Cannot Assign Instrument Identifier To Currency|  | | <a name=\"402\">402</a>|Cannot Assign Currency Identifier To Non Currency|  | | <a name=\"403\">403</a>|Currency Instrument Cannot Be Deleted|  | | <a name=\"404\">404</a>|Currency Instrument Cannot Have Economic Definition|  | | <a name=\"405\">405</a>|Currency Instrument Cannot Have Lookthrough Portfolio|  | | <a name=\"406\">406</a>|Cannot Create Currency Instrument With Multiple Identifiers|  | | <a name=\"407\">407</a>|Specified Currency Is Undefined|  | | <a name=\"410\">410</a>|Index Does Not Exist|  | | <a name=\"411\">411</a>|Sort Field Does Not Exist|  | | <a name=\"413\">413</a>|Negative Pagination Parameters|  | | <a name=\"414\">414</a>|Invalid Search Syntax|  | | <a name=\"415\">415</a>|Filter Execution Timeout|  | | <a name=\"420\">420</a>|Side Definition Inconsistent|  | | <a name=\"450\">450</a>|Invalid Quote Access Metadata Rule|  | | <a name=\"451\">451</a>|Access Metadata Not Found|  | | <a name=\"452\">452</a>|Invalid Access Metadata Identifier|  | | <a name=\"460\">460</a>|Standard Resource Not Found|  | | <a name=\"461\">461</a>|Standard Resource Conflict|  | | <a name=\"601\">601</a>|Person Identifier Already In Use|  | | <a name=\"602\">602</a>|Person Not Found|  | | <a name=\"603\">603</a>|Cannot Set Identifier|  | | <a name=\"617\">617</a>|Invalid Recipe Specification In Request|  | | <a name=\"618\">618</a>|Inline Recipe Deserialisation Failure|  | | <a name=\"619\">619</a>|Identifier Types Not Set For Entity Object|  | | <a name=\"620\">620</a>|Cannot Delete All Client Defined Identifiers|  | | <a name=\"650\">650</a>|The Order requested was not found.|  | | <a name=\"654\">654</a>|The Allocation requested was not found.|  | | <a name=\"655\">655</a>|Cannot build the fx forward target with the given holdings.|  | | <a name=\"656\">656</a>|Group does not contain expected entities.|  | | <a name=\"667\">667</a>|Relation definition already exists|  | | <a name=\"673\">673</a>|Missing entitlements for entities in Group|  |
 *
 * The version of the OpenAPI document: 0.10.1437
 * Contact: info@finbourne.com
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */
var localVarRequest = require("request");
var models_1 = require("../model/models");
var models_2 = require("../model/models");
var defaultBasePath = 'http://localhost/api';
// ===============================================
// This file is autogenerated - Please do not edit
// ===============================================
var PortfoliosApiApiKeys;
(function (PortfoliosApiApiKeys) {
})(PortfoliosApiApiKeys = exports.PortfoliosApiApiKeys || (exports.PortfoliosApiApiKeys = {}));
var PortfoliosApi = /** @class */ (function () {
    function PortfoliosApi(basePathOrUsername, password, basePath) {
        this._basePath = defaultBasePath;
        this.defaultHeaders = {};
        this._useQuerystring = false;
        this.authentications = {
            'default': new models_1.VoidAuth(),
            'oauth2': new models_2.OAuth(),
        };
        if (password) {
            if (basePath) {
                this.basePath = basePath;
            }
        }
        else {
            if (basePathOrUsername) {
                this.basePath = basePathOrUsername;
            }
        }
    }
    Object.defineProperty(PortfoliosApi.prototype, "useQuerystring", {
        set: function (value) {
            this._useQuerystring = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PortfoliosApi.prototype, "basePath", {
        get: function () {
            return this._basePath;
        },
        set: function (basePath) {
            this._basePath = basePath;
        },
        enumerable: false,
        configurable: true
    });
    PortfoliosApi.prototype.setDefaultAuthentication = function (auth) {
        this.authentications.default = auth;
    };
    PortfoliosApi.prototype.setApiKey = function (key, value) {
        this.authentications[PortfoliosApiApiKeys[key]].apiKey = value;
    };
    Object.defineProperty(PortfoliosApi.prototype, "accessToken", {
        set: function (token) {
            this.authentications.oauth2.accessToken = token;
        },
        enumerable: false,
        configurable: true
    });
    /**
     * Delete the Portfolio Access Metadata Rule that exactly matches the provided identifier parts
     * @summary [EXPERIMENTAL] Delete a Portfolio Access Metadata Rule
     * @param scope The scope of the Quote Access Metadata Rule to retrieve.
     * @param code Portfolio code
     * @param metadataKey The metadataKey identifying the access metadata entry to delete
     * @param effectiveAt The effective date to delete at, if this is not supplied, it will delete all data found
     */
    PortfoliosApi.prototype.deleteKeyFromPortfolioAccessMetadata = function (scope, code, metadataKey, effectiveAt, options) {
        if (options === void 0) { options = { headers: {} }; }
        return __awaiter(this, void 0, void 0, function () {
            var localVarPath, localVarQueryParameters, localVarHeaderParams, localVarFormParams, localVarUseFormData, localVarRequestOptions;
            return __generator(this, function (_a) {
                localVarPath = this.basePath + '/api/portfolios/{scope}/{code}/metadata/{metadataKey}'
                    .replace('{' + 'scope' + '}', encodeURIComponent(String(scope)))
                    .replace('{' + 'code' + '}', encodeURIComponent(String(code)))
                    .replace('{' + 'metadataKey' + '}', encodeURIComponent(String(metadataKey)));
                localVarQueryParameters = {};
                localVarHeaderParams = Object.assign({}, this.defaultHeaders);
                localVarFormParams = {};
                // verify required parameter 'scope' is not null or undefined
                if (scope === null || scope === undefined) {
                    throw new Error('Required parameter scope was null or undefined when calling deleteKeyFromPortfolioAccessMetadata.');
                }
                // verify required parameter 'code' is not null or undefined
                if (code === null || code === undefined) {
                    throw new Error('Required parameter code was null or undefined when calling deleteKeyFromPortfolioAccessMetadata.');
                }
                // verify required parameter 'metadataKey' is not null or undefined
                if (metadataKey === null || metadataKey === undefined) {
                    throw new Error('Required parameter metadataKey was null or undefined when calling deleteKeyFromPortfolioAccessMetadata.');
                }
                if (effectiveAt !== undefined) {
                    localVarQueryParameters['effectiveAt'] = models_1.ObjectSerializer.serialize(effectiveAt, "string");
                }
                Object.assign(localVarHeaderParams, options.headers);
                localVarUseFormData = false;
                localVarRequestOptions = {
                    method: 'DELETE',
                    qs: localVarQueryParameters,
                    headers: localVarHeaderParams,
                    uri: localVarPath,
                    useQuerystring: this._useQuerystring,
                    json: true,
                };
                this.authentications.oauth2.applyToRequest(localVarRequestOptions);
                this.authentications.default.applyToRequest(localVarRequestOptions);
                if (Object.keys(localVarFormParams).length) {
                    if (localVarUseFormData) {
                        localVarRequestOptions.formData = localVarFormParams;
                    }
                    else {
                        localVarRequestOptions.form = localVarFormParams;
                    }
                }
                return [2 /*return*/, new Promise(function (resolve, reject) {
                        localVarRequest(localVarRequestOptions, function (error, response, body) {
                            if (error) {
                                reject(error);
                            }
                            else {
                                body = models_1.ObjectSerializer.deserialize(body, "DeletedEntityResponse");
                                if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                                    resolve({ response: response, body: body });
                                }
                                else {
                                    reject({ response: response, body: body });
                                }
                            }
                        });
                    })];
            });
        });
    };
    /**
     * Delete a single portfolio. The deletion of the portfolio will be valid from the portfolio\'s creation datetime. This means that the portfolio will no longer exist at any effective datetime from the asAt datetime of deletion.
     * @summary Delete portfolio
     * @param scope The scope of the portfolio.
     * @param code The code of the portfolio.
     */
    PortfoliosApi.prototype.deletePortfolio = function (scope, code, options) {
        if (options === void 0) { options = { headers: {} }; }
        return __awaiter(this, void 0, void 0, function () {
            var localVarPath, localVarQueryParameters, localVarHeaderParams, localVarFormParams, localVarUseFormData, localVarRequestOptions;
            return __generator(this, function (_a) {
                localVarPath = this.basePath + '/api/portfolios/{scope}/{code}'
                    .replace('{' + 'scope' + '}', encodeURIComponent(String(scope)))
                    .replace('{' + 'code' + '}', encodeURIComponent(String(code)));
                localVarQueryParameters = {};
                localVarHeaderParams = Object.assign({}, this.defaultHeaders);
                localVarFormParams = {};
                // verify required parameter 'scope' is not null or undefined
                if (scope === null || scope === undefined) {
                    throw new Error('Required parameter scope was null or undefined when calling deletePortfolio.');
                }
                // verify required parameter 'code' is not null or undefined
                if (code === null || code === undefined) {
                    throw new Error('Required parameter code was null or undefined when calling deletePortfolio.');
                }
                Object.assign(localVarHeaderParams, options.headers);
                localVarUseFormData = false;
                localVarRequestOptions = {
                    method: 'DELETE',
                    qs: localVarQueryParameters,
                    headers: localVarHeaderParams,
                    uri: localVarPath,
                    useQuerystring: this._useQuerystring,
                    json: true,
                };
                this.authentications.oauth2.applyToRequest(localVarRequestOptions);
                this.authentications.default.applyToRequest(localVarRequestOptions);
                if (Object.keys(localVarFormParams).length) {
                    if (localVarUseFormData) {
                        localVarRequestOptions.formData = localVarFormParams;
                    }
                    else {
                        localVarRequestOptions.form = localVarFormParams;
                    }
                }
                return [2 /*return*/, new Promise(function (resolve, reject) {
                        localVarRequest(localVarRequestOptions, function (error, response, body) {
                            if (error) {
                                reject(error);
                            }
                            else {
                                body = models_1.ObjectSerializer.deserialize(body, "DeletedEntityResponse");
                                if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                                    resolve({ response: response, body: body });
                                }
                                else {
                                    reject({ response: response, body: body });
                                }
                            }
                        });
                    })];
            });
        });
    };
    /**
     * Delete one or more properties from a single portfolio. If the properties are time variant then an effective date time from which the properties  will be deleted must be specified. If the properties are perpetual then it is invalid to specify an effective date time for deletion.
     * @summary Delete portfolio properties
     * @param scope The scope of the portfolio to delete properties from.
     * @param code The code of the portfolio to delete properties from. Together with the scope this uniquely              identifies the portfolio.
     * @param propertyKeys The property keys of the properties to delete. These take the format              {domain}/{scope}/{code} e.g. \&quot;Portfolio/Manager/Id\&quot;. Each property must be from the \&quot;Portfolio\&quot; domain.
     * @param effectiveAt The effective datetime or cut label at which to delete the properties.
     */
    PortfoliosApi.prototype.deletePortfolioProperties = function (scope, code, propertyKeys, effectiveAt, options) {
        if (options === void 0) { options = { headers: {} }; }
        return __awaiter(this, void 0, void 0, function () {
            var localVarPath, localVarQueryParameters, localVarHeaderParams, localVarFormParams, localVarUseFormData, localVarRequestOptions;
            return __generator(this, function (_a) {
                localVarPath = this.basePath + '/api/portfolios/{scope}/{code}/properties'
                    .replace('{' + 'scope' + '}', encodeURIComponent(String(scope)))
                    .replace('{' + 'code' + '}', encodeURIComponent(String(code)));
                localVarQueryParameters = {};
                localVarHeaderParams = Object.assign({}, this.defaultHeaders);
                localVarFormParams = {};
                // verify required parameter 'scope' is not null or undefined
                if (scope === null || scope === undefined) {
                    throw new Error('Required parameter scope was null or undefined when calling deletePortfolioProperties.');
                }
                // verify required parameter 'code' is not null or undefined
                if (code === null || code === undefined) {
                    throw new Error('Required parameter code was null or undefined when calling deletePortfolioProperties.');
                }
                // verify required parameter 'propertyKeys' is not null or undefined
                if (propertyKeys === null || propertyKeys === undefined) {
                    throw new Error('Required parameter propertyKeys was null or undefined when calling deletePortfolioProperties.');
                }
                if (effectiveAt !== undefined) {
                    localVarQueryParameters['effectiveAt'] = models_1.ObjectSerializer.serialize(effectiveAt, "string");
                }
                if (propertyKeys !== undefined) {
                    localVarQueryParameters['propertyKeys'] = models_1.ObjectSerializer.serialize(propertyKeys, "Array<string>");
                }
                Object.assign(localVarHeaderParams, options.headers);
                localVarUseFormData = false;
                localVarRequestOptions = {
                    method: 'DELETE',
                    qs: localVarQueryParameters,
                    headers: localVarHeaderParams,
                    uri: localVarPath,
                    useQuerystring: this._useQuerystring,
                    json: true,
                };
                this.authentications.oauth2.applyToRequest(localVarRequestOptions);
                this.authentications.default.applyToRequest(localVarRequestOptions);
                if (Object.keys(localVarFormParams).length) {
                    if (localVarUseFormData) {
                        localVarRequestOptions.formData = localVarFormParams;
                    }
                    else {
                        localVarRequestOptions.form = localVarFormParams;
                    }
                }
                return [2 /*return*/, new Promise(function (resolve, reject) {
                        localVarRequest(localVarRequestOptions, function (error, response, body) {
                            if (error) {
                                reject(error);
                            }
                            else {
                                body = models_1.ObjectSerializer.deserialize(body, "DeletedEntityResponse");
                                if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                                    resolve({ response: response, body: body });
                                }
                                else {
                                    reject({ response: response, body: body });
                                }
                            }
                        });
                    })];
            });
        });
    };
    /**
     * Retrieve the definition of a single portfolio.
     * @summary Get portfolio
     * @param scope The scope of the portfolio to retrieve the definition for.
     * @param code The code of the portfolio to retrieve the definition for. Together with the scope this              uniquely identifies the portfolio.
     * @param effectiveAt The effective datetime or cut label at which to retrieve the portfolio definition. Defaults to the current LUSID system datetime if not specified.
     * @param asAt The asAt datetime at which to retrieve the portfolio definition. Defaults to return the latest version of the portfolio definition if not specified.
     * @param propertyKeys A list of property keys from the \&quot;Portfolio\&quot; domain to decorate onto the portfolio.              These take the format {domain}/{scope}/{code} e.g. \&quot;Portfolio/Manager/Id\&quot;.
     */
    PortfoliosApi.prototype.getPortfolio = function (scope, code, effectiveAt, asAt, propertyKeys, options) {
        if (options === void 0) { options = { headers: {} }; }
        return __awaiter(this, void 0, void 0, function () {
            var localVarPath, localVarQueryParameters, localVarHeaderParams, localVarFormParams, localVarUseFormData, localVarRequestOptions;
            return __generator(this, function (_a) {
                localVarPath = this.basePath + '/api/portfolios/{scope}/{code}'
                    .replace('{' + 'scope' + '}', encodeURIComponent(String(scope)))
                    .replace('{' + 'code' + '}', encodeURIComponent(String(code)));
                localVarQueryParameters = {};
                localVarHeaderParams = Object.assign({}, this.defaultHeaders);
                localVarFormParams = {};
                // verify required parameter 'scope' is not null or undefined
                if (scope === null || scope === undefined) {
                    throw new Error('Required parameter scope was null or undefined when calling getPortfolio.');
                }
                // verify required parameter 'code' is not null or undefined
                if (code === null || code === undefined) {
                    throw new Error('Required parameter code was null or undefined when calling getPortfolio.');
                }
                if (effectiveAt !== undefined) {
                    localVarQueryParameters['effectiveAt'] = models_1.ObjectSerializer.serialize(effectiveAt, "string");
                }
                if (asAt !== undefined) {
                    localVarQueryParameters['asAt'] = models_1.ObjectSerializer.serialize(asAt, "Date");
                }
                if (propertyKeys !== undefined) {
                    localVarQueryParameters['propertyKeys'] = models_1.ObjectSerializer.serialize(propertyKeys, "Array<string>");
                }
                Object.assign(localVarHeaderParams, options.headers);
                localVarUseFormData = false;
                localVarRequestOptions = {
                    method: 'GET',
                    qs: localVarQueryParameters,
                    headers: localVarHeaderParams,
                    uri: localVarPath,
                    useQuerystring: this._useQuerystring,
                    json: true,
                };
                this.authentications.oauth2.applyToRequest(localVarRequestOptions);
                this.authentications.default.applyToRequest(localVarRequestOptions);
                if (Object.keys(localVarFormParams).length) {
                    if (localVarUseFormData) {
                        localVarRequestOptions.formData = localVarFormParams;
                    }
                    else {
                        localVarRequestOptions.form = localVarFormParams;
                    }
                }
                return [2 /*return*/, new Promise(function (resolve, reject) {
                        localVarRequest(localVarRequestOptions, function (error, response, body) {
                            if (error) {
                                reject(error);
                            }
                            else {
                                body = models_1.ObjectSerializer.deserialize(body, "Portfolio");
                                if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                                    resolve({ response: response, body: body });
                                }
                                else {
                                    reject({ response: response, body: body });
                                }
                            }
                        });
                    })];
            });
        });
    };
    /**
     * Gets all the commands that modified a single portfolio, including any input transactions.
     * @summary [EARLY ACCESS] Get portfolio commands
     * @param scope The scope of the portfolio to retrieve the commands for.
     * @param code The code of the portfolio to retrieve the commands for. Together with the scope this uniquely identifies              the portfolio.
     * @param fromAsAt The lower bound asAt datetime (inclusive) from which to retrieve commands. There is no lower bound if this is not specified.
     * @param toAsAt The upper bound asAt datetime (inclusive) from which to retrieve commands. There is no upper bound if this is not specified.
     * @param filter Expression to filter the result set.              For example, to filter on the User ID, use \&quot;userId.id eq \&#39;string\&#39;\&quot;              Read more about filtering results from LUSID here https://support.lusid.com/filtering-results-from-lusid.
     */
    PortfoliosApi.prototype.getPortfolioCommands = function (scope, code, fromAsAt, toAsAt, filter, options) {
        if (options === void 0) { options = { headers: {} }; }
        return __awaiter(this, void 0, void 0, function () {
            var localVarPath, localVarQueryParameters, localVarHeaderParams, localVarFormParams, localVarUseFormData, localVarRequestOptions;
            return __generator(this, function (_a) {
                localVarPath = this.basePath + '/api/portfolios/{scope}/{code}/commands'
                    .replace('{' + 'scope' + '}', encodeURIComponent(String(scope)))
                    .replace('{' + 'code' + '}', encodeURIComponent(String(code)));
                localVarQueryParameters = {};
                localVarHeaderParams = Object.assign({}, this.defaultHeaders);
                localVarFormParams = {};
                // verify required parameter 'scope' is not null or undefined
                if (scope === null || scope === undefined) {
                    throw new Error('Required parameter scope was null or undefined when calling getPortfolioCommands.');
                }
                // verify required parameter 'code' is not null or undefined
                if (code === null || code === undefined) {
                    throw new Error('Required parameter code was null or undefined when calling getPortfolioCommands.');
                }
                if (fromAsAt !== undefined) {
                    localVarQueryParameters['fromAsAt'] = models_1.ObjectSerializer.serialize(fromAsAt, "Date");
                }
                if (toAsAt !== undefined) {
                    localVarQueryParameters['toAsAt'] = models_1.ObjectSerializer.serialize(toAsAt, "Date");
                }
                if (filter !== undefined) {
                    localVarQueryParameters['filter'] = models_1.ObjectSerializer.serialize(filter, "string");
                }
                Object.assign(localVarHeaderParams, options.headers);
                localVarUseFormData = false;
                localVarRequestOptions = {
                    method: 'GET',
                    qs: localVarQueryParameters,
                    headers: localVarHeaderParams,
                    uri: localVarPath,
                    useQuerystring: this._useQuerystring,
                    json: true,
                };
                this.authentications.oauth2.applyToRequest(localVarRequestOptions);
                this.authentications.default.applyToRequest(localVarRequestOptions);
                if (Object.keys(localVarFormParams).length) {
                    if (localVarUseFormData) {
                        localVarRequestOptions.formData = localVarFormParams;
                    }
                    else {
                        localVarRequestOptions.form = localVarFormParams;
                    }
                }
                return [2 /*return*/, new Promise(function (resolve, reject) {
                        localVarRequest(localVarRequestOptions, function (error, response, body) {
                            if (error) {
                                reject(error);
                            }
                            else {
                                body = models_1.ObjectSerializer.deserialize(body, "ResourceListOfProcessedCommand");
                                if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                                    resolve({ response: response, body: body });
                                }
                                else {
                                    reject({ response: response, body: body });
                                }
                            }
                        });
                    })];
            });
        });
    };
    /**
     * Pass the scope and portfolio code parameters to retrieve the AccessMetadata associated with a portfolio
     * @summary [EXPERIMENTAL] Get access metadata rules for a portfolio
     * @param scope The scope of the Portfolio Access Metadata Rule to retrieve.
     * @param code Portfolio code
     * @param effectiveAt The effectiveAt datetime at which to retrieve the access metadata rule.
     * @param asAt The asAt datetime at which to retrieve the portfolio access metadata.
     */
    PortfoliosApi.prototype.getPortfolioMetadata = function (scope, code, effectiveAt, asAt, options) {
        if (options === void 0) { options = { headers: {} }; }
        return __awaiter(this, void 0, void 0, function () {
            var localVarPath, localVarQueryParameters, localVarHeaderParams, localVarFormParams, localVarUseFormData, localVarRequestOptions;
            return __generator(this, function (_a) {
                localVarPath = this.basePath + '/api/portfolios/{scope}/{code}/metadata'
                    .replace('{' + 'scope' + '}', encodeURIComponent(String(scope)))
                    .replace('{' + 'code' + '}', encodeURIComponent(String(code)));
                localVarQueryParameters = {};
                localVarHeaderParams = Object.assign({}, this.defaultHeaders);
                localVarFormParams = {};
                // verify required parameter 'scope' is not null or undefined
                if (scope === null || scope === undefined) {
                    throw new Error('Required parameter scope was null or undefined when calling getPortfolioMetadata.');
                }
                // verify required parameter 'code' is not null or undefined
                if (code === null || code === undefined) {
                    throw new Error('Required parameter code was null or undefined when calling getPortfolioMetadata.');
                }
                if (effectiveAt !== undefined) {
                    localVarQueryParameters['effectiveAt'] = models_1.ObjectSerializer.serialize(effectiveAt, "string");
                }
                if (asAt !== undefined) {
                    localVarQueryParameters['asAt'] = models_1.ObjectSerializer.serialize(asAt, "Date");
                }
                Object.assign(localVarHeaderParams, options.headers);
                localVarUseFormData = false;
                localVarRequestOptions = {
                    method: 'GET',
                    qs: localVarQueryParameters,
                    headers: localVarHeaderParams,
                    uri: localVarPath,
                    useQuerystring: this._useQuerystring,
                    json: true,
                };
                this.authentications.oauth2.applyToRequest(localVarRequestOptions);
                this.authentications.default.applyToRequest(localVarRequestOptions);
                if (Object.keys(localVarFormParams).length) {
                    if (localVarUseFormData) {
                        localVarRequestOptions.formData = localVarFormParams;
                    }
                    else {
                        localVarRequestOptions.form = localVarFormParams;
                    }
                }
                return [2 /*return*/, new Promise(function (resolve, reject) {
                        localVarRequest(localVarRequestOptions, function (error, response, body) {
                            if (error) {
                                reject(error);
                            }
                            else {
                                body = models_1.ObjectSerializer.deserialize(body, "{ [key: string]: Array<AccessMetadataValue>; }");
                                if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                                    resolve({ response: response, body: body });
                                }
                                else {
                                    reject({ response: response, body: body });
                                }
                            }
                        });
                    })];
            });
        });
    };
    /**
     * List all the properties of a single portfolio.
     * @summary Get portfolio properties
     * @param scope The scope of the portfolio to list the properties for.
     * @param code The code of the portfolio to list the properties for. Together with the scope this uniquely              identifies the portfolio.
     * @param effectiveAt The effective datetime or cut label at which to list the portfolio\&#39;s properties. Defaults to the current LUSID system datetime if not specified.
     * @param asAt The asAt datetime at which to list the portfolio\&#39;s properties. Defaults to return the latest version of each property if not specified.
     */
    PortfoliosApi.prototype.getPortfolioProperties = function (scope, code, effectiveAt, asAt, options) {
        if (options === void 0) { options = { headers: {} }; }
        return __awaiter(this, void 0, void 0, function () {
            var localVarPath, localVarQueryParameters, localVarHeaderParams, localVarFormParams, localVarUseFormData, localVarRequestOptions;
            return __generator(this, function (_a) {
                localVarPath = this.basePath + '/api/portfolios/{scope}/{code}/properties'
                    .replace('{' + 'scope' + '}', encodeURIComponent(String(scope)))
                    .replace('{' + 'code' + '}', encodeURIComponent(String(code)));
                localVarQueryParameters = {};
                localVarHeaderParams = Object.assign({}, this.defaultHeaders);
                localVarFormParams = {};
                // verify required parameter 'scope' is not null or undefined
                if (scope === null || scope === undefined) {
                    throw new Error('Required parameter scope was null or undefined when calling getPortfolioProperties.');
                }
                // verify required parameter 'code' is not null or undefined
                if (code === null || code === undefined) {
                    throw new Error('Required parameter code was null or undefined when calling getPortfolioProperties.');
                }
                if (effectiveAt !== undefined) {
                    localVarQueryParameters['effectiveAt'] = models_1.ObjectSerializer.serialize(effectiveAt, "string");
                }
                if (asAt !== undefined) {
                    localVarQueryParameters['asAt'] = models_1.ObjectSerializer.serialize(asAt, "Date");
                }
                Object.assign(localVarHeaderParams, options.headers);
                localVarUseFormData = false;
                localVarRequestOptions = {
                    method: 'GET',
                    qs: localVarQueryParameters,
                    headers: localVarHeaderParams,
                    uri: localVarPath,
                    useQuerystring: this._useQuerystring,
                    json: true,
                };
                this.authentications.oauth2.applyToRequest(localVarRequestOptions);
                this.authentications.default.applyToRequest(localVarRequestOptions);
                if (Object.keys(localVarFormParams).length) {
                    if (localVarUseFormData) {
                        localVarRequestOptions.formData = localVarFormParams;
                    }
                    else {
                        localVarRequestOptions.form = localVarFormParams;
                    }
                }
                return [2 /*return*/, new Promise(function (resolve, reject) {
                        localVarRequest(localVarRequestOptions, function (error, response, body) {
                            if (error) {
                                reject(error);
                            }
                            else {
                                body = models_1.ObjectSerializer.deserialize(body, "PortfolioProperties");
                                if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                                    resolve({ response: response, body: body });
                                }
                                else {
                                    reject({ response: response, body: body });
                                }
                            }
                        });
                    })];
            });
        });
    };
    /**
     * Get a specific portfolio access metadata rule by specifying the corresponding identifier parts                No matching will be performed through this endpoint. To retrieve a rule, it is necessary to specify, exactly, the identifier of the rule
     * @summary [EXPERIMENTAL] Get an entry identified by a metadataKey in the access metadata object
     * @param scope The scope of the Portfolio Access Metadata Rule to retrieve.
     * @param code The code of the portfolio
     * @param metadataKey Key of the metadata to retrieve
     * @param effectiveAt The effective date of the rule
     * @param asAt The asAt datetime at which to retrieve the portfolio access metadata.
     */
    PortfoliosApi.prototype.getPortfoliosAccessMetadataByKey = function (scope, code, metadataKey, effectiveAt, asAt, options) {
        if (options === void 0) { options = { headers: {} }; }
        return __awaiter(this, void 0, void 0, function () {
            var localVarPath, localVarQueryParameters, localVarHeaderParams, localVarFormParams, localVarUseFormData, localVarRequestOptions;
            return __generator(this, function (_a) {
                localVarPath = this.basePath + '/api/portfolios/{scope}/{code}/metadata/{metadataKey}'
                    .replace('{' + 'scope' + '}', encodeURIComponent(String(scope)))
                    .replace('{' + 'code' + '}', encodeURIComponent(String(code)))
                    .replace('{' + 'metadataKey' + '}', encodeURIComponent(String(metadataKey)));
                localVarQueryParameters = {};
                localVarHeaderParams = Object.assign({}, this.defaultHeaders);
                localVarFormParams = {};
                // verify required parameter 'scope' is not null or undefined
                if (scope === null || scope === undefined) {
                    throw new Error('Required parameter scope was null or undefined when calling getPortfoliosAccessMetadataByKey.');
                }
                // verify required parameter 'code' is not null or undefined
                if (code === null || code === undefined) {
                    throw new Error('Required parameter code was null or undefined when calling getPortfoliosAccessMetadataByKey.');
                }
                // verify required parameter 'metadataKey' is not null or undefined
                if (metadataKey === null || metadataKey === undefined) {
                    throw new Error('Required parameter metadataKey was null or undefined when calling getPortfoliosAccessMetadataByKey.');
                }
                if (effectiveAt !== undefined) {
                    localVarQueryParameters['effectiveAt'] = models_1.ObjectSerializer.serialize(effectiveAt, "string");
                }
                if (asAt !== undefined) {
                    localVarQueryParameters['asAt'] = models_1.ObjectSerializer.serialize(asAt, "Date");
                }
                Object.assign(localVarHeaderParams, options.headers);
                localVarUseFormData = false;
                localVarRequestOptions = {
                    method: 'GET',
                    qs: localVarQueryParameters,
                    headers: localVarHeaderParams,
                    uri: localVarPath,
                    useQuerystring: this._useQuerystring,
                    json: true,
                };
                this.authentications.oauth2.applyToRequest(localVarRequestOptions);
                this.authentications.default.applyToRequest(localVarRequestOptions);
                if (Object.keys(localVarFormParams).length) {
                    if (localVarUseFormData) {
                        localVarRequestOptions.formData = localVarFormParams;
                    }
                    else {
                        localVarRequestOptions.form = localVarFormParams;
                    }
                }
                return [2 /*return*/, new Promise(function (resolve, reject) {
                        localVarRequest(localVarRequestOptions, function (error, response, body) {
                            if (error) {
                                reject(error);
                            }
                            else {
                                body = models_1.ObjectSerializer.deserialize(body, "Array<AccessMetadataValue>");
                                if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                                    resolve({ response: response, body: body });
                                }
                                else {
                                    reject({ response: response, body: body });
                                }
                            }
                        });
                    })];
            });
        });
    };
    /**
     * List all the portfolios matching the specified criteria.
     * @summary List portfolios
     * @param effectiveAt The effective datetime or cut label at which to list the portfolios. Defaults to the current LUSID              system datetime if not specified.
     * @param asAt The asAt datetime at which to list the portfolios. Defaults to return the latest version              of each portfolio if not specified.
     * @param page The pagination token to use to continue listing portfolios from a previous call to list portfolios. This  value is returned from the previous call. If a pagination token is provided the filter, effectiveAt  and asAt fields must not have changed since the original request. Also, if set, a start value cannot be provided.
     * @param start When paginating, skip this number of results.
     * @param limit When paginating, limit the number of returned results to this many. Defaults to 65,535 if not specified.
     * @param filter Expression to filter the result set.               For example, to filter on the Type, use \&quot;type eq \&#39;Transaction\&#39;\&quot;              Read more about filtering results from LUSID here https://support.lusid.com/filtering-results-from-lusid.
     * @param query Expression specifying the criteria that the returned portfolios must meet e.g. to see which              portfolios have holdings in the instruments with a Lusid Instrument Id (LUID) of \&#39;LUID_PPA8HI6M\&#39; or a Figi of \&#39;BBG000BLNNH6\&#39;              you would specify \&quot;instrument.identifiers in ((\&#39;LusidInstrumentId\&#39;, \&#39;LUID_PPA8HI6M\&#39;), (\&#39;Figi\&#39;, \&#39;BBG000BLNNH6\&#39;))\&quot;.
     * @param propertyKeys A list of property keys from the \&quot;Portfolio\&quot; domain to decorate onto each portfolio.              These take the format {domain}/{scope}/{code} e.g. \&quot;Portfolio/Manager/Id\&quot;.
     */
    PortfoliosApi.prototype.listPortfolios = function (effectiveAt, asAt, page, start, limit, filter, query, propertyKeys, options) {
        if (options === void 0) { options = { headers: {} }; }
        return __awaiter(this, void 0, void 0, function () {
            var localVarPath, localVarQueryParameters, localVarHeaderParams, localVarFormParams, localVarUseFormData, localVarRequestOptions;
            return __generator(this, function (_a) {
                localVarPath = this.basePath + '/api/portfolios';
                localVarQueryParameters = {};
                localVarHeaderParams = Object.assign({}, this.defaultHeaders);
                localVarFormParams = {};
                if (effectiveAt !== undefined) {
                    localVarQueryParameters['effectiveAt'] = models_1.ObjectSerializer.serialize(effectiveAt, "string");
                }
                if (asAt !== undefined) {
                    localVarQueryParameters['asAt'] = models_1.ObjectSerializer.serialize(asAt, "Date");
                }
                if (page !== undefined) {
                    localVarQueryParameters['page'] = models_1.ObjectSerializer.serialize(page, "string");
                }
                if (start !== undefined) {
                    localVarQueryParameters['start'] = models_1.ObjectSerializer.serialize(start, "number");
                }
                if (limit !== undefined) {
                    localVarQueryParameters['limit'] = models_1.ObjectSerializer.serialize(limit, "number");
                }
                if (filter !== undefined) {
                    localVarQueryParameters['filter'] = models_1.ObjectSerializer.serialize(filter, "string");
                }
                if (query !== undefined) {
                    localVarQueryParameters['query'] = models_1.ObjectSerializer.serialize(query, "string");
                }
                if (propertyKeys !== undefined) {
                    localVarQueryParameters['propertyKeys'] = models_1.ObjectSerializer.serialize(propertyKeys, "Array<string>");
                }
                Object.assign(localVarHeaderParams, options.headers);
                localVarUseFormData = false;
                localVarRequestOptions = {
                    method: 'GET',
                    qs: localVarQueryParameters,
                    headers: localVarHeaderParams,
                    uri: localVarPath,
                    useQuerystring: this._useQuerystring,
                    json: true,
                };
                this.authentications.oauth2.applyToRequest(localVarRequestOptions);
                this.authentications.default.applyToRequest(localVarRequestOptions);
                if (Object.keys(localVarFormParams).length) {
                    if (localVarUseFormData) {
                        localVarRequestOptions.formData = localVarFormParams;
                    }
                    else {
                        localVarRequestOptions.form = localVarFormParams;
                    }
                }
                return [2 /*return*/, new Promise(function (resolve, reject) {
                        localVarRequest(localVarRequestOptions, function (error, response, body) {
                            if (error) {
                                reject(error);
                            }
                            else {
                                body = models_1.ObjectSerializer.deserialize(body, "ResourceListOfPortfolio");
                                if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                                    resolve({ response: response, body: body });
                                }
                                else {
                                    reject({ response: response, body: body });
                                }
                            }
                        });
                    })];
            });
        });
    };
    /**
     * List all the portfolios in a single scope.
     * @summary List portfolios for scope
     * @param scope The scope of the portfolios.
     * @param effectiveAt The effective datetime or cut label at which to list the portfolios. Defaults to the current LUSID              system datetime if not specified.
     * @param asAt The asAt datetime at which to list the portfolios. Defaults to return the latest version              of each portfolio if not specified.
     * @param page The pagination token to use to continue listing portfolios from a previous call to list portfolios. This  value is returned from the previous call. If a pagination token is provided the filter, effectiveAt  and asAt fields must not have changed since the original request. Also, if set, a start value cannot be provided.
     * @param start When paginating, skip this number of results.
     * @param limit When paginating, limit the number of returned results to this many. Defaults to 65,535 if not specified.
     * @param filter Expression to filter the result set.              For example, to filter on the Type, use \&quot;type eq \&#39;Transaction\&#39;\&quot;              Read more about filtering results from LUSID here https://support.lusid.com/filtering-results-from-lusid.
     * @param propertyKeys A list of property keys from the \&quot;Portfolio\&quot; domain to decorate onto each portfolio.              These take the format {domain}/{scope}/{code} e.g. \&quot;Portfolio/Manager/Id\&quot;.
     */
    PortfoliosApi.prototype.listPortfoliosForScope = function (scope, effectiveAt, asAt, page, start, limit, filter, propertyKeys, options) {
        if (options === void 0) { options = { headers: {} }; }
        return __awaiter(this, void 0, void 0, function () {
            var localVarPath, localVarQueryParameters, localVarHeaderParams, localVarFormParams, localVarUseFormData, localVarRequestOptions;
            return __generator(this, function (_a) {
                localVarPath = this.basePath + '/api/portfolios/{scope}'
                    .replace('{' + 'scope' + '}', encodeURIComponent(String(scope)));
                localVarQueryParameters = {};
                localVarHeaderParams = Object.assign({}, this.defaultHeaders);
                localVarFormParams = {};
                // verify required parameter 'scope' is not null or undefined
                if (scope === null || scope === undefined) {
                    throw new Error('Required parameter scope was null or undefined when calling listPortfoliosForScope.');
                }
                if (effectiveAt !== undefined) {
                    localVarQueryParameters['effectiveAt'] = models_1.ObjectSerializer.serialize(effectiveAt, "string");
                }
                if (asAt !== undefined) {
                    localVarQueryParameters['asAt'] = models_1.ObjectSerializer.serialize(asAt, "Date");
                }
                if (page !== undefined) {
                    localVarQueryParameters['page'] = models_1.ObjectSerializer.serialize(page, "string");
                }
                if (start !== undefined) {
                    localVarQueryParameters['start'] = models_1.ObjectSerializer.serialize(start, "number");
                }
                if (limit !== undefined) {
                    localVarQueryParameters['limit'] = models_1.ObjectSerializer.serialize(limit, "number");
                }
                if (filter !== undefined) {
                    localVarQueryParameters['filter'] = models_1.ObjectSerializer.serialize(filter, "string");
                }
                if (propertyKeys !== undefined) {
                    localVarQueryParameters['propertyKeys'] = models_1.ObjectSerializer.serialize(propertyKeys, "Array<string>");
                }
                Object.assign(localVarHeaderParams, options.headers);
                localVarUseFormData = false;
                localVarRequestOptions = {
                    method: 'GET',
                    qs: localVarQueryParameters,
                    headers: localVarHeaderParams,
                    uri: localVarPath,
                    useQuerystring: this._useQuerystring,
                    json: true,
                };
                this.authentications.oauth2.applyToRequest(localVarRequestOptions);
                this.authentications.default.applyToRequest(localVarRequestOptions);
                if (Object.keys(localVarFormParams).length) {
                    if (localVarUseFormData) {
                        localVarRequestOptions.formData = localVarFormParams;
                    }
                    else {
                        localVarRequestOptions.form = localVarFormParams;
                    }
                }
                return [2 /*return*/, new Promise(function (resolve, reject) {
                        localVarRequest(localVarRequestOptions, function (error, response, body) {
                            if (error) {
                                reject(error);
                            }
                            else {
                                body = models_1.ObjectSerializer.deserialize(body, "ResourceListOfPortfolio");
                                if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                                    resolve({ response: response, body: body });
                                }
                                else {
                                    reject({ response: response, body: body });
                                }
                            }
                        });
                    })];
            });
        });
    };
    /**
     * Update the definition of a single portfolio. Not all elements within a portfolio definition are  modifiable due to the potential implications for data already stored against the portfolio.
     * @summary Update portfolio
     * @param scope The scope of the portfolio to update the definition for.
     * @param code The code of the portfolio to update the definition for. Together with the scope this uniquely              identifies the portfolio.
     * @param portfolioDefinition The updated portfolio definition.
     * @param effectiveAt The effective datetime or cut label at which to update the definition. Defaults to the current              LUSID system datetime if not specified.
     */
    PortfoliosApi.prototype.updatePortfolio = function (scope, code, portfolioDefinition, effectiveAt, options) {
        if (options === void 0) { options = { headers: {} }; }
        return __awaiter(this, void 0, void 0, function () {
            var localVarPath, localVarQueryParameters, localVarHeaderParams, localVarFormParams, localVarUseFormData, localVarRequestOptions;
            return __generator(this, function (_a) {
                localVarPath = this.basePath + '/api/portfolios/{scope}/{code}'
                    .replace('{' + 'scope' + '}', encodeURIComponent(String(scope)))
                    .replace('{' + 'code' + '}', encodeURIComponent(String(code)));
                localVarQueryParameters = {};
                localVarHeaderParams = Object.assign({}, this.defaultHeaders);
                localVarFormParams = {};
                // verify required parameter 'scope' is not null or undefined
                if (scope === null || scope === undefined) {
                    throw new Error('Required parameter scope was null or undefined when calling updatePortfolio.');
                }
                // verify required parameter 'code' is not null or undefined
                if (code === null || code === undefined) {
                    throw new Error('Required parameter code was null or undefined when calling updatePortfolio.');
                }
                // verify required parameter 'portfolioDefinition' is not null or undefined
                if (portfolioDefinition === null || portfolioDefinition === undefined) {
                    throw new Error('Required parameter portfolioDefinition was null or undefined when calling updatePortfolio.');
                }
                if (effectiveAt !== undefined) {
                    localVarQueryParameters['effectiveAt'] = models_1.ObjectSerializer.serialize(effectiveAt, "string");
                }
                Object.assign(localVarHeaderParams, options.headers);
                localVarUseFormData = false;
                localVarRequestOptions = {
                    method: 'PUT',
                    qs: localVarQueryParameters,
                    headers: localVarHeaderParams,
                    uri: localVarPath,
                    useQuerystring: this._useQuerystring,
                    json: true,
                    body: models_1.ObjectSerializer.serialize(portfolioDefinition, "UpdatePortfolioRequest")
                };
                this.authentications.oauth2.applyToRequest(localVarRequestOptions);
                this.authentications.default.applyToRequest(localVarRequestOptions);
                if (Object.keys(localVarFormParams).length) {
                    if (localVarUseFormData) {
                        localVarRequestOptions.formData = localVarFormParams;
                    }
                    else {
                        localVarRequestOptions.form = localVarFormParams;
                    }
                }
                return [2 /*return*/, new Promise(function (resolve, reject) {
                        localVarRequest(localVarRequestOptions, function (error, response, body) {
                            if (error) {
                                reject(error);
                            }
                            else {
                                body = models_1.ObjectSerializer.deserialize(body, "Portfolio");
                                if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                                    resolve({ response: response, body: body });
                                }
                                else {
                                    reject({ response: response, body: body });
                                }
                            }
                        });
                    })];
            });
        });
    };
    /**
     * Update or insert one Portfolio Access Metadata Rule in a single scope. An item will be updated if it already exists  and inserted if it does not.    The response will return the successfully updated or inserted Portfolio Access Metadata Rule or failure message if unsuccessful    It is important to always check to verify success (or failure).                Multiple rules for a metadataKey can exists with different effective at dates, when resources are accessed the rule that is active for the current time will be fetched
     * @summary [EXPERIMENTAL] Upsert a Portfolio Access Metadata Rule associated with specific metadataKey. This creates or updates the data in LUSID.
     * @param scope The scope to use when updating or inserting the Portfolio Access Metadata Rule.
     * @param code Portfolio code
     * @param metadataKey Key of the access metadata to upsert
     * @param request The Portfolio Access Metadata Rule to update or insert
     * @param effectiveAt The date this rule will effective from
     */
    PortfoliosApi.prototype.upsertPortfolioAccessMetadata = function (scope, code, metadataKey, request, effectiveAt, options) {
        if (options === void 0) { options = { headers: {} }; }
        return __awaiter(this, void 0, void 0, function () {
            var localVarPath, localVarQueryParameters, localVarHeaderParams, localVarFormParams, localVarUseFormData, localVarRequestOptions;
            return __generator(this, function (_a) {
                localVarPath = this.basePath + '/api/portfolios/{scope}/{code}/metadata/{metadataKey}'
                    .replace('{' + 'scope' + '}', encodeURIComponent(String(scope)))
                    .replace('{' + 'code' + '}', encodeURIComponent(String(code)))
                    .replace('{' + 'metadataKey' + '}', encodeURIComponent(String(metadataKey)));
                localVarQueryParameters = {};
                localVarHeaderParams = Object.assign({}, this.defaultHeaders);
                localVarFormParams = {};
                // verify required parameter 'scope' is not null or undefined
                if (scope === null || scope === undefined) {
                    throw new Error('Required parameter scope was null or undefined when calling upsertPortfolioAccessMetadata.');
                }
                // verify required parameter 'code' is not null or undefined
                if (code === null || code === undefined) {
                    throw new Error('Required parameter code was null or undefined when calling upsertPortfolioAccessMetadata.');
                }
                // verify required parameter 'metadataKey' is not null or undefined
                if (metadataKey === null || metadataKey === undefined) {
                    throw new Error('Required parameter metadataKey was null or undefined when calling upsertPortfolioAccessMetadata.');
                }
                // verify required parameter 'request' is not null or undefined
                if (request === null || request === undefined) {
                    throw new Error('Required parameter request was null or undefined when calling upsertPortfolioAccessMetadata.');
                }
                if (effectiveAt !== undefined) {
                    localVarQueryParameters['effectiveAt'] = models_1.ObjectSerializer.serialize(effectiveAt, "string");
                }
                Object.assign(localVarHeaderParams, options.headers);
                localVarUseFormData = false;
                localVarRequestOptions = {
                    method: 'PUT',
                    qs: localVarQueryParameters,
                    headers: localVarHeaderParams,
                    uri: localVarPath,
                    useQuerystring: this._useQuerystring,
                    json: true,
                    body: models_1.ObjectSerializer.serialize(request, "UpsertPortfolioAccessMetadataRequest")
                };
                this.authentications.oauth2.applyToRequest(localVarRequestOptions);
                this.authentications.default.applyToRequest(localVarRequestOptions);
                if (Object.keys(localVarFormParams).length) {
                    if (localVarUseFormData) {
                        localVarRequestOptions.formData = localVarFormParams;
                    }
                    else {
                        localVarRequestOptions.form = localVarFormParams;
                    }
                }
                return [2 /*return*/, new Promise(function (resolve, reject) {
                        localVarRequest(localVarRequestOptions, function (error, response, body) {
                            if (error) {
                                reject(error);
                            }
                            else {
                                body = models_1.ObjectSerializer.deserialize(body, "ResourceListOfAccessMetadataValueOf");
                                if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                                    resolve({ response: response, body: body });
                                }
                                else {
                                    reject({ response: response, body: body });
                                }
                            }
                        });
                    })];
            });
        });
    };
    /**
     * Update or insert one or more properties onto a single portfolio. A property will be updated if it  already exists and inserted if it does not. All properties must be of the domain \'Portfolio\'.
     * @summary Upsert portfolio properties
     * @param scope The scope of the portfolio to update or insert the properties onto.
     * @param code The code of the portfolio to update or insert the properties onto. Together with the scope              this uniquely identifies the portfolio.
     * @param portfolioProperties The properties to be updated or inserted onto the portfolio. Each property in              the request must be keyed by its unique property key. This has the format {domain}/{scope}/{code} e.g. \&quot;Portfolio/Manager/Id\&quot;.
     */
    PortfoliosApi.prototype.upsertPortfolioProperties = function (scope, code, portfolioProperties, options) {
        if (options === void 0) { options = { headers: {} }; }
        return __awaiter(this, void 0, void 0, function () {
            var localVarPath, localVarQueryParameters, localVarHeaderParams, localVarFormParams, localVarUseFormData, localVarRequestOptions;
            return __generator(this, function (_a) {
                localVarPath = this.basePath + '/api/portfolios/{scope}/{code}/properties'
                    .replace('{' + 'scope' + '}', encodeURIComponent(String(scope)))
                    .replace('{' + 'code' + '}', encodeURIComponent(String(code)));
                localVarQueryParameters = {};
                localVarHeaderParams = Object.assign({}, this.defaultHeaders);
                localVarFormParams = {};
                // verify required parameter 'scope' is not null or undefined
                if (scope === null || scope === undefined) {
                    throw new Error('Required parameter scope was null or undefined when calling upsertPortfolioProperties.');
                }
                // verify required parameter 'code' is not null or undefined
                if (code === null || code === undefined) {
                    throw new Error('Required parameter code was null or undefined when calling upsertPortfolioProperties.');
                }
                // verify required parameter 'portfolioProperties' is not null or undefined
                if (portfolioProperties === null || portfolioProperties === undefined) {
                    throw new Error('Required parameter portfolioProperties was null or undefined when calling upsertPortfolioProperties.');
                }
                Object.assign(localVarHeaderParams, options.headers);
                localVarUseFormData = false;
                localVarRequestOptions = {
                    method: 'POST',
                    qs: localVarQueryParameters,
                    headers: localVarHeaderParams,
                    uri: localVarPath,
                    useQuerystring: this._useQuerystring,
                    json: true,
                    body: models_1.ObjectSerializer.serialize(portfolioProperties, "{ [key: string]: Property; }")
                };
                this.authentications.oauth2.applyToRequest(localVarRequestOptions);
                this.authentications.default.applyToRequest(localVarRequestOptions);
                if (Object.keys(localVarFormParams).length) {
                    if (localVarUseFormData) {
                        localVarRequestOptions.formData = localVarFormParams;
                    }
                    else {
                        localVarRequestOptions.form = localVarFormParams;
                    }
                }
                return [2 /*return*/, new Promise(function (resolve, reject) {
                        localVarRequest(localVarRequestOptions, function (error, response, body) {
                            if (error) {
                                reject(error);
                            }
                            else {
                                body = models_1.ObjectSerializer.deserialize(body, "PortfolioProperties");
                                if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
                                    resolve({ response: response, body: body });
                                }
                                else {
                                    reject({ response: response, body: body });
                                }
                            }
                        });
                    })];
            });
        });
    };
    return PortfoliosApi;
}());
exports.PortfoliosApi = PortfoliosApi;
