mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-05 02:06:08 +00:00
Preserve order of securitySchemes (#14536)
* Remove alphabetical sort * Update integration testing expectations * Regenerate files
This commit is contained in:
@@ -187,6 +187,16 @@ Class | Method | HTTP request | Description
|
||||
## Documentation For Authorization
|
||||
|
||||
|
||||
## petstore_auth
|
||||
|
||||
- **Type**: OAuth
|
||||
- **Flow**: implicit
|
||||
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
|
||||
- **Scopes**:
|
||||
- **write:pets**: modify pets in your account
|
||||
- **read:pets**: read your pets
|
||||
|
||||
|
||||
## api_key
|
||||
|
||||
- **Type**: API key
|
||||
@@ -201,30 +211,20 @@ Class | Method | HTTP request | Description
|
||||
- **Location**: URL query string
|
||||
|
||||
|
||||
## bearer_test
|
||||
|
||||
- **Type**: Bearer authentication (JWT)
|
||||
|
||||
|
||||
## http_basic_test
|
||||
|
||||
- **Type**: HTTP basic authentication
|
||||
|
||||
|
||||
## bearer_test
|
||||
|
||||
- **Type**: Bearer authentication (JWT)
|
||||
|
||||
|
||||
## http_signature_test
|
||||
|
||||
|
||||
|
||||
## petstore_auth
|
||||
|
||||
- **Type**: OAuth
|
||||
- **Flow**: implicit
|
||||
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
|
||||
- **Scopes**:
|
||||
- **write:pets**: modify pets in your account
|
||||
- **read:pets**: read your pets
|
||||
|
||||
|
||||
## Author
|
||||
|
||||
|
||||
|
||||
@@ -24,99 +24,6 @@ Add a new pet to the store
|
||||
|
||||
### Example
|
||||
|
||||
```python
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import os
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
|
||||
# See configuration.py for a list of all supported configuration parameters.
|
||||
configuration = petstore_api.Configuration(
|
||||
host = "http://petstore.swagger.io:80/v2"
|
||||
)
|
||||
|
||||
# The client must configure the authentication and authorization parameters
|
||||
# in accordance with the API server security policy.
|
||||
# Examples for each auth method are provided below, use the example that
|
||||
# satisfies your auth use case.
|
||||
|
||||
# Configure HTTP message signature: http_signature_test
|
||||
# The HTTP Signature Header mechanism that can be used by a client to
|
||||
# authenticate the sender of a message and ensure that particular headers
|
||||
# have not been modified in transit.
|
||||
#
|
||||
# You can specify the signing key-id, private key path, signing scheme,
|
||||
# signing algorithm, list of signed headers and signature max validity.
|
||||
# The 'key_id' parameter is an opaque string that the API server can use
|
||||
# to lookup the client and validate the signature.
|
||||
# The 'private_key_path' parameter should be the path to a file that
|
||||
# contains a DER or base-64 encoded private key.
|
||||
# The 'private_key_passphrase' parameter is optional. Set the passphrase
|
||||
# if the private key is encrypted.
|
||||
# The 'signed_headers' parameter is used to specify the list of
|
||||
# HTTP headers included when generating the signature for the message.
|
||||
# You can specify HTTP headers that you want to protect with a cryptographic
|
||||
# signature. Note that proxies may add, modify or remove HTTP headers
|
||||
# for legitimate reasons, so you should only add headers that you know
|
||||
# will not be modified. For example, if you want to protect the HTTP request
|
||||
# body, you can specify the Digest header. In that case, the client calculates
|
||||
# the digest of the HTTP request body and includes the digest in the message
|
||||
# signature.
|
||||
# The 'signature_max_validity' parameter is optional. It is configured as a
|
||||
# duration to express when the signature ceases to be valid. The client calculates
|
||||
# the expiration date every time it generates the cryptographic signature
|
||||
# of an HTTP request. The API server may have its own security policy
|
||||
# that controls the maximum validity of the signature. The client max validity
|
||||
# must be lower than the server max validity.
|
||||
# The time on the client and server must be synchronized, otherwise the
|
||||
# server may reject the client signature.
|
||||
#
|
||||
# The client must use a combination of private key, signing scheme,
|
||||
# signing algorithm and hash algorithm that matches the security policy of
|
||||
# the API server.
|
||||
#
|
||||
# See petstore_api.signing for a list of all supported parameters.
|
||||
configuration = petstore_api.Configuration(
|
||||
host = "http://petstore.swagger.io:80/v2",
|
||||
signing_info = petstore_api.signing.HttpSigningConfiguration(
|
||||
key_id = 'my-key-id',
|
||||
private_key_path = 'private_key.pem',
|
||||
private_key_passphrase = 'YOUR_PASSPHRASE',
|
||||
signing_scheme = petstore_api.signing.SCHEME_HS2019,
|
||||
signing_algorithm = petstore_api.signing.ALGORITHM_ECDSA_MODE_FIPS_186_3,
|
||||
hash_algorithm = petstore_api.signing.SCHEME_RSA_SHA256,
|
||||
signed_headers = [
|
||||
petstore_api.signing.HEADER_REQUEST_TARGET,
|
||||
petstore_api.signing.HEADER_CREATED,
|
||||
petstore_api.signing.HEADER_EXPIRES,
|
||||
petstore_api.signing.HEADER_HOST,
|
||||
petstore_api.signing.HEADER_DATE,
|
||||
petstore_api.signing.HEADER_DIGEST,
|
||||
'Content-Type',
|
||||
'Content-Length',
|
||||
'User-Agent'
|
||||
],
|
||||
signature_max_validity = datetime.timedelta(minutes=5)
|
||||
)
|
||||
)
|
||||
|
||||
configuration.access_token = os.environ["ACCESS_TOKEN"]
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
async with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
|
||||
|
||||
try:
|
||||
# Add a new pet to the store
|
||||
await api_instance.add_pet(pet)
|
||||
except Exception as e:
|
||||
print("Exception when calling PetApi->add_pet: %s\n" % e)
|
||||
```
|
||||
|
||||
* OAuth Authentication (petstore_auth):
|
||||
```python
|
||||
from __future__ import print_function
|
||||
@@ -136,6 +43,8 @@ configuration = petstore_api.Configuration(
|
||||
# Examples for each auth method are provided below, use the example that
|
||||
# satisfies your auth use case.
|
||||
|
||||
configuration.access_token = os.environ["ACCESS_TOKEN"]
|
||||
|
||||
# Configure HTTP message signature: http_signature_test
|
||||
# The HTTP Signature Header mechanism that can be used by a client to
|
||||
# authenticate the sender of a message and ensure that particular headers
|
||||
@@ -196,8 +105,99 @@ configuration = petstore_api.Configuration(
|
||||
)
|
||||
)
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
async with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
|
||||
|
||||
try:
|
||||
# Add a new pet to the store
|
||||
await api_instance.add_pet(pet)
|
||||
except Exception as e:
|
||||
print("Exception when calling PetApi->add_pet: %s\n" % e)
|
||||
```
|
||||
|
||||
```python
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import os
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
|
||||
# See configuration.py for a list of all supported configuration parameters.
|
||||
configuration = petstore_api.Configuration(
|
||||
host = "http://petstore.swagger.io:80/v2"
|
||||
)
|
||||
|
||||
# The client must configure the authentication and authorization parameters
|
||||
# in accordance with the API server security policy.
|
||||
# Examples for each auth method are provided below, use the example that
|
||||
# satisfies your auth use case.
|
||||
|
||||
configuration.access_token = os.environ["ACCESS_TOKEN"]
|
||||
|
||||
# Configure HTTP message signature: http_signature_test
|
||||
# The HTTP Signature Header mechanism that can be used by a client to
|
||||
# authenticate the sender of a message and ensure that particular headers
|
||||
# have not been modified in transit.
|
||||
#
|
||||
# You can specify the signing key-id, private key path, signing scheme,
|
||||
# signing algorithm, list of signed headers and signature max validity.
|
||||
# The 'key_id' parameter is an opaque string that the API server can use
|
||||
# to lookup the client and validate the signature.
|
||||
# The 'private_key_path' parameter should be the path to a file that
|
||||
# contains a DER or base-64 encoded private key.
|
||||
# The 'private_key_passphrase' parameter is optional. Set the passphrase
|
||||
# if the private key is encrypted.
|
||||
# The 'signed_headers' parameter is used to specify the list of
|
||||
# HTTP headers included when generating the signature for the message.
|
||||
# You can specify HTTP headers that you want to protect with a cryptographic
|
||||
# signature. Note that proxies may add, modify or remove HTTP headers
|
||||
# for legitimate reasons, so you should only add headers that you know
|
||||
# will not be modified. For example, if you want to protect the HTTP request
|
||||
# body, you can specify the Digest header. In that case, the client calculates
|
||||
# the digest of the HTTP request body and includes the digest in the message
|
||||
# signature.
|
||||
# The 'signature_max_validity' parameter is optional. It is configured as a
|
||||
# duration to express when the signature ceases to be valid. The client calculates
|
||||
# the expiration date every time it generates the cryptographic signature
|
||||
# of an HTTP request. The API server may have its own security policy
|
||||
# that controls the maximum validity of the signature. The client max validity
|
||||
# must be lower than the server max validity.
|
||||
# The time on the client and server must be synchronized, otherwise the
|
||||
# server may reject the client signature.
|
||||
#
|
||||
# The client must use a combination of private key, signing scheme,
|
||||
# signing algorithm and hash algorithm that matches the security policy of
|
||||
# the API server.
|
||||
#
|
||||
# See petstore_api.signing for a list of all supported parameters.
|
||||
configuration = petstore_api.Configuration(
|
||||
host = "http://petstore.swagger.io:80/v2",
|
||||
signing_info = petstore_api.signing.HttpSigningConfiguration(
|
||||
key_id = 'my-key-id',
|
||||
private_key_path = 'private_key.pem',
|
||||
private_key_passphrase = 'YOUR_PASSPHRASE',
|
||||
signing_scheme = petstore_api.signing.SCHEME_HS2019,
|
||||
signing_algorithm = petstore_api.signing.ALGORITHM_ECDSA_MODE_FIPS_186_3,
|
||||
hash_algorithm = petstore_api.signing.SCHEME_RSA_SHA256,
|
||||
signed_headers = [
|
||||
petstore_api.signing.HEADER_REQUEST_TARGET,
|
||||
petstore_api.signing.HEADER_CREATED,
|
||||
petstore_api.signing.HEADER_EXPIRES,
|
||||
petstore_api.signing.HEADER_HOST,
|
||||
petstore_api.signing.HEADER_DATE,
|
||||
petstore_api.signing.HEADER_DIGEST,
|
||||
'Content-Type',
|
||||
'Content-Length',
|
||||
'User-Agent'
|
||||
],
|
||||
signature_max_validity = datetime.timedelta(minutes=5)
|
||||
)
|
||||
)
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
async with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
@@ -223,7 +223,7 @@ void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[http_signature_test](../README.md#http_signature_test), [petstore_auth](../README.md#petstore_auth)
|
||||
[petstore_auth](../README.md#petstore_auth), [http_signature_test](../README.md#http_signature_test)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
@@ -319,101 +319,6 @@ Multiple status values can be provided with comma separated strings
|
||||
|
||||
### Example
|
||||
|
||||
```python
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import os
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
|
||||
# See configuration.py for a list of all supported configuration parameters.
|
||||
configuration = petstore_api.Configuration(
|
||||
host = "http://petstore.swagger.io:80/v2"
|
||||
)
|
||||
|
||||
# The client must configure the authentication and authorization parameters
|
||||
# in accordance with the API server security policy.
|
||||
# Examples for each auth method are provided below, use the example that
|
||||
# satisfies your auth use case.
|
||||
|
||||
# Configure HTTP message signature: http_signature_test
|
||||
# The HTTP Signature Header mechanism that can be used by a client to
|
||||
# authenticate the sender of a message and ensure that particular headers
|
||||
# have not been modified in transit.
|
||||
#
|
||||
# You can specify the signing key-id, private key path, signing scheme,
|
||||
# signing algorithm, list of signed headers and signature max validity.
|
||||
# The 'key_id' parameter is an opaque string that the API server can use
|
||||
# to lookup the client and validate the signature.
|
||||
# The 'private_key_path' parameter should be the path to a file that
|
||||
# contains a DER or base-64 encoded private key.
|
||||
# The 'private_key_passphrase' parameter is optional. Set the passphrase
|
||||
# if the private key is encrypted.
|
||||
# The 'signed_headers' parameter is used to specify the list of
|
||||
# HTTP headers included when generating the signature for the message.
|
||||
# You can specify HTTP headers that you want to protect with a cryptographic
|
||||
# signature. Note that proxies may add, modify or remove HTTP headers
|
||||
# for legitimate reasons, so you should only add headers that you know
|
||||
# will not be modified. For example, if you want to protect the HTTP request
|
||||
# body, you can specify the Digest header. In that case, the client calculates
|
||||
# the digest of the HTTP request body and includes the digest in the message
|
||||
# signature.
|
||||
# The 'signature_max_validity' parameter is optional. It is configured as a
|
||||
# duration to express when the signature ceases to be valid. The client calculates
|
||||
# the expiration date every time it generates the cryptographic signature
|
||||
# of an HTTP request. The API server may have its own security policy
|
||||
# that controls the maximum validity of the signature. The client max validity
|
||||
# must be lower than the server max validity.
|
||||
# The time on the client and server must be synchronized, otherwise the
|
||||
# server may reject the client signature.
|
||||
#
|
||||
# The client must use a combination of private key, signing scheme,
|
||||
# signing algorithm and hash algorithm that matches the security policy of
|
||||
# the API server.
|
||||
#
|
||||
# See petstore_api.signing for a list of all supported parameters.
|
||||
configuration = petstore_api.Configuration(
|
||||
host = "http://petstore.swagger.io:80/v2",
|
||||
signing_info = petstore_api.signing.HttpSigningConfiguration(
|
||||
key_id = 'my-key-id',
|
||||
private_key_path = 'private_key.pem',
|
||||
private_key_passphrase = 'YOUR_PASSPHRASE',
|
||||
signing_scheme = petstore_api.signing.SCHEME_HS2019,
|
||||
signing_algorithm = petstore_api.signing.ALGORITHM_ECDSA_MODE_FIPS_186_3,
|
||||
hash_algorithm = petstore_api.signing.SCHEME_RSA_SHA256,
|
||||
signed_headers = [
|
||||
petstore_api.signing.HEADER_REQUEST_TARGET,
|
||||
petstore_api.signing.HEADER_CREATED,
|
||||
petstore_api.signing.HEADER_EXPIRES,
|
||||
petstore_api.signing.HEADER_HOST,
|
||||
petstore_api.signing.HEADER_DATE,
|
||||
petstore_api.signing.HEADER_DIGEST,
|
||||
'Content-Type',
|
||||
'Content-Length',
|
||||
'User-Agent'
|
||||
],
|
||||
signature_max_validity = datetime.timedelta(minutes=5)
|
||||
)
|
||||
)
|
||||
|
||||
configuration.access_token = os.environ["ACCESS_TOKEN"]
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
async with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
status = ['status_example'] # List[str] | Status values that need to be considered for filter
|
||||
|
||||
try:
|
||||
# Finds Pets by status
|
||||
api_response = await api_instance.find_pets_by_status(status)
|
||||
print("The response of PetApi->find_pets_by_status:\n")
|
||||
pprint(api_response)
|
||||
except Exception as e:
|
||||
print("Exception when calling PetApi->find_pets_by_status: %s\n" % e)
|
||||
```
|
||||
|
||||
* OAuth Authentication (petstore_auth):
|
||||
```python
|
||||
from __future__ import print_function
|
||||
@@ -433,6 +338,8 @@ configuration = petstore_api.Configuration(
|
||||
# Examples for each auth method are provided below, use the example that
|
||||
# satisfies your auth use case.
|
||||
|
||||
configuration.access_token = os.environ["ACCESS_TOKEN"]
|
||||
|
||||
# Configure HTTP message signature: http_signature_test
|
||||
# The HTTP Signature Header mechanism that can be used by a client to
|
||||
# authenticate the sender of a message and ensure that particular headers
|
||||
@@ -493,8 +400,101 @@ configuration = petstore_api.Configuration(
|
||||
)
|
||||
)
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
async with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
status = ['status_example'] # List[str] | Status values that need to be considered for filter
|
||||
|
||||
try:
|
||||
# Finds Pets by status
|
||||
api_response = await api_instance.find_pets_by_status(status)
|
||||
print("The response of PetApi->find_pets_by_status:\n")
|
||||
pprint(api_response)
|
||||
except Exception as e:
|
||||
print("Exception when calling PetApi->find_pets_by_status: %s\n" % e)
|
||||
```
|
||||
|
||||
```python
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import os
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
|
||||
# See configuration.py for a list of all supported configuration parameters.
|
||||
configuration = petstore_api.Configuration(
|
||||
host = "http://petstore.swagger.io:80/v2"
|
||||
)
|
||||
|
||||
# The client must configure the authentication and authorization parameters
|
||||
# in accordance with the API server security policy.
|
||||
# Examples for each auth method are provided below, use the example that
|
||||
# satisfies your auth use case.
|
||||
|
||||
configuration.access_token = os.environ["ACCESS_TOKEN"]
|
||||
|
||||
# Configure HTTP message signature: http_signature_test
|
||||
# The HTTP Signature Header mechanism that can be used by a client to
|
||||
# authenticate the sender of a message and ensure that particular headers
|
||||
# have not been modified in transit.
|
||||
#
|
||||
# You can specify the signing key-id, private key path, signing scheme,
|
||||
# signing algorithm, list of signed headers and signature max validity.
|
||||
# The 'key_id' parameter is an opaque string that the API server can use
|
||||
# to lookup the client and validate the signature.
|
||||
# The 'private_key_path' parameter should be the path to a file that
|
||||
# contains a DER or base-64 encoded private key.
|
||||
# The 'private_key_passphrase' parameter is optional. Set the passphrase
|
||||
# if the private key is encrypted.
|
||||
# The 'signed_headers' parameter is used to specify the list of
|
||||
# HTTP headers included when generating the signature for the message.
|
||||
# You can specify HTTP headers that you want to protect with a cryptographic
|
||||
# signature. Note that proxies may add, modify or remove HTTP headers
|
||||
# for legitimate reasons, so you should only add headers that you know
|
||||
# will not be modified. For example, if you want to protect the HTTP request
|
||||
# body, you can specify the Digest header. In that case, the client calculates
|
||||
# the digest of the HTTP request body and includes the digest in the message
|
||||
# signature.
|
||||
# The 'signature_max_validity' parameter is optional. It is configured as a
|
||||
# duration to express when the signature ceases to be valid. The client calculates
|
||||
# the expiration date every time it generates the cryptographic signature
|
||||
# of an HTTP request. The API server may have its own security policy
|
||||
# that controls the maximum validity of the signature. The client max validity
|
||||
# must be lower than the server max validity.
|
||||
# The time on the client and server must be synchronized, otherwise the
|
||||
# server may reject the client signature.
|
||||
#
|
||||
# The client must use a combination of private key, signing scheme,
|
||||
# signing algorithm and hash algorithm that matches the security policy of
|
||||
# the API server.
|
||||
#
|
||||
# See petstore_api.signing for a list of all supported parameters.
|
||||
configuration = petstore_api.Configuration(
|
||||
host = "http://petstore.swagger.io:80/v2",
|
||||
signing_info = petstore_api.signing.HttpSigningConfiguration(
|
||||
key_id = 'my-key-id',
|
||||
private_key_path = 'private_key.pem',
|
||||
private_key_passphrase = 'YOUR_PASSPHRASE',
|
||||
signing_scheme = petstore_api.signing.SCHEME_HS2019,
|
||||
signing_algorithm = petstore_api.signing.ALGORITHM_ECDSA_MODE_FIPS_186_3,
|
||||
hash_algorithm = petstore_api.signing.SCHEME_RSA_SHA256,
|
||||
signed_headers = [
|
||||
petstore_api.signing.HEADER_REQUEST_TARGET,
|
||||
petstore_api.signing.HEADER_CREATED,
|
||||
petstore_api.signing.HEADER_EXPIRES,
|
||||
petstore_api.signing.HEADER_HOST,
|
||||
petstore_api.signing.HEADER_DATE,
|
||||
petstore_api.signing.HEADER_DIGEST,
|
||||
'Content-Type',
|
||||
'Content-Length',
|
||||
'User-Agent'
|
||||
],
|
||||
signature_max_validity = datetime.timedelta(minutes=5)
|
||||
)
|
||||
)
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
async with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
@@ -522,7 +522,7 @@ Name | Type | Description | Notes
|
||||
|
||||
### Authorization
|
||||
|
||||
[http_signature_test](../README.md#http_signature_test), [petstore_auth](../README.md#petstore_auth)
|
||||
[petstore_auth](../README.md#petstore_auth), [http_signature_test](../README.md#http_signature_test)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
@@ -546,101 +546,6 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3
|
||||
|
||||
### Example
|
||||
|
||||
```python
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import os
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
|
||||
# See configuration.py for a list of all supported configuration parameters.
|
||||
configuration = petstore_api.Configuration(
|
||||
host = "http://petstore.swagger.io:80/v2"
|
||||
)
|
||||
|
||||
# The client must configure the authentication and authorization parameters
|
||||
# in accordance with the API server security policy.
|
||||
# Examples for each auth method are provided below, use the example that
|
||||
# satisfies your auth use case.
|
||||
|
||||
# Configure HTTP message signature: http_signature_test
|
||||
# The HTTP Signature Header mechanism that can be used by a client to
|
||||
# authenticate the sender of a message and ensure that particular headers
|
||||
# have not been modified in transit.
|
||||
#
|
||||
# You can specify the signing key-id, private key path, signing scheme,
|
||||
# signing algorithm, list of signed headers and signature max validity.
|
||||
# The 'key_id' parameter is an opaque string that the API server can use
|
||||
# to lookup the client and validate the signature.
|
||||
# The 'private_key_path' parameter should be the path to a file that
|
||||
# contains a DER or base-64 encoded private key.
|
||||
# The 'private_key_passphrase' parameter is optional. Set the passphrase
|
||||
# if the private key is encrypted.
|
||||
# The 'signed_headers' parameter is used to specify the list of
|
||||
# HTTP headers included when generating the signature for the message.
|
||||
# You can specify HTTP headers that you want to protect with a cryptographic
|
||||
# signature. Note that proxies may add, modify or remove HTTP headers
|
||||
# for legitimate reasons, so you should only add headers that you know
|
||||
# will not be modified. For example, if you want to protect the HTTP request
|
||||
# body, you can specify the Digest header. In that case, the client calculates
|
||||
# the digest of the HTTP request body and includes the digest in the message
|
||||
# signature.
|
||||
# The 'signature_max_validity' parameter is optional. It is configured as a
|
||||
# duration to express when the signature ceases to be valid. The client calculates
|
||||
# the expiration date every time it generates the cryptographic signature
|
||||
# of an HTTP request. The API server may have its own security policy
|
||||
# that controls the maximum validity of the signature. The client max validity
|
||||
# must be lower than the server max validity.
|
||||
# The time on the client and server must be synchronized, otherwise the
|
||||
# server may reject the client signature.
|
||||
#
|
||||
# The client must use a combination of private key, signing scheme,
|
||||
# signing algorithm and hash algorithm that matches the security policy of
|
||||
# the API server.
|
||||
#
|
||||
# See petstore_api.signing for a list of all supported parameters.
|
||||
configuration = petstore_api.Configuration(
|
||||
host = "http://petstore.swagger.io:80/v2",
|
||||
signing_info = petstore_api.signing.HttpSigningConfiguration(
|
||||
key_id = 'my-key-id',
|
||||
private_key_path = 'private_key.pem',
|
||||
private_key_passphrase = 'YOUR_PASSPHRASE',
|
||||
signing_scheme = petstore_api.signing.SCHEME_HS2019,
|
||||
signing_algorithm = petstore_api.signing.ALGORITHM_ECDSA_MODE_FIPS_186_3,
|
||||
hash_algorithm = petstore_api.signing.SCHEME_RSA_SHA256,
|
||||
signed_headers = [
|
||||
petstore_api.signing.HEADER_REQUEST_TARGET,
|
||||
petstore_api.signing.HEADER_CREATED,
|
||||
petstore_api.signing.HEADER_EXPIRES,
|
||||
petstore_api.signing.HEADER_HOST,
|
||||
petstore_api.signing.HEADER_DATE,
|
||||
petstore_api.signing.HEADER_DIGEST,
|
||||
'Content-Type',
|
||||
'Content-Length',
|
||||
'User-Agent'
|
||||
],
|
||||
signature_max_validity = datetime.timedelta(minutes=5)
|
||||
)
|
||||
)
|
||||
|
||||
configuration.access_token = os.environ["ACCESS_TOKEN"]
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
async with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
tags = ['tags_example'] # List[str] | Tags to filter by
|
||||
|
||||
try:
|
||||
# Finds Pets by tags
|
||||
api_response = await api_instance.find_pets_by_tags(tags)
|
||||
print("The response of PetApi->find_pets_by_tags:\n")
|
||||
pprint(api_response)
|
||||
except Exception as e:
|
||||
print("Exception when calling PetApi->find_pets_by_tags: %s\n" % e)
|
||||
```
|
||||
|
||||
* OAuth Authentication (petstore_auth):
|
||||
```python
|
||||
from __future__ import print_function
|
||||
@@ -660,6 +565,8 @@ configuration = petstore_api.Configuration(
|
||||
# Examples for each auth method are provided below, use the example that
|
||||
# satisfies your auth use case.
|
||||
|
||||
configuration.access_token = os.environ["ACCESS_TOKEN"]
|
||||
|
||||
# Configure HTTP message signature: http_signature_test
|
||||
# The HTTP Signature Header mechanism that can be used by a client to
|
||||
# authenticate the sender of a message and ensure that particular headers
|
||||
@@ -720,8 +627,101 @@ configuration = petstore_api.Configuration(
|
||||
)
|
||||
)
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
async with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
tags = ['tags_example'] # List[str] | Tags to filter by
|
||||
|
||||
try:
|
||||
# Finds Pets by tags
|
||||
api_response = await api_instance.find_pets_by_tags(tags)
|
||||
print("The response of PetApi->find_pets_by_tags:\n")
|
||||
pprint(api_response)
|
||||
except Exception as e:
|
||||
print("Exception when calling PetApi->find_pets_by_tags: %s\n" % e)
|
||||
```
|
||||
|
||||
```python
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import os
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
|
||||
# See configuration.py for a list of all supported configuration parameters.
|
||||
configuration = petstore_api.Configuration(
|
||||
host = "http://petstore.swagger.io:80/v2"
|
||||
)
|
||||
|
||||
# The client must configure the authentication and authorization parameters
|
||||
# in accordance with the API server security policy.
|
||||
# Examples for each auth method are provided below, use the example that
|
||||
# satisfies your auth use case.
|
||||
|
||||
configuration.access_token = os.environ["ACCESS_TOKEN"]
|
||||
|
||||
# Configure HTTP message signature: http_signature_test
|
||||
# The HTTP Signature Header mechanism that can be used by a client to
|
||||
# authenticate the sender of a message and ensure that particular headers
|
||||
# have not been modified in transit.
|
||||
#
|
||||
# You can specify the signing key-id, private key path, signing scheme,
|
||||
# signing algorithm, list of signed headers and signature max validity.
|
||||
# The 'key_id' parameter is an opaque string that the API server can use
|
||||
# to lookup the client and validate the signature.
|
||||
# The 'private_key_path' parameter should be the path to a file that
|
||||
# contains a DER or base-64 encoded private key.
|
||||
# The 'private_key_passphrase' parameter is optional. Set the passphrase
|
||||
# if the private key is encrypted.
|
||||
# The 'signed_headers' parameter is used to specify the list of
|
||||
# HTTP headers included when generating the signature for the message.
|
||||
# You can specify HTTP headers that you want to protect with a cryptographic
|
||||
# signature. Note that proxies may add, modify or remove HTTP headers
|
||||
# for legitimate reasons, so you should only add headers that you know
|
||||
# will not be modified. For example, if you want to protect the HTTP request
|
||||
# body, you can specify the Digest header. In that case, the client calculates
|
||||
# the digest of the HTTP request body and includes the digest in the message
|
||||
# signature.
|
||||
# The 'signature_max_validity' parameter is optional. It is configured as a
|
||||
# duration to express when the signature ceases to be valid. The client calculates
|
||||
# the expiration date every time it generates the cryptographic signature
|
||||
# of an HTTP request. The API server may have its own security policy
|
||||
# that controls the maximum validity of the signature. The client max validity
|
||||
# must be lower than the server max validity.
|
||||
# The time on the client and server must be synchronized, otherwise the
|
||||
# server may reject the client signature.
|
||||
#
|
||||
# The client must use a combination of private key, signing scheme,
|
||||
# signing algorithm and hash algorithm that matches the security policy of
|
||||
# the API server.
|
||||
#
|
||||
# See petstore_api.signing for a list of all supported parameters.
|
||||
configuration = petstore_api.Configuration(
|
||||
host = "http://petstore.swagger.io:80/v2",
|
||||
signing_info = petstore_api.signing.HttpSigningConfiguration(
|
||||
key_id = 'my-key-id',
|
||||
private_key_path = 'private_key.pem',
|
||||
private_key_passphrase = 'YOUR_PASSPHRASE',
|
||||
signing_scheme = petstore_api.signing.SCHEME_HS2019,
|
||||
signing_algorithm = petstore_api.signing.ALGORITHM_ECDSA_MODE_FIPS_186_3,
|
||||
hash_algorithm = petstore_api.signing.SCHEME_RSA_SHA256,
|
||||
signed_headers = [
|
||||
petstore_api.signing.HEADER_REQUEST_TARGET,
|
||||
petstore_api.signing.HEADER_CREATED,
|
||||
petstore_api.signing.HEADER_EXPIRES,
|
||||
petstore_api.signing.HEADER_HOST,
|
||||
petstore_api.signing.HEADER_DATE,
|
||||
petstore_api.signing.HEADER_DIGEST,
|
||||
'Content-Type',
|
||||
'Content-Length',
|
||||
'User-Agent'
|
||||
],
|
||||
signature_max_validity = datetime.timedelta(minutes=5)
|
||||
)
|
||||
)
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
async with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
@@ -749,7 +749,7 @@ Name | Type | Description | Notes
|
||||
|
||||
### Authorization
|
||||
|
||||
[http_signature_test](../README.md#http_signature_test), [petstore_auth](../README.md#petstore_auth)
|
||||
[petstore_auth](../README.md#petstore_auth), [http_signature_test](../README.md#http_signature_test)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
@@ -850,99 +850,6 @@ Update an existing pet
|
||||
|
||||
### Example
|
||||
|
||||
```python
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import os
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
|
||||
# See configuration.py for a list of all supported configuration parameters.
|
||||
configuration = petstore_api.Configuration(
|
||||
host = "http://petstore.swagger.io:80/v2"
|
||||
)
|
||||
|
||||
# The client must configure the authentication and authorization parameters
|
||||
# in accordance with the API server security policy.
|
||||
# Examples for each auth method are provided below, use the example that
|
||||
# satisfies your auth use case.
|
||||
|
||||
# Configure HTTP message signature: http_signature_test
|
||||
# The HTTP Signature Header mechanism that can be used by a client to
|
||||
# authenticate the sender of a message and ensure that particular headers
|
||||
# have not been modified in transit.
|
||||
#
|
||||
# You can specify the signing key-id, private key path, signing scheme,
|
||||
# signing algorithm, list of signed headers and signature max validity.
|
||||
# The 'key_id' parameter is an opaque string that the API server can use
|
||||
# to lookup the client and validate the signature.
|
||||
# The 'private_key_path' parameter should be the path to a file that
|
||||
# contains a DER or base-64 encoded private key.
|
||||
# The 'private_key_passphrase' parameter is optional. Set the passphrase
|
||||
# if the private key is encrypted.
|
||||
# The 'signed_headers' parameter is used to specify the list of
|
||||
# HTTP headers included when generating the signature for the message.
|
||||
# You can specify HTTP headers that you want to protect with a cryptographic
|
||||
# signature. Note that proxies may add, modify or remove HTTP headers
|
||||
# for legitimate reasons, so you should only add headers that you know
|
||||
# will not be modified. For example, if you want to protect the HTTP request
|
||||
# body, you can specify the Digest header. In that case, the client calculates
|
||||
# the digest of the HTTP request body and includes the digest in the message
|
||||
# signature.
|
||||
# The 'signature_max_validity' parameter is optional. It is configured as a
|
||||
# duration to express when the signature ceases to be valid. The client calculates
|
||||
# the expiration date every time it generates the cryptographic signature
|
||||
# of an HTTP request. The API server may have its own security policy
|
||||
# that controls the maximum validity of the signature. The client max validity
|
||||
# must be lower than the server max validity.
|
||||
# The time on the client and server must be synchronized, otherwise the
|
||||
# server may reject the client signature.
|
||||
#
|
||||
# The client must use a combination of private key, signing scheme,
|
||||
# signing algorithm and hash algorithm that matches the security policy of
|
||||
# the API server.
|
||||
#
|
||||
# See petstore_api.signing for a list of all supported parameters.
|
||||
configuration = petstore_api.Configuration(
|
||||
host = "http://petstore.swagger.io:80/v2",
|
||||
signing_info = petstore_api.signing.HttpSigningConfiguration(
|
||||
key_id = 'my-key-id',
|
||||
private_key_path = 'private_key.pem',
|
||||
private_key_passphrase = 'YOUR_PASSPHRASE',
|
||||
signing_scheme = petstore_api.signing.SCHEME_HS2019,
|
||||
signing_algorithm = petstore_api.signing.ALGORITHM_ECDSA_MODE_FIPS_186_3,
|
||||
hash_algorithm = petstore_api.signing.SCHEME_RSA_SHA256,
|
||||
signed_headers = [
|
||||
petstore_api.signing.HEADER_REQUEST_TARGET,
|
||||
petstore_api.signing.HEADER_CREATED,
|
||||
petstore_api.signing.HEADER_EXPIRES,
|
||||
petstore_api.signing.HEADER_HOST,
|
||||
petstore_api.signing.HEADER_DATE,
|
||||
petstore_api.signing.HEADER_DIGEST,
|
||||
'Content-Type',
|
||||
'Content-Length',
|
||||
'User-Agent'
|
||||
],
|
||||
signature_max_validity = datetime.timedelta(minutes=5)
|
||||
)
|
||||
)
|
||||
|
||||
configuration.access_token = os.environ["ACCESS_TOKEN"]
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
async with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
|
||||
|
||||
try:
|
||||
# Update an existing pet
|
||||
await api_instance.update_pet(pet)
|
||||
except Exception as e:
|
||||
print("Exception when calling PetApi->update_pet: %s\n" % e)
|
||||
```
|
||||
|
||||
* OAuth Authentication (petstore_auth):
|
||||
```python
|
||||
from __future__ import print_function
|
||||
@@ -962,6 +869,8 @@ configuration = petstore_api.Configuration(
|
||||
# Examples for each auth method are provided below, use the example that
|
||||
# satisfies your auth use case.
|
||||
|
||||
configuration.access_token = os.environ["ACCESS_TOKEN"]
|
||||
|
||||
# Configure HTTP message signature: http_signature_test
|
||||
# The HTTP Signature Header mechanism that can be used by a client to
|
||||
# authenticate the sender of a message and ensure that particular headers
|
||||
@@ -1022,8 +931,99 @@ configuration = petstore_api.Configuration(
|
||||
)
|
||||
)
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
async with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = petstore_api.PetApi(api_client)
|
||||
pet = petstore_api.Pet() # Pet | Pet object that needs to be added to the store
|
||||
|
||||
try:
|
||||
# Update an existing pet
|
||||
await api_instance.update_pet(pet)
|
||||
except Exception as e:
|
||||
print("Exception when calling PetApi->update_pet: %s\n" % e)
|
||||
```
|
||||
|
||||
```python
|
||||
from __future__ import print_function
|
||||
import time
|
||||
import os
|
||||
import petstore_api
|
||||
from petstore_api.rest import ApiException
|
||||
from pprint import pprint
|
||||
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
|
||||
# See configuration.py for a list of all supported configuration parameters.
|
||||
configuration = petstore_api.Configuration(
|
||||
host = "http://petstore.swagger.io:80/v2"
|
||||
)
|
||||
|
||||
# The client must configure the authentication and authorization parameters
|
||||
# in accordance with the API server security policy.
|
||||
# Examples for each auth method are provided below, use the example that
|
||||
# satisfies your auth use case.
|
||||
|
||||
configuration.access_token = os.environ["ACCESS_TOKEN"]
|
||||
|
||||
# Configure HTTP message signature: http_signature_test
|
||||
# The HTTP Signature Header mechanism that can be used by a client to
|
||||
# authenticate the sender of a message and ensure that particular headers
|
||||
# have not been modified in transit.
|
||||
#
|
||||
# You can specify the signing key-id, private key path, signing scheme,
|
||||
# signing algorithm, list of signed headers and signature max validity.
|
||||
# The 'key_id' parameter is an opaque string that the API server can use
|
||||
# to lookup the client and validate the signature.
|
||||
# The 'private_key_path' parameter should be the path to a file that
|
||||
# contains a DER or base-64 encoded private key.
|
||||
# The 'private_key_passphrase' parameter is optional. Set the passphrase
|
||||
# if the private key is encrypted.
|
||||
# The 'signed_headers' parameter is used to specify the list of
|
||||
# HTTP headers included when generating the signature for the message.
|
||||
# You can specify HTTP headers that you want to protect with a cryptographic
|
||||
# signature. Note that proxies may add, modify or remove HTTP headers
|
||||
# for legitimate reasons, so you should only add headers that you know
|
||||
# will not be modified. For example, if you want to protect the HTTP request
|
||||
# body, you can specify the Digest header. In that case, the client calculates
|
||||
# the digest of the HTTP request body and includes the digest in the message
|
||||
# signature.
|
||||
# The 'signature_max_validity' parameter is optional. It is configured as a
|
||||
# duration to express when the signature ceases to be valid. The client calculates
|
||||
# the expiration date every time it generates the cryptographic signature
|
||||
# of an HTTP request. The API server may have its own security policy
|
||||
# that controls the maximum validity of the signature. The client max validity
|
||||
# must be lower than the server max validity.
|
||||
# The time on the client and server must be synchronized, otherwise the
|
||||
# server may reject the client signature.
|
||||
#
|
||||
# The client must use a combination of private key, signing scheme,
|
||||
# signing algorithm and hash algorithm that matches the security policy of
|
||||
# the API server.
|
||||
#
|
||||
# See petstore_api.signing for a list of all supported parameters.
|
||||
configuration = petstore_api.Configuration(
|
||||
host = "http://petstore.swagger.io:80/v2",
|
||||
signing_info = petstore_api.signing.HttpSigningConfiguration(
|
||||
key_id = 'my-key-id',
|
||||
private_key_path = 'private_key.pem',
|
||||
private_key_passphrase = 'YOUR_PASSPHRASE',
|
||||
signing_scheme = petstore_api.signing.SCHEME_HS2019,
|
||||
signing_algorithm = petstore_api.signing.ALGORITHM_ECDSA_MODE_FIPS_186_3,
|
||||
hash_algorithm = petstore_api.signing.SCHEME_RSA_SHA256,
|
||||
signed_headers = [
|
||||
petstore_api.signing.HEADER_REQUEST_TARGET,
|
||||
petstore_api.signing.HEADER_CREATED,
|
||||
petstore_api.signing.HEADER_EXPIRES,
|
||||
petstore_api.signing.HEADER_HOST,
|
||||
petstore_api.signing.HEADER_DATE,
|
||||
petstore_api.signing.HEADER_DIGEST,
|
||||
'Content-Type',
|
||||
'Content-Length',
|
||||
'User-Agent'
|
||||
],
|
||||
signature_max_validity = datetime.timedelta(minutes=5)
|
||||
)
|
||||
)
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
async with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
@@ -1049,7 +1049,7 @@ void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[http_signature_test](../README.md#http_signature_test), [petstore_auth](../README.md#petstore_auth)
|
||||
[petstore_auth](../README.md#petstore_auth), [http_signature_test](../README.md#http_signature_test)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ class PetApi(object):
|
||||
_header_params['Content-Type'] = _content_types_list
|
||||
|
||||
# authentication setting
|
||||
_auth_settings = ['http_signature_test', 'petstore_auth'] # noqa: E501
|
||||
_auth_settings = ['petstore_auth', 'http_signature_test'] # noqa: E501
|
||||
|
||||
_response_types_map = {}
|
||||
|
||||
@@ -452,7 +452,7 @@ class PetApi(object):
|
||||
['application/xml', 'application/json']) # noqa: E501
|
||||
|
||||
# authentication setting
|
||||
_auth_settings = ['http_signature_test', 'petstore_auth'] # noqa: E501
|
||||
_auth_settings = ['petstore_auth', 'http_signature_test'] # noqa: E501
|
||||
|
||||
_response_types_map = {
|
||||
'200': "List[Pet]",
|
||||
@@ -597,7 +597,7 @@ class PetApi(object):
|
||||
['application/xml', 'application/json']) # noqa: E501
|
||||
|
||||
# authentication setting
|
||||
_auth_settings = ['http_signature_test', 'petstore_auth'] # noqa: E501
|
||||
_auth_settings = ['petstore_auth', 'http_signature_test'] # noqa: E501
|
||||
|
||||
_response_types_map = {
|
||||
'200': "List[Pet]",
|
||||
@@ -889,7 +889,7 @@ class PetApi(object):
|
||||
_header_params['Content-Type'] = _content_types_list
|
||||
|
||||
# authentication setting
|
||||
_auth_settings = ['http_signature_test', 'petstore_auth'] # noqa: E501
|
||||
_auth_settings = ['petstore_auth', 'http_signature_test'] # noqa: E501
|
||||
|
||||
_response_types_map = {}
|
||||
|
||||
|
||||
@@ -435,6 +435,13 @@ conf = petstore_api.Configuration(
|
||||
:return: The Auth Settings information dict.
|
||||
"""
|
||||
auth = {}
|
||||
if self.access_token is not None:
|
||||
auth['petstore_auth'] = {
|
||||
'type': 'oauth2',
|
||||
'in': 'header',
|
||||
'key': 'Authorization',
|
||||
'value': 'Bearer ' + self.access_token
|
||||
}
|
||||
if 'api_key' in self.api_key:
|
||||
auth['api_key'] = {
|
||||
'type': 'api_key',
|
||||
@@ -453,6 +460,13 @@ conf = petstore_api.Configuration(
|
||||
'api_key_query',
|
||||
),
|
||||
}
|
||||
if self.username is not None and self.password is not None:
|
||||
auth['http_basic_test'] = {
|
||||
'type': 'basic',
|
||||
'in': 'header',
|
||||
'key': 'Authorization',
|
||||
'value': self.get_basic_auth_token()
|
||||
}
|
||||
if self.access_token is not None:
|
||||
auth['bearer_test'] = {
|
||||
'type': 'bearer',
|
||||
@@ -461,13 +475,6 @@ conf = petstore_api.Configuration(
|
||||
'key': 'Authorization',
|
||||
'value': 'Bearer ' + self.access_token
|
||||
}
|
||||
if self.username is not None and self.password is not None:
|
||||
auth['http_basic_test'] = {
|
||||
'type': 'basic',
|
||||
'in': 'header',
|
||||
'key': 'Authorization',
|
||||
'value': self.get_basic_auth_token()
|
||||
}
|
||||
if self.signing_info is not None:
|
||||
auth['http_signature_test'] = {
|
||||
'type': 'http-signature',
|
||||
@@ -475,13 +482,6 @@ conf = petstore_api.Configuration(
|
||||
'key': 'Authorization',
|
||||
'value': None # Signature headers are calculated for every HTTP request
|
||||
}
|
||||
if self.access_token is not None:
|
||||
auth['petstore_auth'] = {
|
||||
'type': 'oauth2',
|
||||
'in': 'header',
|
||||
'key': 'Authorization',
|
||||
'value': 'Bearer ' + self.access_token
|
||||
}
|
||||
return auth
|
||||
|
||||
def to_debug_report(self):
|
||||
|
||||
Reference in New Issue
Block a user