Skip to content

Commit

Permalink
Microsoft.Chaos TypeSpec migration (Azure#31664)
Browse files Browse the repository at this point in the history
* sorted existing swagger

* initial autogenerated typespec

* initial TypeSpec updates to resolve warnings

* added generated files

* changed inputs to typespec-generated openapi

* Revert "added generated files"

This reverts commit c09b60a.

Revert "initial TypeSpec updates to resolve warnings"

This reverts commit 805007d.

* added new typespec migration api version

* file format updates

* reverted back unintentionally changed spec from previous api version

* various modelvalidation fixes

* fix

* model validation fixes

* linting fixes

* fixes for linting

* fixing swagger avocado

* fixed x-ms-example for privatelink list

* updated readme

* fixed tspconfig formatting

* updated tspconfig

* updates to try to fix breaking sdk changes

* trying to fix typescript client generation

* updated tspconfig

* another attempted fix for typescript sdk

* updates to client.tsp

* attempted ts fix

* updated tspconfig

* changed tspconfig back to original values

* update to tspconfig for ts sdk

* reverted back tspconfig

* attempted javascript replacement for SDK operation

* LintDiff fix

* LintDiff fix

* updated client.tsp

* updated client.tsp for csharp replacements

* updating metadata types for csharp client

* updated csharp client replacements

* updating target location visibility

* updates to fix net sdk breaking changes

* updated for net sdk

* fixing net sdk failures

* fixed client.tsp format

* updated visibility for readonly properties

* updated managed identity model reference

* updated readme directives based on feedback

* breaking change fix

* split up models into separate files

* changed file casing

* fixed bad file reference

* fixed spelling failure

* fixed tsp formatting
  • Loading branch information
brrusino authored Jan 8, 2025
1 parent 04b59b5 commit 9591372
Show file tree
Hide file tree
Showing 97 changed files with 9,153 additions and 14 deletions.
77 changes: 77 additions & 0 deletions specification/chaos/Chaos.Management/capability.models.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import "@typespec/rest";
import "@typespec/http";
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "./common.models.tsp";

using TypeSpec.Rest;
using TypeSpec.Http;
using Azure.ResourceManager;
using Azure.ResourceManager.Foundations;
using TypeSpec.OpenAPI;

namespace Microsoft.Chaos;

/**
* Model that represents a Capability resource.
*/
@parentResource(Target)
model Capability is Azure.ResourceManager.ProxyResource<CapabilityProperties> {
...ResourceNameParameter<
Resource = Capability,
KeyName = "capabilityName",
SegmentName = "capabilities",
NamePattern = "^[a-zA-Z0-9\\-\\.]+-\\d\\.\\d$"
>;
}

alias CapabilityParentResourceParameters = BaseParameters<Capability> &
ParentResourceParameters;

/**
* Model that represents the Capability properties model.
*/
model CapabilityProperties {
/**
* String of the Publisher that this Capability extends.
*/
@visibility("read")
publisher?: string;

/**
* String of the Target Type that this Capability extends.
*/
@visibility("read")
targetType?: string;

/**
* Localized string of the description.
*/
@visibility("read")
description?: string;

/**
* URL to retrieve JSON schema of the Capability parameters.
*/
@visibility("read")
@maxLength(2048)
parametersSchema?: string;

/**
* String of the URN for this Capability Type.
*/
@visibility("read")
@maxLength(2048)
urn?: string;

/**
* Resource provisioning state. Not currently in use because resource is created synchronously.
*/
@visibility("read")
provisioningState?: ProvisioningState;
}

/**
* Model that represents a list of Capability resources and a link for pagination.
*/
model CapabilityListResult is Azure.Core.Page<Capability>;
61 changes: 61 additions & 0 deletions specification/chaos/Chaos.Management/capability.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/openapi";
import "@typespec/rest";
import "./capability.models.tsp";
import "./target.tsp";

using TypeSpec.Rest;
using Azure.ResourceManager;
using Azure.ResourceManager.Foundations;
using TypeSpec.Http;
using TypeSpec.OpenAPI;

namespace Microsoft.Chaos;

@armResourceOperations
interface Capabilities {
/**
* Get a Capability resource that extends a Target resource.
*/
get is ArmResourceRead<Capability, CapabilityParentResourceParameters>;

/**
* Create or update a Capability resource that extends a Target resource.
*/
createOrUpdate is ArmResourceCreateOrReplaceSync<
Capability,
CapabilityParentResourceParameters
>;

/**
* Delete a Capability that extends a Target resource.
*/
delete is ArmResourceDeleteSync<
Capability,
CapabilityParentResourceParameters
>;

/**
* Get a list of Capability resources that extend a Target resource.
*/
list is ArmResourceListByParent<
Capability,
{
...CapabilityParentResourceParameters;

/**
* String that sets the continuation token.
*/
@query("continuationToken")
continuationToken?: string;
},
Response = CapabilityListResult
>;
}

@@doc(Capability.name, "String that represents a Capability resource name.");
@@doc(Capability.properties, "The properties of a capability resource.");
@@doc(Capabilities.createOrUpdate::parameters.resource,
"Capability resource to be created or updated."
);
110 changes: 110 additions & 0 deletions specification/chaos/Chaos.Management/capabilityType.models.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import "@typespec/rest";
import "@typespec/http";
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";

using TypeSpec.Rest;
using TypeSpec.Http;
using Azure.ResourceManager;
using Azure.ResourceManager.Foundations;
using TypeSpec.OpenAPI;

namespace Microsoft.Chaos;

/**
* Model that represents a Capability Type resource.
*/
@parentResource(TargetType)
model CapabilityType
is Azure.ResourceManager.ProxyResource<CapabilityTypeProperties> {
...ResourceNameParameter<
Resource = CapabilityType,
KeyName = "capabilityTypeName",
SegmentName = "capabilityTypes",
NamePattern = "^[a-zA-Z0-9\\-\\.]+-\\d\\.\\d$"
>;
}

/**
* Model that represents the Capability Type properties model.
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-provisioning-state" "Read-only metadata resource."
model CapabilityTypeProperties {
/**
* String of the Publisher that this Capability Type extends.
*/
@visibility("read")
publisher?: string;

/**
* String of the Target Type that this Capability Type extends.
*/
@visibility("read")
targetType?: string;

/**
* Localized string of the display name.
*/
@visibility("read")
displayName?: string;

/**
* Localized string of the description.
*/
@visibility("read")
description?: string;

/**
* URL to retrieve JSON schema of the Capability Type parameters.
*/
@visibility("read")
@maxLength(2048)
parametersSchema?: string;

/**
* String of the URN for this Capability Type.
*/
@visibility("read")
@maxLength(2048)
urn?: string;

/**
* String of the kind of this Capability Type.
*/
@visibility("read")
kind?: string;

/**
* Control plane actions necessary to execute capability type.
*/
@visibility("read")
azureRbacActions?: string[];

/**
* Data plane actions necessary to execute capability type.
*/
@visibility("read")
azureRbacDataActions?: string[];

/**
* Runtime properties of this Capability Type.
*/
@visibility("read")
runtimeProperties?: CapabilityTypePropertiesRuntimeProperties;
}

