Skip to content

Commit

Permalink
Fix usage (#2716)
Browse files Browse the repository at this point in the history
* inv

* changelog
  • Loading branch information
msyyc authored Jul 25, 2024
1 parent 8d37048 commit e53f376
Show file tree
Hide file tree
Showing 78 changed files with 12 additions and 341 deletions.
7 changes: 7 additions & 0 deletions .chronus/changes/fix-usage-2024-6-25-11-21-42.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@azure-tools/typespec-python"
---

Fix the logic to judge whether model is output or not
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ class UsageFlags(Enum):
ApiVersionEnum = 8
JsonMergePatch = 16
MultipartFormData = 32
Spread = 64
Error = 128
Json = 256
Xml = 512


def _get_properties(type: "ModelType", properties: List[Property]) -> List[Property]:
Expand Down Expand Up @@ -86,7 +90,7 @@ def __init__(

@property
def is_usage_output(self) -> bool:
return self.usage == UsageFlags.Output.value
return self.usage & UsageFlags.Output.value

@property
def flattened_property(self) -> Optional[Property]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
class InvalidAuth(_model_base.Model):
"""InvalidAuth.
All required parameters must be populated in order to send to server.
:ivar error: Required.
:vartype error: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
class InvalidAuth(_model_base.Model):
"""InvalidAuth.
All required parameters must be populated in order to send to server.
:ivar error: Required.
:vartype error: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
class InvalidAuth(_model_base.Model):
"""InvalidAuth.
All required parameters must be populated in order to send to server.
:ivar error: Required.
:vartype error: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class AbstractModel(_model_base.Model):
You probably want to use the sub-classes and not this class directly. Known sub-classes are:
RealModel
All required parameters must be populated in order to send to server.
:ivar kind: Discriminator property for AbstractModel. Required. Default value is None.
:vartype kind: str
Expand All @@ -41,7 +40,6 @@ class AbstractModel(_model_base.Model):
class BaseModel(_model_base.Model):
"""Used in internal operations, should be generated but not exported.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand All @@ -54,7 +52,6 @@ class BaseModel(_model_base.Model):
class InnerModel(_model_base.Model):
"""Used in internal operations, should be generated but not exported.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand All @@ -67,7 +64,6 @@ class InnerModel(_model_base.Model):
class InternalDecoratorModelInInternal(_model_base.Model):
"""Used in an internal operation, should be generated but not exported.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand All @@ -80,7 +76,6 @@ class InternalDecoratorModelInInternal(_model_base.Model):
class NoDecoratorModelInInternal(_model_base.Model):
"""Used in an internal operation, should be generated but not exported.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand All @@ -93,7 +88,6 @@ class NoDecoratorModelInInternal(_model_base.Model):
class NoDecoratorModelInPublic(_model_base.Model):
"""Used in a public operation, should be generated and exported.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand Down Expand Up @@ -123,7 +117,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles
class OuterModel(BaseModel):
"""Used in internal operations, should be generated but not exported.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand All @@ -138,7 +131,6 @@ class OuterModel(BaseModel):
class PublicDecoratorModelInInternal(_model_base.Model):
"""Used in an internal operation but with public decorator, should be generated and exported.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand Down Expand Up @@ -168,7 +160,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles
class PublicDecoratorModelInPublic(_model_base.Model):
"""Used in a public operation, should be generated and exported.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand Down Expand Up @@ -198,7 +189,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles
class RealModel(AbstractModel, discriminator="real"):
"""Used in internal operations, should be generated but not exported.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand All @@ -213,7 +203,6 @@ class RealModel(AbstractModel, discriminator="real"):
class SharedModel(_model_base.Model):
"""Used by both public and internal operation. It should be generated and exported.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
class InputModel(_model_base.Model):
"""Usage override to roundtrip.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand Down Expand Up @@ -81,7 +80,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles
class OutputModel(_model_base.Model):
"""Usage override to roundtrip.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand Down Expand Up @@ -111,7 +109,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles
class ResultModel(_model_base.Model):
"""ResultModel.
All required parameters must be populated in order to send to server.
:ivar name: Required.
:vartype name: str
Expand Down Expand Up @@ -143,7 +140,6 @@ class RoundTripModel(_model_base.Model):
Readonly variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to server.
:ivar result: Required.
:vartype result: ~specs.azure.clientgenerator.core.usage.models.ResultModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class FirstItem(_model_base.Model):
Readonly variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to server.
:ivar id: The id of the item. Required.
:vartype id: int
Expand Down Expand Up @@ -67,7 +66,6 @@ class SecondItem(_model_base.Model):
Readonly variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to server.
:ivar name: The name of the item. Required.
:vartype name: str
Expand All @@ -82,7 +80,6 @@ class User(_model_base.Model):
Readonly variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to server.
:ivar id: The user's id. Required.
:vartype id: int
Expand Down Expand Up @@ -127,7 +124,6 @@ class UserOrder(_model_base.Model):
Readonly variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to server.
:ivar id: The user's id. Required.
:vartype id: int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
class ExportedUser(_model_base.Model):
"""The exported user data.
All required parameters must be populated in order to send to server.
:ivar name: The name of user. Required.
:vartype name: str
Expand Down Expand Up @@ -53,7 +52,6 @@ class User(_model_base.Model):
Readonly variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to server.
:ivar name: The name of user. Required.
:vartype name: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
class AzureEmbeddingModel(_model_base.Model):
"""AzureEmbeddingModel.
All required parameters must be populated in order to send to server.
:ivar embedding: Required.
:vartype embedding: list[int]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
class AzureLocationModel(_model_base.Model):
"""AzureLocationModel.
All required parameters must be populated in order to send to server.
:ivar location: Required.
:vartype location: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class User(_model_base.Model):
Readonly variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to server.
:ivar id: The user's id. Required.
:vartype id: int
Expand Down Expand Up @@ -82,7 +81,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles
class UserActionResponse(_model_base.Model):
"""User action response.
All required parameters must be populated in order to send to server.
:ivar user_action_result: User action result. Required.
:vartype user_action_result: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles
class ActionResponse(_model_base.Model):
"""ActionResponse.
All required parameters must be populated in order to send to server.
:ivar string_property: Required.
:vartype string_property: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class TrackedResource(Resource):
Readonly variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to server.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long
Expand Down Expand Up @@ -102,7 +101,6 @@ class Catalog(TrackedResource):
Readonly variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to server.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long
Expand Down Expand Up @@ -345,7 +343,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles
class CountElementsResponse(_model_base.Model):
"""Response of the count for elements.
All required parameters must be populated in order to send to server.
:ivar value: Number of children resources in parent resource. Required.
:vartype value: int
Expand Down Expand Up @@ -375,7 +372,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles
class CountDevicesResponse(CountElementsResponse):
"""Response to the action call for count devices in a catalog.
All required parameters must be populated in order to send to server.
:ivar value: Number of children resources in parent resource. Required.
:vartype value: int
Expand Down Expand Up @@ -736,7 +732,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles
class DeviceInsight(_model_base.Model):
"""Device insight report.
All required parameters must be populated in order to send to server.
:ivar device_id: Device ID. Required.
:vartype device_id: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ class TrackedResource(Resource):
Readonly variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to server.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long
Expand Down Expand Up @@ -184,7 +183,6 @@ class ManagedIdentityTrackedResource(TrackedResource):
Readonly variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to server.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long
Expand Down Expand Up @@ -241,7 +239,6 @@ class ManagedIdentityTrackedResourceProperties(_model_base.Model):
Readonly variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to server.
:ivar provisioning_state: The status of the last operation. Required.
:vartype provisioning_state: str
Expand All @@ -256,7 +253,6 @@ class ManagedServiceIdentity(_model_base.Model):
Readonly variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to server.
:ivar principal_id: The service principal ID of the system assigned identity. This property
will only be provided for a system assigned identity.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ class TrackedResource(Resource):
Readonly variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to server.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long
Expand Down Expand Up @@ -340,7 +339,6 @@ class TopLevelTrackedResource(TrackedResource):
Readonly variables are only populated by the server, and will be ignored when sending a request.
All required parameters must be populated in order to send to server.
:ivar id: Fully qualified resource ID for the resource. Ex -
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles
class GenerationResult(_model_base.Model):
"""Result of the generation.
All required parameters must be populated in order to send to server.
:ivar data: The data. Required.
:vartype data: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
class Base64BytesProperty(_model_base.Model):
"""Base64BytesProperty.
All required parameters must be populated in order to send to server.
:ivar value: Required.
:vartype value: bytes
Expand Down Expand Up @@ -46,7 +45,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles
class Base64urlArrayBytesProperty(_model_base.Model):
"""Base64urlArrayBytesProperty.
All required parameters must be populated in order to send to server.
:ivar value: Required.
:vartype value: list[bytes]
Expand Down Expand Up @@ -76,7 +74,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles
class Base64urlBytesProperty(_model_base.Model):
"""Base64urlBytesProperty.
All required parameters must be populated in order to send to server.
:ivar value: Required.
:vartype value: bytes
Expand Down Expand Up @@ -106,7 +103,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # pylint: disable=useles
class DefaultBytesProperty(_model_base.Model):
"""DefaultBytesProperty.
All required parameters must be populated in order to send to server.
:ivar value: Required.
:vartype value: bytes
Expand Down
Loading

0 comments on commit e53f376

Please sign in to comment.