forked from loafle/openapi-generator-original
[REQ][PowerShell] Improve generated PowerShell examples (#9836)
* Implement new PowerShell example structure Signed-off-by: Simeon Gerginov <sgerginov@vmware.com> * Modify documentation template to work with the new PowerShell example format Signed-off-by: Simeon Gerginov <sgerginov@vmware.com> * Update PowerShell Generator documentation with the new properties Signed-off-by: Simeon Gerginov <sgerginov@vmware.com> * Update PowerShell samples with the new PowerShell example format Signed-off-by: Simeon Gerginov <sgerginov@vmware.com> * Fix issues with array of models as parameters Signed-off-by: Simeon Gerginov <simeongerginov1@gmail.com> * Change string value generation to include the prefix 'My' Signed-off-by: Simeon Gerginov <simeongerginov1@gmail.com> * Remove multiple new lines and trim leading and trailing spaces in PowerShell example Signed-off-by: Simeon Gerginov <simeongerginov1@gmail.com>
This commit is contained in:
parent
32a3eb1655
commit
3663831b4d
@ -13,6 +13,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
|discardReadOnly|Set discardReadonly to true to generate the Initialize cmdlet without readonly parameters| |null|
|
|discardReadOnly|Set discardReadonly to true to generate the Initialize cmdlet without readonly parameters| |null|
|
||||||
|iconUri|A URL to an icon representing the generated PowerShell module| |null|
|
|iconUri|A URL to an icon representing the generated PowerShell module| |null|
|
||||||
|licenseUri|A URL to the license for the generated PowerShell module| |null|
|
|licenseUri|A URL to the license for the generated PowerShell module| |null|
|
||||||
|
|modelsCmdletVerb|Verb to be used when generating the Models cmdlets in the examples.| |Initialize|
|
||||||
|packageGuid|GUID for PowerShell module (e.g. a27b908d-2a20-467f-bc32-af6f3a654ac5). A random GUID will be generated by default.| |null|
|
|packageGuid|GUID for PowerShell module (e.g. a27b908d-2a20-467f-bc32-af6f3a654ac5). A random GUID will be generated by default.| |null|
|
||||||
|packageName|Client package name (e.g. PSTwitter).| |PSOpenAPITools|
|
|packageName|Client package name (e.g. PSTwitter).| |PSOpenAPITools|
|
||||||
|packageVersion|Package version (e.g. 0.1.2).| |0.1.2|
|
|packageVersion|Package version (e.g. 0.1.2).| |0.1.2|
|
||||||
@ -21,6 +22,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
|releaseNotes|Release notes of the generated PowerShell module| |null|
|
|releaseNotes|Release notes of the generated PowerShell module| |null|
|
||||||
|skipVerbParsing|Set skipVerbParsing to not try get powershell verbs of operation names| |null|
|
|skipVerbParsing|Set skipVerbParsing to not try get powershell verbs of operation names| |null|
|
||||||
|tags|Tags applied to the generated PowerShell module. These help with module discovery in online galleries| |null|
|
|tags|Tags applied to the generated PowerShell module. These help with module discovery in online galleries| |null|
|
||||||
|
|useClassNameInModelsExamples|Use classname instead of name when generating the Models cmdlets in the examples.| |true|
|
||||||
|useOneOfDiscriminatorLookup|Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and only one match in oneOf's schemas) will be skipped.| |null|
|
|useOneOfDiscriminatorLookup|Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and only one match in oneOf's schemas) will be skipped.| |null|
|
||||||
|
|
||||||
## IMPORT MAPPING
|
## IMPORT MAPPING
|
||||||
|
@ -63,6 +63,8 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
protected String tags;
|
protected String tags;
|
||||||
protected String iconUri;
|
protected String iconUri;
|
||||||
protected Set<String> paramNameReservedWords;
|
protected Set<String> paramNameReservedWords;
|
||||||
|
protected String modelsCmdletVerb = "Initialize";
|
||||||
|
protected boolean useClassNameInModelsExamples = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an instance of `PowerShellClientCodegen`.
|
* Constructs an instance of `PowerShellClientCodegen`.
|
||||||
@ -539,6 +541,13 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
cliOptions.add(new CliOption("iconUri","A URL to an icon representing the generated PowerShell module"));
|
cliOptions.add(new CliOption("iconUri","A URL to an icon representing the generated PowerShell module"));
|
||||||
cliOptions.add(new CliOption("releaseNotes","Release notes of the generated PowerShell module"));
|
cliOptions.add(new CliOption("releaseNotes","Release notes of the generated PowerShell module"));
|
||||||
cliOptions.add(new CliOption("skipVerbParsing", "Set skipVerbParsing to not try get powershell verbs of operation names"));
|
cliOptions.add(new CliOption("skipVerbParsing", "Set skipVerbParsing to not try get powershell verbs of operation names"));
|
||||||
|
cliOptions.add(new CliOption("modelsCmdletVerb", "Verb to be used when generating the Models cmdlets in the examples.").defaultValue(this.modelsCmdletVerb));
|
||||||
|
|
||||||
|
CliOption useClassNameInModelsExamplesOpt = CliOption.newBoolean(
|
||||||
|
"useClassNameInModelsExamples",
|
||||||
|
"Use classname instead of name when generating the Models cmdlets in the examples."
|
||||||
|
).defaultValue(this.useClassNameInModelsExamples ? Boolean.TRUE.toString() : Boolean.FALSE.toString());
|
||||||
|
cliOptions.add(useClassNameInModelsExamplesOpt);
|
||||||
|
|
||||||
// option to change how we process + set the data in the 'additionalProperties' keyword.
|
// option to change how we process + set the data in the 'additionalProperties' keyword.
|
||||||
CliOption disallowAdditionalPropertiesIfNotPresentOpt = CliOption.newBoolean(
|
CliOption disallowAdditionalPropertiesIfNotPresentOpt = CliOption.newBoolean(
|
||||||
@ -632,6 +641,10 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
|
|
||||||
public void setSkipVerbParsing(boolean skipVerbParsing) { this.skipVerbParsing = skipVerbParsing; }
|
public void setSkipVerbParsing(boolean skipVerbParsing) { this.skipVerbParsing = skipVerbParsing; }
|
||||||
|
|
||||||
|
public void SetModelsCmdletVerb(String modelsCmdletVerb) { this.modelsCmdletVerb = modelsCmdletVerb; }
|
||||||
|
|
||||||
|
public void SetUseClassNameInModelsExamples(boolean useClassNameInModelsExamples) { this.useClassNameInModelsExamples = useClassNameInModelsExamples; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processOpts() {
|
public void processOpts() {
|
||||||
this.setLegacyDiscriminatorBehavior(false);
|
this.setLegacyDiscriminatorBehavior(false);
|
||||||
@ -704,6 +717,18 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
additionalProperties.put("iconUri", iconUri);
|
additionalProperties.put("iconUri", iconUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey("modelsCmdletVerb")) {
|
||||||
|
this.SetModelsCmdletVerb((String) additionalProperties.get("modelsCmdletVerb"));
|
||||||
|
} else {
|
||||||
|
additionalProperties.put("modelsCmdletVerb", this.modelsCmdletVerb);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey("useClassNameInModelsExamples")) {
|
||||||
|
this.SetUseClassNameInModelsExamples(convertPropertyToBoolean("useClassNameInModelsExamples"));
|
||||||
|
} else {
|
||||||
|
additionalProperties.put("useClassNameInModelsExamples", this.useClassNameInModelsExamples);
|
||||||
|
}
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(powershellGalleryUrl)) {
|
if (StringUtils.isNotBlank(powershellGalleryUrl)) {
|
||||||
// get the last segment of the URL
|
// get the last segment of the URL
|
||||||
// e.g. https://www.powershellgallery.com/packages/PSTwitter => PSTwitter
|
// e.g. https://www.powershellgallery.com/packages/PSTwitter => PSTwitter
|
||||||
@ -1000,11 +1025,22 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
for (CodegenParameter p : op.allParams) {
|
for (CodegenParameter p : op.allParams) {
|
||||||
p.vendorExtensions.put("x-powershell-data-type", getPSDataType(p));
|
p.vendorExtensions.put("x-powershell-data-type", getPSDataType(p));
|
||||||
p.vendorExtensions.put("x-powershell-example", constructExampleCode(p, modelMaps, processedModelMaps));
|
p.vendorExtensions.put("x-powershell-example", constructExampleCode(p, modelMaps, processedModelMaps, false));
|
||||||
|
|
||||||
|
if (p.required) {
|
||||||
|
// clear processed Models after each constructed API Operation full example.
|
||||||
|
processedModelMaps.clear();
|
||||||
|
|
||||||
|
p.vendorExtensions.put("x-powershell-example-required", constructExampleCode(p, modelMaps, processedModelMaps, true));
|
||||||
|
}
|
||||||
|
|
||||||
p.vendorExtensions.put("x-index", index);
|
p.vendorExtensions.put("x-index", index);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clear processed Models after each constructed API Operation examples.
|
||||||
|
processedModelMaps.clear();
|
||||||
|
|
||||||
if (!op.vendorExtensions.containsKey("x-powershell-method-name")) { // x-powershell-method-name not set
|
if (!op.vendorExtensions.containsKey("x-powershell-method-name")) { // x-powershell-method-name not set
|
||||||
String methodName = toMethodName(op.operationId);
|
String methodName = toMethodName(op.operationId);
|
||||||
op.vendorExtensions.put("x-powershell-method-name", methodName);
|
op.vendorExtensions.put("x-powershell-method-name", methodName);
|
||||||
@ -1025,13 +1061,6 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
processedModelMaps.clear();
|
|
||||||
for (CodegenOperation operation : operationList) {
|
|
||||||
for (CodegenParameter cp : operation.allParams) {
|
|
||||||
cp.vendorExtensions.put("x-powershell-example", constructExampleCode(cp, modelMaps, processedModelMaps));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if return type is oneOf/anyeOf model
|
// check if return type is oneOf/anyeOf model
|
||||||
for (CodegenOperation op : operationList) {
|
for (CodegenOperation op : operationList) {
|
||||||
if (op.returnType != null) {
|
if (op.returnType != null) {
|
||||||
@ -1115,126 +1144,259 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String constructExampleCode(CodegenParameter codegenParameter, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) {
|
private String constructExampleCode(CodegenParameter codegenParameter, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap, boolean requiredOnly) {
|
||||||
if (codegenParameter.isArray) { // array
|
StringBuilder example = new StringBuilder();
|
||||||
return "@(" + constructExampleCode(codegenParameter.items, modelMaps, processedModelMap) + ")";
|
|
||||||
} else if (codegenParameter.isMap) { // TODO: map, file type
|
if (codegenParameter.isString) {
|
||||||
return "@{ \"Key\" = \"Value\" }";
|
if (codegenParameter.isEnum || (codegenParameter.allowableValues != null && !codegenParameter.allowableValues.isEmpty())) {
|
||||||
} else if (languageSpecificPrimitives.contains(codegenParameter.dataType) ||
|
example.append(constructEnumExample(codegenParameter.allowableValues));
|
||||||
nullablePrimitives.contains(codegenParameter.dataType)) { // primitive type
|
} else {
|
||||||
if ("String".equals(codegenParameter.dataType) || "Character".equals(codegenParameter.dataType)) {
|
String genericStringExample = codegenParameter.paramName + "_example";
|
||||||
if (StringUtils.isEmpty(codegenParameter.example)) {
|
example.append(constructStringExample(codegenParameter.paramName, codegenParameter.example, genericStringExample));
|
||||||
return "\"" + codegenParameter.example + "\"";
|
|
||||||
} else {
|
|
||||||
if (Boolean.TRUE.equals(codegenParameter.isEnum)) { // enum
|
|
||||||
List<Object> enumValues = (List<Object>) codegenParameter.allowableValues.get("values");
|
|
||||||
return "\"" + String.valueOf(enumValues.get(0)) + "\"";
|
|
||||||
} else {
|
|
||||||
return "\"" + codegenParameter.paramName + "_example\"";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if ("Boolean".equals(codegenParameter.dataType) ||
|
|
||||||
"System.Nullable[Boolean]".equals(codegenParameter.dataType)) { // boolean
|
|
||||||
if (Boolean.parseBoolean(codegenParameter.example)) {
|
|
||||||
return "true";
|
|
||||||
} else {
|
|
||||||
return "false";
|
|
||||||
}
|
|
||||||
} else if ("URL".equals(codegenParameter.dataType)) { // URL
|
|
||||||
return "URL(string: \"https://example.com\")!";
|
|
||||||
} else if ("System.DateTime".equals(codegenParameter.dataType)) { // datetime or date
|
|
||||||
return "Get-Date";
|
|
||||||
} else { // numeric
|
|
||||||
if (StringUtils.isEmpty(codegenParameter.example)) {
|
|
||||||
return codegenParameter.example;
|
|
||||||
} else {
|
|
||||||
return "987";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else { // model
|
} else if (codegenParameter.isBoolean) {
|
||||||
// look up the model
|
example.append(constructBooleanExample(codegenParameter.example));
|
||||||
|
} else if (codegenParameter.isDate || codegenParameter.isDateTime) {
|
||||||
|
example.append("(Get-Date)");
|
||||||
|
} else if (codegenParameter.isArray) {
|
||||||
|
if (codegenParameter.items.isModel || (modelMaps.containsKey(codegenParameter.items.dataType) && codegenParameter.items.allowableValues == null)) {
|
||||||
|
String modelExample;
|
||||||
|
if (codegenParameter.items.isModel) {
|
||||||
|
modelExample = constructExampleCode(codegenParameter.items, modelMaps, processedModelMap, requiredOnly);
|
||||||
|
} else {
|
||||||
|
modelExample = constructExampleCode(modelMaps.get(codegenParameter.items.dataType), modelMaps, processedModelMap, requiredOnly);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StringUtils.isEmpty(modelExample)) {
|
||||||
|
example.append(modelExample);
|
||||||
|
}
|
||||||
|
} else if (codegenParameter.items.isString) {
|
||||||
|
if (codegenParameter.items.isEnum || (codegenParameter.items.allowableValues != null && !codegenParameter.items.allowableValues.isEmpty())) {
|
||||||
|
example.append(constructEnumExample(codegenParameter.items.allowableValues));
|
||||||
|
} else {
|
||||||
|
String genericStringExample = codegenParameter.items.name + "_example";
|
||||||
|
example.append(constructStringExample(codegenParameter.paramName, codegenParameter.items.example, genericStringExample));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
example.append(constructExampleCode(codegenParameter.items, modelMaps, processedModelMap, requiredOnly));
|
||||||
|
}
|
||||||
|
} else if (codegenParameter.isMap) {
|
||||||
|
if (codegenParameter.items.isModel) {
|
||||||
|
String modelExample = constructExampleCode(codegenParameter.items, modelMaps, processedModelMap, requiredOnly);
|
||||||
|
if (!StringUtils.isEmpty(modelExample)) {
|
||||||
|
example.append(modelExample + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
example.append("$" + codegenParameter.paramName + " = @{ key_example = $" + codegenParameter.items.dataType + " }");
|
||||||
|
} else {
|
||||||
|
example.append("@{ key_example = ");
|
||||||
|
example.append(constructExampleCode(codegenParameter.items, modelMaps, processedModelMap, requiredOnly));
|
||||||
|
example.append(" }");
|
||||||
|
}
|
||||||
|
} else if (codegenParameter.isEnum || (codegenParameter.allowableValues != null && !codegenParameter.allowableValues.isEmpty())) {
|
||||||
|
example.append(constructEnumExample(codegenParameter.allowableValues));
|
||||||
|
} else if (codegenParameter.isModel) {
|
||||||
if (modelMaps.containsKey(codegenParameter.dataType)) {
|
if (modelMaps.containsKey(codegenParameter.dataType)) {
|
||||||
return constructExampleCode(modelMaps.get(codegenParameter.dataType), modelMaps, processedModelMap);
|
String modelExample = constructExampleCode(modelMaps.get(codegenParameter.dataType), modelMaps, processedModelMap, requiredOnly);
|
||||||
} else {
|
if (!StringUtils.isEmpty(modelExample)) {
|
||||||
//LOGGER.error("Error in constructing examples. Failed to look up the model " + codegenParameter.dataType);
|
example.append(modelExample);
|
||||||
return "TODO";
|
}
|
||||||
}
|
}
|
||||||
|
} else if ((languageSpecificPrimitives.contains(codegenParameter.dataType) || nullablePrimitives.contains(codegenParameter.dataType)) && !codegenParameter.isFile) {
|
||||||
|
// If the data type is primitive and it is not a String, Enum, Boolean, File, Date or DateTime, then it's a number.
|
||||||
|
example.append(constructNumericExample(codegenParameter.example));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Replace multiple new lines with a single new line and trim leading and trailing spaces.
|
||||||
|
return example.toString().replaceAll("[\n]{2,}", "\n\n").trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String constructExampleCode(CodegenProperty codegenProperty, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) {
|
private String constructExampleCode(CodegenProperty codegenProperty, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap, boolean requiredOnly) {
|
||||||
if (codegenProperty.isArray) { // array
|
StringBuilder example = new StringBuilder();
|
||||||
return "@(" + constructExampleCode(codegenProperty.items, modelMaps, processedModelMap) + ")";
|
|
||||||
} else if (codegenProperty.isMap) { // map
|
if (codegenProperty.isString) {
|
||||||
return "\"TODO\"";
|
if (codegenProperty.isEnum || (codegenProperty.allowableValues != null && !codegenProperty.allowableValues.isEmpty())) {
|
||||||
} else if (languageSpecificPrimitives.contains(codegenProperty.dataType) || // primitive type
|
example.append(constructEnumExample(codegenProperty.allowableValues));
|
||||||
nullablePrimitives.contains(codegenProperty.dataType)) { // nullable primitive type
|
} else {
|
||||||
if ("String".equals(codegenProperty.dataType)) {
|
String genericStringExample = codegenProperty.name + "_example";
|
||||||
if (StringUtils.isEmpty(codegenProperty.example)) {
|
example.append(constructStringExample(codegenProperty.name, codegenProperty.example, genericStringExample));
|
||||||
return "\"" + codegenProperty.example + "\"";
|
|
||||||
} else {
|
|
||||||
if (Boolean.TRUE.equals(codegenProperty.isEnum)) { // enum
|
|
||||||
List<Object> enumValues = (List<Object>) codegenProperty.allowableValues.get("values");
|
|
||||||
return "\"" + String.valueOf(enumValues.get(0)) + "\"";
|
|
||||||
} else {
|
|
||||||
return "\"" + codegenProperty.name + "_example\"";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if ("Boolean".equals(codegenProperty.dataType) ||
|
|
||||||
"System.Nullable[Boolean]".equals(codegenProperty.dataType)) { // boolean
|
|
||||||
if (Boolean.parseBoolean(codegenProperty.example)) {
|
|
||||||
return "$true";
|
|
||||||
} else {
|
|
||||||
return "$false";
|
|
||||||
}
|
|
||||||
} else if ("URL".equals(codegenProperty.dataType)) { // URL
|
|
||||||
return "URL(string: \"https://example.com\")!";
|
|
||||||
} else if ("System.DateTime".equals(codegenProperty.dataType)) { // datetime or date
|
|
||||||
return "Get-Date";
|
|
||||||
} else { // numeric
|
|
||||||
if (StringUtils.isEmpty(codegenProperty.example)) {
|
|
||||||
return codegenProperty.example;
|
|
||||||
} else {
|
|
||||||
return "123";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else if (codegenProperty.isBoolean) {
|
||||||
// look up the model
|
example.append(constructBooleanExample(codegenProperty.example));
|
||||||
|
} else if (codegenProperty.isDate || codegenProperty.isDateTime) {
|
||||||
|
example.append("(Get-Date)");
|
||||||
|
} else if (codegenProperty.isArray) {
|
||||||
|
example.append(constructExampleCode(codegenProperty.items, modelMaps, processedModelMap, requiredOnly));
|
||||||
|
} else if (codegenProperty.isMap) {
|
||||||
|
example.append("@{ key_example = ");
|
||||||
|
example.append(constructExampleCode(codegenProperty.items, modelMaps, processedModelMap, requiredOnly));
|
||||||
|
example.append(" }");
|
||||||
|
} else if (codegenProperty.isEnum || (codegenProperty.allowableValues != null && !codegenProperty.allowableValues.isEmpty())) {
|
||||||
|
example.append(constructEnumExample(codegenProperty.allowableValues));
|
||||||
|
} else if (codegenProperty.isModel) {
|
||||||
if (modelMaps.containsKey(codegenProperty.dataType)) {
|
if (modelMaps.containsKey(codegenProperty.dataType)) {
|
||||||
return constructExampleCode(modelMaps.get(codegenProperty.dataType), modelMaps, processedModelMap);
|
String modelExample = constructExampleCode(modelMaps.get(codegenProperty.dataType), modelMaps, processedModelMap, requiredOnly);
|
||||||
} else {
|
if (!StringUtils.isEmpty(modelExample)) {
|
||||||
//LOGGER.error("Error in constructing examples. Failed to look up the model " + codegenProperty.dataType);
|
example.append(modelExample);
|
||||||
return "\"TODO\"";
|
}
|
||||||
}
|
}
|
||||||
|
} else if ((languageSpecificPrimitives.contains(codegenProperty.dataType) || nullablePrimitives.contains(codegenProperty.dataType)) && !codegenProperty.isFile) {
|
||||||
|
// If the data type is primitive and it is not a String, Enum, Boolean, File, Date or DateTime, then it's a number.
|
||||||
|
example.append(constructNumericExample(codegenProperty.example));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return example.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String constructExampleCode(CodegenModel codegenModel, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap) {
|
private String constructExampleCode(CodegenModel codegenModel, HashMap<String, CodegenModel> modelMaps, HashMap<String, Integer> processedModelMap, boolean requiredOnly) {
|
||||||
String example;
|
StringBuilder example = new StringBuilder();
|
||||||
|
Boolean hasModelProperty = false;
|
||||||
|
|
||||||
// break infinite recursion. Return, in case a model is already processed in the current context.
|
// This behaviour is needed to break infinite recursion. Return, in case a model is already processed in the current context.
|
||||||
String model = codegenModel.name;
|
String model = codegenModel.name;
|
||||||
if (processedModelMap.containsKey(model)) {
|
if (processedModelMap.containsKey(model)) {
|
||||||
int count = processedModelMap.get(model);
|
return "";
|
||||||
if (count == 1) {
|
|
||||||
processedModelMap.put(model, 2);
|
|
||||||
} else if (count == 2) {
|
|
||||||
return "";
|
|
||||||
} else {
|
|
||||||
throw new RuntimeException("Invalid count when constructing example: " + count);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
processedModelMap.put(model, 1);
|
processedModelMap.put(model, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
example = "(Initialize-" + codegenModel.name + " ";
|
|
||||||
List<String> propertyExamples = new ArrayList<>();
|
List<String> propertyExamples = new ArrayList<>();
|
||||||
for (CodegenProperty codegenProperty : codegenModel.allVars) {
|
for (CodegenProperty codegenProperty : codegenModel.allVars) {
|
||||||
propertyExamples.add("-" + codegenProperty.name + " " + constructExampleCode(codegenProperty, modelMaps, processedModelMap));
|
if (
|
||||||
|
!hasModelProperty && (
|
||||||
|
codegenProperty.isModel ||
|
||||||
|
(codegenProperty.isArray && (codegenProperty.items.isModel || (modelMaps.containsKey(codegenProperty.items.dataType) && codegenProperty.items.allowableValues == null))) ||
|
||||||
|
(codegenProperty.isMap && codegenProperty.items.isModel))
|
||||||
|
) {
|
||||||
|
example.append("\n");
|
||||||
|
hasModelProperty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requiredOnly && !codegenProperty.required) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (codegenProperty.isModel) {
|
||||||
|
String modelExample = constructExampleCode(codegenProperty, modelMaps, processedModelMap, requiredOnly);
|
||||||
|
if (!StringUtils.isEmpty(modelExample)) {
|
||||||
|
example.append(modelExample + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
propertyExamples.add("-" + codegenProperty.name + " " + "$" + codegenProperty.dataType);
|
||||||
|
} else if (codegenProperty.isArray && (codegenProperty.items.isModel || (modelMaps.containsKey(codegenProperty.items.dataType) && codegenProperty.items.allowableValues == null))) {
|
||||||
|
String modelExample;
|
||||||
|
if (codegenProperty.items.isModel) {
|
||||||
|
modelExample = constructExampleCode(codegenProperty.items, modelMaps, processedModelMap, requiredOnly);
|
||||||
|
} else {
|
||||||
|
modelExample = constructExampleCode(modelMaps.get(codegenProperty.items.dataType), modelMaps, processedModelMap, requiredOnly);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StringUtils.isEmpty(modelExample)) {
|
||||||
|
example.append(modelExample + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
propertyExamples.add("-" + codegenProperty.name + " " + "$" + codegenProperty.complexType);
|
||||||
|
} else if (codegenProperty.isArray && codegenProperty.items.isString) {
|
||||||
|
if (codegenProperty.items.isEnum || (codegenProperty.items.allowableValues != null && !codegenProperty.items.allowableValues.isEmpty())) {
|
||||||
|
example.append(constructEnumExample(codegenProperty.items.allowableValues));
|
||||||
|
propertyExamples.add("-" + codegenProperty.name + " " + example.toString());
|
||||||
|
} else {
|
||||||
|
StringBuilder stringArrayPropertyValue = new StringBuilder();
|
||||||
|
String genericStringExample = codegenProperty.items.name + "_example";
|
||||||
|
|
||||||
|
stringArrayPropertyValue.append(constructStringExample(codegenProperty.name, codegenProperty.items.example, genericStringExample));
|
||||||
|
|
||||||
|
propertyExamples.add("-" + codegenProperty.name + " " + stringArrayPropertyValue.toString());
|
||||||
|
}
|
||||||
|
} else if (codegenProperty.isMap && codegenProperty.items.isModel) {
|
||||||
|
String modelExample = constructExampleCode(codegenProperty.items, modelMaps, processedModelMap, requiredOnly);
|
||||||
|
if (!StringUtils.isEmpty(modelExample)) {
|
||||||
|
example.append(modelExample + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
propertyExamples.add("-" + codegenProperty.name + " " + "@{ key_example = " + "$" + codegenProperty.complexType + " }");
|
||||||
|
} else {
|
||||||
|
propertyExamples.add("-" + codegenProperty.name + " " + constructExampleCode(codegenProperty, modelMaps, processedModelMap, requiredOnly));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
example += StringUtils.join(propertyExamples, " ");
|
|
||||||
example += ")";
|
example.append("$");
|
||||||
return example;
|
if (this.useClassNameInModelsExamples) {
|
||||||
|
example.append(codegenModel.classname);
|
||||||
|
} else {
|
||||||
|
example.append(codegenModel.name);
|
||||||
|
}
|
||||||
|
example.append(" = " + this.modelsCmdletVerb + "-");
|
||||||
|
if (this.useClassNameInModelsExamples) {
|
||||||
|
example.append(codegenModel.classname);
|
||||||
|
} else {
|
||||||
|
example.append(codegenModel.name);
|
||||||
|
}
|
||||||
|
example.append(" ");
|
||||||
|
|
||||||
|
example.append(StringUtils.join(propertyExamples, " "));
|
||||||
|
|
||||||
|
if (hasModelProperty) {
|
||||||
|
example.append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return example.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String constructStringExample(String codegenName, String codegenExample, String genericStringExample) {
|
||||||
|
StringBuilder example = new StringBuilder();
|
||||||
|
example.append("\"");
|
||||||
|
|
||||||
|
if (
|
||||||
|
StringUtils.isEmpty(codegenExample) ||
|
||||||
|
codegenExample.equals("null") ||
|
||||||
|
codegenExample.equals(genericStringExample)
|
||||||
|
) {
|
||||||
|
example.append("My" + codegenName);
|
||||||
|
} else {
|
||||||
|
example.append(codegenExample);
|
||||||
|
}
|
||||||
|
|
||||||
|
example.append("\"");
|
||||||
|
|
||||||
|
return example.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String constructEnumExample(Map<String, Object> allowableValues) {
|
||||||
|
StringBuilder example = new StringBuilder();
|
||||||
|
|
||||||
|
example.append("\"");
|
||||||
|
|
||||||
|
List<Object> enumValues = (List<Object>) allowableValues.get("values");
|
||||||
|
example.append(String.valueOf(enumValues.get(0)));
|
||||||
|
|
||||||
|
example.append("\"");
|
||||||
|
|
||||||
|
return example.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String constructNumericExample(String codegenExample) {
|
||||||
|
StringBuilder example = new StringBuilder();
|
||||||
|
|
||||||
|
if (StringUtils.isEmpty(codegenExample) || codegenExample.equals("null")) {
|
||||||
|
example.append("0");
|
||||||
|
} else {
|
||||||
|
example.append(codegenExample);
|
||||||
|
}
|
||||||
|
|
||||||
|
return example.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String constructBooleanExample(String codegenExample) {
|
||||||
|
StringBuilder example = new StringBuilder();
|
||||||
|
|
||||||
|
if (Boolean.parseBoolean(codegenExample)) {
|
||||||
|
example.append("$true");
|
||||||
|
} else {
|
||||||
|
example.append("$false");
|
||||||
|
}
|
||||||
|
|
||||||
|
return example.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPSDataType(CodegenProperty cp) {
|
private String getPSDataType(CodegenProperty cp) {
|
||||||
|
@ -56,14 +56,29 @@ Set-ConfigurationHttpSigning $httpSigningParams
|
|||||||
{{/authMethods}}
|
{{/authMethods}}
|
||||||
{{/hasAuthMethods}}
|
{{/hasAuthMethods}}
|
||||||
{{#allParams}}
|
{{#allParams}}
|
||||||
|
{{^isArray}}
|
||||||
|
{{#isModel}}
|
||||||
|
{{{vendorExtensions.x-powershell-example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
||||||
|
{{/isModel}}
|
||||||
|
{{^isModel}}
|
||||||
${{paramName}} = {{{vendorExtensions.x-powershell-example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
${{paramName}} = {{{vendorExtensions.x-powershell-example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
||||||
|
{{/isModel}}
|
||||||
|
{{/isArray}}
|
||||||
|
{{#isArray}}
|
||||||
|
{{#items.isModel}}
|
||||||
|
{{{vendorExtensions.x-powershell-example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
||||||
|
{{/items.isModel}}
|
||||||
|
{{^items.isModel}}
|
||||||
|
${{paramName}} = {{{vendorExtensions.x-powershell-example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
||||||
|
{{/items.isModel}}
|
||||||
|
{{/isArray}}
|
||||||
{{/allParams}}
|
{{/allParams}}
|
||||||
|
|
||||||
{{#summary}}
|
{{#summary}}
|
||||||
# {{{.}}}
|
# {{{.}}}
|
||||||
{{/summary}}
|
{{/summary}}
|
||||||
try {
|
try {
|
||||||
$Result = {{{vendorExtensions.x-powershell-method-name}}}{{#allParams}} -{{paramName}} ${{paramName}}{{/allParams}}
|
$Result = {{{vendorExtensions.x-powershell-method-name}}}{{#allParams}} -{{paramName}} ${{paramName}}{{/allParams}}
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host ("Exception occured when calling {{{vendorExtensions.x-powershell-method-name}}}: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
Write-Host ("Exception occured when calling {{{vendorExtensions.x-powershell-method-name}}}: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
||||||
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
||||||
|
@ -28,11 +28,13 @@ $Configuration = Get-Configuration
|
|||||||
# Configure OAuth2 access token for authorization: petstore_auth
|
# Configure OAuth2 access token for authorization: petstore_auth
|
||||||
$Configuration.AccessToken = "YOUR_ACCESS_TOKEN"
|
$Configuration.AccessToken = "YOUR_ACCESS_TOKEN"
|
||||||
|
|
||||||
$Pet = (Initialize-Pet -Id 123 -Category (Initialize-Category -Id 123 -Name "Name_example") -Name "Name_example" -PhotoUrls @("PhotoUrls_example") -Tags @((Initialize-Tag -Id 123 -Name "Name_example")) -Status "available") # Pet | Pet object that needs to be added to the store
|
$Category = Initialize-Category -Id 0 -Name "MyName"
|
||||||
|
$Tag = Initialize-Tag -Id 0 -Name "MyName"
|
||||||
|
$Pet = Initialize-Pet -Id 0 -Category $Category -Name "doggie" -PhotoUrls "MyPhotoUrls" -Tags $Tag -Status "available" # Pet | Pet object that needs to be added to the store
|
||||||
|
|
||||||
# Add a new pet to the store
|
# Add a new pet to the store
|
||||||
try {
|
try {
|
||||||
$Result = Add-PSPet -Pet $Pet
|
$Result = Add-PSPet -Pet $Pet
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host ("Exception occured when calling Add-PSPet: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
Write-Host ("Exception occured when calling Add-PSPet: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
||||||
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
||||||
@ -43,7 +45,7 @@ try {
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**Pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
|
**Pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
@ -75,12 +77,12 @@ $Configuration = Get-Configuration
|
|||||||
# Configure OAuth2 access token for authorization: petstore_auth
|
# Configure OAuth2 access token for authorization: petstore_auth
|
||||||
$Configuration.AccessToken = "YOUR_ACCESS_TOKEN"
|
$Configuration.AccessToken = "YOUR_ACCESS_TOKEN"
|
||||||
|
|
||||||
$PetId = 987 # Int64 | Pet id to delete
|
$PetId = 789 # Int64 | Pet id to delete
|
||||||
$ApiKey = "ApiKey_example" # String | (optional)
|
$ApiKey = "MyApiKey" # String | (optional)
|
||||||
|
|
||||||
# Deletes a pet
|
# Deletes a pet
|
||||||
try {
|
try {
|
||||||
$Result = Remove-Pet -PetId $PetId -ApiKey $ApiKey
|
$Result = Remove-Pet -PetId $PetId -ApiKey $ApiKey
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host ("Exception occured when calling Remove-Pet: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
Write-Host ("Exception occured when calling Remove-Pet: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
||||||
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
||||||
@ -91,8 +93,8 @@ try {
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**PetId** | **Int64**| Pet id to delete |
|
**PetId** | **Int64**| Pet id to delete |
|
||||||
**ApiKey** | **String**| | [optional]
|
**ApiKey** | **String**| | [optional]
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
@ -125,11 +127,11 @@ $Configuration = Get-Configuration
|
|||||||
# Configure OAuth2 access token for authorization: petstore_auth
|
# Configure OAuth2 access token for authorization: petstore_auth
|
||||||
$Configuration.AccessToken = "YOUR_ACCESS_TOKEN"
|
$Configuration.AccessToken = "YOUR_ACCESS_TOKEN"
|
||||||
|
|
||||||
$Status = @("available") # String[] | Status values that need to be considered for filter
|
$Status = "available" # String[] | Status values that need to be considered for filter
|
||||||
|
|
||||||
# Finds Pets by status
|
# Finds Pets by status
|
||||||
try {
|
try {
|
||||||
$Result = Find-PSPetsByStatus -Status $Status
|
$Result = Find-PSPetsByStatus -Status $Status
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host ("Exception occured when calling Find-PSPetsByStatus: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
Write-Host ("Exception occured when calling Find-PSPetsByStatus: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
||||||
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
||||||
@ -140,7 +142,7 @@ try {
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**Status** | [**String[]**](String.md)| Status values that need to be considered for filter |
|
**Status** | [**String[]**](String.md)| Status values that need to be considered for filter |
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
@ -173,11 +175,11 @@ $Configuration = Get-Configuration
|
|||||||
# Configure OAuth2 access token for authorization: petstore_auth
|
# Configure OAuth2 access token for authorization: petstore_auth
|
||||||
$Configuration.AccessToken = "YOUR_ACCESS_TOKEN"
|
$Configuration.AccessToken = "YOUR_ACCESS_TOKEN"
|
||||||
|
|
||||||
$Tags = @("Inner_example") # String[] | Tags to filter by
|
$Tags = "MyTags" # String[] | Tags to filter by
|
||||||
|
|
||||||
# Finds Pets by tags
|
# Finds Pets by tags
|
||||||
try {
|
try {
|
||||||
$Result = Find-PSPetsByTags -Tags $Tags
|
$Result = Find-PSPetsByTags -Tags $Tags
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host ("Exception occured when calling Find-PSPetsByTags: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
Write-Host ("Exception occured when calling Find-PSPetsByTags: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
||||||
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
||||||
@ -188,7 +190,7 @@ try {
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**Tags** | [**String[]**](String.md)| Tags to filter by |
|
**Tags** | [**String[]**](String.md)| Tags to filter by |
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
@ -223,11 +225,11 @@ $Configuration.ApiKey.api_key = "YOUR_API_KEY"
|
|||||||
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||||
#$Configuration.ApiKeyPrefix.api_key = "Bearer"
|
#$Configuration.ApiKeyPrefix.api_key = "Bearer"
|
||||||
|
|
||||||
$PetId = 987 # Int64 | ID of pet to return
|
$PetId = 789 # Int64 | ID of pet to return
|
||||||
|
|
||||||
# Find pet by ID
|
# Find pet by ID
|
||||||
try {
|
try {
|
||||||
$Result = Get-PSPetById -PetId $PetId
|
$Result = Get-PSPetById -PetId $PetId
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host ("Exception occured when calling Get-PSPetById: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
Write-Host ("Exception occured when calling Get-PSPetById: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
||||||
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
||||||
@ -238,7 +240,7 @@ try {
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**PetId** | **Int64**| ID of pet to return |
|
**PetId** | **Int64**| ID of pet to return |
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
@ -269,11 +271,13 @@ $Configuration = Get-Configuration
|
|||||||
# Configure OAuth2 access token for authorization: petstore_auth
|
# Configure OAuth2 access token for authorization: petstore_auth
|
||||||
$Configuration.AccessToken = "YOUR_ACCESS_TOKEN"
|
$Configuration.AccessToken = "YOUR_ACCESS_TOKEN"
|
||||||
|
|
||||||
$Pet = (Initialize-Pet -Id 123 -Category (Initialize-Category -Id 123 -Name "Name_example") -Name "Name_example" -PhotoUrls @("PhotoUrls_example") -Tags @((Initialize-Tag -Id 123 -Name "Name_example")) -Status "available") # Pet | Pet object that needs to be added to the store
|
$Category = Initialize-Category -Id 0 -Name "MyName"
|
||||||
|
$Tag = Initialize-Tag -Id 0 -Name "MyName"
|
||||||
|
$Pet = Initialize-Pet -Id 0 -Category $Category -Name "doggie" -PhotoUrls "MyPhotoUrls" -Tags $Tag -Status "available" # Pet | Pet object that needs to be added to the store
|
||||||
|
|
||||||
# Update an existing pet
|
# Update an existing pet
|
||||||
try {
|
try {
|
||||||
$Result = Update-PSPet -Pet $Pet
|
$Result = Update-PSPet -Pet $Pet
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host ("Exception occured when calling Update-PSPet: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
Write-Host ("Exception occured when calling Update-PSPet: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
||||||
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
||||||
@ -284,7 +288,7 @@ try {
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**Pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
|
**Pet** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
@ -317,13 +321,13 @@ $Configuration = Get-Configuration
|
|||||||
# Configure OAuth2 access token for authorization: petstore_auth
|
# Configure OAuth2 access token for authorization: petstore_auth
|
||||||
$Configuration.AccessToken = "YOUR_ACCESS_TOKEN"
|
$Configuration.AccessToken = "YOUR_ACCESS_TOKEN"
|
||||||
|
|
||||||
$PetId = 987 # Int64 | ID of pet that needs to be updated
|
$PetId = 789 # Int64 | ID of pet that needs to be updated
|
||||||
$Name = "Name_example" # String | Updated name of the pet (optional)
|
$Name = "MyName" # String | Updated name of the pet (optional)
|
||||||
$Status = "Status_example" # String | Updated status of the pet (optional)
|
$Status = "MyStatus" # String | Updated status of the pet (optional)
|
||||||
|
|
||||||
# Updates a pet in the store with form data
|
# Updates a pet in the store with form data
|
||||||
try {
|
try {
|
||||||
$Result = Update-PSPetWithForm -PetId $PetId -Name $Name -Status $Status
|
$Result = Update-PSPetWithForm -PetId $PetId -Name $Name -Status $Status
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host ("Exception occured when calling Update-PSPetWithForm: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
Write-Host ("Exception occured when calling Update-PSPetWithForm: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
||||||
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
||||||
@ -334,9 +338,9 @@ try {
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**PetId** | **Int64**| ID of pet that needs to be updated |
|
**PetId** | **Int64**| ID of pet that needs to be updated |
|
||||||
**Name** | **String**| Updated name of the pet | [optional]
|
**Name** | **String**| Updated name of the pet | [optional]
|
||||||
**Status** | **String**| Updated status of the pet | [optional]
|
**Status** | **String**| Updated status of the pet | [optional]
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
@ -369,13 +373,13 @@ $Configuration = Get-Configuration
|
|||||||
# Configure OAuth2 access token for authorization: petstore_auth
|
# Configure OAuth2 access token for authorization: petstore_auth
|
||||||
$Configuration.AccessToken = "YOUR_ACCESS_TOKEN"
|
$Configuration.AccessToken = "YOUR_ACCESS_TOKEN"
|
||||||
|
|
||||||
$PetId = 987 # Int64 | ID of pet to update
|
$PetId = 789 # Int64 | ID of pet to update
|
||||||
$AdditionalMetadata = "AdditionalMetadata_example" # String | Additional data to pass to server (optional)
|
$AdditionalMetadata = "MyAdditionalMetadata" # String | Additional data to pass to server (optional)
|
||||||
$File = 987 # System.IO.FileInfo | file to upload (optional)
|
$File = # System.IO.FileInfo | file to upload (optional)
|
||||||
|
|
||||||
# uploads an image
|
# uploads an image
|
||||||
try {
|
try {
|
||||||
$Result = Invoke-PSUploadFile -PetId $PetId -AdditionalMetadata $AdditionalMetadata -File $File
|
$Result = Invoke-PSUploadFile -PetId $PetId -AdditionalMetadata $AdditionalMetadata -File $File
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host ("Exception occured when calling Invoke-PSUploadFile: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
Write-Host ("Exception occured when calling Invoke-PSUploadFile: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
||||||
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
||||||
@ -386,9 +390,9 @@ try {
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**PetId** | **Int64**| ID of pet to update |
|
**PetId** | **Int64**| ID of pet to update |
|
||||||
**AdditionalMetadata** | **String**| Additional data to pass to server | [optional]
|
**AdditionalMetadata** | **String**| Additional data to pass to server | [optional]
|
||||||
**File** | **System.IO.FileInfo****System.IO.FileInfo**| file to upload | [optional]
|
**File** | **System.IO.FileInfo****System.IO.FileInfo**| file to upload | [optional]
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
|
@ -21,11 +21,11 @@ For valid response try integer IDs with value < 1000. Anything above 1000 or non
|
|||||||
|
|
||||||
### Example
|
### Example
|
||||||
```powershell
|
```powershell
|
||||||
$OrderId = "OrderId_example" # String | ID of the order that needs to be deleted
|
$OrderId = "MyOrderId" # String | ID of the order that needs to be deleted
|
||||||
|
|
||||||
# Delete purchase order by ID
|
# Delete purchase order by ID
|
||||||
try {
|
try {
|
||||||
$Result = Remove-PSOrder -OrderId $OrderId
|
$Result = Remove-PSOrder -OrderId $OrderId
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host ("Exception occured when calling Remove-PSOrder: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
Write-Host ("Exception occured when calling Remove-PSOrder: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
||||||
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
||||||
@ -36,7 +36,7 @@ try {
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**OrderId** | **String**| ID of the order that needs to be deleted |
|
**OrderId** | **String**| ID of the order that needs to be deleted |
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ $Configuration.ApiKey.api_key = "YOUR_API_KEY"
|
|||||||
|
|
||||||
# Returns pet inventories by status
|
# Returns pet inventories by status
|
||||||
try {
|
try {
|
||||||
$Result = Get-PSInventory
|
$Result = Get-PSInventory
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host ("Exception occured when calling Get-PSInventory: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
Write-Host ("Exception occured when calling Get-PSInventory: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
||||||
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
||||||
@ -109,11 +109,11 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge
|
|||||||
|
|
||||||
### Example
|
### Example
|
||||||
```powershell
|
```powershell
|
||||||
$OrderId = 987 # Int64 | ID of pet that needs to be fetched
|
$OrderId = 789 # Int64 | ID of pet that needs to be fetched
|
||||||
|
|
||||||
# Find purchase order by ID
|
# Find purchase order by ID
|
||||||
try {
|
try {
|
||||||
$Result = Get-PSOrderById -OrderId $OrderId
|
$Result = Get-PSOrderById -OrderId $OrderId
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host ("Exception occured when calling Get-PSOrderById: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
Write-Host ("Exception occured when calling Get-PSOrderById: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
||||||
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
||||||
@ -124,7 +124,7 @@ try {
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**OrderId** | **Int64**| ID of pet that needs to be fetched |
|
**OrderId** | **Int64**| ID of pet that needs to be fetched |
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
@ -150,11 +150,11 @@ Place an order for a pet
|
|||||||
|
|
||||||
### Example
|
### Example
|
||||||
```powershell
|
```powershell
|
||||||
$Order = (Initialize-Order -Id 123 -PetId 123 -Quantity 123 -ShipDate Get-Date -Status "placed" -Complete $false) # Order | order placed for purchasing the pet
|
$Order = Initialize-Order -Id 0 -PetId 0 -Quantity 0 -ShipDate (Get-Date) -Status "placed" -Complete $false # Order | order placed for purchasing the pet
|
||||||
|
|
||||||
# Place an order for a pet
|
# Place an order for a pet
|
||||||
try {
|
try {
|
||||||
$Result = Invoke-PSPlaceOrder -Order $Order
|
$Result = Invoke-PSPlaceOrder -Order $Order
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host ("Exception occured when calling Invoke-PSPlaceOrder: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
Write-Host ("Exception occured when calling Invoke-PSPlaceOrder: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
||||||
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
||||||
@ -165,7 +165,7 @@ try {
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**Order** | [**Order**](Order.md)| order placed for purchasing the pet |
|
**Order** | [**Order**](Order.md)| order placed for purchasing the pet |
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
|
@ -32,11 +32,11 @@ $Configuration.ApiKey.AUTH_KEY = "YOUR_API_KEY"
|
|||||||
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||||
#$Configuration.ApiKeyPrefix.AUTH_KEY = "Bearer"
|
#$Configuration.ApiKeyPrefix.AUTH_KEY = "Bearer"
|
||||||
|
|
||||||
$User = (Initialize-User -Id 123 -Username "Username_example" -FirstName "FirstName_example" -LastName "LastName_example" -Email "Email_example" -Password "Password_example" -Phone "Phone_example" -UserStatus 123) # User | Created user object
|
$User = Initialize-User -Id 0 -Username "MyUsername" -FirstName "MyFirstName" -LastName "MyLastName" -Email "MyEmail" -Password "MyPassword" -Phone "MyPhone" -UserStatus 0 # User | Created user object
|
||||||
|
|
||||||
# Create user
|
# Create user
|
||||||
try {
|
try {
|
||||||
$Result = New-PSUser -User $User
|
$Result = New-PSUser -User $User
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host ("Exception occured when calling New-PSUser: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
Write-Host ("Exception occured when calling New-PSUser: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
||||||
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
||||||
@ -47,7 +47,7 @@ try {
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**User** | [**User**](User.md)| Created user object |
|
**User** | [**User**](User.md)| Created user object |
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
@ -80,11 +80,11 @@ $Configuration.ApiKey.AUTH_KEY = "YOUR_API_KEY"
|
|||||||
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||||
#$Configuration.ApiKeyPrefix.AUTH_KEY = "Bearer"
|
#$Configuration.ApiKeyPrefix.AUTH_KEY = "Bearer"
|
||||||
|
|
||||||
$User = @((Initialize-User -Id 123 -Username "Username_example" -FirstName "FirstName_example" -LastName "LastName_example" -Email "Email_example" -Password "Password_example" -Phone "Phone_example" -UserStatus 123)) # User[] | List of user object
|
$User = Initialize-User -Id 0 -Username "MyUsername" -FirstName "MyFirstName" -LastName "MyLastName" -Email "MyEmail" -Password "MyPassword" -Phone "MyPhone" -UserStatus 0 # User[] | List of user object
|
||||||
|
|
||||||
# Creates list of users with given input array
|
# Creates list of users with given input array
|
||||||
try {
|
try {
|
||||||
$Result = New-PSUsersWithArrayInput -User $User
|
$Result = New-PSUsersWithArrayInput -User $User
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host ("Exception occured when calling New-PSUsersWithArrayInput: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
Write-Host ("Exception occured when calling New-PSUsersWithArrayInput: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
||||||
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
||||||
@ -95,7 +95,7 @@ try {
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**User** | [**User[]**](User.md)| List of user object |
|
**User** | [**User[]**](User.md)| List of user object |
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
@ -128,11 +128,11 @@ $Configuration.ApiKey.AUTH_KEY = "YOUR_API_KEY"
|
|||||||
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||||
#$Configuration.ApiKeyPrefix.AUTH_KEY = "Bearer"
|
#$Configuration.ApiKeyPrefix.AUTH_KEY = "Bearer"
|
||||||
|
|
||||||
$User = @() # User[] | List of user object
|
$User = Initialize-User -Id 0 -Username "MyUsername" -FirstName "MyFirstName" -LastName "MyLastName" -Email "MyEmail" -Password "MyPassword" -Phone "MyPhone" -UserStatus 0 # User[] | List of user object
|
||||||
|
|
||||||
# Creates list of users with given input array
|
# Creates list of users with given input array
|
||||||
try {
|
try {
|
||||||
$Result = New-PSUsersWithListInput -User $User
|
$Result = New-PSUsersWithListInput -User $User
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host ("Exception occured when calling New-PSUsersWithListInput: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
Write-Host ("Exception occured when calling New-PSUsersWithListInput: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
||||||
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
||||||
@ -143,7 +143,7 @@ try {
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**User** | [**User[]**](User.md)| List of user object |
|
**User** | [**User[]**](User.md)| List of user object |
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
@ -178,11 +178,11 @@ $Configuration.ApiKey.AUTH_KEY = "YOUR_API_KEY"
|
|||||||
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||||
#$Configuration.ApiKeyPrefix.AUTH_KEY = "Bearer"
|
#$Configuration.ApiKeyPrefix.AUTH_KEY = "Bearer"
|
||||||
|
|
||||||
$Username = "Username_example" # String | The name that needs to be deleted
|
$Username = "MyUsername" # String | The name that needs to be deleted
|
||||||
|
|
||||||
# Delete user
|
# Delete user
|
||||||
try {
|
try {
|
||||||
$Result = Remove-PSUser -Username $Username
|
$Result = Remove-PSUser -Username $Username
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host ("Exception occured when calling Remove-PSUser: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
Write-Host ("Exception occured when calling Remove-PSUser: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
||||||
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
||||||
@ -193,7 +193,7 @@ try {
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**Username** | **String**| The name that needs to be deleted |
|
**Username** | **String**| The name that needs to be deleted |
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
@ -219,11 +219,11 @@ Get user by user name
|
|||||||
|
|
||||||
### Example
|
### Example
|
||||||
```powershell
|
```powershell
|
||||||
$Username = "Username_example" # String | The name that needs to be fetched. Use user1 for testing.
|
$Username = "MyUsername" # String | The name that needs to be fetched. Use user1 for testing.
|
||||||
|
|
||||||
# Get user by user name
|
# Get user by user name
|
||||||
try {
|
try {
|
||||||
$Result = Get-PSUserByName -Username $Username
|
$Result = Get-PSUserByName -Username $Username
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host ("Exception occured when calling Get-PSUserByName: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
Write-Host ("Exception occured when calling Get-PSUserByName: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
||||||
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
||||||
@ -234,7 +234,7 @@ try {
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**Username** | **String**| The name that needs to be fetched. Use user1 for testing. |
|
**Username** | **String**| The name that needs to be fetched. Use user1 for testing. |
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
@ -261,12 +261,12 @@ Logs user into the system
|
|||||||
|
|
||||||
### Example
|
### Example
|
||||||
```powershell
|
```powershell
|
||||||
$Username = "Username_example" # String | The user name for login
|
$Username = "MyUsername" # String | The user name for login
|
||||||
$Password = "Password_example" # String | The password for login in clear text
|
$Password = "MyPassword" # String | The password for login in clear text
|
||||||
|
|
||||||
# Logs user into the system
|
# Logs user into the system
|
||||||
try {
|
try {
|
||||||
$Result = Invoke-PSLoginUser -Username $Username -Password $Password
|
$Result = Invoke-PSLoginUser -Username $Username -Password $Password
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host ("Exception occured when calling Invoke-PSLoginUser: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
Write-Host ("Exception occured when calling Invoke-PSLoginUser: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
||||||
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
||||||
@ -277,8 +277,8 @@ try {
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**Username** | **String**| The user name for login |
|
**Username** | **String**| The user name for login |
|
||||||
**Password** | **String**| The password for login in clear text |
|
**Password** | **String**| The password for login in clear text |
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
@ -313,7 +313,7 @@ $Configuration.ApiKey.AUTH_KEY = "YOUR_API_KEY"
|
|||||||
|
|
||||||
# Logs out current logged in user session
|
# Logs out current logged in user session
|
||||||
try {
|
try {
|
||||||
$Result = Invoke-PSLogoutUser
|
$Result = Invoke-PSLogoutUser
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host ("Exception occured when calling Invoke-PSLogoutUser: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
Write-Host ("Exception occured when calling Invoke-PSLogoutUser: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
||||||
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
||||||
@ -357,12 +357,12 @@ $Configuration.ApiKey.AUTH_KEY = "YOUR_API_KEY"
|
|||||||
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||||
#$Configuration.ApiKeyPrefix.AUTH_KEY = "Bearer"
|
#$Configuration.ApiKeyPrefix.AUTH_KEY = "Bearer"
|
||||||
|
|
||||||
$Username = "Username_example" # String | name that need to be deleted
|
$Username = "MyUsername" # String | name that need to be deleted
|
||||||
$User = # User | Updated user object
|
$User = Initialize-User -Id 0 -Username "MyUsername" -FirstName "MyFirstName" -LastName "MyLastName" -Email "MyEmail" -Password "MyPassword" -Phone "MyPhone" -UserStatus 0 # User | Updated user object
|
||||||
|
|
||||||
# Updated user
|
# Updated user
|
||||||
try {
|
try {
|
||||||
$Result = Update-PSUser -Username $Username -User $User
|
$Result = Update-PSUser -Username $Username -User $User
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host ("Exception occured when calling Update-PSUser: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
Write-Host ("Exception occured when calling Update-PSUser: {0}" -f ($_.ErrorDetails | ConvertFrom-Json))
|
||||||
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
Write-Host ("Response headers: {0}" -f ($_.Exception.Response.Headers | ConvertTo-Json))
|
||||||
@ -373,8 +373,8 @@ try {
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**Username** | **String**| name that need to be deleted |
|
**Username** | **String**| name that need to be deleted |
|
||||||
**User** | [**User**](User.md)| Updated user object |
|
**User** | [**User**](User.md)| Updated user object |
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user