/**
* Runtime properties of this Capability Type.
*/
model CapabilityTypePropertiesRuntimeProperties {
/**
* String of the kind of the resource's action type (continuous or discrete).
*/
@visibility("read")
kind?: string;
}

/**
* Model that represents a list of Capability Type resources and a link for pagination.
*/
model CapabilityTypeListResult is Azure.Core.Page<CapabilityType>;
42 changes: 42 additions & 0 deletions specification/chaos/Chaos.Management/capabilityType.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/openapi";
import "@typespec/rest";
import "./capabilityType.models.tsp";

using TypeSpec.Rest;
using Azure.ResourceManager;
using TypeSpec.Http;
using TypeSpec.OpenAPI;

namespace Microsoft.Chaos;

@armResourceOperations
interface CapabilityTypes {
/**
* Get a Capability Type resource for given Target Type and location.
*/
get is ArmResourceRead<CapabilityType>;

/**
* Get a list of Capability Type resources for given Target Type and location.
*/
list is ArmResourceListByParent<
CapabilityType,
Parameters = {
/**
* String that sets the continuation token.
*/
@query("continuationToken")
continuationToken?: string;
},
Response = CapabilityTypeListResult
>;
}

@@doc(CapabilityType.name,
"String that represents a Capability Type resource name."
);
@@doc(CapabilityType.properties,
"The properties of the capability type resource."
);
55 changes: 55 additions & 0 deletions specification/chaos/Chaos.Management/client.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import "./main.tsp";
import "@azure-tools/typespec-client-generator-core";

