Skip to content

Commit

Permalink
Merge pull request #246 from okta/develop
Browse files Browse the repository at this point in the history
Merge develop branch, release 2.2.0
  • Loading branch information
serhiibuniak-okta authored Oct 4, 2021
2 parents 4c7c9e4 + 8f55029 commit ccf160f
Show file tree
Hide file tree
Showing 61 changed files with 6,037 additions and 12 deletions.
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
# Okta Python SDK Changelog

## v2.2.0
- Regenerate code using the [open API spec v2.7.0](https://github.com/okta/okta-management-openapi-spec/releases/tag/openapi-2.7.0).
- Allow Bearer auth
- Support Python 3.9

_New resources:_
* Authenticator
* GroupSchema
* Org

_New models:_
* AllowedForEnum
* Authenticator
* AuthenticatorSettings
* AuthenticatorStatus
* AuthenticatorType
* GroupSchema
* GroupSchemaBase
* GroupSchemaCustom
* GroupSchemaAttribute
* GroupSchemaDefinitions
* GroupSchemaBaseProperties
* OrgContactType
* OrgContactTypeObj
* OrgContactUser
* OrgOktaCommunicationSetting
* OrgOktaSupportSetting
* OrgOktaSupportSettingsObj
* OrgPreferences
* OrgSetting

## v2.1.0
- Regenerate code using the [open API spec v2.6.0](https://github.com/okta/okta-management-openapi-spec/releases/tag/openapi-2.6.0).
- Expose parameter `keep_empty_params` to all user interfaces.
Expand Down
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,43 @@ swa_app_model = models.SwaApplication({
app, resp, err = await client.create_application(swa_app_model)
```

### Manage Group Schema custom atributes

There are 2 ways of creating custom attribute for Group Schema Profile:
1) via UI of your ORG (Directory -> Profile Editor -> Groups)
2) with the following request (create custom attribute with name "testCustomAttr"):

```py
definition = {'custom':
{'id': '#custom',
'properties':
{'testCustomAttr':
{'description': 'Custom attribute for testing purposes',
'maxLength': 20,
'minLength': 1,
'permissions': [{'action': 'READ_WRITE',
'principal': 'SELF'}],
'required': False,
'title': 'Test Custom Attribute',
'type': 'string'},
'required': []},
'type': 'object'
}
}
resp, _, err = await client.update_group_schema({'definitions': definition})
```

Update existing attribute:

```py
# Get existing GroupSchema
resp, _, err = await client.get_group_schema()
# Set new title for custom attribute 'testCustomAttr'
resp.definitions.custom.properties['testCustomAttr']['title'] = 'New Title'
# Launch api request to update GroupSchema
resp, _, err = await client.update_group_schema(resp)
```

### Call other API endpoints

Not every API endpoint is represented by a method in this library. You can call any Okta management API endpoint using this generic syntax:
Expand Down
2 changes: 1 addition & 1 deletion okta/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.1.0'
__version__ = '2.2.0'
9 changes: 9 additions & 0 deletions okta/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
from okta.logger import setup_logging
from okta.resource_clients.application_client\
import ApplicationClient
from okta.resource_clients.authenticator_client\
import AuthenticatorClient
from okta.resource_clients.authorization_server_client\
import AuthorizationServerClient
from okta.resource_clients.domain_client\
Expand All @@ -47,10 +49,14 @@
import ProfileMappingClient
from okta.resource_clients.user_schema_client\
import UserSchemaClient
from okta.resource_clients.group_schema_client\
import GroupSchemaClient
from okta.resource_clients.linked_object_client\
import LinkedObjectClient
from okta.resource_clients.user_type_client\
import UserTypeClient
from okta.resource_clients.org_client\
import OrgClient
from okta.resource_clients.policy_client\
import PolicyClient
from okta.resource_clients.session_client\
Expand All @@ -71,6 +77,7 @@

class Client(
ApplicationClient,
AuthenticatorClient,
AuthorizationServerClient,
DomainClient,
EventHookClient,
Expand All @@ -81,8 +88,10 @@ class Client(
LogEventClient,
ProfileMappingClient,
UserSchemaClient,
GroupSchemaClient,
LinkedObjectClient,
UserTypeClient,
OrgClient,
PolicyClient,
SessionClient,
SmsTemplateClient,
Expand Down
2 changes: 1 addition & 1 deletion okta/config/config_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def validate_config(self):
if "proxy" in client:
errors += self._validate_proxy_settings(client["proxy"])
# check API details based on authorization mode
if client.get('authorizationMode') == "SSWS":
if client.get('authorizationMode') in ("SSWS", "Bearer"):
errors += \
self._validate_token(
client.get('token', ""))
Expand Down
2 changes: 1 addition & 1 deletion okta/error_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
ERROR_MESSAGE_AUTH_MODE_INVALID = (
"The AuthorizationMode configuration "
"option must be one of: "
"[SSWS, PrivateKey]. "
"[SSWS, Bearer, PrivateKey]. "
"You provided the SDK with "
)
ERROR_MESSAGE_ORG_URL_YOUROKTADOMAIN = (
Expand Down
40 changes: 40 additions & 0 deletions okta/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
AcsEndpoint = acs_endpoint.AcsEndpoint
from okta.models import activate_factor_request as activate_factor_request
ActivateFactorRequest = activate_factor_request.ActivateFactorRequest
from okta.models import allowed_for_enum as allowed_for_enum
AllowedForEnum = allowed_for_enum.AllowedForEnum
from okta.models import app_and_instance_condition_evaluator_app_or_instance as app_and_instance_condition_evaluator_app_or_instance
AppAndInstanceConditionEvaluatorAppOrInstance = app_and_instance_condition_evaluator_app_or_instance.AppAndInstanceConditionEvaluatorAppOrInstance
from okta.models import app_and_instance_policy_rule_condition as app_and_instance_policy_rule_condition
Expand Down Expand Up @@ -80,6 +82,14 @@
AuthenticationProvider = authentication_provider.AuthenticationProvider
from okta.models import authentication_provider_type as authentication_provider_type
AuthenticationProviderType = authentication_provider_type.AuthenticationProviderType
from okta.models import authenticator as authenticator
Authenticator = authenticator.Authenticator
from okta.models import authenticator_settings as authenticator_settings
AuthenticatorSettings = authenticator_settings.AuthenticatorSettings
from okta.models import authenticator_status as authenticator_status
AuthenticatorStatus = authenticator_status.AuthenticatorStatus
from okta.models import authenticator_type as authenticator_type
AuthenticatorType = authenticator_type.AuthenticatorType
from okta.models import authorization_server as authorization_server
AuthorizationServer = authorization_server.AuthorizationServer
from okta.models import authorization_server_credentials as authorization_server_credentials
Expand Down Expand Up @@ -242,6 +252,18 @@
GroupRuleStatus = group_rule_status.GroupRuleStatus
from okta.models import group_rule_user_condition as group_rule_user_condition
GroupRuleUserCondition = group_rule_user_condition.GroupRuleUserCondition
from okta.models import group_schema as group_schema
GroupSchema = group_schema.GroupSchema
from okta.models import group_schema_attribute as group_schema_attribute
GroupSchemaAttribute = group_schema_attribute.GroupSchemaAttribute
from okta.models import group_schema_base as group_schema_base
GroupSchemaBase = group_schema_base.GroupSchemaBase
from okta.models import group_schema_base_properties as group_schema_base_properties
GroupSchemaBaseProperties = group_schema_base_properties.GroupSchemaBaseProperties
from okta.models import group_schema_custom as group_schema_custom
GroupSchemaCustom = group_schema_custom.GroupSchemaCustom
from okta.models import group_schema_definitions as group_schema_definitions
GroupSchemaDefinitions = group_schema_definitions.GroupSchemaDefinitions
from okta.models import group_type as group_type
GroupType = group_type.GroupType
from okta.models import hardware_user_factor as hardware_user_factor
Expand Down Expand Up @@ -424,6 +446,22 @@
OpenIdConnectApplicationType = open_id_connect_application_type.OpenIdConnectApplicationType
from okta.models import open_id_connect_refresh_token_rotation_type as open_id_connect_refresh_token_rotation_type
OpenIdConnectRefreshTokenRotationType = open_id_connect_refresh_token_rotation_type.OpenIdConnectRefreshTokenRotationType
from okta.models import org_contact_type as org_contact_type
OrgContactType = org_contact_type.OrgContactType
from okta.models import org_contact_type_obj as org_contact_type_obj
OrgContactTypeObj = org_contact_type_obj.OrgContactTypeObj
from okta.models import org_contact_user as org_contact_user
OrgContactUser = org_contact_user.OrgContactUser
from okta.models import org_okta_communication_setting as org_okta_communication_setting
OrgOktaCommunicationSetting = org_okta_communication_setting.OrgOktaCommunicationSetting
from okta.models import org_okta_support_setting as org_okta_support_setting
OrgOktaSupportSetting = org_okta_support_setting.OrgOktaSupportSetting
from okta.models import org_okta_support_settings_obj as org_okta_support_settings_obj
OrgOktaSupportSettingsObj = org_okta_support_settings_obj.OrgOktaSupportSettingsObj
from okta.models import org_preferences as org_preferences
OrgPreferences = org_preferences.OrgPreferences
from okta.models import org_setting as org_setting
OrgSetting = org_setting.OrgSetting
from okta.models import password_credential as password_credential
PasswordCredential = password_credential.PasswordCredential
from okta.models import password_credential_hash as password_credential_hash
Expand Down Expand Up @@ -682,6 +720,8 @@
UserCredentials = user_credentials.UserCredentials
from okta.models import user_factor as user_factor
UserFactor = user_factor.UserFactor
from okta.models import user_id_string as user_id_string
UserIdString = user_id_string.UserIdString
from okta.models import user_identifier_condition_evaluator_pattern as user_identifier_condition_evaluator_pattern
UserIdentifierConditionEvaluatorPattern = user_identifier_condition_evaluator_pattern.UserIdentifierConditionEvaluatorPattern
from okta.models import user_identifier_policy_rule_condition as user_identifier_policy_rule_condition
Expand Down
35 changes: 35 additions & 0 deletions okta/models/allowed_for_enum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# flake8: noqa
"""
Copyright 2021 - Present Okta, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

# AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY
# SEE CONTRIBUTOR DOCUMENTATION

from aenum import MultiValueEnum


class AllowedForEnum(
str,
MultiValueEnum
):
"""
An enumeration class for AllowedForEnum.
"""

RECOVERY = "recovery", "RECOVERY"
SSO = "sso", "SSO"
ANY = "any", "ANY"
NONE = "none", "NONE"
4 changes: 4 additions & 0 deletions okta/models/application_visibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def __init__(self, config=None):
if config:
self.app_links = config["appLinks"]\
if "appLinks" in config else None
self.auto_launch = config["autoLaunch"]\
if "autoLaunch" in config else None
self.auto_submit_toolbar = config["autoSubmitToolbar"]\
if "autoSubmitToolbar" in config else None
if "hide" in config:
Expand All @@ -51,13 +53,15 @@ def __init__(self, config=None):
self.hide = None
else:
self.app_links = None
self.auto_launch = None
self.auto_submit_toolbar = None
self.hide = None

def request_format(self):
parent_req_format = super().request_format()
current_obj_format = {
"appLinks": self.app_links,
"autoLaunch": self.auto_launch,
"autoSubmitToolbar": self.auto_submit_toolbar,
"hide": self.hide
}
Expand Down
113 changes: 113 additions & 0 deletions okta/models/authenticator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# flake8: noqa
"""
Copyright 2021 - Present Okta, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

# AUTO-GENERATED! DO NOT EDIT FILE DIRECTLY
# SEE CONTRIBUTOR DOCUMENTATION

from okta.okta_object import OktaObject
from okta.models import authenticator_settings\
as authenticator_settings
from okta.models import authenticator_status\
as authenticator_status
from okta.models import authenticator_type\
as authenticator_type


class Authenticator(
OktaObject
):
"""
A class for Authenticator objects.
"""

def __init__(self, config=None):
super().__init__(config)
if config:
self.links = config["links"]\
if "links" in config else None
self.created = config["created"]\
if "created" in config else None
self.id = config["id"]\
if "id" in config else None
self.key = config["key"]\
if "key" in config else None
self.last_updated = config["lastUpdated"]\
if "lastUpdated" in config else None
self.name = config["name"]\
if "name" in config else None
if "settings" in config:
if isinstance(config["settings"],
authenticator_settings.AuthenticatorSettings):
self.settings = config["settings"]
elif config["settings"] is not None:
self.settings = authenticator_settings.AuthenticatorSettings(
config["settings"]
)
else:
self.settings = None
else:
self.settings = None
if "status" in config:
if isinstance(config["status"],
authenticator_status.AuthenticatorStatus):
self.status = config["status"]
elif config["status"] is not None:
self.status = authenticator_status.AuthenticatorStatus(
config["status"].upper()
)
else:
self.status = None
else:
self.status = None
if "type" in config:
if isinstance(config["type"],
authenticator_type.AuthenticatorType):
self.type = config["type"]
elif config["type"] is not None:
self.type = authenticator_type.AuthenticatorType(
config["type"].upper()
)
else:
self.type = None
else:
self.type = None
else:
self.links = None
self.created = None
self.id = None
self.key = None
self.last_updated = None
self.name = None
self.settings = None
self.status = None
self.type = None

def request_format(self):
parent_req_format = super().request_format()
current_obj_format = {
"_links": self.links,
"created": self.created,
"id": self.id,
"key": self.key,
"lastUpdated": self.last_updated,
"name": self.name,
"settings": self.settings,
"status": self.status,
"type": self.type
}
parent_req_format.update(current_obj_format)
return parent_req_format
Loading

0 comments on commit ccf160f

Please sign in to comment.