using Azure.ClientGenerator.Core;
using Microsoft.Chaos;

// csharp
@@clientName(ExperimentExecution, "ChaosExperimentExecution", "csharp");
@@clientName(Experiment, "ChaosExperiment", "csharp");
@@clientName(ExperimentExecution, "ChaosExperimentExecution", "csharp");
@@clientName(Target, "ChaosTarget", "csharp");
@@clientName(TargetType, "ChaosTargetMetadata", "csharp");
@@clientName(Capability, "ChaosCapability", "csharp");
@@clientName(CapabilityType, "ChaosCapabilityMetadata", "csharp");
@@clientName(TargetReference, "ChaosTargetReference", "csharp");
@@clientName(TargetReferenceType, "ChaosTargetReferenceType", "csharp");
@@clientName(ProvisioningState, "ChaosProvisioningState", "csharp");
@@clientName(KeyValuePair, "ChaosKeyValuePair", "csharp");
@@clientName(StepStatus, "ChaosExperimentRunStepStatus", "csharp");
@@clientName(BranchStatus, "ChaosExperimentRunBranchStatus", "csharp");
@@clientName(ActionStatus, "ChaosExperimentRunActionStatus", "csharp");
@@clientName(ContinuousAction, "ChaosContinuousAction", "csharp");
@@clientName(DiscreteAction, "ChaosDiscreteAction", "csharp");
@@clientName(DelayAction, "ChaosDelayAction", "csharp");
@@clientName(CapabilityTypePropertiesRuntimeProperties,
"ChaosCapabilityMetadataRuntimeProperties",
"csharp"
);
@@clientName(TargetReference.type, "ReferenceType", "csharp");
@@clientName(ExperimentExecutions.getExecutionDetails,
"ExecutionDetails",
"csharp"
);

// typescript
@@clientName(Microsoft.Chaos, "ChaosManagementClient", "javascript");

// python
@@clientName(Microsoft.Chaos, "ChaosManagementClient", "python");

// java
@@clientName(Microsoft.Chaos, "ChaosManagementClient", "java");

#suppress "deprecated" "property flatten for SDK backward compatibility"
@@flattenProperty(Experiment.properties);
#suppress "deprecated" "property flatten for SDK backward compatibility"
@@flattenProperty(ExperimentExecution.properties);
#suppress "deprecated" "property flatten for SDK backward compatibility"
@@flattenProperty(TargetType.properties);
#suppress "deprecated" "property flatten for SDK backward compatibility"
@@flattenProperty(Capability.properties);
#suppress "deprecated" "property flatten for SDK backward compatibility"
@@flattenProperty(CapabilityType.properties);
#suppress "deprecated" "property flatten for SDK backward compatibility"
@@flattenProperty(ExperimentExecutionDetails.properties);
Loading

0 comments on commit 9591372

Please sign in to comment.